diff --git a/src/api/optimize.py b/src/api/optimize.py index 9f2e7046d..1f7fdeca4 100644 --- a/src/api/optimize.py +++ b/src/api/optimize.py @@ -58,7 +58,7 @@ def _visit(self, node: ToVisit): if node.obj is None: return None - __DEBUG__(f"Optimizer: Visiting node {node.obj!s}", 1) + __DEBUG__(f"Optimizer: Visiting node {node.obj!s}[{node.obj.token}]", 1) meth = getattr(self, f"visit_{node.obj.token}", self.generic_visit) return meth(node.obj) diff --git a/src/arch/z80/visitor/translator_visitor.py b/src/arch/z80/visitor/translator_visitor.py index 389e95762..b4d072ab8 100644 --- a/src/arch/z80/visitor/translator_visitor.py +++ b/src/arch/z80/visitor/translator_visitor.py @@ -225,9 +225,6 @@ def traverse_const(node): syntax_error_cant_convert_to_type(node.lineno, str(node.operand), node.type_) return None - if node.token == "VARARRAY": - return node.data_label - if node.token in ("CONST", "VAR", "LABEL", "FUNCTION"): # TODO: Check what happens with local vars and params return node.t @@ -238,7 +235,7 @@ def traverse_const(node): if node.token == "ARRAYACCESS": return f"({node.entry.data_label} + {node.offset})" - if node.token == "ID" and node.has_address and node.scope == SCOPE.global_: + if node.token in ("ID", "VARARRAY") and node.has_address and node.scope == SCOPE.global_: return node.mangled raise InvalidCONSTexpr(node) diff --git a/tests/functional/arch/zx48k/arrlabels1.asm b/tests/functional/arch/zx48k/arrlabels1.asm index c4ffc044c..04fe186d0 100644 --- a/tests/functional/arch/zx48k/arrlabels1.asm +++ b/tests/functional/arch/zx48k/arrlabels1.asm @@ -23,9 +23,9 @@ _a.__DATA__.__PTR__: DEFW 0 DEFW 0 _a.__DATA__: - DEFW _a.__DATA__ - DEFW _a.__DATA__ - DEFW (_a.__DATA__) + (1) + DEFW _a + DEFW _a + DEFW (_a) + (1) .LABEL.__LABEL0: DEFW 0000h DEFB 02h diff --git a/tests/functional/arch/zx48k/arrlabels10a.asm b/tests/functional/arch/zx48k/arrlabels10a.asm index dc1990e0c..94fb04e61 100644 --- a/tests/functional/arch/zx48k/arrlabels10a.asm +++ b/tests/functional/arch/zx48k/arrlabels10a.asm @@ -23,8 +23,8 @@ _a.__DATA__.__PTR__: DEFW 0 DEFW 0 _a.__DATA__: - DEFB (_a.__DATA__) & 0xFF - DEFB ((_a.__DATA__) + (1)) & 0xFF + DEFB (_a) & 0xFF + DEFB ((_a) + (1)) & 0xFF DEFB 04h .LABEL.__LABEL0: DEFW 0000h diff --git a/tests/functional/arch/zx48k/arrlabels10b.asm b/tests/functional/arch/zx48k/arrlabels10b.asm index 475a63093..c58503445 100644 --- a/tests/functional/arch/zx48k/arrlabels10b.asm +++ b/tests/functional/arch/zx48k/arrlabels10b.asm @@ -24,9 +24,9 @@ _a.__DATA__.__PTR__: DEFW 0 _a.__DATA__: DEFW 0000h - DEFW (_a.__DATA__) & 0xFFFF + DEFW (_a) & 0xFFFF DEFW 0000h - DEFW ((_a.__DATA__) + (1)) & 0xFFFF + DEFW ((_a) + (1)) & 0xFFFF DEFB 00h DEFB 00h DEFB 04h diff --git a/tests/functional/arch/zx48k/arrlabels2.asm b/tests/functional/arch/zx48k/arrlabels2.asm index 298dcbb8d..8c5487fe9 100644 --- a/tests/functional/arch/zx48k/arrlabels2.asm +++ b/tests/functional/arch/zx48k/arrlabels2.asm @@ -23,9 +23,9 @@ _a.__DATA__.__PTR__: DEFW _a.__LBOUND__ DEFW 0 _a.__DATA__: - DEFW _a.__DATA__ - DEFW _a.__DATA__ - DEFW (_a.__DATA__) + (1) + DEFW _a + DEFW _a + DEFW (_a) + (1) .LABEL.__LABEL0: DEFW 0000h DEFB 02h diff --git a/tests/functional/arch/zx48k/arrlabels3.asm b/tests/functional/arch/zx48k/arrlabels3.asm index 6fef6c8f8..f68726dc2 100644 --- a/tests/functional/arch/zx48k/arrlabels3.asm +++ b/tests/functional/arch/zx48k/arrlabels3.asm @@ -23,9 +23,9 @@ _a.__DATA__.__PTR__: DEFW _a.__LBOUND__ DEFW 0 _a.__DATA__: - DEFW _a.__DATA__ - DEFW _a.__DATA__ - DEFW (_a.__DATA__) + (_f) + DEFW _a + DEFW _a + DEFW (_a) + (_f) .LABEL.__LABEL0: DEFW 0000h DEFB 02h diff --git a/tests/functional/arch/zx48k/opt1_dim_arr_at1.asm b/tests/functional/arch/zx48k/opt1_dim_arr_at1.asm index 3c8082363..0c84c787c 100644 --- a/tests/functional/arch/zx48k/opt1_dim_arr_at1.asm +++ b/tests/functional/arch/zx48k/opt1_dim_arr_at1.asm @@ -72,9 +72,9 @@ _b.__DATA__: DEFB 02h .core.ZXBASIC_USER_DATA_END: .core.__MAIN_PROGRAM__: - ld hl, _a.__DATA__ + ld hl, _a ld (_c), hl - ld hl, _b.__DATA__ + ld hl, _b ld (_c), hl ld hl, 0 ld b, h