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

SCM Repository

[diderot] Diff of /branches/pure-cfg/src/compiler/c-target/c-target.sml
ViewVC logotype

Diff of /branches/pure-cfg/src/compiler/c-target/c-target.sml

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

revision 544, Wed Feb 16 23:14:14 2011 UTC revision 547, Thu Feb 17 14:57:07 2011 UTC
# Line 148  Line 148 
148        struct        struct
149        (* variable references *)        (* variable references *)
150          fun global (ty, x) = (CL.mkVar x, ty)          fun global (ty, x) = (CL.mkVar x, ty)
151          fun getState (ty, x) = (CL.mkIndirect(CL.mkVar "self", x), ty)          fun getState (ty, x) = (CL.mkIndirect(CL.mkVar "selfIn", x), ty)
152          fun param (ty, x) = (CL.mkVar x, ty)          fun param (ty, x) = (CL.mkVar x, ty)
153          fun var (ty, x) = (CL.mkVar x, ty)          fun var (ty, x) = (CL.mkVar x, ty)
154    
# Line 298  Line 298 
298                  (CL.mkCast(cTy, CL.mkIndirect(e, "data")), T_Data cTy)                  (CL.mkCast(cTy, CL.mkIndirect(e, "data")), T_Data cTy)
299                end                end
300            | imageAddr _ = raise Fail "invalid argument to imageAddr"            | imageAddr _ = raise Fail "invalid argument to imageAddr"
301            fun inside (d, (pos, T_Vec n), (img, T_Image d'), s) = let
302                  val fnName = concat["Diderot_Inside", Int.toString d, "D"]
303                  val e = CL.mkApply(fnName,
304                        [pos, img, CL.mkInt(IntInf.fromInt n, CL.int32)])
305                  in
306                    (e, T_Bool)
307        end        end
308    
309          end (* Expr *)
310    
311    (* statement construction *)    (* statement construction *)
312      structure Stmt =      structure Stmt =
313        struct        struct
314          val comment = CL.S_Comment          val comment = CL.S_Comment
315          fun assignState (x, (e, _)) = CL.mkAssign(#1(Expr.getState x), e)          fun assignState ((_, x), (e, _)) =
316                  CL.mkAssign(CL.mkIndirect(CL.mkVar "selfOut", x), e)
317          fun assign ((_, x), (e, _)) = CL.mkAssign(CL.mkVar x, e)          fun assign ((_, x), (e, _)) = CL.mkAssign(CL.mkVar x, e)
318          fun decl ((ty, x), SOME(e, _)) = CL.mkDecl(cvtTy ty, x, SOME e)          fun decl ((ty, x), SOME(e, _)) = CL.mkDecl(cvtTy ty, x, SOME e)
319            | decl ((ty, x), NONE) = CL.mkDecl(cvtTy ty, x, NONE)            | decl ((ty, x), NONE) = CL.mkDecl(cvtTy ty, x, NONE)
# Line 369  Line 378 
378          fun init (Strand{name, tyName, code, ...}, params, init) = let          fun init (Strand{name, tyName, code, ...}, params, init) = let
379                val fName = name ^ "_InitState"                val fName = name ^ "_InitState"
380                val params =                val params =
381                      CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "self") ::                      CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "selfOut") ::
382                        List.map (fn (ty, x) => CL.PARAM([], cvtTy ty, x)) params                        List.map (fn (ty, x) => CL.PARAM([], cvtTy ty, x)) params
383                val initFn = CL.D_Func([], CL.voidTy, fName, params, init)                val initFn = CL.D_Func([], CL.voidTy, fName, params, init)
384                in                in
385                  code := initFn :: !code                  code := initFn :: !code
386                end                end
387    
388          (* register a strand method *)
389            fun method (Strand{name, tyName, code, ...}, methName, body) = let
390                  val fName = concat[name, "_", methName]
391                  val params = [
392                          CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "selfIn"),
393                          CL.PARAM([], CL.T_Ptr(CL.T_Named tyName), "selfOut")
394                        ]
395                  val methFn = CL.D_Func([], CL.int32, fName, params, body)
396                  in
397                    code := methFn :: !code
398                  end
399        end (* Strand *)        end (* Strand *)
400    
401      fun genStrand (Strand{name, tyName, state, code}) = let      fun genStrand (Strand{name, tyName, state, code}) = let

Legend:
Removed from v.544  
changed lines
  Added in v.547

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