summaryrefslogtreecommitdiff
path: root/interpret/interpret.ml
diff options
context:
space:
mode:
Diffstat (limited to 'interpret/interpret.ml')
-rw-r--r--interpret/interpret.ml24
1 files changed, 13 insertions, 11 deletions
diff --git a/interpret/interpret.ml b/interpret/interpret.ml
index 6f7c90e..b9a5576 100644
--- a/interpret/interpret.ml
+++ b/interpret/interpret.ml
@@ -1,6 +1,7 @@
open Ast
open Util
open Ast_util
+open Typing
module I : sig
@@ -26,13 +27,13 @@ module I : sig
(*
Get the constants only
*)
- val consts : prog -> id -> value VarMap.t
+ val consts : rooted_prog -> value VarMap.t
(*
Construct initial state for a program.
The id is the root node of the program evaluation.
*)
- val init_state : prog -> id -> state
+ val init_state : rooted_prog -> state
(*
Run a step of the program (not necessary to specify the program,
@@ -88,6 +89,7 @@ end = struct
type state = {
+ rp : rooted_prog;
p : prog;
root_scope : scope;
outputs : id list;
@@ -441,13 +443,13 @@ end = struct
(*
init_state : prog -> id -> state
*)
- let init_state p root =
- let (n, _) = find_node_decl p root in
+ let init_state rp =
let st = {
- p = p;
- root_scope = get_root_scope p root;
+ rp = rp;
+ p = rp.p;
+ root_scope = rp.root_scope;
save = VarMap.empty;
- outputs = (List.map (fun (_,n,_) -> n) n.ret);
+ outputs = (List.map (fun (_,n,_) -> n) rp.root_node.ret);
} in
let env = { st = st; vars = Hashtbl.create 42 } in
@@ -461,11 +463,11 @@ end = struct
| [v] -> Hashtbl.replace env.vars cpath v
| _ -> loc_error l error "Arity error in constant expression."))
| _ -> ())
- p;
+ rp.p;
List.iter (function
| AST_const_decl(d, l) -> ignore (get_var env "cst" d.c_name)
| _ -> ())
- p;
+ rp.p;
reset_scope env st.root_scope;
{ st with save = Hashtbl.fold VarMap.add env.vars VarMap.empty }
@@ -485,7 +487,7 @@ end = struct
do_weak_transitions env st.root_scope;
extract_st env, out
- let consts p root =
- (init_state p root).save
+ let consts rp =
+ (init_state rp).save
end