From 8878da1ebcbf4eacc17cc5c162bbcb460f838eff Mon Sep 17 00:00:00 2001 From: x0r Date: Tue, 23 Apr 2024 19:13:12 +0200 Subject: [PATCH] more mypyc --- masm2c/parser.py | 3 ++- masm2c/pgparser.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/masm2c/parser.py b/masm2c/parser.py index 59624ea..1bd14d9 100644 --- a/masm2c/parser.py +++ b/masm2c/parser.py @@ -213,7 +213,7 @@ def next_pass(self, counter: int) -> None: self.flow_terminated = True self.need_label = True - self.structures: OrderedDict[str, Optional[Struct]] = OrderedDict() + self.structures: OrderedDict[str, Struct] = OrderedDict() self.macro_names_stack: set[str] = set() self.proc_list: list[str] = [] self.proc = None @@ -979,6 +979,7 @@ def add_structinstance(self, label: str, type: str, args: list[Any | Tree], raw: if isinstance(args, list) and len(args) > 2 and isinstance(args[1], str) and args[1] == "dup": cpp = cpp_module.Cpp(self) expr = Token_.find_tokens(args[0],"expr") + assert isinstance(expr, Expression) number = literal_eval(cpp.render_instruction_argument(expr)) args = args[3] args = Token_.remove_tokens(args, ["structinstance"]) diff --git a/masm2c/pgparser.py b/masm2c/pgparser.py index 7224487..f8cc6a4 100644 --- a/masm2c/pgparser.py +++ b/masm2c/pgparser.py @@ -12,7 +12,7 @@ import lark.tree from lark.visitors import _DiscardType -from masm2c.op import Data, _assignment, baseop +from masm2c.op import Data, _assignment, baseop, Struct from masm2c.Token import Expression if TYPE_CHECKING: @@ -54,7 +54,7 @@ def process(self, stream: Iterator[lark.Token]) -> Iterator[lark.Token]: if self.last_type == "LABEL" and t.type == "STRUCTHDR": assert self.last - self.context.structures[self.last.lower()] = None + self.context.structures[self.last.lower()] = Struct("", "") # if t.type == "STRUCTHDR": if self.context.structures and self.last_type == "LABEL" \