Skip to content

Commit 7b87be8

Browse files
committed
Change namespace to core.
This should move all routines out of user scope
1 parent e8397ff commit 7b87be8

3 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/arch/zx48k/backend/__init__.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
from . import errors
1515
from .errors import InvalidICError as InvalidIC
1616

17+
from .runtime.namespace import NAMESPACE
18+
1719

1820
# 8 bit arithmetic functions
1921
from .__8bit import _add8, _sub8, _mul8, _divu8, _divi8, _modu8, _modi8, _neg8, _abs8
@@ -116,12 +118,12 @@
116118
RE_IX_IDX = re.compile(r'^\([ \t]*ix[ \t]*[-+][ \t]*.+\)$')
117119

118120
# Label for the program START end EXIT
119-
START_LABEL = '__START_PROGRAM'
120-
END_LABEL = '__END_PROGRAM'
121-
CALL_BACK = '__CALL_BACK__'
122-
MAIN_LABEL = '__MAIN_PROGRAM__'
123-
DATA_LABEL = 'ZXBASIC_USER_DATA'
124-
DATA_END_LABEL = 'ZXBASIC_USER_DATA_END'
121+
START_LABEL = f'{NAMESPACE}__START_PROGRAM'
122+
END_LABEL = f'{NAMESPACE}__END_PROGRAM'
123+
CALL_BACK = f'{NAMESPACE}__CALL_BACK__'
124+
MAIN_LABEL = f'{NAMESPACE}__MAIN_PROGRAM__'
125+
DATA_LABEL = f'{NAMESPACE}ZXBASIC_USER_DATA'
126+
DATA_END_LABEL = f'{NAMESPACE}ZXBASIC_USER_DATA_END'
125127

126128
# Whether to use the FunctionExit scheme
127129
FLAG_use_function_exit = False
@@ -196,9 +198,9 @@ def init():
196198
# Default HEAP SIZE (Dynamic memory) in bytes
197199
OPTIONS.add_option('heap_size', int, 4768) # A bit more than 4K
198200
# Labels for HEAP START (might not be used if not needed)
199-
OPTIONS.add_option('heap_start_label', str, f'{RuntimeLabel.NAMESPACE}ZXBASIC_MEM_HEAP')
201+
OPTIONS.add_option('heap_start_label', str, f'{NAMESPACE}ZXBASIC_MEM_HEAP')
200202
# Labels for HEAP SIZE (might not be used if not needed)
201-
OPTIONS.add_option('heap_size_label', str, f'{RuntimeLabel.NAMESPACE}ZXBASIC_HEAP_SIZE')
203+
OPTIONS.add_option('heap_size_label', str, f'{NAMESPACE}ZXBASIC_HEAP_SIZE')
202204
# Flag for headerless mode (No prologue / epilogue)
203205
OPTIONS.add_option('headerless', bool, False)
204206

@@ -2222,16 +2224,16 @@ def emit_start():
22222224
heap_init = ['%s:' % DATA_LABEL]
22232225
output.append('org %s' % OPTIONS.org)
22242226

2225-
if REQUIRES.intersection(MEMINITS) or '__MEM_INIT' in INITS:
2227+
if REQUIRES.intersection(MEMINITS) or f'{NAMESPACE}__MEM_INIT' in INITS:
22262228
heap_init.append('; Defines HEAP SIZE\n' + OPTIONS.heap_size_label + ' EQU ' +
22272229
str(OPTIONS.heap_size))
22282230
heap_init.append(OPTIONS.heap_start_label + ':')
22292231
heap_init.append('DEFS %s' % str(OPTIONS.heap_size))
22302232

22312233
heap_init.append('; Defines USER DATA Length in bytes\n' +
2232-
'ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_END - ZXBASIC_USER_DATA')
2233-
heap_init.append('.__LABEL__.ZXBASIC_USER_DATA_LEN EQU ZXBASIC_USER_DATA_LEN')
2234-
heap_init.append('.__LABEL__.ZXBASIC_USER_DATA EQU ZXBASIC_USER_DATA')
2234+
f'{NAMESPACE}ZXBASIC_USER_DATA_LEN EQU {DATA_END_LABEL} - {DATA_LABEL}')
2235+
heap_init.append(f'{NAMESPACE}.__LABEL__.ZXBASIC_USER_DATA_LEN EQU {NAMESPACE}ZXBASIC_USER_DATA_LEN')
2236+
heap_init.append(f'{NAMESPACE}.__LABEL__.ZXBASIC_USER_DATA EQU {DATA_LABEL}')
22352237

22362238
output.append('%s:' % START_LABEL)
22372239
if OPTIONS.headerless:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Define just the main Private namespace
22

3-
NAMESPACE = ''
3+
NAMESPACE = 'core.'

src/arch/zx48k/library-asm/print.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
; Putting a comment starting with @INIT <address>
2222
; will make the compiler to add a CALL to <address>
2323
; It is useful for initialization routines.
24-
#init __PRINT_INIT
24+
#init core.__PRINT_INIT
2525

2626
push namespace core
2727

0 commit comments

Comments
 (0)