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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/cxx-util/tree-to-cxx.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/cxx-util/tree-to-cxx.sml

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

revision 3922, Wed Jun 1 17:02:34 2016 UTC revision 3924, Fri Jun 3 17:30:27 2016 UTC
# Line 15  Line 15 
15    
16      val trBlock : CodeGenEnv.t * TreeIR.block -> CLang.stm      val trBlock : CodeGenEnv.t * TreeIR.block -> CLang.stm
17    
18        val trWithLocals : CodeGenEnv.t * TreeVar.t list * (CodeGenEnv.t -> CLang.stm list) -> CLang.stm
19    
20        val trStms : CodeGenEnv.t * TreeIR.stm list -> CLang.stm list
21    
22      val trExp : CodeGenEnv.t * TreeIR.exp -> CLang.exp      val trExp : CodeGenEnv.t * TreeIR.exp -> CLang.exp
23    
24    (* translate an expression to a variable form; return the variable (as an expression)    (* translate an expression to a variable form; return the variable (as an expression)
# Line 62  Line 66 
66      fun rvalueVar (env, x) = CL.mkVar(Env.lookup(env, x))      fun rvalueVar (env, x) = CL.mkVar(Env.lookup(env, x))
67    
68    (* translate a global variable that occurs in an l-value context *)    (* translate a global variable that occurs in an l-value context *)
69      fun lvalueGlobalVar (env, x) = CL.mkIndirect(CL.mkVar(Env.global env), TreeGlobalVar.name x)      fun lvalueGlobalVar (env, x) = CL.mkIndirect(CL.mkVar(Env.global env), TreeGlobalVar.qname x)
70    (* translate a global variable that occurs in an r-value context *)    (* translate a global variable that occurs in an r-value context *)
71      val rvalueGlobalVar = lvalueGlobalVar      val rvalueGlobalVar = lvalueGlobalVar
72    
73    (* translate a strand state variable that occurs in an l-value context *)    (* translate a strand state variable that occurs in an l-value context *)
74      fun lvalueStateVar (env, x) = CL.mkIndirect(CL.mkVar(Env.selfOut env), TreeStateVar.name x)      fun lvalueStateVar (env, x) = CL.mkIndirect(CL.mkVar(Env.selfOut env), TreeStateVar.qname x)
75    (* translate a strand state variable that occurs in an r-value context *)    (* translate a strand state variable that occurs in an r-value context *)
76      fun rvalueStateVar (env, x) = CL.mkIndirect(CL.mkVar(Env.selfIn env), TreeStateVar.name x)      fun rvalueStateVar (env, x) = CL.mkIndirect(CL.mkVar(Env.selfIn env), TreeStateVar.qname x)
77    
78    (* generate new variables *)    (* generate new variables *)
79      local      local
# Line 309  Line 313 
313                        in                        in
314                          (env, stm :: stms)                          (env, stm :: stms)
315                        end                        end
316                    | IR.S_Foreach(x, IR.E_Op(Op.Range, [lo, hi]), blk) => let                    | IR.S_For(x, lo, hi, blk) => let
317                        val x' = V.name x                        val x' = V.name x
318                        val env' = Env.insert (env, x, x')                        val env' = Env.insert (env, x, x')
319                        val (hi', hiInit) = if CodeGenUtil.isSimple hi                        val (hi', hiInit) = if CodeGenUtil.isSimple hi
# Line 376  Line 380 
380              CL.mkBlock (dcls @ trStms (env, body))              CL.mkBlock (dcls @ trStms (env, body))
381            end            end
382    
383        and trWithLocals (env, locals, trBody) = let
384              fun trLocal (x, (env, dcls)) = let
385                    val x' = V.name x
386                    val dcl = CL.mkDecl(trType(env, V.ty x), x', NONE)
387                    in
388                      (Env.insert(env, x, x'), dcl :: dcls)
389                    end
390              val (env, dcls) = List.foldl trLocal (env, []) locals
391              in
392                CL.mkBlock (dcls @ trBody env)
393              end
394    
395      fun errorMsgAdd msg =      fun errorMsgAdd msg =
396            CL.mkCall("biffMsgAdd", [CL.mkIndirect(CL.mkVar "wrld", "_errors"), msg])            CL.mkCall("biffMsgAdd", [CL.mkIndirect(CL.mkVar "wrld", "_errors"), msg])
397    

Legend:
Removed from v.3922  
changed lines
  Added in v.3924

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