Skip to content

Commit e8a2cf9

Browse files
committed
Take command-line define values into account
When compiling with -D name=value the value was being ignored. Fixed.
1 parent ae3e94d commit e8a2cf9

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

tests/functional/define_val.asm

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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, 0
14+
ld b, h
15+
ld c, l
16+
__END_PROGRAM:
17+
di
18+
ld hl, (__CALL_BACK__)
19+
ld sp, hl
20+
exx
21+
pop hl
22+
exx
23+
pop iy
24+
pop ix
25+
ei
26+
ret
27+
__CALL_BACK__:
28+
DEFW 0
29+
ZXBASIC_USER_DATA:
30+
; Defines DATA END --> HEAP size is 0
31+
ZXBASIC_USER_DATA_END:
32+
; Defines USER DATA Length in bytes
33+
ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA
34+
END

tests/functional/define_val.bas

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
#ifdef MACRO
3+
# if MACRO != VALUE
4+
# error "MACRO should be VALUE"
5+
# endif
6+
#endif
7+
8+

tests/functional/test_cmdline.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ no_zxnext.asm:29: Syntax error. Unexpected token 'C' [C]
3030

3131
>>> process_file('zxnext_all.asm')
3232

33+
>>> process_file('define_val.bas', ['-q', '-S', '-O -D MACRO=VALUE'])
34+
>>> process_file('define_val.bas', ['-q', '-S', '-O -D MACRO'])
35+
define_val.bas:4: Error: "MACRO should be VALUE"

zxb/zxb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def main(args=None, emitter=None):
187187
name = macro[0]
188188
val = ''.join(macro[1:])
189189
OPTIONS.__DEFINES.value[name] = val
190-
zxbpp.ID_TABLE.define(name, lineno=0)
190+
zxbpp.ID_TABLE.define(name, value=val, lineno=0)
191191

192192
if OPTIONS.Sinclair.value:
193193
OPTIONS.array_base.value = 1

0 commit comments

Comments
 (0)