self.__root = root
self.__insn = insn
- self.__decls = set()
+ self.__vars = set()
self.__header = object()
self.__footer = object()
self.__code = collections.defaultdict(lambda: pc_util.Code())
super().__init__(root=root)
- for decl in (operand.name for operand in insn.dynamic_operands):
- if decl not in self.__decls:
- self.__code[self.__header].emit(stmt=f"struct oppc_value {decl};")
- for decl in sorted(self.__decls):
- self.__code[self.__header].emit(stmt=f"struct oppc_value {decl};")
+ operands = tuple(operand.name for operand in insn.dynamic_operands)
+ for var in operands:
+ self.__code[self.__header].emit(stmt=f"struct oppc_value {var};")
+ for var in filter(lambda var: var not in operands, sorted(self.__vars)):
+ self.__code[self.__header].emit(stmt=f"struct oppc_value {var};")
self.__code[self.__header].emit()
for operand in insn.dynamic_operands:
def Symbol(self, node):
yield node
with self.pseudocode(node=node):
- decl = str(node)
- if decl not in ("fallthrough",):
- if decl in ("TRAP",):
- self[node].emit(stmt=f"OPPC_CALL_{decl}();")
+ var = str(node)
+ if var not in ("fallthrough",):
+ if var in ("TRAP",):
+ self[node].emit(stmt=f"OPPC_CALL_{var}();")
else:
if node in self.__pseudocode:
- self.__decls.add(decl)
- self[node].emit(stmt=f"&{decl}")
+ self.__vars.add(var)
+ self[node].emit(stmt=f"&{var}")
@pc_util.Hook(Instruction)
def Instruction(self, node):