Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/cm/main/symval.sml
ViewVC logotype

View of /sml/trunk/src/cm/main/symval.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (download) (annotate)
Thu Jun 17 09:43:40 1999 UTC (20 years, 5 months ago) by blume
File size: 1643 byte(s)
missing copyright notices added
(*
 * Implementation of environments for CM "preprocessor" variables.
 *
 * (C) 1999 Lucent Technologies, Bell Laboratories
 *
 * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
 *)
signature SYMVAL = sig

    type env

    val look : env -> string -> int option
    val empty : env

    val default : { arch: string,
		    extra_arch: string option,
		    big: bool,
		    size: int,
		    os: SMLofNJ.SysInfo.os_kind,
		    version: int list }
	-> env
end

structure SymVal :> SYMVAL = struct

    type env = int StringMap.map

    fun look e s = StringMap.find (e, s)

    val empty = StringMap.empty

    fun default { arch, extra_arch, big, size, os, version } = let
	fun mk_arch_sym a = "ARCH_" ^ a
	val arch_sym = mk_arch_sym arch
	val endian_sym = if big then "BIG_ENDIAN" else "LITTLE_ENDIAN"
	val size_sym = "SIZE_" ^ Int.toString size
	val os_sym = case os of
	    SMLofNJ.SysInfo.UNIX => "OPSYS_UNIX"
	  | SMLofNJ.SysInfo.WIN32 => "OPSYS_WIN32"
	  | SMLofNJ.SysInfo.MACOS => "OPSYS_MACOS"
	  | SMLofNJ.SysInfo.OS2 => "OPSYS_OS2"
	  | SMLofNJ.SysInfo.BEOS => "OPSYS_BEOS"
	val (major, minor) =
	    case version of
		[] => (0, 0)
	      | [major] => (major, 0)
	      | major :: minor :: _ => (major, minor)
	val major_sym = "SMLNJ_VERSION"
	val minor_sym = "SMLNJ_MINOR_VERSION"

	val almost_alldefs = [(arch_sym, 1),
			      (endian_sym, 1),
			      (size_sym, 1),
			      (os_sym, 1),
			      (major_sym, major),
			      (minor_sym, minor)]

	val alldefs =
	    case extra_arch of
		NONE => almost_alldefs
	      | SOME a => (mk_arch_sym a, 1) :: almost_alldefs
    in
	foldl StringMap.insert' empty alldefs
    end
end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0