| 31 | |
| 32 | |
| 33 | class LinearDisassemblyLine: |
| 34 | def __init__(self, line_type, func, block, contents): |
| 35 | self.type = line_type |
| 36 | self.function = func |
| 37 | self.block = block |
| 38 | self.contents = contents |
| 39 | |
| 40 | def __repr__(self): |
| 41 | return repr(self.contents) |
| 42 | |
| 43 | def __str__(self): |
| 44 | return str(self.contents) |
| 45 | |
| 46 | @classmethod |
| 47 | def _from_core_struct(cls, struct: core.BNLinearDisassemblyLine, obj: Optional['LinearViewObject'] = None) -> 'LinearDisassemblyLine': |
| 48 | function = None |
| 49 | if struct.function: |
| 50 | function = _function.Function(handle=core.BNNewFunctionReference(struct.function)) |
| 51 | block = None |
| 52 | if struct.block: |
| 53 | block = basicblock.BasicBlock._from_core_block(core.BNNewBasicBlockReference(struct.block)) |
| 54 | il_func = None |
| 55 | if block is not None: |
| 56 | il_func = block.il_function |
| 57 | if obj is not None and function is not None: |
| 58 | # Hack: HLIL bodies don't have basic blocks |
| 59 | if obj.identifier.name == "HLIL Function Body": |
| 60 | il_func = function.hlil |
| 61 | elif obj.identifier.name == "HLIL SSA Function Body": |
| 62 | func_hlil = function.hlil |
| 63 | if func_hlil is not None: |
| 64 | il_func = func_hlil.ssa_form |
| 65 | elif obj.identifier.name == "Language Representation Function Body": |
| 66 | il_func = function.hlil |
| 67 | |
| 68 | contents = _function.DisassemblyTextLine._from_core_struct(struct.contents, il_func) |
| 69 | return LinearDisassemblyLine(LinearDisassemblyLineType(struct.type), function, block, contents) |
| 70 | |
| 71 | def _to_core_struct(self) -> core.BNLinearDisassemblyLine: |
| 72 | result = core.BNLinearDisassemblyLine() |
| 73 | result.type = self.type |
| 74 | result.function = None |
| 75 | if self.function is not None: |
| 76 | result.function = self.function.handle |
| 77 | result.block = None |
| 78 | if self.block is not None: |
| 79 | result.block = self.block.handle |
| 80 | result.contents = _function.DisassemblyTextLine._to_core_struct(self.contents) |
| 81 | return result |
| 82 | |
| 83 | |
| 84 | class LinearViewObjectIdentifier: |
no outgoing calls
no test coverage detected