-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit fa797d9
Showing
14 changed files
with
497 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: Builds, tests & co | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
permissions: read-all | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: | ||
- macos-latest | ||
- ubuntu-latest | ||
|
||
runs-on: ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout tree | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set-up OCaml | ||
uses: ocaml/setup-ocaml@v2 | ||
with: | ||
ocaml-compiler: "ocaml-variants.5.1.1+effect-syntax" | ||
|
||
- run: opam install . --deps-only --with-test | ||
|
||
- run: opam exec -- dune build | ||
|
||
- run: opam exec -- dune runtest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
profile = default | ||
version = 0.26.2 | ||
wrap-comments = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
(executable | ||
(public_name react_trace) | ||
(name main) | ||
(libraries react_trace)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
let () = print_endline "Hello, World!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(lang dune 3.15) | ||
|
||
(name react_trace) | ||
|
||
(generate_opam_files true) | ||
|
||
(source | ||
(github React-Analysis/ReacttRace)) | ||
|
||
(authors "Jay Lee") | ||
|
||
(maintainers "Jay Lee") | ||
|
||
(license LICENSE) | ||
|
||
; (documentation https://url/to/documentation) | ||
|
||
(package | ||
(name react_trace) | ||
(synopsis "React Analyzer") | ||
(description "ReacttRace is a tool for analyzing React programs.") | ||
(depends | ||
ocaml | ||
dune | ||
(ocaml-variants (= 5.1.1+effect-syntax)) | ||
base | ||
logs | ||
stdio) | ||
(tags | ||
(React "Static Analysis"))) | ||
|
||
; See the complete stanza docs at https://dune.readthedocs.io/en/stable/dune-files.html#dune-project |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
open! Base | ||
|
||
type 'a t = { f : 'a list; r : 'a list } | ||
|
||
exception Empty_queue | ||
|
||
let empty = { f = []; r = [] } | ||
let is_empty = function { f = []; _ } -> true | _ -> false | ||
|
||
let enqueue q x = | ||
match q with | ||
| { f = []; _ } -> { f = [ x ]; r = [] } | ||
| { f; r } -> { f; r = x :: r } | ||
|
||
let front = function | ||
| { f = []; _ } -> raise Empty_queue | ||
| { f = h :: _; _ } -> h | ||
|
||
let dequeue = function | ||
| { f = []; _ } -> raise Empty_queue | ||
| { f = [ _ ]; r } -> { f = List.rev r; r = [] } | ||
| { f = _ :: t; r } -> { f = t; r } | ||
|
||
let size { f; r } = List.(length f + length r) | ||
let to_list { f; r } = f @ List.rev r | ||
let fold q = List.fold (to_list q) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
open! Base | ||
open Syntax | ||
|
||
module Env = struct | ||
type 'a t = 'a Id.Map.t | ||
|
||
let empty = Id.Map.empty | ||
let lookup env ~id = Map.find env id | ||
let extend env ~id ~value = Map.set env ~key:id ~data:value | ||
end | ||
|
||
module Store = struct | ||
type 'a t = 'a Label.Map.t | ||
|
||
let empty = Label.Map.empty | ||
let lookup store ~label = Map.find_exn store label | ||
let update store ~label ~value = Map.set store ~key:label ~data:value | ||
end | ||
|
||
module Tree_path = struct | ||
module T = Int | ||
include T | ||
|
||
module Map = struct | ||
open Map | ||
include M (T) | ||
|
||
let empty = empty (module T) | ||
end | ||
end | ||
|
||
module Job_q = Batched_queue | ||
|
||
type value = | ||
| Unit | ||
| Int of int | ||
| View_spec of view_spec list | ||
| Clos of clos | ||
| Set_clos of set_clos | ||
| Comp_clos of comp_clos | ||
| Comp_thunk of comp_thunk | ||
|
||
and clos = { param : Id.t; body : hook_free Expr.t; env : env } | ||
and set_clos = { label : Label.t; path : path } | ||
and comp_clos = { comp : Prog.comp; env : env } | ||
and comp_thunk = { comp : Prog.comp; env : env; arg : value } | ||
and view_spec = Vs_null | Vs_int of int | Vs_comp of comp_thunk | ||
and env = value Env.t | ||
and phase = P_init | P_update | P_retry | P_effect | ||
and node_ctx = { decision : decision; st_store : st_store; tree_mem : tree_mem } | ||
and decision = Idle | Retry | Update | ||
and st_store = (value * job_q) Store.t | ||
and job_q = clos Job_q.t | ||
|
||
and part_view = { | ||
view_spec : view_spec; | ||
decision : decision; | ||
st_store : st_store; | ||
eff_q : job_q; | ||
} | ||
|
||
and tree = | ||
| Leaf of tree_val | ||
| Node of { part_view : part_view; children : path list } | ||
|
||
and tree_val = Leaf_null | Leaf_int of int | ||
and tree_mem = tree option Tree_path.Map.t | ||
and path = Tree_path.t | ||
|
||
let empty_env : env = Env.empty | ||
let empty_st_store : st_store = Store.empty | ||
let empty_tree_mem : tree_mem = Tree_path.Map.empty | ||
let empty_setq : job_q = Job_q.empty | ||
let empty_effq : job_q = Job_q.empty | ||
|
||
let equal v1 v2 = | ||
match (v1, v2) with | ||
| Unit, Unit -> true | ||
| Int i1, Int i2 -> i1 = i2 | ||
| _, _ -> false | ||
|
||
let ( = ) = equal | ||
let ( <> ) v1 v2 = not (equal v1 v2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(library | ||
(name react_trace) | ||
(libraries base logs stdio)) |
Oops, something went wrong.