From 9710ed9b8b3b479db1de1e522e9fa4d81e740a9f Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Sat, 17 Apr 2021 20:42:22 +0200 Subject: [PATCH] added Executable.__repr__ and added return self to ExecutableParser.parse --- riscemu/Executable.py | 11 ++++++++++- riscemu/ExecutableParser.py | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/riscemu/Executable.py b/riscemu/Executable.py index ef02f38..c1f4821 100644 --- a/riscemu/Executable.py +++ b/riscemu/Executable.py @@ -4,11 +4,11 @@ from .Exceptions import * from .helpers import parse_numeric_argument, align_addr import typing + if typing.TYPE_CHECKING: from .Tokenizer import RiscVInstructionToken - @dataclass(frozen=True) class MemoryFlags: read_only: bool @@ -60,6 +60,15 @@ class Executable: symbols: Dict[str, Tuple[str, int]] stack_pref: Optional[int] + def __repr__(self): + return "{}(sections = {}, symbols = {}, stack = {}, run_ptr = {})".format( + self.__class__.__name__, + " ".join(self.sections.keys()), + " ".join(self.symbols.keys()), + self.stack_pref, + self.run_ptr + ) + ### LOADING CODE diff --git a/riscemu/ExecutableParser.py b/riscemu/ExecutableParser.py index 1fcb100..1bd8495 100644 --- a/riscemu/ExecutableParser.py +++ b/riscemu/ExecutableParser.py @@ -27,6 +27,7 @@ class ExecutableParser: self.handle_symbol(token) elif isinstance(token, RiscVPseudoOpToken): self.handle_pseudo_op(token) + return self def get_execuable(self): start_ptr = ('text', 0)