From c6882eca0f4259f2bdc3d54b65dde2237d955af8 Mon Sep 17 00:00:00 2001 From: alexcere <48130030+alexcere@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:19:23 +0100 Subject: [PATCH] Handle push with no int value in greedy algorithm --- src/greedy/greedy.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/greedy/greedy.py b/src/greedy/greedy.py index 1e512b60..9fd6ede4 100644 --- a/src/greedy/greedy.py +++ b/src/greedy/greedy.py @@ -15,7 +15,7 @@ var_instr_map_T = Dict[var_T, instr_T] opid_instr_map_T = Dict[var_T, instr_T] -VERBOSE = 0 +VERBOSE = 3 def get_ops_map(instructions: List[Dict[str, Any]], op: id_T) -> Dict[var_T, id_T]: @@ -789,7 +789,8 @@ def compute_one_with_stack(self, o: Union[var_T, id_T], stack: List[var_T], need opcode = self._opid_instr_map[o]['disasm'] opcodeid = self._opid_instr_map[o]['id'] outs = [] - elif 'PUSH' in self._var_instr_map[o]['disasm'] and 'value' in self._var_instr_map[o]: + elif 'PUSH' in self._var_instr_map[o]['disasm'] and 'value' in self._var_instr_map[o] \ + and isinstance(self._var_instr_map[o]['value'], int): if 'tag' in self._var_instr_map[o]['disasm']: tag = str(self._var_instr_map[o]['value'][0]) # tag = hex(self._var_instr_map[o]['value'][0]) @@ -1713,7 +1714,8 @@ def greedy_from_json(json_data: Dict[str, Any], verb=False) -> Tuple[ pass # print(name, encoding._b0, encoding._b0) error = 0 - except Exception: + except Exception as e: + # print(e) # print(json_data) # _, _, tb = sys.exc_info() # traceback.print_tb(tb) @@ -1772,6 +1774,7 @@ def greedy_standalone(sms: Dict) -> Tuple[str, float, List[str]]: name = name[p + 1:] json_info, encod, rs, rsids, error = greedy_from_json(json_read) # ,True) if verbose + print("Solution", rsids) # if error == 0: # print(name, "m:", minst, "g:", len(rs), "e:", error)