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 304 - (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 304 val toIdent : primitive -> char
20 :     val fromIdent : char -> primitive option
21 :    
22 : blume 301 val reqpriv : primitive -> StringSet.set
23 : blume 295
24 : blume 278 (* the domain of (lookup p) must always properly include (exports p) *)
25 : blume 286 val exports : configuration -> primitive -> SymbolSet.set
26 :     val lookup : configuration -> primitive -> Symbol.symbol -> DAEnv.value
27 : blume 295 val env : configuration -> primitive -> GenericVC.Environment.environment
28 :     val pidInfo : configuration -> primitive
29 :     -> { statpid: GenericVC.PersStamps.persstamp,
30 :     sympid: GenericVC.PersStamps.persstamp,
31 :     ctxt: GenericVC.Environment.staticEnv }
32 : blume 286
33 :     val configuration :
34 :     { basis: GenericVC.Environment.environment }
35 :     -> configuration
36 : blume 270 end
37 :    
38 : blume 272 structure Primitive :> PRIMITIVE = struct
39 : blume 270
40 : blume 286 structure BE = GenericVC.BareEnvironment
41 : blume 294 structure E = GenericVC.Environment
42 : blume 286 structure DE = DAEnv
43 : blume 270
44 : blume 286 (* For now, we only know about the "basis".
45 :     * This is for testing only -- the basis will become a real
46 :     * "non-primitive" library, and there will be other primitives
47 :     * that are used to implement the basis. *)
48 :     datatype primitive =
49 :     BASIS
50 :    
51 :     type pinfo = { exports : SymbolSet.set,
52 : blume 294 lookup : Symbol.symbol -> DE.value,
53 : blume 295 env : GenericVC.Environment.environment }
54 : blume 286
55 :     type configuration = primitive -> pinfo
56 :    
57 : blume 279 fun eq (p1 : primitive, p2) = p1 = p2
58 :    
59 : blume 286 fun fromString "basis" = SOME BASIS
60 : blume 274 | fromString _ = NONE
61 :    
62 : blume 286 fun toString BASIS = "basis"
63 : blume 274
64 : blume 304 fun toIdent BASIS = #"b"
65 :    
66 :     fun fromIdent #"b" = SOME BASIS
67 :     | fromIdent _ = NONE
68 :    
69 : blume 301 val reqpriv_basis = StringSet.empty
70 : blume 295
71 : blume 301 fun reqpriv BASIS = reqpriv_basis
72 :    
73 : blume 286 fun exports (cfg: configuration) p = #exports (cfg p)
74 :     fun lookup (cfg: configuration) p = #lookup (cfg p)
75 : blume 295 fun env (cfg: configuration) p = #env (cfg p)
76 : blume 286
77 :     fun configuration { basis } = let
78 : blume 294
79 :     fun gen_pinfo e = let
80 :     fun l2s l = let
81 :     fun addModule (sy, set) =
82 :     case Symbol.nameSpace sy of
83 :     (Symbol.STRspace | Symbol.SIGspace |
84 :     Symbol.FCTspace | Symbol.FSIGspace) =>
85 : blume 286 SymbolSet.add (set, sy)
86 : blume 294 | _ => set
87 :     in
88 :     foldl addModule SymbolSet.empty l
89 :     end
90 : blume 286
91 : blume 294 fun cvt_fctenv { symbols, look } =
92 :     { looker = cvt_result o look, domain = l2s o symbols }
93 : blume 286
94 : blume 294 and cvt_result (BE.CM_ENV cme) = SOME (DE.FCTENV (cvt_fctenv cme))
95 :     | cvt_result BE.CM_NONE = NONE
96 : blume 286
97 : blume 294 val sb = BE.staticPart (GenericVC.CoerceEnv.e2b e)
98 : blume 286
99 : blume 294 val { domain, looker } =
100 :     cvt_fctenv { symbols = fn () => BE.catalogEnv sb,
101 :     look = BE.cmEnvOfModule sb }
102 :     in
103 : blume 295 { exports = domain (), lookup = valOf o looker, env = e }
104 : blume 294 end
105 :    
106 :     val basis_pinfo = gen_pinfo basis
107 :     fun cfg BASIS = basis_pinfo
108 : blume 286 in
109 :     cfg
110 :     end
111 : blume 301 (* this doesn't make much sense yet -- there aren't any singular
112 :     * pids describing the basis *)
113 :     fun pidInfo c BASIS = let
114 :     val p = GenericVC.PersStamps.fromBytes
115 :     (Byte.stringToBytes "0123456789abcdef")
116 :     in
117 :     { statpid = p, sympid = p, ctxt = GenericVC.CMStaticEnv.empty }
118 :     end
119 : blume 270 end

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