9 |
* |
* |
10 |
* Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp) |
* Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp) |
11 |
*) |
*) |
12 |
functor ExecFn (structure PS : FULL_PERSSTATE) : COMPILATION_TYPE = struct |
functor ExecFn (structure PS : FULL_PERSSTATE) : sig |
13 |
|
structure Recomp : COMPILATION_TYPE |
14 |
|
structure RecompTraversal : TRAVERSAL |
15 |
|
structure Exec : COMPILATION_TYPE |
16 |
|
end = struct |
17 |
|
|
18 |
|
structure Recomp = RecompFn (structure PS = PS) |
19 |
|
structure RecompTraversal = CompileGenericFn (structure CT = Recomp) |
20 |
|
|
21 |
|
structure Exec = struct |
22 |
structure E = GenericVC.Environment |
structure E = GenericVC.Environment |
23 |
structure DE = GenericVC.DynamicEnv |
structure DE = GenericVC.DynamicEnv |
24 |
structure BF = PS.MachDepVC.Binfile |
structure BF = PS.MachDepVC.Binfile |
75 |
NONE |
NONE |
76 |
end |
end |
77 |
|
|
78 |
fun dostable (i, mkbenv, gp) = |
fun dostable (i, mkbenv, gp, bn) = |
79 |
case mkbenv () of |
case mkbenv () of |
80 |
NONE => NONE |
NONE => NONE |
81 |
| SOME (benv, sl, bl) => let |
| SOME (benv, sl, bl) => |
82 |
val bfc = PS.bfc_fetch_stable i |
(case RecompTraversal.bnode gp bn of |
83 |
in |
SOME { bfc = SOME bfc, ... } => |
84 |
case PS.exec_look_stable (i, gp, BF.exportPidOf bfc) of |
(case PS.exec_look_stable (i, gp, BF.exportPidOf bfc) of |
85 |
SOME m => |
SOME m => |
86 |
(BF.discardCode bfc; |
(BF.discardCode bfc; |
87 |
SOME (thunkify m, [], [i])) |
SOME (thunkify m, [], [i])) |
88 |
| NONE => (execute (bfc, benv, |
| NONE => (execute |
89 |
|
(bfc, benv, |
90 |
BinInfo.error i EM.COMPLAIN, |
BinInfo.error i EM.COMPLAIN, |
91 |
BinInfo.describe i, |
BinInfo.describe i, |
92 |
fn e => PS.exec_memo_stable (i, e, bl), |
fn e => PS.exec_memo_stable (i, e, bl), |
93 |
[], [i])) |
[], [i]))) |
94 |
end |
| _ => NONE) |
95 |
|
|
96 |
fun dosml (i, (env, sl, bl), gp) = let |
fun dosml (i, (env, sl, bl), gp, sn) = |
97 |
val bfc = PS.bfc_fetch_sml i |
case RecompTraversal.snode gp sn of |
98 |
handle e => (print "!!! fetch_sml\n"; raise e) |
SOME { bfc = SOME bfc, ... } => |
99 |
in |
(case PS.exec_look_sml (i, gp, BF.exportPidOf bfc) of |
|
case PS.exec_look_sml (i, gp, BF.exportPidOf bfc) of |
|
100 |
SOME m => |
SOME m => |
101 |
(BF.discardCode bfc; |
(BF.discardCode bfc; |
102 |
SOME (thunkify m, [i], [])) |
SOME (thunkify m, [i], [])) |
104 |
SmlInfo.error gp i EM.COMPLAIN, |
SmlInfo.error gp i EM.COMPLAIN, |
105 |
SmlInfo.descr i, |
SmlInfo.descr i, |
106 |
fn m => PS.exec_memo_sml (i, m, sl, bl), |
fn m => PS.exec_memo_sml (i, m, sl, bl), |
107 |
[i], [])) |
[i], []))) |
108 |
|
| _ => NONE |
109 |
|
|
110 |
|
val nestedTraversalReset = RecompTraversal.reset |
111 |
end |
end |
112 |
end |
end |