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 294 - (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 : blume 294 val static : configuration -> primitive -> GenericVC.Environment.staticEnv
23 :     val symbolic : configuration -> primitive -> GenericVC.Environment.symenv
24 : blume 286
25 :     val configuration :
26 :     { basis: GenericVC.Environment.environment }
27 :     -> configuration
28 : blume 270 end
29 :    
30 : blume 272 structure Primitive :> PRIMITIVE = struct
31 : blume 270
32 : blume 286 structure BE = GenericVC.BareEnvironment
33 : blume 294 structure E = GenericVC.Environment
34 : blume 286 structure DE = DAEnv
35 : blume 270
36 : blume 286 (* For now, we only know about the "basis".
37 :     * This is for testing only -- the basis will become a real
38 :     * "non-primitive" library, and there will be other primitives
39 :     * that are used to implement the basis. *)
40 :     datatype primitive =
41 :     BASIS
42 :    
43 :     type pinfo = { exports : SymbolSet.set,
44 : blume 294 lookup : Symbol.symbol -> DE.value,
45 :     static : GenericVC.Environment.staticEnv,
46 :     symbolic : GenericVC.Environment.symenv }
47 : blume 286
48 :     type configuration = primitive -> pinfo
49 :    
50 : blume 279 fun eq (p1 : primitive, p2) = p1 = p2
51 :    
52 : blume 286 fun fromString "basis" = SOME BASIS
53 : blume 274 | fromString _ = NONE
54 :    
55 : blume 286 fun toString BASIS = "basis"
56 : blume 274
57 : blume 286 fun exports (cfg: configuration) p = #exports (cfg p)
58 :     fun lookup (cfg: configuration) p = #lookup (cfg p)
59 : blume 294 fun static (cfg: configuration) p = #static (cfg p)
60 :     fun symbolic (cfg: configuration) p = #symbolic (cfg p)
61 : blume 286
62 :     fun configuration { basis } = let
63 : blume 294
64 :     fun gen_pinfo e = let
65 :     fun l2s l = let
66 :     fun addModule (sy, set) =
67 :     case Symbol.nameSpace sy of
68 :     (Symbol.STRspace | Symbol.SIGspace |
69 :     Symbol.FCTspace | Symbol.FSIGspace) =>
70 : blume 286 SymbolSet.add (set, sy)
71 : blume 294 | _ => set
72 :     in
73 :     foldl addModule SymbolSet.empty l
74 :     end
75 : blume 286
76 : blume 294 fun cvt_fctenv { symbols, look } =
77 :     { looker = cvt_result o look, domain = l2s o symbols }
78 : blume 286
79 : blume 294 and cvt_result (BE.CM_ENV cme) = SOME (DE.FCTENV (cvt_fctenv cme))
80 :     | cvt_result BE.CM_NONE = NONE
81 : blume 286
82 : blume 294 val sb = BE.staticPart (GenericVC.CoerceEnv.e2b e)
83 :     val static = E.staticPart e
84 :     val symbolic = E.symbolicPart e
85 : blume 286
86 : blume 294 val { domain, looker } =
87 :     cvt_fctenv { symbols = fn () => BE.catalogEnv sb,
88 :     look = BE.cmEnvOfModule sb }
89 :     in
90 :     { exports = domain (), lookup = valOf o looker,
91 :     static = static, symbolic = symbolic }
92 :     end
93 :    
94 :     val basis_pinfo = gen_pinfo basis
95 :     fun cfg BASIS = basis_pinfo
96 : blume 286 in
97 :     cfg
98 :     end
99 : blume 270 end

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