Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Annotation of /trunk/src/compiler/translate/translate.sml
ViewVC logotype

Annotation of /trunk/src/compiler/translate/translate.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 176 - (view) (download)

1 : jhr 137 (* translate.sml
2 :     *
3 :     * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu)
4 :     * All rights reserved.
5 :     *
6 : jhr 176 * Translate Simple-AST code into the IL representation.
7 : jhr 137 *)
8 :    
9 :     structure Translate : sig
10 :    
11 : jhr 176 val translate : Simple.program -> HighIL.program
12 : jhr 137
13 :     end = struct
14 :    
15 : jhr 176 structure S = Simple
16 : jhr 137 structure VMap = Var.Map
17 : jhr 168 structure IL = HighIL
18 : jhr 137
19 : jhr 176 fun lookup env x = (case VMap.find x
20 :     of SOME x' => x'
21 :     | NONE => raise Fail(concat[
22 :     "no binding for ", Var.toString x, " in environment"
23 :     ])
24 :     (* end case *))
25 :    
26 : jhr 168 (* expression translation *)
27 : jhr 176 fun cvtExpr (env, exp) = (case exp
28 :     of S.E_Var x => IL.VAR(lookup env x)
29 :     | S.E_Lit lit => IL.LIT lit
30 :     | S.E_Tuple xs => raise Fail "E_Tuple not implemeted"
31 :     | S.E_Apply(f, tyArgs, args, ty) =>
32 :     | S.E_Cons args => IL.CONS(List.map (lookup env) args)
33 :     (* end case *))
34 : jhr 168
35 :     and cvtStmt (env, stm) = (case stm
36 : jhr 176 of S.S_Block stms =>
37 :     | S.S_Assign(x, e) =>
38 :     | S.S_IfThenElse(x, s1, s2) =>
39 :     | S.S_New(name, xs) =>
40 :     | S.S_Die =>
41 :     | S.S_Stabilize =>
42 : jhr 168 (* end case *))
43 :    
44 : jhr 176 fun translate (S.Program{globals, globaInit, actors}) = ??
45 :    
46 : jhr 137 end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0