SCM Repository
[diderot] Diff of /trunk/src/compiler/simplify/eval.sml
Diff of /trunk/src/compiler/simplify/eval.sml
Parent Directory
|
Revision Log
|
Patch
6 |
* Evaluation of "static" expressions. |
* Evaluation of "static" expressions. |
7 |
*) |
*) |
8 |
|
|
9 |
structure Eval = |
structure Eval : sig |
10 |
struct |
|
11 |
|
datatype value |
12 |
|
= BV of bool |
13 |
|
| SV of string |
14 |
|
| IV of IntInf.int |
15 |
|
| TV of (int list * real list) (* tensors *) |
16 |
|
| FV of FieldDef.field_def |
17 |
|
| Img of ImageInfo.info |
18 |
|
| KV of Kernel.kernel |
19 |
|
|
20 |
|
val evalStatics : Simple.program -> value Var.Map.map |
21 |
|
|
22 |
|
end = struct |
23 |
|
|
24 |
structure Ty = Types |
structure Ty = Types |
25 |
structure BV = BasisVars |
structure BV = BasisVars |
182 |
| S.E_LoadImage info => Img info |
| S.E_LoadImage info => Img info |
183 |
(* end case *)) |
(* end case *)) |
184 |
|
|
185 |
|
fun evalBlock (env, S.Block stms) = let |
186 |
|
fun evalStm (stm, env) = (case stm |
187 |
|
of S.S_Assign(x, e) => VMap.insert(env, x, evalExp(env, e)) |
188 |
|
| S.S_IfThenElse(x, b1, b2) => (case evalVar env x |
189 |
|
of BV true => evalBlock(env, b1) |
190 |
|
| BV false => evalBlock(env, b2) |
191 |
|
| _ => raise Fail "type error" |
192 |
|
(* end case *)) |
193 |
|
| S.S_New _ => raise Fail "unexpected new actor" |
194 |
|
| S.S_Die => raise Fail "unexpected die" |
195 |
|
| S.S_Stabilize => raise Fail "unexpected stabilize" |
196 |
|
(* end case *)) |
197 |
|
in |
198 |
|
List.foldl evalStm env stms |
199 |
|
end |
200 |
|
|
201 |
|
fun evalStatics (S.Program{staticInit, ...}) = |
202 |
|
evalBlock (VMap.empty, staticInit) |
203 |
|
|
204 |
end |
end |
|
Legend:
Removed from v.235 |
|
changed lines |
|
Added in v.236 |
|
|