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

SCM Repository

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

Diff of /branches/vis12/src/compiler/c-target/c-target.sml

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

revision 2810, Sat Nov 8 18:26:25 2014 UTC revision 2811, Sat Nov 8 18:34:41 2014 UTC
# Line 82  Line 82 
82                end                end
83  (* NOTE: we may be able to simplify the interface to ToC.trBlock! *)  (* NOTE: we may be able to simplify the interface to ToC.trBlock! *)
84          fun block (ENV{vMap, ...}, blk) = ToC.trBlock (vMap, blk)          fun block (ENV{vMap, ...}, blk) = ToC.trBlock (vMap, blk)
         fun free (ENV{vMap, ...}, blk) = ToC.trFree (vMap, blk)  
85          fun exp (ENV{vMap, ...}, e) = ToC.trExp(vMap, e)          fun exp (ENV{vMap, ...}, e) = ToC.trExp(vMap, e)
86        end        end
87    
# Line 262  Line 261 
261                  end                  end
262                else ()                else ()
263        (* register the global destruction part of a program *)        (* register the global destruction part of a program *)
264          fun free (Prog{props, topDecls, ...}, free) = if (#hasGlobals props)          fun free (Prog{props, topDecls, ...}, env, globals) = let
               then let  
265                  val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy props))                  val worldTy = CL.T_Ptr(CL.T_Named(N.worldTy props))
266                  val globTy = CL.T_Ptr(CL.T_Named(N.globalsTy props))                  val globTy = CL.T_Ptr(CL.T_Named(N.globalsTy props))
267                  fun global x = CL.mkIndirect(CL.mkVar "glob", "gv_" ^ IL.GlobalVar.name x)
268                  fun freeGlob (x, stms) = (case IL.GlobalVar.ty x
269                         of Ty.DynSeqTy _ => CL.mkCall("Diderot_DynSeqFree", [global x]) :: stms
270                          | Ty.ImageTy info => CL.mkCall(N.freeImage(ImageInfo.dim info), [
271                                CL.mkCast(World.prefixTy, CL.mkVar "wrld"), global x
272                              ]) :: stms
273                          | _ => stms
274                        (* end case *))
275                  val body = CL.mkBlock(                  val body = CL.mkBlock(
276                        CL.mkDeclInit(globTy, "glob", CL.mkIndirect(CL.mkVar "wrld", "globals")) ::                        CL.mkDeclInit(globTy, "glob", CL.mkIndirect(CL.mkVar "wrld", "globals")) ::
277                        CL.unBlock free @ [CL.mkReturn(SOME(CL.mkVar "false"))])                      List.foldr freeGlob [CL.mkReturn(SOME(CL.mkVar "false"))] globals)
278                  val freeFn = CL.D_Func(                  val freeFn = CL.D_Func(
279                        ["static"], CL.boolTy, N.freeGlobals,                        ["static"], CL.boolTy, N.freeGlobals,
280                        [CL.PARAM([], worldTy, "wrld")],                        [CL.PARAM([], worldTy, "wrld")],
# Line 276  Line 282 
282                  in                  in
283                    topDecls := freeFn :: !topDecls                    topDecls := freeFn :: !topDecls
284                  end                  end
               else ()  
285        (* create and register the initially function for a program *)        (* create and register the initially function for a program *)
286          fun initially {          fun initially {
287                prog = Prog{props, strands, nAxes, initially, ...},                prog = Prog{props, strands, nAxes, initially, ...},

Legend:
Removed from v.2810  
changed lines
  Added in v.2811

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