diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2014-09-27 15:33:20 +0200 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2014-09-27 15:33:20 +0200 |
| commit | 5f754e3f883b468953a73afd8a12b279a3a5c2b8 (patch) | |
| tree | 5226363fd35eb471ee0414e1c52ce024436f4127 /Environment.ml | |
| parent | 70a66df43253ee29f3856cf48c7e08e238f5cd20 (diff) | |
Moved the code into src/
Diffstat (limited to 'Environment.ml')
| -rw-r--r-- | Environment.ml | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/Environment.ml b/Environment.ml deleted file mode 100644 index dab9bce..0000000 --- a/Environment.ml +++ /dev/null @@ -1,52 +0,0 @@ -(* -Copyright (c) 2014, Grégoire Duchêne <gduchene@awhk.org> - -Permission to use, copy, modify, and/or distribute this software for -any purpose with or without fee is hereby granted, provided that the -above copyright notice and this permission notice appear in all -copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL -WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE -AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL -DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR -PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER -TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. -*) - -open Common - -type t = { - global : (id, value) Hashtbl.t; - lexical : (id * value ref) list; -} - -let assign_lexical env id v = - List.assoc id env.lexical := v - -let bind_global env id v = - Hashtbl.add env.global id v - -let bind_lexical env id v = - { env with lexical = (id, ref v) :: env.lexical } - -let bind_lexical_all env l = - List.fold_left (fun env (id, v) -> bind_lexical env id v) env l - -let fresh () = - { global = Hashtbl.create 10; lexical = []; } - -let lookup_global env id = - try Hashtbl.find env.global id - with Not_found -> - try Symtable.get_global_value id - with Symtable.Error e -> id_not_found id - -let lookup_lexical env id = - try !(List.assoc id env.lexical) - with Not_found -> id_not_found id - -let lookup_lexical_str env id = - !(snd @$ List.find (fun (id', _) -> id = id'.Ident.name) env.lexical) |
