mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-27 11:28:05 +11:00
xcomp: shrink scope
It seems that xcomp can't manage to reliably compile core+ units. Let's limit the role of xcomp to z80c+icore. I'm getting a little desperate here. I'll revisit the link.fs approach with a new idea I had...
This commit is contained in:
parent
6368cc3bac
commit
3822182226
@ -1,13 +1,3 @@
|
|||||||
: _
|
|
||||||
['] EXIT ,
|
|
||||||
R> DROP ( exit : )
|
|
||||||
XCOFF
|
|
||||||
; IMMEDIATE
|
|
||||||
';' CURRENT @ 4 - C!
|
|
||||||
|
|
||||||
: (find) (xfind) ;
|
|
||||||
: ['] X['] ; IMMEDIATE
|
|
||||||
: COMPILE XCOMPILE ; IMMEDIATE
|
|
||||||
: CODE XCODE ;
|
: CODE XCODE ;
|
||||||
: IMMEDIATE XIMM ;
|
: IMMEDIATE XIMM ;
|
||||||
: : [ ' X: , ] ;
|
: : [ ' X: , ] ;
|
||||||
|
@ -214,7 +214,7 @@
|
|||||||
R> DROP ( exit : )
|
R> DROP ( exit : )
|
||||||
; IMMEDIATE
|
; IMMEDIATE
|
||||||
|
|
||||||
';' XCURRENT @ 4 - C!
|
XCURRENT @ ( to PSP )
|
||||||
|
|
||||||
: :
|
: :
|
||||||
(entry)
|
(entry)
|
||||||
@ -231,3 +231,5 @@
|
|||||||
ELSE (parse*) @ EXECUTE LITN THEN
|
ELSE (parse*) @ EXECUTE LITN THEN
|
||||||
AGAIN
|
AGAIN
|
||||||
;
|
;
|
||||||
|
|
||||||
|
( from PSP ) ';' SWAP 4 - C!
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
( Do dictionary cross compilation.
|
( Allow cross-compilation of z80c and icore.
|
||||||
Include this file right before your cross compilation, then
|
Include this file right before your cross compilation, then
|
||||||
set XCURRENT to CURRENT and XOFF to H@ - your target hook.
|
set XCURRENT to CURRENT and XOFF to H@.
|
||||||
Example: H@ ' _bend - XOFF !
|
|
||||||
|
|
||||||
This redefines defining words to achieve cross compilation.
|
This redefines defining words to achieve cross compilation.
|
||||||
The goal is two-fold:
|
The goal is two-fold:
|
||||||
@ -9,11 +8,6 @@
|
|||||||
1. Add an offset to all word references in definitions.
|
1. Add an offset to all word references in definitions.
|
||||||
2. Don't shadow important words we need right now.
|
2. Don't shadow important words we need right now.
|
||||||
|
|
||||||
New defining words establish a new XCURRENT, a copy of
|
|
||||||
CURRENT. From now on, CURRENT doesn't move. This means that
|
|
||||||
"'" and friends will *not* find words you're about to
|
|
||||||
define. Only (xfind) will.
|
|
||||||
|
|
||||||
Words overrides like ":", "IMMEDIATE" and "CODE" are not
|
Words overrides like ":", "IMMEDIATE" and "CODE" are not
|
||||||
automatically shadowed to allow the harmless inclusion of
|
automatically shadowed to allow the harmless inclusion of
|
||||||
this unit. This shadowing has to take place in your xcomp
|
this unit. This shadowing has to take place in your xcomp
|
||||||
@ -21,15 +15,8 @@
|
|||||||
|
|
||||||
See example in /emul/forth/xcomp.fs
|
See example in /emul/forth/xcomp.fs
|
||||||
|
|
||||||
Note that this cross compilation unit is far from foolproof
|
Why limit ourselves to icore? Oh, I've tried cross-compiling
|
||||||
and cannot cross compile any kind of code. Cross compliation
|
the whole shebang. I tried. And failed. Too dynamic.
|
||||||
of Forth dicts is *tricky*. This unit is designed to cross
|
|
||||||
compile the core full interpreter, that is, the contents
|
|
||||||
of the "/forth" folder of the project.
|
|
||||||
|
|
||||||
Cross compiling anything else might work, but as soon as
|
|
||||||
you start defining immediates and using them on-the-fly,
|
|
||||||
things get icky.
|
|
||||||
)
|
)
|
||||||
|
|
||||||
VARIABLE XCURRENT
|
VARIABLE XCURRENT
|
||||||
@ -44,60 +31,26 @@ VARIABLE XOFF
|
|||||||
|
|
||||||
: XIMM XCON IMMEDIATE XCOFF ;
|
: XIMM XCON IMMEDIATE XCOFF ;
|
||||||
|
|
||||||
: XAPPLY
|
|
||||||
DUP XOFF @ > IF XOFF @ - THEN
|
|
||||||
;
|
|
||||||
|
|
||||||
( Run find in XCURRENT and apply XOFF )
|
|
||||||
: (xfind)
|
|
||||||
XCURRENT @ SWAP ( xcur w )
|
|
||||||
_find ( a f )
|
|
||||||
IF ( a )
|
|
||||||
( apply XOFF )
|
|
||||||
XAPPLY 1
|
|
||||||
ELSE
|
|
||||||
0
|
|
||||||
THEN
|
|
||||||
;
|
|
||||||
|
|
||||||
: X' XCON ' XCOFF XAPPLY ;
|
|
||||||
: X['] X' LITN ;
|
|
||||||
( TODO: am I making the word "," stable here? )
|
|
||||||
: XCOMPILE X' LITN ['] , , ;
|
|
||||||
|
|
||||||
: X:
|
: X:
|
||||||
(xentry)
|
(xentry)
|
||||||
( 0e == compiledWord )
|
( 0e == compiledWord )
|
||||||
[ 0x0e LITN ] ,
|
[ 0x0e LITN ] ,
|
||||||
BEGIN
|
BEGIN
|
||||||
( DUP is because we need a copy in case it's IMMED )
|
WORD
|
||||||
WORD DUP
|
|
||||||
( cross compile CURRENT )
|
( cross compile CURRENT )
|
||||||
XCURRENT @ SWAP ( w xcur w )
|
XCURRENT @ SWAP ( w xcur w )
|
||||||
_find ( w a f )
|
_find ( w a f )
|
||||||
IF
|
IF
|
||||||
( is word )
|
( is word )
|
||||||
DUP IMMED?
|
( never supposed to encounter an IMMEDIATE in xdict )
|
||||||
IF ( w a )
|
DUP IMMED? IF ABORT THEN
|
||||||
( When encountering IMMEDIATE, we exec the *host*
|
( not an immed. drop backup w and write, with
|
||||||
word. )
|
offset. )
|
||||||
DROP ( w )
|
DUP XOFF @ > IF XOFF @ - THEN
|
||||||
( system CURRENT )
|
,
|
||||||
0x02 RAM+ @ SWAP ( cur w )
|
ELSE ( w )
|
||||||
_find ( a f )
|
|
||||||
NOT IF ABORT THEN ( a )
|
|
||||||
XCON EXECUTE XCOFF
|
|
||||||
ELSE
|
|
||||||
( not an immed. drop backup w and write, with
|
|
||||||
offset. )
|
|
||||||
SWAP DROP ( a )
|
|
||||||
XAPPLY
|
|
||||||
,
|
|
||||||
THEN
|
|
||||||
ELSE ( w a )
|
|
||||||
( not found? it might be an immediate that isn't yet defined in our
|
( not found? it might be an immediate that isn't yet defined in our
|
||||||
cross-compiled dict. It's alright, we can find-and-execute it. )
|
cross-compiled dict. It's alright, we can find-and-execute it. )
|
||||||
DROP ( w )
|
|
||||||
( system CURRENT )
|
( system CURRENT )
|
||||||
0x02 RAM+ @ SWAP ( cur w )
|
0x02 RAM+ @ SWAP ( cur w )
|
||||||
_find ( a f )
|
_find ( a f )
|
||||||
|
Loading…
Reference in New Issue
Block a user