SCM Repository
View of /trunk/src/env/env.sml
Parent Directory
|
Revision Log
Revision 78 -
(download)
(annotate)
Mon May 24 22:31:49 2010 UTC (12 years ago) by jhr
File size: 1104 byte(s)
Mon May 24 22:31:49 2010 UTC (12 years ago) by jhr
File size: 1104 byte(s)
Rosking on type checker
(* 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 |