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 433 - (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 : blume 433 val define : env * string * int option -> env
15 : blume 336
16 :     val default : { arch: string,
17 :     big: bool,
18 :     size: int,
19 :     os: SMLofNJ.SysInfo.os_kind,
20 :     version: int list }
21 :     -> env
22 :     end
23 :    
24 :     structure SymVal :> SYMVAL = struct
25 :    
26 :     type env = int StringMap.map
27 :    
28 :     fun look e s = StringMap.find (e, s)
29 :    
30 :     val empty = StringMap.empty
31 :    
32 : blume 433 fun define (e, s, NONE) =
33 :     (#1 (StringMap.remove (e, s))
34 :     handle LibBase.NotFound => e)
35 :     | define (e, s, SOME v) = StringMap.insert (e, s, v)
36 :    
37 : blume 386 fun default { arch, big, size, os, version } = let
38 :     val arch_sym = "ARCH_" ^ arch
39 : blume 336 val endian_sym = if big then "BIG_ENDIAN" else "LITTLE_ENDIAN"
40 :     val size_sym = "SIZE_" ^ Int.toString size
41 :     val os_sym = case os of
42 :     SMLofNJ.SysInfo.UNIX => "OPSYS_UNIX"
43 :     | SMLofNJ.SysInfo.WIN32 => "OPSYS_WIN32"
44 :     | SMLofNJ.SysInfo.MACOS => "OPSYS_MACOS"
45 :     | SMLofNJ.SysInfo.OS2 => "OPSYS_OS2"
46 :     | SMLofNJ.SysInfo.BEOS => "OPSYS_BEOS"
47 :     val (major, minor) =
48 :     case version of
49 :     [] => (0, 0)
50 :     | [major] => (major, 0)
51 :     | major :: minor :: _ => (major, minor)
52 :     val major_sym = "SMLNJ_VERSION"
53 :     val minor_sym = "SMLNJ_MINOR_VERSION"
54 :    
55 : blume 386 val alldefs = [(arch_sym, 1),
56 :     (endian_sym, 1),
57 :     (size_sym, 1),
58 :     (os_sym, 1),
59 :     (major_sym, major),
60 :     (minor_sym, minor),
61 :     ("NEW_CM", 1)]
62 : blume 336 in
63 :     foldl StringMap.insert' empty alldefs
64 :     end
65 :     end

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