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 188 - (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 188 fun cvtExpr (env, lhs, exp) = (case exp
28 :     of S.E_Var x => [(lhs, IL.VAR(lookup env x))]
29 :     | S.E_Lit lit => [(lhs, IL.LIT lit)]
30 : jhr 176 | S.E_Tuple xs => raise Fail "E_Tuple not implemeted"
31 : jhr 188 | S.E_Apply(f, tyArgs, args, ty) => let
32 :     val args' = List.map (lookup env) args
33 :     in
34 :     TranslateBasis.translate (lhs, f, tyArgs, args')
35 :     end
36 :     | S.E_Cons args => [(lhs, IL.CONS(List.map (lookup env) args))]
37 : jhr 176 (* end case *))
38 : jhr 168
39 :     and cvtStmt (env, stm) = (case stm
40 : jhr 176 of S.S_Block stms =>
41 :     | S.S_Assign(x, e) =>
42 :     | S.S_IfThenElse(x, s1, s2) =>
43 :     | S.S_New(name, xs) =>
44 :     | S.S_Die =>
45 :     | S.S_Stabilize =>
46 : jhr 168 (* end case *))
47 :    
48 : jhr 176 fun translate (S.Program{globals, globaInit, actors}) = ??
49 :    
50 : jhr 137 end

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