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

SCM Repository

[diderot] Diff of /branches/vis12-cl/src/compiler/c-util/tree-to-c.sml
ViewVC logotype

Diff of /branches/vis12-cl/src/compiler/c-util/tree-to-c.sml

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

revision 2053, Tue Oct 23 04:40:18 2012 UTC revision 2082, Tue Nov 6 22:54:10 2012 UTC
# Line 14  Line 14 
14    (* translate a variable that occurs in a r-value context *)    (* translate a variable that occurs in a r-value context *)
15      val rvalueVar : env * TreeIL.var -> CLang.exp      val rvalueVar : env * TreeIL.var -> CLang.exp
16    (* translate a strand state variable that occurs in an l-value context *)    (* translate a strand state variable that occurs in an l-value context *)
17      val lvalueStateVar : TreeIL.state_var -> CLang.exp      val lvalueStateVar : env * TreeIL.state_var -> CLang.exp
18    (* translate a strand state variable that occurs in a r-value context *)    (* translate a strand state variable that occurs in a r-value context *)
19      val rvalueStateVar : TreeIL.state_var -> CLang.exp      val rvalueStateVar : env * TreeIL.state_var -> CLang.exp
20    end    end
21    
22  functor TreeToCFn (VarToC : TREE_VAR_TO_C) : sig  functor TreeToCFn (VarToC : TREE_VAR_TO_C) : sig
# Line 249  Line 249 
249            (* end case *))            (* end case *))
250    
251      fun trExp (env, e) = (case e      fun trExp (env, e) = (case e
252             of IL.E_State x => VarToC.rvalueStateVar x             of IL.E_State x => VarToC.rvalueStateVar (env, x)
253              | IL.E_Var x => VarToC.rvalueVar (env, x)              | IL.E_Var x => VarToC.rvalueVar (env, x)
254              | IL.E_Lit(Literal.Int n) => CL.mkIntTy(n, !N.gIntTy)              | IL.E_Lit(Literal.Int n) => CL.mkIntTy(n, !N.gIntTy)
255              | IL.E_Lit(Literal.Bool b) => CL.mkBool b              | IL.E_Lit(Literal.Bool b) => CL.mkBool b
# Line 454  Line 454 
454                    doAssign (0, trExps(env, args))                    doAssign (0, trExps(env, args))
455                  end                  end
456              | IL.E_State x => (case IL.StateVar.ty x              | IL.E_State x => (case IL.StateVar.ty x
457                   of Ty.TensorTy[n,m] => [CL.mkCall(N.copyMat(n,m), [lhs, VarToC.rvalueStateVar x])]                   of Ty.TensorTy[n,m] => [CL.mkCall(N.copyMat(n,m), [lhs, VarToC.rvalueStateVar(env, x)])]
458                    | Ty.TensorTy[n,m,l] => [CL.mkCall(N.copyTen3(n,m,l), [lhs, VarToC.rvalueStateVar x])]                    | Ty.TensorTy[n,m,l] => [CL.mkCall(N.copyTen3(n,m,l), [lhs, VarToC.rvalueStateVar(env, x)])]
459                    | _ => [CL.mkAssign(lhs, VarToC.rvalueStateVar x)]                    | _ => [CL.mkAssign(lhs, VarToC.rvalueStateVar(env, x))]
460                  (* end case *))                  (* end case *))
461              | IL.E_Var x => (case IL.Var.ty x              | IL.E_Var x => (case IL.Var.ty x
462                   of Ty.TensorTy[n,m] => [CL.mkCall(N.copyMat(n,m), [lhs, VarToC.rvalueVar(env, x)])]                   of Ty.TensorTy[n,m] => [CL.mkCall(N.copyMat(n,m), [lhs, VarToC.rvalueVar(env, x)])]
# Line 560  Line 560 
560                          trBlk(env, thenBlk),                          trBlk(env, thenBlk),
561                          trBlk(env, elseBlk))]                          trBlk(env, elseBlk))]
562                    | IL.S_New _ => raise Fail "new not supported yet" (* FIXME *)                    | IL.S_New _ => raise Fail "new not supported yet" (* FIXME *)
563                    | IL.S_Save([x], exp) => trAssign (env, VarToC.lvalueStateVar x, exp)                    | IL.S_Save([x], exp) => trAssign (env, VarToC.lvalueStateVar(env, x), exp)
564                    | IL.S_Save(xs, exp) =>                    | IL.S_Save(xs, exp) =>
565                        trMultiAssign (env, List.map VarToC.lvalueStateVar xs, exp)                        trMultiAssign (env, List.map (fn x => VarToC.lvalueStateVar(env, x)) xs, exp)
566                    | IL.S_LoadNrrd(lhs, Ty.DynSeqTy ty, nrrd) =>                    | IL.S_LoadNrrd(lhs, Ty.DynSeqTy ty, nrrd) =>
567                        [GenLoadNrrd.loadSeqFromFile (VarToC.lvalueVar (env, lhs), ty, CL.mkStr nrrd)]                        [GenLoadNrrd.loadSeqFromFile (VarToC.lvalueVar (env, lhs), ty, CL.mkStr nrrd)]
568                    | IL.S_LoadNrrd(lhs, Ty.ImageTy info, nrrd) =>                    | IL.S_LoadNrrd(lhs, Ty.ImageTy info, nrrd) =>
# Line 639  Line 639 
639                | _ => CL.mkIndirect(CL.mkVar "glob", lookup(env, x))                | _ => CL.mkIndirect(CL.mkVar "glob", lookup(env, x))
640              (* end case *))              (* end case *))
641      (* translate a strand state variable that occurs in an l-value context *)      (* translate a strand state variable that occurs in an l-value context *)
642        fun lvalueStateVar x = CL.mkIndirect(CL.mkVar "selfOut", IL.StateVar.name x)        fun lvalueStateVar (env, x) = CL.mkIndirect(CL.mkVar "selfOut", IL.StateVar.name x)
643      (* translate a strand state variable that occurs in an r-value context *)      (* translate a strand state variable that occurs in an r-value context *)
644        fun rvalueStateVar x = CL.mkIndirect(CL.mkVar "selfIn", IL.StateVar.name x)        fun rvalueStateVar (env, x) = CL.mkIndirect(CL.mkVar "selfIn", IL.StateVar.name x)
645      end      end
646  in  in
647  structure TreeToC = TreeToCFn (TrVar)  structure TreeToC = TreeToCFn (TrVar)

Legend:
Removed from v.2053  
changed lines
  Added in v.2082

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