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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 386 - (view) (download)

1 : blume 337 (*
2 :     * Implementation of environments for CM "preprocessor" variables.
3 :     *
4 :     * (C) 1999 Lucent Technologies, Bell Laboratories
5 :     *
6 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     *)
8 : blume 336 signature SYMVAL = sig
9 :    
10 :     type env
11 :    
12 :     val look : env -> string -> int option
13 :     val empty : env
14 :    
15 :     val default : { arch: string,
16 :     big: bool,
17 :     size: int,
18 :     os: SMLofNJ.SysInfo.os_kind,
19 :     version: int list }
20 :     -> env
21 :     end
22 :    
23 :     structure SymVal :> SYMVAL = struct
24 :    
25 :     type env = int StringMap.map
26 :    
27 :     fun look e s = StringMap.find (e, s)
28 :    
29 :     val empty = StringMap.empty
30 :    
31 : blume 386 fun default { arch, big, size, os, version } = let
32 :     val arch_sym = "ARCH_" ^ arch
33 : blume 336 val endian_sym = if big then "BIG_ENDIAN" else "LITTLE_ENDIAN"
34 :     val size_sym = "SIZE_" ^ Int.toString size
35 :     val os_sym = case os of
36 :     SMLofNJ.SysInfo.UNIX => "OPSYS_UNIX"
37 :     | SMLofNJ.SysInfo.WIN32 => "OPSYS_WIN32"
38 :     | SMLofNJ.SysInfo.MACOS => "OPSYS_MACOS"
39 :     | SMLofNJ.SysInfo.OS2 => "OPSYS_OS2"
40 :     | SMLofNJ.SysInfo.BEOS => "OPSYS_BEOS"
41 :     val (major, minor) =
42 :     case version of
43 :     [] => (0, 0)
44 :     | [major] => (major, 0)
45 :     | major :: minor :: _ => (major, minor)
46 :     val major_sym = "SMLNJ_VERSION"
47 :     val minor_sym = "SMLNJ_MINOR_VERSION"
48 :    
49 : blume 386 val alldefs = [(arch_sym, 1),
50 :     (endian_sym, 1),
51 :     (size_sym, 1),
52 :     (os_sym, 1),
53 :     (major_sym, major),
54 :     (minor_sym, minor),
55 :     ("NEW_CM", 1)]
56 : blume 336 in
57 :     foldl StringMap.insert' empty alldefs
58 :     end
59 :     end

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