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

SCM Repository

[diderot] Diff of /branches/vis15/src/compiler/codegen/codegen-env.sml
ViewVC logotype

Diff of /branches/vis15/src/compiler/codegen/codegen-env.sml

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

revision 3958, Sun Jun 12 19:51:51 2016 UTC revision 3959, Mon Jun 13 14:54:10 2016 UTC
# Line 19  Line 19 
19    
20      val empty : TargetSpec.t -> t      val empty : TargetSpec.t -> t
21    
22      (* a callback for the TreeIR S_Exit statement *)
23        val setExitHandler : t * (t -> CLang.stm list) -> t
24        val handleExit     : t -> CLang.stm list
25    
26    (* get the target spec record from the environment *)    (* get the target spec record from the environment *)
27      val target : t -> TargetSpec.t      val target : t -> TargetSpec.t
28    
# Line 49  Line 53 
53    
54      datatype t = Env of {      datatype t = Env of {
55          vmap : CL.var VMap.map,          vmap : CL.var VMap.map,
56          spec : TargetSpec.t          spec : TargetSpec.t,
57            onExit : (t -> CL.stm list)
58        }        }
59    
60      fun new {spec, global, selfIn, selfOut} = Env{      fun new {spec, global, selfIn, selfOut} = Env{
# Line 59  Line 64 
64                  (PseudoVars.selfOut, selfOut),                  (PseudoVars.selfOut, selfOut),
65                  (PseudoVars.world, "wrld")                  (PseudoVars.world, "wrld")
66                ],                ],
67              spec = spec              spec = spec,
68                onExit = fn _ => []
69            }            }
70    
71      fun empty spec = Env{      fun empty spec = Env{
72              vmap = VMap.empty,              vmap = VMap.empty,
73              spec = spec              spec = spec,
74                onExit = fn _ => []
75            }            }
76    
77        fun setExitHandler (Env{vmap, spec, ...}, f) = Env{vmap=vmap, spec=spec, onExit=f}
78        fun handleExit (env as Env{onExit, ...}) = onExit env
79    
80      fun target (Env{spec, ...}) = spec      fun target (Env{spec, ...}) = spec
81    
82      fun lookup (Env{vmap, ...}, x) = (case VMap.find (vmap, x)      fun lookup (Env{vmap, ...}, x) = (case VMap.find (vmap, x)
# Line 74  Line 84 
84              | NONE => raise Fail(concat["lookup(_, ", V.name x, ")"])              | NONE => raise Fail(concat["lookup(_, ", V.name x, ")"])
85            (* end case *))            (* end case *))
86    
87      fun insert (Env{vmap, spec}, x, x') = Env{vmap = VMap.insert(vmap, x, x'), spec = spec}      fun insert (Env{vmap, spec, onExit}, x, x') =
88              Env{vmap = VMap.insert(vmap, x, x'), spec = spec, onExit = onExit}
89    
90      fun global env = lookup(env, PseudoVars.global)      fun global env = lookup(env, PseudoVars.global)
91      fun selfIn env = lookup(env, PseudoVars.selfIn)      fun selfIn env = lookup(env, PseudoVars.selfIn)

Legend:
Removed from v.3958  
changed lines
  Added in v.3959

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