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