SCM Repository
View of /trunk/src/compiler/env/env.sml
Parent Directory
|
Revision Log
Revision 110 -
(download)
(annotate)
Wed Jun 23 19:28:48 2010 UTC (11 years, 11 months ago) by jhr
File size: 1104 byte(s)
Wed Jun 23 19:28:48 2010 UTC (11 years, 11 months ago) by jhr
File size: 1104 byte(s)
Moving compiler sources into src/compiler
(* env.sml * * COPYRIGHT (c) 2010 The Diderot Project (http://diderot.cs.uchicago.edu) * All rights reserved. *) structure Env : sig type env val new : unit -> env val findVar : env * Atom.atom -> AST.var option val insertGlobal : env * Atom.atom * AST.var -> env val insertLocal : env * Atom.atom * AST.var -> env end = struct structure ATbl = AtomTable structure AMap = AtomMap (* global environment holds global variables and actors *) datatype global_env = GE of { vEnv : AST.var ATbl.hash_table } datatype env = E of { g : global_env, vEnv : AST.var AMap.map } fun new () = E{ g = GE{vEnv = ATbl.mkTable(128, Fail "global env")}, vEnv = AMap.empty } fun findVar (E{g=GE{vEnv=gvEnv, ...}, vEnv}, x) = (case AMap.find(vEnv, x) of NONE => ATbl.find gvEnv x | someVar => someVar (* end case *)) fun insertGlobal (env as E{g=GE{vEnv, ...}, ...}, x, x') = ( ATbl.insert vEnv (x, x'); env) fun insertLocal (env as E{vEnv, g}, x, x') = E{vEnv = AMap.insert(vEnv, x, x'), g = g} end
root@smlnj-gforge.cs.uchicago.edu | ViewVC Help |
Powered by ViewVC 1.0.0 |