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

SCM Repository

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

Diff of /branches/vis15/src/compiler/typechecker/env.sml

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

revision 4348, Tue Aug 2 15:48:33 2016 UTC revision 4349, Tue Aug 2 18:14:48 2016 UTC
# Line 20  Line 20 
20      datatype scope      datatype scope
21        = GlobalScope                             (* global declarations *)        = GlobalScope                             (* global declarations *)
22        | FunctionScope of Types.ty * Atom.atom   (* inside a function definition *)        | FunctionScope of Types.ty * Atom.atom   (* inside a function definition *)
23        | StrandScope                             (* inside a strand definition *)        | StrandScope of Atom.atom                (* inside a strand definition *)
24        | MethodScope of StrandUtil.method_name   (* inside a strand method definition *)        | MethodScope of Atom.atom * StrandUtil.method_name
25                                                    (* inside a strand method definition *)
26        | InitScope                               (* inside global initialization *)        | InitScope                               (* inside global initialization *)
27        | CreateScope                             (* inside initial strand creation *)        | CreateScope                             (* inside initial strand creation *)
28        | InitiallyScope                          (* inside global initially *)        | InitiallyScope                          (* inside global initially *)
# Line 51  Line 52 
52    (* start a new function scope *)    (* start a new function scope *)
53      val functionScope : t * Types.ty * Atom.atom -> t      val functionScope : t * Types.ty * Atom.atom -> t
54    (* start a new strand scope *)    (* start a new strand scope *)
55      val strandScope : t -> t      val strandScope : t * Atom.atom -> t
56    (* start a new strand scope *)    (* start a new strand-method scope *)
57      val methodScope : t * StrandUtil.method_name -> t      val methodScope : t * StrandUtil.method_name -> t
58    (* start a new global initialization scope *)    (* start a new global initialization scope *)
59      val initScope : t -> t      val initScope : t -> t
# Line 65  Line 66 
66    (* start a new block scope *)    (* start a new block scope *)
67      val blockScope : t -> t      val blockScope : t -> t
68    
69      (* get the strand type (NONE if not within Strand or Method scope) *)
70        val strandTy : t -> Types.ty option
71    
72    (* functions are either user-defined or pre-defined *)    (* functions are either user-defined or pre-defined *)
73      datatype fun_def      datatype fun_def
74        = PrimFun of AST.var list                 (* possibly overloaded builtin function *)        = PrimFun of AST.var list                 (* possibly overloaded builtin function *)
# Line 114  Line 118 
118      datatype scope      datatype scope
119        = GlobalScope                             (* global declarations *)        = GlobalScope                             (* global declarations *)
120        | FunctionScope of Ty.ty * Atom.atom      (* inside a function definition *)        | FunctionScope of Ty.ty * Atom.atom      (* inside a function definition *)
121        | StrandScope                             (* inside a strand definition *)        | StrandScope of Atom.atom                (* inside a strand definition *)
122        | MethodScope of StrandUtil.method_name   (* inside a strand method definition *)        | MethodScope of Atom.atom * StrandUtil.method_name
123                                                    (* inside a strand method definition *)
124        | InitScope                               (* inside global initialization *)        | InitScope                               (* inside global initialization *)
125        | CreateScope                             (* inside initial strand creation *)        | CreateScope                             (* inside initial strand creation *)
126        | InitiallyScope                          (* inside global initially *)        | InitiallyScope                          (* inside global initially *)
# Line 123  Line 128 
128    
129      fun scopeToString GlobalScope = "global scope"      fun scopeToString GlobalScope = "global scope"
130        | scopeToString (FunctionScope(_, f)) = "function " ^ Atom.toString f        | scopeToString (FunctionScope(_, f)) = "function " ^ Atom.toString f
131        | scopeToString StrandScope = "strand initialization"        | scopeToString (StrandScope s)= "strand " ^ Atom.toString s
132        | scopeToString (MethodScope m) = "method " ^ StrandUtil.nameToString m        | scopeToString (MethodScope(s, m)) = concat[
133                "method ", Atom.toString s, ".", StrandUtil.nameToString m
134              ]
135        | scopeToString InitScope = "global initialization"        | scopeToString InitScope = "global initialization"
136        | scopeToString CreateScope = "strand creation"        | scopeToString CreateScope = "strand creation"
137        | scopeToString InitiallyScope = "global initially"        | scopeToString InitiallyScope = "global initially"
# Line 151  Line 158 
158    (* start a new scope *)    (* start a new scope *)
159      fun functionScope (E{scope, bindings, gEnv, vEnv}, ty, f) =      fun functionScope (E{scope, bindings, gEnv, vEnv}, ty, f) =
160            E{scope=FunctionScope(ty, f), bindings=AtomMap.empty, gEnv=gEnv, vEnv=AMap.empty}            E{scope=FunctionScope(ty, f), bindings=AtomMap.empty, gEnv=gEnv, vEnv=AMap.empty}
161      fun strandScope (E{scope, bindings, gEnv, vEnv}) =      fun strandScope (E{scope, bindings, gEnv, vEnv}, strand) =
162            E{scope=StrandScope, bindings=AtomMap.empty, gEnv=gEnv, vEnv=AMap.empty}            E{scope=StrandScope strand, bindings=AtomMap.empty, gEnv=gEnv, vEnv=AMap.empty}
163      fun methodScope (E{scope, bindings, gEnv, vEnv}, name) =      fun methodScope (E{scope, bindings, gEnv, vEnv}, name) = (case scope
164            E{scope=MethodScope name, bindings=AtomMap.empty, gEnv=gEnv, vEnv=vEnv}             of StrandScope strand => E{
165                      scope=MethodScope(strand, name),
166                      bindings=AtomMap.empty, gEnv=gEnv, vEnv=vEnv
167                    }
168                | _ => raise Fail("methodScope called in " ^ scopeToString scope)
169              (* end case *))
170      fun initScope (E{scope, bindings, gEnv, vEnv}) =      fun initScope (E{scope, bindings, gEnv, vEnv}) =
171            E{scope=InitScope, bindings=AtomMap.empty, gEnv=gEnv, vEnv=AMap.empty}            E{scope=InitScope, bindings=AtomMap.empty, gEnv=gEnv, vEnv=AMap.empty}
172      fun createScope (E{scope, bindings, gEnv, vEnv}) =      fun createScope (E{scope, bindings, gEnv, vEnv}) =
# Line 171  Line 183 
183      fun inMethod (E{scope=MethodScope _, ...}) = true      fun inMethod (E{scope=MethodScope _, ...}) = true
184        | inMethod _ = false        | inMethod _ = false
185    
186      fun inStrand (E{scope=StrandScope, ...}) = true      fun inStrand (E{scope=StrandScope _, ...}) = true
187        | inStrand (E{scope=MethodScope _, ...}) = true        | inStrand (E{scope=MethodScope _, ...}) = true
188        | inStrand _ = false        | inStrand _ = false
189    
190        fun strandTy (E{scope=StrandScope s, ...}) = SOME(Types.T_Strand s)
191          | strandTy (E{scope=MethodScope(s, _), ...}) = SOME(Types.T_Strand s)
192          | strandTy (E{scope, ...}) = NONE
193    
194      fun inGlobalInit (E{scope=InitScope, ...}) = true      fun inGlobalInit (E{scope=InitScope, ...}) = true
195        | inGlobalInit _ = false        | inGlobalInit _ = false
196    

Legend:
Removed from v.4348  
changed lines
  Added in v.4349

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