Skip to content

Commit 04ab1a1

Browse files
committed
✨ Implement basic event recorder
1 parent d95b99a commit 04ab1a1

File tree

3 files changed

+27
-3
lines changed

3 files changed

+27
-3
lines changed

bin/js/main.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ let () =
3030
let Interp.{ recording; _ } =
3131
Interp.run
3232
?fuel:(if fuel < 1 then None else Some fuel)
33-
~recorder:(module Recorder)
33+
~recorder:(module String_recorder)
3434
prog
3535
in
3636
if Logs.err_count () > 0 then Error "error" else Ok recording)

bin/js/recorder.ml renamed to bin/js/string_recorder.ml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
open! Core
12
open Stdlib.Effect
23
open Stdlib.Effect.Deep
34
open React_trace
5+
open Concrete_domains
46
open Interp_effects
57
include Recorder_intf
68

7-
(* TODO: Replace the dummy string with an actual recording type *)
89
type recording = string
910

10-
let emp_recording = "empty recording"
11+
let emp_recording = "= Recording =\n"
1112

1213
let event_h =
1314
{
@@ -20,21 +21,44 @@ let event_h =
2021
Some
2122
(fun (k : (a, _) continuation) ~(recording : recording) ->
2223
let () = perform (Update_st (path, label, (v, q))) in
24+
let recording =
25+
recording
26+
^ sprintf "[path %s] Update state %d -> %s\n"
27+
(Sexp.to_string (Path.sexp_of_t path))
28+
label
29+
(Sexp.to_string (sexp_of_value v))
30+
in
2331
continue k () ~recording)
2432
| Set_dec (path, dec) ->
2533
Some
2634
(fun (k : (a, _) continuation) ~(recording : recording) ->
2735
let () = perform (Set_dec (path, dec)) in
36+
let recording =
37+
recording
38+
^ sprintf "[path %s] Set decision %s\n"
39+
(Sexp.to_string (Path.sexp_of_t path))
40+
(Sexp.to_string (sexp_of_decision dec))
41+
in
2842
continue k () ~recording)
2943
| Enq_eff (path, clos) ->
3044
Some
3145
(fun (k : (a, _) continuation) ~(recording : recording) ->
3246
let () = perform (Enq_eff (path, clos)) in
47+
let recording =
48+
recording
49+
^ sprintf "[path %s] Enqueue effect\n"
50+
(Sexp.to_string (Path.sexp_of_t path))
51+
in
3352
continue k () ~recording)
3453
| Alloc_pt ->
3554
Some
3655
(fun (k : (a, _) continuation) ~(recording : recording) ->
3756
let path = perform Alloc_pt in
57+
let recording =
58+
recording
59+
^ sprintf "Allocate path %s\n"
60+
(Sexp.to_string (Path.sexp_of_t path))
61+
in
3862
continue k path ~recording)
3963
| _ -> None);
4064
}
File renamed without changes.

0 commit comments

Comments
 (0)