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

SCM Repository

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

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

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

revision 1858, Fri Apr 20 20:14:41 2012 UTC revision 1870, Fri May 11 17:44:18 2012 UTC
# Line 27  Line 27 
27    
28      val trBlock : env * TreeIL.block -> CLang.stm      val trBlock : env * TreeIL.block -> CLang.stm
29    
30        val trFree : env * TreeIL.block -> CLang.stm
31    
32      val trFragment : env * TreeIL.block -> env * CLang.stm list      val trFragment : env * TreeIL.block -> env * CLang.stm list
33    
34      val trExp : env * TreeIL.exp -> CLang.exp      val trExp : env * TreeIL.exp -> CLang.exp
# Line 482  Line 484 
484                CL.mkReturn(SOME(CL.mkVar "true")))]                CL.mkReturn(SOME(CL.mkVar "true")))]
485            end            end
486    
487        fun trF (env, stms) = let
488              fun trStmt (env, stm) = (case stm
489                     of IL.S_Comment text => [CL.mkComment text]
490                      | IL.S_LoadImage(lhs, dim, name) => checkSts (fn sts => let
491                          val lhs = VarToC.lvalueVar (env, lhs)
492                          val imgTy = CL.T_Named(N.imageTy dim)
493                          val freeFn = N.freeImage dim
494                          in [
495                            CL.mkDecl(
496                              CL.T_Named N.statusTy, sts,
497                              SOME(CL.I_Exp(CL.E_Apply(freeFn, [
498                                  CL.mkCast(CL.T_Ptr(CL.T_Named "WorldPrefix_t"), CL.mkVar "wrld"),
499                                  addrOf lhs
500                                ]))))
501                          ] end)
502                      | _ => []
503                    (* end case *))
504              in
505                List.foldr (fn (stm, stms) => trStmt(env, stm)@stms) [] stms
506              end
507    
508        and trFr (env, IL.Block{locals, body}) = let
509              val env = trLocals (env, locals)
510              val stms = trF (env, body)
511              fun mkDecl (x, stms) = (case V.Map.find (env, x)
512                     of SOME(V(ty, x')) => CL.mkDecl(ty, x', NONE) :: stms
513                      | NONE => raise Fail(concat["mkDecl(", V.name x, ", _)"])
514                    (* end case *))
515              val stms = List.foldr mkDecl stms locals
516              in
517                CL.mkBlock stms
518              end
519    
520      fun trStms (env, stms) = let      fun trStms (env, stms) = let
521            fun trStmt (env, stm) = (case stm            fun trStmt (env, stm) = (case stm
522                   of IL.S_Comment text => [CL.mkComment text]                   of IL.S_Comment text => [CL.mkComment text]
# Line 550  Line 585 
585    
586      val trBlock = trBlk      val trBlock = trBlk
587    
588        val trFree = trFr
589    
590    end    end

Legend:
Removed from v.1858  
changed lines
  Added in v.1870

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