Skip to content

Commit

Permalink
start to switch completely to the new interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
zapashcanon committed Jul 11, 2023
1 parent eed119c commit 47072f4
Show file tree
Hide file tree
Showing 19 changed files with 225 additions and 1,510 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ val link_state : Link.state =
...
# let () =
Log.debug_on := true;
match Interpret.modul module_to_run with
match Interpret.I.modul module_to_run with
| Ok () -> ()
| Error e -> failwith e;;
interpreting ...
Expand Down
2 changes: 1 addition & 1 deletion example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ let module_to_run =
(* let's run it ! it will print the values as defined in the print_i32 function *)
let () =
match Interpret.modul module_to_run with
match Interpret.I.modul module_to_run with
| Error msg -> failwith msg
| Ok () -> ()
```
Expand Down
2 changes: 1 addition & 1 deletion example/extern.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ let module_to_run =

(* let's run it ! it will print the values as defined in the print_i32 function *)
let () =
match Interpret.modul link_state.envs module_to_run with
match Interpret.I.modul link_state.envs module_to_run with
| Error msg -> failwith msg
| Ok () -> ()
4 changes: 2 additions & 2 deletions example/life_game/life_console.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ let module_to_run, link_state =

(* let's run it ! First module to be interpreted *)
let () =
match Interpret.modul link_state.envs module_to_run with
match Interpret.I.modul link_state.envs module_to_run with
| Error msg -> failwith msg
| Ok () -> ()

Expand All @@ -82,6 +82,6 @@ let module_to_run =

(* let's run it ! it will animate the game of life in console *)
let () =
match Interpret.modul link_state.envs module_to_run with
match Interpret.I.modul link_state.envs module_to_run with
| Error msg -> failwith msg
| Ok () -> ()
4 changes: 2 additions & 2 deletions example/life_game/life_graphics.ml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ let module_to_run, link_state =

(* let's run it ! First module to be interpreted *)
let () =
match Interpret.modul link_state.envs module_to_run with
match Interpret.I.modul link_state.envs module_to_run with
| Error msg -> failwith msg
| Ok () -> ()

Expand All @@ -94,6 +94,6 @@ let module_to_run =

(* let's run it ! it will animate the game of life in a graphics window *)
let () =
match Interpret.modul link_state.envs module_to_run with
match Interpret.I.modul link_state.envs module_to_run with
| Error msg -> failwith msg
| Ok () -> ()
5 changes: 1 addition & 4 deletions src/bin/owi.ml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
open Owi
open Syntax

let test = true

let simplify_then_link_then_run ~optimize file =
let* to_run, link_state =
list_fold_left
Expand All @@ -17,8 +15,7 @@ let simplify_then_link_then_run ~optimize file =
| _ -> Ok acc )
([], Link.empty_state) file
in
let interp_modul = if test then Interpret2.I.modul else Interpret.modul in
list_iter (interp_modul link_state.envs) (List.rev to_run)
list_iter (Interpret.I.modul link_state.envs) (List.rev to_run)

let run_file exec filename =
if not @@ Sys.file_exists filename then
Expand Down
7 changes: 3 additions & 4 deletions src/bin/owi_sym.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
open Owi
open Syntax

module Choice = Sym_state.P.Choice

let print_extern_module : Sym_state.P.extern_func Link.extern_module =
Expand All @@ -20,8 +19,8 @@ let print_extern_module : Sym_state.P.extern_func Link.extern_module =
let assert_extern_module : Sym_state.P.extern_func Link.extern_module =
let positive_i32 (i : Sym_value.S.int32) : unit Choice.t =
fun thread ->
let c = Sym_value.S.I32.ge i (Sym_value.S.I32.zero) in
[(), { thread with pc = c :: thread.pc } ]
let c = Sym_value.S.I32.ge i Sym_value.S.I32.zero in
[ ((), { thread with pc = c :: thread.pc }) ]
in
(* we need to describe their types *)
let functions =
Expand Down Expand Up @@ -91,7 +90,7 @@ let simplify_then_link_then_run ~optimize pc file =
([], link_state) file
in
let f pc to_run =
let c = (Interpret2.S.modul link_state.envs) to_run in
let c = (Interpret.S.modul link_state.envs) to_run in
let results = List.flatten @@ List.map c pc in
let results =
List.map (function Ok (), t -> t | Error _, _ -> assert false) results
Expand Down
2 changes: 1 addition & 1 deletion src/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ let until_link link_state ~optimize ~name m =

let until_interpret link_state ~optimize ~name m =
let* m, link_state = until_link link_state ~optimize ~name m in
let* () = Interpret.modul link_state.envs m in
let* () = Interpret.I.modul link_state.envs m in
Ok link_state
2 changes: 1 addition & 1 deletion src/dune
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
int64
func_intf
interpret
interpret2
interpret_functor
value_intf
value_test
Expand Down Expand Up @@ -54,6 +53,7 @@
string_map
symbolic
syntax
trap
typecheck
types
value
Expand Down
Loading

0 comments on commit 47072f4

Please sign in to comment.