Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore commits inadvertently lost #44

Merged
merged 5 commits into from
Oct 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 25 additions & 13 deletions src/sail_json_backend/json.ml
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ let parse_type_union i ucl =
match ucl with
| Tu_aux (Tu_ty_id (c, d), annot) ->
debug_print ~printer:prerr_string ("Tu_ty_id " ^ string_of_id d ^ "(");
List.iter
(fun attr ->
match attr with _, "name", Some (AD_aux (AD_string s, _)) -> Hashtbl.add names (string_of_id d) s | _ -> ()
)
annot.attrs;
begin
match annot.doc_comment with None -> () | Some s -> Hashtbl.add descriptions (string_of_id d) s
end;
begin
match c with
| Typ_aux (Typ_tuple x, _) ->
Expand All @@ -375,17 +383,7 @@ let parse_type_union i ucl =
)
x;
let l = List.map string_of_typ x in
Hashtbl.add sigs (string_of_id d) l;
List.iter
(fun attr ->
match attr with
| _, "name", Some (AD_aux (AD_string s, _)) -> Hashtbl.add names (string_of_id d) s
| _ -> ()
)
annot.attrs;
begin
match annot.doc_comment with None -> () | Some s -> Hashtbl.add descriptions (string_of_id d) s
end
Hashtbl.add sigs (string_of_id d) l
| Typ_aux (Typ_id i, _) -> Hashtbl.add sigs (string_of_id d) [string_of_id i]
| Typ_aux (Typ_app (i, _), _) ->
debug_print (string_of_typ c);
Expand Down Expand Up @@ -485,6 +483,10 @@ let identity_funcs =
"freg_or_reg_name";
"vreg_name";
"maybe_vmask";
"sew_flag";
"maybe_lmul_flag";
"maybe_ta_flag";
"maybe_ma_flag";
]

let defunction f n =
Expand Down Expand Up @@ -612,6 +614,16 @@ let json_of_syntax k =
if String.equal s "sep" then ","
else if String.equal s "\"(\"" then "("
else if String.equal s "\")\"" then ")"
else if String.starts_with ~prefix:"maybe_" s then "[," ^ remove_identity_funcs s ^ "]"
else if String.contains s ',' then (
let elements = Str.split (Str.regexp ",") (remove_identity_funcs s) in
let filtered_elements =
match Hashtbl.find_opt inputs k with
| None -> []
| Some inputl -> List.filter (fun element -> List.mem element inputl) elements
in
String.concat "," filtered_elements
)
else remove_identity_funcs s
)
(List.tl (Hashtbl.find assembly_clean k))
Expand Down Expand Up @@ -673,8 +685,8 @@ let json_of_function k =

let json_of_name k mnemonic =
let name =
match Hashtbl.find_opt names k with
| None -> begin match Hashtbl.find_opt names mnemonic with None -> "TBD" | Some s -> String.escaped s end
match Hashtbl.find_opt names mnemonic with
| None -> begin match Hashtbl.find_opt names k with None -> "TBD" | Some s -> String.escaped s end
| Some s -> String.escaped s
in
"\"" ^ name ^ "\""
Expand Down
Loading