diff --git a/crashlink/core.py b/crashlink/core.py index 3044420..1a03dc0 100644 --- a/crashlink/core.py +++ b/crashlink/core.py @@ -14,7 +14,7 @@ from io import BytesIO from typing import Any, BinaryIO, Dict, List, Literal, Optional, Tuple, TypeVar -T = TypeVar("T", bound="VarInt") # HACK: easier than reimplementing deserialise for each subclass +T = TypeVar("T", bound="VarInt") # easier than reimplementing deserialise for each subclass from .errors import (FailedSerialisation, InvalidOpCode, MalformedBytecode, NoMagic) @@ -30,7 +30,6 @@ USE_TQDM = False -# TODO: rewrite all ABCs like this to use the PEP 3119 `abc` module class Serialisable(ABC): """ Base class for all serialisable objects. @@ -218,13 +217,14 @@ def serialise(self) -> bytes: ) -class ResolvableVarInt(VarInt): +class ResolvableVarInt(VarInt, ABC): """ Base class for resolvable VarInts. Call `resolve` to get a direct reference to the object it points to. """ + @abstractmethod def resolve(self, code: "Bytecode") -> Any: - raise NotImplementedError("resolve is not implemented for this class.") + pass class fIndex(ResolvableVarInt): diff --git a/crashlink/disasm.py b/crashlink/disasm.py index 7da68a8..20da341 100644 --- a/crashlink/disasm.py +++ b/crashlink/disasm.py @@ -412,7 +412,7 @@ def from_asm(asm: str) -> List[Opcode]: opargs = opcodes[op] for name, type in opargs.items(): new_value = Opcode.TYPE_MAP[type]() - new_value.value = literal_eval(args.pop(0)) # FIXME: unsafe? + new_value.value = literal_eval(args.pop(0)) new_opcode.definition[name] = new_value ops.append(new_opcode) return ops