37 |
fun simplifyDecl dcl = (case dcl |
fun simplifyDecl dcl = (case dcl |
38 |
of AST.D_Input(x, NONE) => globals := x :: !globals |
of AST.D_Input(x, NONE) => globals := x :: !globals |
39 |
| AST.D_Input(x, SOME e) => let |
| AST.D_Input(x, SOME e) => let |
40 |
val (stms, e') = simplifyExp (e, []) |
val (stms, x') = simplifyExpToVar (e, []) |
41 |
|
val t = newTemp Ty.T_String |
42 |
|
val stm = S.S_Assign(t, S.E_Lit(Literal.String(Var.nameOf x))) |
43 |
|
val ty = Var.monoTypeOf x |
44 |
|
val e' = S.E_Apply(BasisVars.input, |
45 |
|
[Ty.TYPE(MetaVar.newFromType ty)], [t, x'], ty) |
46 |
in |
in |
|
(* FIXME: note that we should add code to check for the input value overriding the default value *) |
|
47 |
globals := x :: !globals; |
globals := x :: !globals; |
48 |
globalInit := S.S_Assign(x, e') :: (stms @ !globalInit) |
globalInit := S.S_Assign(x, e') :: stm :: (stms @ !globalInit) |
49 |
end |
end |
50 |
| AST.D_Var(AST.VD_Decl(x, e)) => let |
| AST.D_Var(AST.VD_Decl(x, e)) => let |
51 |
val (stms, e') = simplifyExp (e, []) |
val (stms, e') = simplifyExp (e, []) |