Skip to content

Commit

Permalink
Handle push with no int value in greedy algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcere committed Nov 20, 2024
1 parent 6bf2990 commit c6882ec
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/greedy/greedy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c6882ec

Please sign in to comment.