Skip to content

Commit

Permalink
changing hashmap method to recover data
Browse files Browse the repository at this point in the history
  • Loading branch information
MrDaiki committed Sep 23, 2024
1 parent 7ecaed9 commit 9ebf1fa
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
11 changes: 5 additions & 6 deletions compiler/src/printASM.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@ let string_of_label name p =
Format.asprintf "L%s$%d" (escape name) (Conv.int_of_pos p)

let string_of_glob x occurrences =
let count = Hashtbl.find_opt occurrences x.v_name in
match count with
| None ->
Hashtbl.add occurrences x.v_name 1;

BatHashtbl.modify_def 0 x.v_name (fun x->x+1) occurrences;
let count = BatHashtbl.find occurrences x.v_name in
if count = 0 then
Format.asprintf "G$%s" (escape x.v_name)
| Some count ->
Hashtbl.replace occurrences x.v_name (count+1);
else
(*Adding the number of occurences to the label to avoid names conflict*)
Format.asprintf "G$%s$%d" (escape x.v_name) (count)

Expand Down
1 change: 1 addition & 0 deletions tree/var-initialisation-merge-tree
Submodule var-initialisation-merge-tree added at 885379

0 comments on commit 9ebf1fa

Please sign in to comment.