(* 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
Click to toggle
does not end with </html> tag
does not end with </body> tag
The output has ended thus: fun insertLocal (env as E{vEnv, g}, x, x') = E{vEnv = AMap.insert(vEnv, x, x'), g = g} end