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

SCM Repository

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

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

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

revision 2151, Sun Feb 17 19:07:20 2013 UTC revision 2152, Sun Feb 17 19:39:37 2013 UTC
# Line 10  Line 10 
10    
11      val new : unit -> env      val new : unit -> env
12    
13      val findFunc : env * Atom.atom -> AST.var list    (* functions are either user-defined or pre-defined *)
14        datatype fun_def
15          = PrimFun of AST.var list                 (* possibly overloaded builtin function *)
16          | UserFun of AST.var                      (* user-defined function *)
17    
18        val findFunc : env * Atom.atom -> fun_def
19    
20      val findVar : env * Atom.atom -> AST.var option      val findVar : env * Atom.atom -> AST.var option
21    
22    (* insert a function binding *)    (* insert a function binding *)
23      val insertFunc : env * Atom.atom * AST.var list -> env      val insertFunc : env * Atom.atom * fun_def -> env
24    
25    (* insert variable bindings *)    (* insert variable bindings *)
26      val insertGlobal : env * Atom.atom * AST.var -> env      val insertGlobal : env * Atom.atom * AST.var -> env
# Line 26  Line 31 
31      structure ATbl = AtomTable      structure ATbl = AtomTable
32      structure AMap = AtomMap      structure AMap = AtomMap
33    
34      (* functions are either user-defined or pre-defined *)
35        datatype fun_def
36          = PrimFun of AST.var list                 (* possibly overloaded builtin function *)
37          | UserFun of AST.var                      (* user-defined function *)
38    
39    (* global environment holds global variables and strands *)    (* global environment holds global variables and strands *)
40      datatype global_env = GE of {      datatype global_env = GE of {
41          fEnv : AST.var list ATbl.hash_table,    (* functions, which may be overloaded *)          fEnv : fun_def ATbl.hash_table, (* functions, which may be overloaded *)
42          vEnv : AST.var ATbl.hash_table          (* global variable bindings *)          vEnv : AST.var ATbl.hash_table          (* global variable bindings *)
43        }        }
44    
# Line 46  Line 56 
56            }            }
57    
58      fun findFunc (E{g=GE{fEnv, ...}, ...}, x) = (case ATbl.find fEnv x      fun findFunc (E{g=GE{fEnv, ...}, ...}, x) = (case ATbl.find fEnv x
59             of NONE => []             of NONE => PrimFun[]
60              | SOME fns => fns              | SOME fdef => fdef
61            (* end case *))            (* end case *))
62    
63      fun findVar (E{g=GE{vEnv=gvEnv, ...}, vEnv}, x) = (case AMap.find(vEnv, x)      fun findVar (E{g=GE{vEnv=gvEnv, ...}, vEnv}, x) = (case AMap.find(vEnv, x)

Legend:
Removed from v.2151  
changed lines
  Added in v.2152

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