(* translate.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. * * Translate Simple-AST code into the IL representation. *) structure Translate : sig val translate : Simple.program -> HighIL.program end = struct structure S = Simple structure VMap = Var.Map structure IL = HighIL fun lookup env x = (case VMap.find x of SOME x' => x' | NONE => raise Fail(concat[ "no binding for ", Var.toString x, " in environment" ]) (* end case *)) (* expression translation *) fun cvtExpr (env, exp) = (case exp of S.E_Var x => IL.VAR(lookup env x) | S.E_Lit lit => IL.LIT lit | S.E_Tuple xs => raise Fail "E_Tuple not implemeted" | S.E_Apply(f, tyArgs, args, ty) => | S.E_Cons args => IL.CONS(List.map (lookup env) args) (* end case *)) and cvtStmt (env, stm) = (case stm of S.S_Block stms => | S.S_Assign(x, e) => | S.S_IfThenElse(x, s1, s2) => | S.S_New(name, xs) => | S.S_Die => | S.S_Stabilize => (* end case *)) fun translate (S.Program{globals, globaInit, actors}) = ?? end