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

SCM Repository

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

Diff of /branches/vis12/src/compiler/env/env.sml

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

revision 2210, Tue Feb 26 05:42:16 2013 UTC revision 2211, Tue Feb 26 12:13:36 2013 UTC
# Line 15  Line 15 
15        = PrimFun of AST.var list                 (* possibly overloaded builtin function *)        = PrimFun of AST.var list                 (* possibly overloaded builtin function *)
16        | UserFun of AST.var                      (* user-defined function *)        | UserFun of AST.var                      (* user-defined function *)
17    
18        val findStrand : env * Atom.atom -> AST.strand option
19      val findFunc : env * Atom.atom -> fun_def      val findFunc : env * Atom.atom -> fun_def
   
20      val findVar : env * Atom.atom -> AST.var option      val findVar : env * Atom.atom -> AST.var option
21    
22        val insertStrand : env * AST.strand -> env
23    
24    (* insert a function binding *)    (* insert a function binding *)
25      val insertFunc : env * Atom.atom * fun_def -> env      val insertFunc : env * Atom.atom * fun_def -> env
26    
# Line 38  Line 40 
40    
41    (* global environment holds global variables and strands *)    (* global environment holds global variables and strands *)
42      datatype global_env = GE of {      datatype global_env = GE of {
43            sEnv : AST.strand ATbl.hash_table,      (* strands *)
44          fEnv : fun_def ATbl.hash_table, (* functions, which may be overloaded *)          fEnv : fun_def ATbl.hash_table, (* functions, which may be overloaded *)
45          vEnv : AST.var ATbl.hash_table          (* global variable bindings *)          vEnv : AST.var ATbl.hash_table          (* global variable bindings *)
46        }        }
# Line 49  Line 52 
52    
53      fun new () = E{      fun new () = E{
54              g = GE{              g = GE{
55                    sEnv = ATbl.mkTable(8, Fail "strand env"),
56                  fEnv = ATbl.mkTable(128, Fail "global function env"),                  fEnv = ATbl.mkTable(128, Fail "global function env"),
57                  vEnv = ATbl.mkTable(128, Fail "global variable env")                  vEnv = ATbl.mkTable(128, Fail "global variable env")
58                },                },
59              vEnv = AMap.empty              vEnv = AMap.empty
60            }            }
61    
62        fun findStrand (E{g=GE{sEnv, ...}, ...}, s) = ATbl.find sEnv s
63    
64      fun findFunc (E{g=GE{fEnv, ...}, ...}, x) = (case ATbl.find fEnv x      fun findFunc (E{g=GE{fEnv, ...}, ...}, x) = (case ATbl.find fEnv x
65             of NONE => PrimFun[]             of NONE => PrimFun[]
66              | SOME fdef => fdef              | SOME fdef => fdef
# Line 65  Line 71 
71              | someVar => someVar              | someVar => someVar
72            (* end case *))            (* end case *))
73    
74        fun insertStrand (env as E{g=GE{sEnv, ...}, ...}, s as AST.Strand{name, ...}) = (
75              ATbl.insert sEnv (name, s);
76              env)
77    
78      fun insertFunc (env as E{g=GE{fEnv, ...}, ...}, f, f') = (      fun insertFunc (env as E{g=GE{fEnv, ...}, ...}, f, f') = (
79            ATbl.insert fEnv (f, f');            ATbl.insert fEnv (f, f');
80            env)            env)

Legend:
Removed from v.2210  
changed lines
  Added in v.2211

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