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/semant/primitive.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/semant/primitive.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 286 - (view) (download)

1 : blume 274 (*
2 :     * "Primitive" classes in CM.
3 :     * - provide access to compiler internals in an orderly fashion
4 :     *
5 :     * (C) 1999 Lucent Technologies, Bell Laboratories
6 :     *
7 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
8 :     *)
9 : blume 270 signature PRIMITIVE = sig
10 :    
11 : blume 286 type configuration
12 : blume 270 type primitive
13 :    
14 : blume 279 val eq : primitive * primitive -> bool
15 :    
16 : blume 274 val fromString : string -> primitive option
17 : blume 273 val toString : primitive -> string
18 : blume 272
19 : blume 278 (* the domain of (lookup p) must always properly include (exports p) *)
20 : blume 286 val exports : configuration -> primitive -> SymbolSet.set
21 :     val lookup : configuration -> primitive -> Symbol.symbol -> DAEnv.value
22 :    
23 :     val configuration :
24 :     { basis: GenericVC.Environment.environment }
25 :     -> configuration
26 : blume 270 end
27 :    
28 : blume 272 structure Primitive :> PRIMITIVE = struct
29 : blume 270
30 : blume 286 structure BE = GenericVC.BareEnvironment
31 :     structure DE = DAEnv
32 : blume 270
33 : blume 286 (* For now, we only know about the "basis".
34 :     * This is for testing only -- the basis will become a real
35 :     * "non-primitive" library, and there will be other primitives
36 :     * that are used to implement the basis. *)
37 :     datatype primitive =
38 :     BASIS
39 :    
40 :     type pinfo = { exports : SymbolSet.set,
41 :     lookup : Symbol.symbol -> DE.value }
42 :    
43 :     type configuration = primitive -> pinfo
44 :    
45 : blume 279 fun eq (p1 : primitive, p2) = p1 = p2
46 :    
47 : blume 286 fun fromString "basis" = SOME BASIS
48 : blume 274 | fromString _ = NONE
49 :    
50 : blume 286 fun toString BASIS = "basis"
51 : blume 274
52 : blume 286 fun exports (cfg: configuration) p = #exports (cfg p)
53 :     fun lookup (cfg: configuration) p = #lookup (cfg p)
54 :    
55 :     fun configuration { basis } = let
56 :     fun l2s l = let
57 :     fun addModule (sy, set) =
58 :     case Symbol.nameSpace sy of
59 :     (Symbol.STRspace | Symbol.SIGspace |
60 :     Symbol.FCTspace | Symbol.FSIGspace) =>
61 :     SymbolSet.add (set, sy)
62 :     | _ => set
63 :     in
64 :     foldl addModule SymbolSet.empty l
65 :     end
66 :    
67 :     fun cvt_fctenv { symbols, look } =
68 :     { looker = cvt_result o look, domain = l2s o symbols }
69 :    
70 :     and cvt_result (BE.CM_ENV cme) = SOME (DE.FCTENV (cvt_fctenv cme))
71 :     | cvt_result BE.CM_NONE = NONE
72 :    
73 :     val sb = BE.staticPart (GenericVC.CoerceEnv.e2b basis)
74 :     val { domain, looker } =
75 :     cvt_fctenv { symbols = fn () => BE.catalogEnv sb,
76 :     look = BE.cmEnvOfModule sb }
77 :     val pinfo = { exports = domain (), lookup = valOf o looker }
78 :    
79 :     fun cfg BASIS = pinfo
80 :     in
81 :     cfg
82 :     end
83 : blume 270 end

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