Skip to content

Commit f27a8d8

Browse files
committed
Fix bug in constant evaluation
1 parent d84a204 commit f27a8d8

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

symbols/var.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def __repr__(self):
107107
def t(self):
108108
# HINT: Parameters and local variables must have it's .t member as '$name'
109109
if self.class_ == CLASS.const:
110-
return str(self.default_value)
110+
return str(self.value)
111111

112112
if self.scope == SCOPE.global_:
113113
if self.class_ == CLASS.array:

tests/functional/const8.asm

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
org 32768
2+
__START_PROGRAM:
3+
di
4+
push ix
5+
push iy
6+
exx
7+
push hl
8+
exx
9+
ld hl, 0
10+
add hl, sp
11+
ld (__CALL_BACK__), hl
12+
ei
13+
ld hl, 12345
14+
ld (_a), hl
15+
ld hl, 0
16+
ld b, h
17+
ld c, l
18+
__END_PROGRAM:
19+
di
20+
ld hl, (__CALL_BACK__)
21+
ld sp, hl
22+
exx
23+
pop hl
24+
exx
25+
pop iy
26+
pop ix
27+
ei
28+
ret
29+
__CALL_BACK__:
30+
DEFW 0
31+
ZXBASIC_USER_DATA:
32+
_a:
33+
DEFB 00, 00
34+
; Defines DATA END --> HEAP size is 0
35+
ZXBASIC_USER_DATA_END:
36+
; Defines USER DATA Length in bytes
37+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
38+
END

tests/functional/const8.bas

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
CONST cvalue As UInteger = 12345
3+
CONST caux2 as UInteger = cvalue
4+
a = caux2
5+

0 commit comments

Comments
 (0)