equal
deleted
inserted
replaced
3 *) |
3 *) |
4 |
4 |
5 signature AM_BARRAS = |
5 signature AM_BARRAS = |
6 sig |
6 sig |
7 include ABSTRACT_MACHINE |
7 include ABSTRACT_MACHINE |
8 val max_reductions : int option ref |
8 val max_reductions : int option Unsynchronized.ref |
9 end |
9 end |
10 |
10 |
11 structure AM_Interpreter : AM_BARRAS = struct |
11 structure AM_Interpreter : AM_BARRAS = struct |
12 |
12 |
13 open AbstractMachine; |
13 open AbstractMachine; |
127 | proj_S (Continue (_,_,s,c)) = (s,c) |
127 | proj_S (Continue (_,_,s,c)) = (s,c) |
128 |
128 |
129 fun cont (Continue _) = true |
129 fun cont (Continue _) = true |
130 | cont _ = false |
130 | cont _ = false |
131 |
131 |
132 val max_reductions = ref (NONE : int option) |
132 val max_reductions = Unsynchronized.ref (NONE : int option) |
133 |
133 |
134 fun do_reduction reduce p = |
134 fun do_reduction reduce p = |
135 let |
135 let |
136 val s = ref (Continue p) |
136 val s = Unsynchronized.ref (Continue p) |
137 val counter = ref 0 |
137 val counter = Unsynchronized.ref 0 |
138 val _ = case !max_reductions of |
138 val _ = case !max_reductions of |
139 NONE => while cont (!s) do (s := reduce (proj_C (!s))) |
139 NONE => while cont (!s) do (s := reduce (proj_C (!s))) |
140 | SOME m => while cont (!s) andalso (!counter < m) do (s := reduce (proj_C (!s)); counter := (!counter) + 1) |
140 | SOME m => while cont (!s) andalso (!counter < m) do (s := reduce (proj_C (!s)); counter := (!counter) + 1) |
141 in |
141 in |
142 case !max_reductions of |
142 case !max_reductions of |