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

SCM Repository

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

Diff of /branches/vis12/src/compiler/high-to-mid/high-to-mid.sml

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

revision 365, Wed Sep 29 20:07:58 2010 UTC revision 387, Fri Oct 8 15:29:24 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 122  Line 123 
123              (* end case *)              (* end case *)
124            end            end
125    
126      (* expand a SrcIL assignment to a list of DstIL assignments *)
127      fun expand (env, (y, rhs)) = let      fun expand (env, (y, rhs)) = let
128            val y' = rename (env, y)            val y' = rename (env, y)
129            fun assign rhs = [(y', rhs)]            fun assign rhs = [(y', rhs)]
# Line 129  Line 131 
131              case rhs              case rhs
132               of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))               of SrcIL.VAR x => assign (DstIL.VAR(rename(env, x)))
133                | SrcIL.LIT lit => assign (DstIL.LIT lit)                | SrcIL.LIT lit => assign (DstIL.LIT lit)
134                | SrcIL.OP(rator, args) =>                | SrcIL.OP(rator, args) => expandOp (env, y', rator, args)
135                    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))  
136              (* end case *)              (* end case *)
137            end            end
138    
# Line 147  Line 147 
147          val expand = expand          val expand = expand
148        end)        end)
149    
150      fun translate (SrcIL.Program{globals, globalInit, actors}) =      fun translate (SrcIL.Program{globals, globalInit, actors}) = let
151            raise Fail "unimplemented"            val env = VTbl.mkTable (256, Fail "env")
152              fun transMethod (SrcIL.Method{name, stateIn, stateOut, body}) =
153                    DstIL.Method{
154                        name = name,
155                        stateIn = renameList (env, stateIn),
156                        stateOut = renameList (env, stateOut),
157                        body = Trans.translate (env, body)
158                      }
159              fun transActor (SrcIL.Actor{name, params, state, stateInit, methods}) =
160                    DstIL.Actor{
161                        name = name,
162                        params = renameList (env, params),
163                        state = renameList (env, state),
164                        stateInit = Trans.translate (env, stateInit),
165                        methods = List.map transMethod methods
166                      }
167              in
168                DstIL.Program{
169                    globals = renameList (env, globals),
170                    globalInit = Trans.translate (env, globalInit),
171                    actors = List.map transActor actors
172                  }
173              end
174    
175    end    end

Legend:
Removed from v.365  
changed lines
  Added in v.387

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