version 1.110, 2002/08/20 07:59:01
|
version 1.112, 2002/08/28 21:46:58
|
Line 78 variable line-start \ pointer to start o
|
Line 78 variable line-start \ pointer to start o
|
0 line ! |
0 line ! |
2variable filename \ filename of original input file |
2variable filename \ filename of original input file |
0 0 filename 2! |
0 0 filename 2! |
|
2variable out-filename \ filename of the output file (for sync lines) |
|
0 0 out-filename 2! |
2variable f-comment |
2variable f-comment |
0 0 f-comment 2! |
0 0 f-comment 2! |
variable skipsynclines \ are sync lines ("#line ...") invisible to the parser? |
variable skipsynclines \ are sync lines ("#line ...") invisible to the parser? |
skipsynclines on |
skipsynclines on |
|
variable out-nls \ newlines in output (for output sync lines) |
|
0 out-nls ! |
|
variable store-optimization \ use store optimization? |
|
store-optimization off |
|
|
|
|
: th ( addr1 n -- addr2 ) |
: th ( addr1 n -- addr2 ) |
cells + ; |
cells + ; |
Line 121 skipsynclines on
|
Line 128 skipsynclines on
|
0 |
0 |
recover endtry |
recover endtry |
r> to outfile-id throw |
r> to outfile-id throw |
abort |
1 (bye) \ abort |
endif ; |
endif ; |
|
|
: quote ( -- ) |
: quote ( -- ) |
[char] " emit ; |
[char] " emit ; |
|
|
|
\ count output lines to generate sync lines for output |
|
|
|
: count-nls ( addr u -- ) |
|
bounds u+do |
|
i c@ nl-char = negate out-nls +! |
|
loop ; |
|
|
|
:noname ( addr u -- ) |
|
2dup count-nls |
|
defers type ; |
|
is type |
|
|
variable output \ xt ( -- ) of output word for simple primitives |
variable output \ xt ( -- ) of output word for simple primitives |
variable output-combined \ xt ( -- ) of output word for combined primitives |
variable output-combined \ xt ( -- ) of output word for combined primitives |
|
|
Line 364 defer inst-stream-f ( -- stack )
|
Line 383 defer inst-stream-f ( -- stack )
|
rdrop ; |
rdrop ; |
|
|
: store-single ( item -- ) |
: store-single ( item -- ) |
>r |
>r |
r@ same-as-in? |
store-optimization @ r@ same-as-in? and if |
if |
r@ item-in-index 0= r@ item-out-index 0= xor if |
r@ item-in-index 0= r@ item-out-index 0= xor |
." IF_" r@ item-stack @ stack-pointer 2@ type |
if |
." TOS(" r@ really-store-single ." );" cr |
." IF_" r@ item-stack @ stack-pointer 2@ type |
endif |
." TOS(" r@ really-store-single ." );" cr |
else |
endif |
r@ really-store-single cr |
else |
endif |
r@ really-store-single cr |
rdrop ; |
endif |
|
rdrop ; |
|
|
|
: store-double ( item -- ) |
: store-double ( item -- ) |
\ !! store optimization is not performed, because it is not yet needed |
\ !! store optimization is not performed, because it is not yet needed |
Line 647 stack inst-stream IP Cell
|
Line 664 stack inst-stream IP Cell
|
: type-c-code ( c-addr u xt -- ) |
: type-c-code ( c-addr u xt -- ) |
\ like TYPE, but replaces "INST_TAIL;" with tail code produced by xt |
\ like TYPE, but replaces "INST_TAIL;" with tail code produced by xt |
{ xt } |
{ xt } |
|
." {" cr |
|
." #line " c-line @ . quote c-filename 2@ type quote cr |
begin ( c-addr1 u1 ) |
begin ( c-addr1 u1 ) |
2dup s" INST_TAIL;" search |
2dup s" INST_TAIL;" search |
while ( c-addr1 u1 c-addr3 u3 ) |
while ( c-addr1 u1 c-addr3 u3 ) |
Line 655 stack inst-stream IP Cell
|
Line 674 stack inst-stream IP Cell
|
2r> 10 /string |
2r> 10 /string |
\ !! resync #line missing |
\ !! resync #line missing |
repeat |
repeat |
2drop type ; |
2drop type |
|
." #line " out-nls @ 2 + . quote out-filename 2@ type quote cr |
|
." }" cr ; |
|
|
: print-entry ( -- ) |
: print-entry ( -- ) |
." LABEL(" prim prim-c-name 2@ type ." )" ; |
." LABEL(" prim prim-c-name 2@ type ." )" ; |
|
|
: output-c ( -- ) |
: output-c ( -- ) |
print-entry ." /* " prim prim-name 2@ type ." ( " prim prim-stack-string 2@ type ." ) */" cr |
print-entry ." /* " prim prim-name 2@ type ." ( " prim prim-stack-string 2@ type ." ) */" cr |
." /* " prim prim-doc 2@ type ." */" cr |
." /* " prim prim-doc 2@ type ." */" cr |
." NAME(" quote prim prim-name 2@ type quote ." )" cr \ debugging |
." NAME(" quote prim prim-name 2@ type quote ." )" cr \ debugging |
." {" cr |
." {" cr |
." DEF_CA" cr |
." DEF_CA" cr |
print-declarations |
print-declarations |
." NEXT_P0;" cr |
." NEXT_P0;" cr |
flush-tos |
flush-tos |
fetches |
fetches |
print-debug-args |
print-debug-args |
stack-pointer-updates |
stack-pointer-updates |
." {" cr |
prim prim-c-code 2@ ['] output-c-tail type-c-code |
." #line " c-line @ . quote c-filename 2@ type quote cr |
output-c-tail2 |
prim prim-c-code 2@ ['] output-c-tail type-c-code |
." }" cr |
." }" cr |
cr |
output-c-tail2 |
|
." }" cr |
|
cr |
|
; |
; |
|
|
: disasm-arg { item -- } |
: disasm-arg { item -- } |
Line 1026 stack inst-stream IP Cell
|
Line 1044 stack inst-stream IP Cell
|
part-fetches |
part-fetches |
print-debug-args |
print-debug-args |
prim add-depths \ !! right place? |
prim add-depths \ !! right place? |
." {" cr |
|
." #line " c-line @ . quote c-filename 2@ type quote cr |
|
prim prim-c-code 2@ ['] output-combined-tail type-c-code |
prim prim-c-code 2@ ['] output-combined-tail type-c-code |
." }" cr |
|
part-output-c-tail |
part-output-c-tail |
." }" cr ; |
." }" cr ; |
|
|