12 |
structure DG = DependencyGraph |
structure DG = DependencyGraph |
13 |
structure GG = GroupGraph |
structure GG = GroupGraph |
14 |
in |
in |
15 |
functor CompileGenericFn (structure CT: COMPILATION_TYPE) :> sig |
functor CompileGenericFn (structure CT: COMPILATION_TYPE) :> TRAVERSAL |
16 |
|
where type envdelta = CT.envdelta |
17 |
type envdelta = CT.envdelta |
and type result = CT.result = |
18 |
type result = CT.result |
struct |
|
|
|
|
val bnode : GP.info -> DG.bnode -> envdelta option |
|
|
val group : GP.info -> GG.group -> result option |
|
|
val impexpmap : |
|
|
GP.info -> DependencyGraph.impexp SymbolMap.map -> result option |
|
|
|
|
|
(* If you go through the "sbnode" interface, then |
|
|
* you must reset explicitly when you are done. *) |
|
|
val sbnode : GP.info -> DG.sbnode -> envdelta option |
|
|
val reset : unit -> unit |
|
|
|
|
|
val resetAll : unit -> unit |
|
|
end = struct |
|
19 |
|
|
20 |
type envdelta = CT.envdelta |
type envdelta = CT.envdelta |
21 |
type env = CT.env |
type env = CT.env |
24 |
|
|
25 |
val smlcache = ref (SmlInfoMap.empty: envdelta option SmlInfoMap.map) |
val smlcache = ref (SmlInfoMap.empty: envdelta option SmlInfoMap.map) |
26 |
val stablecache = ref (StableMap.empty: envdelta option StableMap.map) |
val stablecache = ref (StableMap.empty: envdelta option StableMap.map) |
27 |
fun reset () = smlcache := SmlInfoMap.empty |
fun reset () = (CT.nestedTraversalReset (); |
28 |
|
smlcache := SmlInfoMap.empty) |
29 |
fun resetAll () = (reset (); stablecache := StableMap.empty) |
fun resetAll () = (reset (); stablecache := StableMap.empty) |
30 |
|
|
31 |
(* To implement "keep_going" we have two different ways of |
(* To implement "keep_going" we have two different ways of |
49 |
Option.map CT.bnofilter o bnode gp)) |
Option.map CT.bnofilter o bnode gp)) |
50 |
|
|
51 |
fun bn (DG.PNODE p) = SOME (CT.primitive gp p) |
fun bn (DG.PNODE p) = SOME (CT.primitive gp p) |
52 |
| bn (DG.BNODE n) = let |
| bn (node as DG.BNODE n) = let |
53 |
val { bininfo, localimports = li, globalimports = gi } = n |
val { bininfo, localimports = li, globalimports = gi } = n |
54 |
in |
in |
55 |
case StableMap.find (!stablecache, bininfo) of |
case StableMap.find (!stablecache, bininfo) of |
57 |
| NONE => let |
| NONE => let |
58 |
fun mkenv () = |
fun mkenv () = |
59 |
loc (glob (SOME (CT.bpervasive gp)) gi) li |
loc (glob (SOME (CT.bpervasive gp)) gi) li |
60 |
val r = CT.dostable (bininfo, mkenv, gp) |
val r = CT.dostable (bininfo, mkenv, gp, node) |
61 |
in |
in |
62 |
stablecache := |
stablecache := |
63 |
StableMap.insert (!stablecache, bininfo, r); |
StableMap.insert (!stablecache, bininfo, r); |
75 |
| (SOME d, NONE) => SOME (CT.bnofilter d) |
| (SOME d, NONE) => SOME (CT.bnofilter d) |
76 |
| (SOME d, SOME s) => SOME (CT.bfilter (d, s)) |
| (SOME d, SOME s) => SOME (CT.bfilter (d, s)) |
77 |
|
|
78 |
fun snode gp (DG.SNODE n) = let |
fun snode gp (node as DG.SNODE n) = let |
79 |
|
|
80 |
val k = #keep_going (#param gp) |
val k = #keep_going (#param gp) |
81 |
val glob = |
val glob = |
94 |
val e = loc ge li |
val e = loc ge li |
95 |
val r = case e of |
val r = case e of |
96 |
NONE => NONE |
NONE => NONE |
97 |
| SOME e => CT.dosml (smlinfo, e, gp) |
| SOME e => CT.dosml (smlinfo, e, gp, node) |
98 |
in |
in |
99 |
smlcache := SmlInfoMap.insert (!smlcache, smlinfo, r); |
smlcache := SmlInfoMap.insert (!smlcache, smlinfo, r); |
100 |
r |
r |