summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKathy Gray2014-10-07 14:00:20 +0100
committerKathy Gray2014-10-07 14:00:20 +0100
commit6d15542f8fcd520b5741e733408f37a2fc9e37f8 (patch)
treef7063ec5d7d41ef5546c9006d4aa3350d0252939 /src
parent8399a028fc78512214075115bcdb29015d211db9 (diff)
Merge and make real Peter's comment type
Diffstat (limited to 'src')
-rw-r--r--src/lem_interp/interp_inter_imp.lem18
-rw-r--r--src/lem_interp/interp_interface.lem13
2 files changed, 12 insertions, 19 deletions
diff --git a/src/lem_interp/interp_inter_imp.lem b/src/lem_interp/interp_inter_imp.lem
index a69ea430..292552f4 100644
--- a/src/lem_interp/interp_inter_imp.lem
+++ b/src/lem_interp/interp_inter_imp.lem
@@ -91,7 +91,7 @@ let memory_functions =
(v,len,regs) end end)));
]
-let rec interp_to_value_helper thunk =
+let rec interp_to_value_helper arg thunk =
match thunk() with
| Interp.Value value -> (Just value,Nothing)
| Interp.Error l msg -> (Nothing, Just (Internal_error msg))
@@ -99,12 +99,12 @@ let rec interp_to_value_helper thunk =
match List.lookup i external_functions with
| Nothing -> (Nothing, Just (Internal_error ("External function not available " ^ i)))
| Just f ->
- interp_to_value_helper (fun _ -> Interp.resume (make_mode true false) stack (Just (f value)))
+ interp_to_value_helper arg (fun _ -> Interp.resume (make_mode true false) stack (Just (f value)))
end
| Interp.Action (Interp.Exit (E_aux e _)) _ ->
match e with
| E_id (Id_aux (Id "unsupported_instruction") _) -> (Nothing,Just (Unsupported_instruction_error ("",[],[])))
- | E_id (Id_aux (Id "no_matching_pattern") _) -> (Nothing,Just Not_an_instruction_error)
+ | E_id (Id_aux (Id "no_matching_pattern") _) -> (Nothing,Just (Not_an_instruction_error arg))
end
| _ -> (Nothing, Just (Internal_error "Memory or register requested in decode"))
end
@@ -112,7 +112,7 @@ end
let decode_to_istate top_level value =
let mode = make_mode true false in
let (arg,_) = Interp.to_exp mode Interp.eenv (intern_value value) in
- let (instr_decoded,error) = interp_to_value_helper
+ let (instr_decoded,error) = interp_to_value_helper value
(fun _ -> Interp.resume
(make_mode true false)
(Interp.Thunk_frame
@@ -121,7 +121,7 @@ let decode_to_istate top_level value =
match (instr_decoded,error) with
| (Just instr, _) ->
let (arg,_) = Interp.to_exp mode Interp.eenv instr in
- let (instr_decoded,error) = interp_to_value_helper
+ let (instr_decoded,error) = interp_to_value_helper value
(fun _ -> Interp.resume
(make_mode true false)
(Interp.Thunk_frame
@@ -130,13 +130,13 @@ let decode_to_istate top_level value =
match (instr_decoded,error) with
| (Just instr,_) ->
let (arg,_) = Interp.to_exp mode Interp.eenv instr in
- Instr (Interp.Thunk_frame
+ Instr ("",[],[])
+ (Interp.Thunk_frame
(E_aux (E_app (Id_aux (Id "execute") Interp_ast.Unknown) [arg]) (Interp_ast.Unknown,Nothing))
top_level Interp.eenv Interp.emem Interp.Top)
- ("",[],[])
- | (Nothing, Just err) -> err
+ | (Nothing, Just err) -> Decode_error err
end
- | (Nothing, Just err) -> err
+ | (Nothing, Just err) -> Decode_error err
end
let rec interp_to_outcome mode thunk =
diff --git a/src/lem_interp/interp_interface.lem b/src/lem_interp/interp_interface.lem
index 68e57b47..ec863a41 100644
--- a/src/lem_interp/interp_interface.lem
+++ b/src/lem_interp/interp_interface.lem
@@ -82,22 +82,15 @@ Follows the form of the instruction in instruction_extractor, but populates the
*)
type instruction_form = (string * list (string * instr_parm_typ * value) * list base_effect)
-type i_state_or_error =
- | Instr of instruction_state * instruction_form
- | Unsupported_instruction_error of instruction_form
- | Not_an_instruction_error
- | Internal_error of string
-
-(*
type decode_error =
- | Unsupported_instruction_error of instruction
+ | Unsupported_instruction_error of instruction_form
| Not_an_instruction_error of value
| Internal_error of string
type i_state_or_error =
- | Instr of instruction * instruction_state
+ | Instr of instruction_form * instruction_state
| Decode_error of decode_error
-*)
+
(*Function to decode an instruction and build the state to run it*)
val decode_to_istate : context -> value -> i_state_or_error