forked from rems-project/asl-interpreter
-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 parent
712b7c6
commit aaf9810
Showing
4 changed files
with
51 additions
and
32 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
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
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,28 @@ | ||
module StringMap = Map.Make(String) | ||
|
||
let flags = StringMap.of_seq @@ List.to_seq [ | ||
("trace:write", Eval.trace_write); | ||
("trace:fun", Eval.trace_funcall); | ||
("trace:prim", Eval.trace_primop); | ||
("trace:instr", Eval.trace_instruction); | ||
("eval:concrete_unknown", Value.concrete_unknown); | ||
("dis:vectors", Dis.use_vectoriser); | ||
] | ||
|
||
let set_flag s = | ||
let plus = Utils.startswith s "+" in | ||
let minus = Utils.startswith s "-" in | ||
if not (plus || minus) then | ||
raise @@ Arg.Bad "flag should start with + to set and - to unset"; | ||
let flags_str = String.concat ", " @@ List.map fst (StringMap.bindings flags) in | ||
let flag = Utils.stringDrop 1 s in | ||
|
||
match StringMap.find_opt flag flags with | ||
| None -> raise @@ Arg.Bad (Printf.sprintf "unknown flag '%s'\navailable flags: %s" flag flags_str); | ||
| Some f -> f := plus | ||
|
||
let get_flags () = | ||
StringMap.map (fun x -> !x) flags | ||
|
||
let set_flags xs = | ||
StringMap.iter (fun k v -> StringMap.find k flags := v) xs; |