Skip to content

Commit

Permalink
first commit where libasl compiles to js
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Jun 24, 2024
1 parent 16f5021 commit 1a81081
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 8 deletions.
3 changes: 1 addition & 2 deletions libASL/dune
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,4 @@
)
(preprocessor_deps (alias ../asl_files))
(preprocess (pps ppx_blob))
(libraries libASL_support (re_export libASL_ast) str)))

(libraries libASL_support (re_export libASL_ast) str))
5 changes: 2 additions & 3 deletions libASL/tcheck.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ open Utils
open Asl_utils
open Printf

let verbose = false
let verbose = true


(****************************************************************)
Expand Down Expand Up @@ -718,7 +718,6 @@ let simplify_type (x: AST.ty): AST.ty =
let check_constraints (bs: expr list) (cs: expr list): bool =
LibASL_support.Solver.check_constraints bs cs


(****************************************************************)
(** {3 Unification support code} *)
(****************************************************************)
Expand Down Expand Up @@ -2465,7 +2464,7 @@ let tc_declarations (isPrelude: bool) (ds: AST.declaration list): AST.declaratio
if verbose then Printf.printf " - Typechecking %d phase 1 declarations\n" (List.length pre);
let pre' = List.map (tc_declaration env0) pre in
let post' = List.map (tc_declaration env0) post in
if verbose then List.iter (fun ds -> List.iter (fun d -> Printf.printf "\nTypechecked %s\n" (Utils.to_string (PP.pp_declaration d))) ds) post';
(* if verbose then List.iter (fun ds -> List.iter (fun d -> Printf.printf "\nTypechecked %s\n" (Utils.to_string (PP.pp_declaration d))) ds) post'; *)
if verbose then Printf.printf " - Typechecking %d phase 2 declarations\n" (List.length post);
List.append (List.concat pre') (List.concat post')

Expand Down
7 changes: 6 additions & 1 deletion web/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@
(name js)
(modes js)
(modules js)
(libraries z3 libASLResources dune-site str zarith pprint zarith_stubs_js)
(libraries boopimpl libASL dune-site str zarith pprint zarith_stubs_js)
(js_of_ocaml (flags --debug-info --no-inline :standard \ --source-map-inline))
)

(library
(name virtual)
(modules v)
(virtual_modules v))

(alias
(name default)
(deps js.bc.js index.html))
5 changes: 5 additions & 0 deletions web/impl/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

(library
(name boopimpl)
(implements virtual))

3 changes: 3 additions & 0 deletions web/impl/v.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

let read x = x ^ x
let write _ _ = ()
5 changes: 3 additions & 2 deletions web/js.ml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
let () =
print_endline "hello from js";
print_endline @@ Int.to_string @@ List.length LibASLResources.Res.Sites.aslfiles
(* print_endline @@ LibASL.Value.(pp_value @@ from_bitsLit "100") *)
(* print_endline @@ Int.to_string @@ List.length LibASLResources.Res.Sites.aslfiles; *)
print_endline @@ LibASL.Value.(pp_value @@ from_bitsLit "100");
print_endline @@ Virtual.V.read "boop"
2 changes: 2 additions & 0 deletions web/v.mli
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val read : string -> string
val write : string -> string -> unit

0 comments on commit 1a81081

Please sign in to comment.