clean up x86 generator, add SDL and alien to bootstrap
parent
cbc8976e46
commit
6b744e5cd6
|
@ -113,12 +113,21 @@ USE: stdio
|
||||||
"/library/inference/branches.factor"
|
"/library/inference/branches.factor"
|
||||||
"/library/inference/stack.factor"
|
"/library/inference/stack.factor"
|
||||||
|
|
||||||
"/library/compiler/optimizer.factor"
|
|
||||||
"/library/compiler/linearizer.factor"
|
|
||||||
"/library/compiler/assembler.factor"
|
"/library/compiler/assembler.factor"
|
||||||
"/library/compiler/xt.factor"
|
"/library/compiler/xt.factor"
|
||||||
|
"/library/compiler/optimizer.factor"
|
||||||
|
"/library/compiler/linearizer.factor"
|
||||||
"/library/compiler/generator.factor"
|
"/library/compiler/generator.factor"
|
||||||
"/library/compiler/compiler.factor"
|
"/library/compiler/compiler.factor"
|
||||||
|
"/library/compiler/alien-types.factor"
|
||||||
|
"/library/compiler/alien.factor"
|
||||||
|
|
||||||
|
"/library/sdl/sdl.factor"
|
||||||
|
"/library/sdl/sdl-video.factor"
|
||||||
|
"/library/sdl/sdl-event.factor"
|
||||||
|
"/library/sdl/sdl-gfx.factor"
|
||||||
|
"/library/sdl/sdl-keysym.factor"
|
||||||
|
"/library/sdl/sdl-utils.factor"
|
||||||
|
|
||||||
"/library/bootstrap/image.factor"
|
"/library/bootstrap/image.factor"
|
||||||
"/library/bootstrap/cross-compiler.factor"
|
"/library/bootstrap/cross-compiler.factor"
|
||||||
|
@ -149,21 +158,7 @@ cpu "x86" = [
|
||||||
[
|
[
|
||||||
"/library/compiler/assembly-x86.factor"
|
"/library/compiler/assembly-x86.factor"
|
||||||
"/library/compiler/generator-x86.factor"
|
"/library/compiler/generator-x86.factor"
|
||||||
! "/library/compiler/compiler-macros.factor"
|
|
||||||
! "/library/compiler/ifte.factor"
|
|
||||||
! "/library/compiler/generic.factor"
|
|
||||||
! "/library/compiler/stack.factor"
|
|
||||||
! "/library/compiler/interpret-only.factor"
|
|
||||||
! "/library/compiler/alien-types.factor"
|
|
||||||
! "/library/compiler/alien-macros.factor"
|
! "/library/compiler/alien-macros.factor"
|
||||||
! "/library/compiler/alien.factor"
|
|
||||||
!
|
|
||||||
! "/library/sdl/sdl.factor"
|
|
||||||
! "/library/sdl/sdl-video.factor"
|
|
||||||
! "/library/sdl/sdl-event.factor"
|
|
||||||
! "/library/sdl/sdl-gfx.factor"
|
|
||||||
! "/library/sdl/sdl-keysym.factor"
|
|
||||||
! "/library/sdl/sdl-utils.factor"
|
|
||||||
] [
|
] [
|
||||||
dup print
|
dup print
|
||||||
run-resource
|
run-resource
|
||||||
|
|
|
@ -73,12 +73,12 @@ USE: words
|
||||||
: alien-function ( function library -- )
|
: alien-function ( function library -- )
|
||||||
[ library dlsym ] [ dlsym-self ] ifte* ;
|
[ library dlsym ] [ dlsym-self ] ifte* ;
|
||||||
|
|
||||||
: compile-alien-call
|
! : compile-alien-call
|
||||||
pop-literal reverse PARAMETERS >r
|
! pop-literal reverse PARAMETERS >r
|
||||||
pop-literal pop-literal alien-function CALL JUMP-FIXUP
|
! pop-literal pop-literal alien-function CALL JUMP-FIXUP
|
||||||
r> CLEANUP
|
! r> CLEANUP
|
||||||
pop-literal RETURNS ;
|
! pop-literal RETURNS ;
|
||||||
|
!
|
||||||
global [ <namespace> "libraries" set ] bind
|
! global [ <namespace> "libraries" set ] bind
|
||||||
|
!
|
||||||
\ alien-call [ compile-alien-call ] "compiling" set-word-property
|
! \ alien-call [ compile-alien-call ] "compiling" set-word-property
|
||||||
|
|
|
@ -57,19 +57,14 @@ USE: words
|
||||||
] "generator" set-word-property
|
] "generator" set-word-property
|
||||||
|
|
||||||
#call [
|
#call [
|
||||||
dup postpone-word
|
|
||||||
CALL compiled-offset defer-xt
|
CALL compiled-offset defer-xt
|
||||||
] "generator" set-word-property
|
] "generator" set-word-property
|
||||||
|
|
||||||
#call-label [
|
#jump [
|
||||||
CALL compiled-offset defer-xt
|
|
||||||
] "generator" set-word-property
|
|
||||||
|
|
||||||
#jump-label [
|
|
||||||
JUMP compiled-offset defer-xt
|
JUMP compiled-offset defer-xt
|
||||||
] "generator" set-word-property
|
] "generator" set-word-property
|
||||||
|
|
||||||
#jump-label-t [
|
#jump-t [
|
||||||
POP-DS
|
POP-DS
|
||||||
! condition is now in EAX
|
! condition is now in EAX
|
||||||
f address EAX CMP-I-R
|
f address EAX CMP-I-R
|
||||||
|
|
|
@ -44,8 +44,7 @@ USE: errors
|
||||||
|
|
||||||
SYMBOL: #push-immediate
|
SYMBOL: #push-immediate
|
||||||
SYMBOL: #push-indirect
|
SYMBOL: #push-indirect
|
||||||
SYMBOL: #jump-label-t ( branch if top of stack is true )
|
SYMBOL: #jump-t ( branch if top of stack is true )
|
||||||
SYMBOL: #jump-label ( unconditional branch )
|
|
||||||
SYMBOL: #jump ( tail-call )
|
SYMBOL: #jump ( tail-call )
|
||||||
SYMBOL: #return-to ( push addr on C stack )
|
SYMBOL: #return-to ( push addr on C stack )
|
||||||
|
|
||||||
|
@ -87,8 +86,18 @@ SYMBOL: #target ( part of jump table )
|
||||||
swons ,
|
swons ,
|
||||||
] "linearizer" set-word-property
|
] "linearizer" set-word-property
|
||||||
|
|
||||||
|
#call [
|
||||||
|
dup [ node-param get ] bind postpone-word
|
||||||
|
linear,
|
||||||
|
] "linearizer" set-word-property
|
||||||
|
|
||||||
|
#call-label [
|
||||||
|
[ node-param get ] bind #call swons ,
|
||||||
|
] "linearizer" set-word-property
|
||||||
|
|
||||||
: <label> ( -- label )
|
: <label> ( -- label )
|
||||||
gensym ;
|
gensym
|
||||||
|
dup t "label" set-word-property ;
|
||||||
|
|
||||||
: label, ( label -- )
|
: label, ( label -- )
|
||||||
#label swons , ;
|
#label swons , ;
|
||||||
|
@ -124,9 +133,9 @@ SYMBOL: #target ( part of jump table )
|
||||||
#! IR.
|
#! IR.
|
||||||
uncons car
|
uncons car
|
||||||
<label> [
|
<label> [
|
||||||
#jump-label-t swons ,
|
#jump-t swons ,
|
||||||
(linearize) ( false branch )
|
(linearize) ( false branch )
|
||||||
<label> dup #jump-label swons ,
|
<label> dup #jump swons ,
|
||||||
] keep label, ( branch target of BRANCH-T )
|
] keep label, ( branch target of BRANCH-T )
|
||||||
swap (linearize) ( true branch )
|
swap (linearize) ( true branch )
|
||||||
label, ( branch target of false branch end ) ;
|
label, ( branch target of false branch end ) ;
|
||||||
|
@ -144,9 +153,7 @@ SYMBOL: #target ( part of jump table )
|
||||||
|
|
||||||
: dispatch-body ( end label/param -- )
|
: dispatch-body ( end label/param -- )
|
||||||
#! Output each branch, with a jump to the end label.
|
#! Output each branch, with a jump to the end label.
|
||||||
[
|
[ uncons label, (linearize) dup #jump swons , ] each drop ;
|
||||||
uncons label, (linearize) dup #jump-label swons ,
|
|
||||||
] each drop ;
|
|
||||||
|
|
||||||
: check-dispatch ( vtable -- )
|
: check-dispatch ( vtable -- )
|
||||||
length num-types = [
|
length num-types = [
|
||||||
|
|
Loading…
Reference in New Issue