Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/zxbpp/zxbpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def search_filename(fname: str, lineno: int, local_first: bool) -> str:
return fname
else:
for dir_ in i_path:
path = utils.sanitize_filename(os.path.join(dir_, fname))
path = utils.get_absolute_filename_path(utils.sanitize_filename(os.path.join(dir_, fname)))
if os.path.exists(path):
return path

Expand All @@ -198,8 +198,9 @@ def include_file(filename: str, lineno: int, local_first: bool) -> str:
"""
global CURRENT_DIR

filename = search_filename(filename, lineno, local_first)
abs_filename = utils.get_absolute_filename_path(filename)
abs_filename = search_filename(filename, lineno, local_first)
filename = utils.get_relative_filename_path(abs_filename)

if abs_filename not in INCLUDED:
INCLUDED[abs_filename] = IncludedFileInfo(once=False, parents=[])
elif INCLUDED[abs_filename].once:
Expand All @@ -221,14 +222,14 @@ def include_once(filename: str, lineno: int, local_first: bool) -> str:
at line <lineno>.

The file is ignored if it was previously included (a warning will
be emitted though).
be emitted, though).

If local_first is True, then it will first search the file in the
local path before looking for it in the include path chain.
This is used when doing a #include "filename".
"""
filename = search_filename(filename, lineno, local_first)
abs_filename = utils.get_absolute_filename_path(filename)
abs_filename = search_filename(filename, lineno, local_first)

if abs_filename not in INCLUDED: # If not already included
return include_file(filename, lineno, local_first) # include it and return

Expand Down
42 changes: 42 additions & 0 deletions tests/functional/arch/zx48k/rel_include.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
org 32768
.core.__START_PROGRAM:
di
push ix
push iy
exx
push hl
exx
ld (.core.__CALL_BACK__), sp
ei
jp .core.__MAIN_PROGRAM__
.core.__CALL_BACK__:
DEFW 0
.core.ZXBASIC_USER_DATA:
; Defines USER DATA Length in bytes
.core.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_END - .core.ZXBASIC_USER_DATA
.core.__LABEL__.ZXBASIC_USER_DATA_LEN EQU .core.ZXBASIC_USER_DATA_LEN
.core.__LABEL__.ZXBASIC_USER_DATA EQU .core.ZXBASIC_USER_DATA
_a:
DEFB 00
.core.ZXBASIC_USER_DATA_END:
.core.__MAIN_PROGRAM__:
ld a, 1
ld (_a), a
ld a, 1
ld (_a), a
ld hl, 0
ld b, h
ld c, l
.core.__END_PROGRAM:
di
ld hl, (.core.__CALL_BACK__)
ld sp, hl
exx
pop hl
exx
pop iy
pop ix
ei
ret
;; --- end of user code ---
END
3 changes: 3 additions & 0 deletions tests/functional/arch/zx48k/rel_include.bas
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include once "../zx48k/rel_include.bas"

LET a = 1
3 changes: 3 additions & 0 deletions tests/functional/asm/rel_include.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include once "../asm/rel_include.asm"

NOP
Binary file added tests/functional/asm/rel_include.bin
Binary file not shown.
4 changes: 2 additions & 2 deletions tests/functional/zxbpp/prepro70.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ DIM b



#line 1 "./prepro70.bi"
#line 1 "prepro70.bi"
DIM b
#line 10 "./prepro70.bi"
#line 10 "prepro70.bi"
#line 6 "prepro70.bi"

DIM a
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/zxbpp/prepro72.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ DIM b



#line 1 "./prepro70.bi"
#line 1 "prepro70.bi"
DIM b
#line 10 "./prepro70.bi"
#line 10 "prepro70.bi"
#line 6 "prepro72.bi"

DIM a
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/zxbpp/prepro85.bi
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
REM relative import

#include "../zxbpp/prepro00.bi"
132 changes: 132 additions & 0 deletions tests/functional/zxbpp/prepro85.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
#line 1 "prepro85.bi"


#line 1 "prepro00.bi"
#line 1 "/zxbasic/src/lib/arch/zx48k/stdlib/attr.bas"











#line 13 "/zxbasic/src/lib/arch/zx48k/stdlib/attr.bas"

#pragma push(case_insensitive)
#pragma case_insensitive = TRUE











function attr(byval row as ubyte, byval col as ubyte) as ubyte
asm
push namespace core

PROC
LOCAL __ATTR_END

ld e, (ix+7)
ld d, (ix+5)


call __IN_SCREEN
jr nc, __ATTR_END

call __ATTR_ADDR
ld a, (hl)

__ATTR_END:
ENDP

pop namespace
end asm

end function














sub setattr(byval row as ubyte, byval col as ubyte, byval value as ubyte)
asm
push namespace core

PROC
LOCAL __ATTR_END

ld e, (ix+7)
ld d, (ix+5)


call __IN_SCREEN
jr nc, __ATTR_END

call __ATTR_ADDR
ld a, (ix+9)
ld (hl), a

__ATTR_END:
ENDP

pop namespace
end asm

end sub











function fastcall attraddr(byval row as ubyte, byval col as ubyte) as uinteger
asm
push namespace core

pop hl
ex (sp), hl
ld d, a
ld e, h
jp __ATTR_ADDR
pop namespace
end asm
end function



#pragma pop(case_insensitive)


#require "attr.asm"


#require "in_screen.asm"

#line 125 "/zxbasic/src/lib/arch/zx48k/stdlib/attr.bas"
#line 2 "prepro00.bi"
PRINT "HELLO"
#line 4 "prepro85.bi"