Skip to content

Commit 4b8832a

Browse files
committed
Fixes @array label emission
Also improves visitor traversing debug info.
1 parent 069b9f3 commit 4b8832a

File tree

8 files changed

+17
-20
lines changed

8 files changed

+17
-20
lines changed

src/api/optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _visit(self, node: ToVisit):
5858
if node.obj is None:
5959
return None
6060

61-
__DEBUG__(f"Optimizer: Visiting node {node.obj!s}", 1)
61+
__DEBUG__(f"Optimizer: Visiting node {node.obj!s}[{node.obj.token}]", 1)
6262
meth = getattr(self, f"visit_{node.obj.token}", self.generic_visit)
6363
return meth(node.obj)
6464

src/arch/z80/visitor/translator_visitor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,6 @@ def traverse_const(node):
225225
syntax_error_cant_convert_to_type(node.lineno, str(node.operand), node.type_)
226226
return None
227227

228-
if node.token == "VARARRAY":
229-
return node.data_label
230-
231228
if node.token in ("CONST", "VAR", "LABEL", "FUNCTION"):
232229
# TODO: Check what happens with local vars and params
233230
return node.t
@@ -238,7 +235,7 @@ def traverse_const(node):
238235
if node.token == "ARRAYACCESS":
239236
return f"({node.entry.data_label} + {node.offset})"
240237

241-
if node.token == "ID" and node.has_address and node.scope == SCOPE.global_:
238+
if node.token in ("ID", "VARARRAY") and node.has_address and node.scope == SCOPE.global_:
242239
return node.mangled
243240

244241
raise InvalidCONSTexpr(node)

tests/functional/arch/zx48k/arrlabels1.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ _a.__DATA__.__PTR__:
2323
DEFW 0
2424
DEFW 0
2525
_a.__DATA__:
26-
DEFW _a.__DATA__
27-
DEFW _a.__DATA__
28-
DEFW (_a.__DATA__) + (1)
26+
DEFW _a
27+
DEFW _a
28+
DEFW (_a) + (1)
2929
.LABEL.__LABEL0:
3030
DEFW 0000h
3131
DEFB 02h

tests/functional/arch/zx48k/arrlabels10a.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ _a.__DATA__.__PTR__:
2323
DEFW 0
2424
DEFW 0
2525
_a.__DATA__:
26-
DEFB (_a.__DATA__) & 0xFF
27-
DEFB ((_a.__DATA__) + (1)) & 0xFF
26+
DEFB (_a) & 0xFF
27+
DEFB ((_a) + (1)) & 0xFF
2828
DEFB 04h
2929
.LABEL.__LABEL0:
3030
DEFW 0000h

tests/functional/arch/zx48k/arrlabels10b.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ _a.__DATA__.__PTR__:
2424
DEFW 0
2525
_a.__DATA__:
2626
DEFW 0000h
27-
DEFW (_a.__DATA__) & 0xFFFF
27+
DEFW (_a) & 0xFFFF
2828
DEFW 0000h
29-
DEFW ((_a.__DATA__) + (1)) & 0xFFFF
29+
DEFW ((_a) + (1)) & 0xFFFF
3030
DEFB 00h
3131
DEFB 00h
3232
DEFB 04h

tests/functional/arch/zx48k/arrlabels2.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ _a.__DATA__.__PTR__:
2323
DEFW _a.__LBOUND__
2424
DEFW 0
2525
_a.__DATA__:
26-
DEFW _a.__DATA__
27-
DEFW _a.__DATA__
28-
DEFW (_a.__DATA__) + (1)
26+
DEFW _a
27+
DEFW _a
28+
DEFW (_a) + (1)
2929
.LABEL.__LABEL0:
3030
DEFW 0000h
3131
DEFB 02h

tests/functional/arch/zx48k/arrlabels3.asm

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ _a.__DATA__.__PTR__:
2323
DEFW _a.__LBOUND__
2424
DEFW 0
2525
_a.__DATA__:
26-
DEFW _a.__DATA__
27-
DEFW _a.__DATA__
28-
DEFW (_a.__DATA__) + (_f)
26+
DEFW _a
27+
DEFW _a
28+
DEFW (_a) + (_f)
2929
.LABEL.__LABEL0:
3030
DEFW 0000h
3131
DEFB 02h

tests/functional/arch/zx48k/opt1_dim_arr_at1.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ _b.__DATA__:
7272
DEFB 02h
7373
.core.ZXBASIC_USER_DATA_END:
7474
.core.__MAIN_PROGRAM__:
75-
ld hl, _a.__DATA__
75+
ld hl, _a
7676
ld (_c), hl
77-
ld hl, _b.__DATA__
77+
ld hl, _b
7878
ld (_c), hl
7979
ld hl, 0
8080
ld b, h

0 commit comments

Comments
 (0)