From 0afe610c0af7d901730870534760c42804010a9a Mon Sep 17 00:00:00 2001 From: Linda Njau Date: Wed, 28 Aug 2024 12:26:35 +0300 Subject: [PATCH] Add cross-checking for operands with constants Operands with constants `(uimm,0b000)` were previously split and the constant discarded. While this did not cause errors, the change now cross-checks both parts to an `inputl` list before retaining the relevant components. This ensures accuracy and robustness. --- src/sail_json_backend/json.ml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/sail_json_backend/json.ml b/src/sail_json_backend/json.ml index 83e06877e..ce5cc77e9 100644 --- a/src/sail_json_backend/json.ml +++ b/src/sail_json_backend/json.ml @@ -615,7 +615,15 @@ let json_of_syntax k = 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 List.hd (Str.split (Str.regexp ",") (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))