SCM Repository
View of /trunk/src/compiler/translate/translate.sml
Parent Directory
|
Revision Log
Revision 176 -
(download)
(annotate)
Mon Jul 26 19:47:48 2010 UTC (11 years, 11 months ago) by jhr
File size: 1151 byte(s)
Mon Jul 26 19:47:48 2010 UTC (11 years, 11 months ago) by jhr
File size: 1151 byte(s)
Switch the translate code to take simple AST as its input type
(* 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
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |