2026-07-10 10:38:57 +02:00

52 lines
1.5 KiB
Python

from ScEpTIC.AST.elements.instruction import Instruction
class CustomInstruction(Instruction):
"""
CustomInstruction() base class
"""
_omit_target = True
tick_count = 0
def __init__(self, call_operation):
super().__init__()
self.basic_block_id = call_operation.basic_block_id
self.label = call_operation.label
self.preds = call_operation.preds
self.metadata = call_operation.metadata
self.virtual_memory_target = call_operation.virtual_memory_target
self.target = None
self.args = call_operation.function_args
self._str_params = None
def get_val(self):
return
def __str__(self):
retstr = super().__str__()
if self._str_params is None:
params = [self.get_arg(i) for i in range(len(self.args))]
else:
params = self._str_params
str_params = ', '.join([f"\"{x}\"" if isinstance(x, str) else f"{x}" for x in params])
retstr += f"{self.__class__.__name__}({str_params})"
return retstr
def get_arg(self, id):
try:
# llvm string
if self.args[id].is_llvm_string():
address = self.args[id].get_val()
return self._vmstate.memory.gst._get_gst_from_address(address).read_string_from_address(address)
return self.args[id].get_val()
except BaseException:
return self.args[id]
def argc(self):
return len(self.args)