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

SCM Repository

[diderot] Diff of /trunk/src/compiler/high-to-mid/high-to-mid.sml
ViewVC logotype

Diff of /trunk/src/compiler/high-to-mid/high-to-mid.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 366, Thu Sep 30 13:01:12 2010 UTC revision 367, Thu Sep 30 21:20:13 2010 UTC
# Line 18  Line 18 
18      structure DstIL = MidIL      structure DstIL = MidIL
19      structure DstOp = MidOps      structure DstOp = MidOps
20    
21      type var_env = DstIL.var SrcIL.Var.Tbl.hash_table      type var_env = DstIL.var VTbl.hash_table
22    
23      fun rename (env : var_env, x) = (case VTbl.find env x      fun rename (env : var_env, x) = (case VTbl.find env x
24             of SOME x' => x'             of SOME x' => x'
# Line 29  Line 29 
29                    x'                    x'
30                  end                  end
31            (* end case *))            (* end case *))
32        fun renameList (env, xs) = List.map (fn x => rename(env, x)) xs
33    
34    (* expand the field Inside operator into a image-space test *)    (* expand the field Inside operator into a image-space test *)
35      fun expandInside (env, result, pos, fld) = let      fun expandInside (env, result, pos, fld) = let
# Line 72  Line 73 
73    
74      fun expandOp (env, y, rator, args) = let      fun expandOp (env, y, rator, args) = let
75            fun assign rator' =            fun assign rator' =
76                  [(y, DstIL.OP(rator', List.map (fn x => rename(env, x)) args))]                  [(y, DstIL.OP(rator', renameList(env, args)))]
77            in            in
78              case rator              case rator
79               of SrcOp.Add ty => assign (DstOp.Add(cvtTy ty))               of SrcOp.Add ty => assign (DstOp.Add(cvtTy ty))
# Line 129  Line 130 
130              case rhs              case rhs
131               of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))               of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))
132                | SrcIL.LIT lit => assign (DstIL.LIT lit)                | SrcIL.LIT lit => assign (DstIL.LIT lit)
133                | SrcIL.OP(rator, args) =>                | SrcIL.OP(rator, args) => expandOp (env, y', rator, args)
134                    expandOp (env, y', rator, args)                | SrcIL.CONS args => assign (DstIL.CONS(renameList(env, args)))
               | SrcIL.CONS args =>  
                   assign (DstIL.CONS(List.map (fn x => rename(env, x)) args))  
135              (* end case *)              (* end case *)
136            end            end
137    
# Line 147  Line 146 
146          val expand = expand          val expand = expand
147        end)        end)
148    
149      fun translate (SrcIL.Program{globals, globalInit, actors}) =      fun translate (SrcIL.Program{globals, globalInit, actors}) = let
150            raise Fail "unimplemented"            val env = VTbl.mkTable (256, Fail "env")
151              fun transMethod (SrcIL.Method{name, stateIn, stateOut, body}) =
152                    DstIL.Method{
153                        name = name,
154                        stateIn = renameList (env, stateIn),
155                        stateOut = renameList (env, stateOut),
156                        body = Trans.translate (env, body)
157                      }
158              fun transActor (SrcIL.Actor{name, params, state, stateInit, methods}) =
159                    DstIL.Actor{
160                        name = name,
161                        params = renameList (env, params),
162                        state = renameList (env, state),
163                        stateInit = Trans.translate (env, stateInit),
164                        methods = List.map transMethod methods
165                      }
166              in
167                DstIL.Program{
168                    globals = renameList (env, globals),
169                    globalInit = Trans.translate (env, globalInit),
170                    actors = List.map transActor actors
171                  }
172              end
173    
174    end    end

Legend:
Removed from v.366  
changed lines
  Added in v.367

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