version 1.57, 2000/12/26 19:31:56
|
version 1.63, 2001/01/09 16:11:36
|
Line 82 skipsynclines on
|
Line 82 skipsynclines on
|
: end ( addr -- addr u ) |
: end ( addr -- addr u ) |
cookedinput @ over - ; |
cookedinput @ over - ; |
|
|
|
: quote ( -- ) |
|
[char] " emit ; |
|
|
variable output \ xt ( -- ) of output word |
variable output \ xt ( -- ) of output word |
|
|
: printprim ( -- ) |
: printprim ( -- ) |
Line 125 end-struct type%
|
Line 128 end-struct type%
|
s" sp" save-mem s" (Cell)" make-stack data-stack |
s" sp" save-mem s" (Cell)" make-stack data-stack |
s" fp" save-mem s" " make-stack fp-stack |
s" fp" save-mem s" " make-stack fp-stack |
s" rp" save-mem s" (Cell)" make-stack return-stack |
s" rp" save-mem s" (Cell)" make-stack return-stack |
s" ip" save-mem s" error don't use # on results" make-stack inst-stream |
s" IP" save-mem s" error don't use # on results" make-stack inst-stream |
' inst-in-index inst-stream stack-in-index-xt ! |
' inst-in-index inst-stream stack-in-index-xt ! |
\ !! initialize stack-in and stack-out |
\ !! initialize stack-in and stack-out |
|
|
Line 323 Variable c-flag
|
Line 326 Variable c-flag
|
(( {{ start }} c-ident {{ end c-name 2! }} )) ?? |
(( {{ start }} c-ident {{ end c-name 2! }} )) ?? |
)) ?? nl |
)) ?? nl |
)) |
)) |
(( ` " ` " {{ start }} (( noquote ++ ` " )) ++ {{ end 1- doc 2! }} ` " nl )) ?? |
(( ` " ` " {{ start }} (( noquote ++ ` " )) ++ {{ end 1- doc 2! }} ` " white ** nl )) ?? |
{{ skipsynclines off line @ c-line ! filename 2@ c-filename 2! start }} (( nocolonnl nonl ** nl )) ** {{ end c-code 2! skipsynclines on }} |
{{ skipsynclines off line @ c-line ! filename 2@ c-filename 2! start }} (( nocolonnl nonl ** nl white ** )) ** {{ end c-code 2! skipsynclines on }} |
(( ` : nl |
(( ` : white ** nl |
{{ start }} (( nonl ++ nl )) ++ {{ end forth-code 2! }} |
{{ start }} (( nonl ++ nl white ** )) ++ {{ end forth-code 2! }} |
)) ?? {{ printprim }} |
)) ?? {{ printprim }} |
(( nl || eof )) |
(( nl || eof )) |
)) <- primitive ( -- ) |
)) <- primitive ( -- ) |
|
|
(( (( comment || primitive || nl )) ** eof )) |
(( (( comment || primitive || nl white ** )) ** eof )) |
parser primitives2something |
parser primitives2something |
warnings @ [IF] |
warnings @ [IF] |
.( parser generated ok ) cr |
.( parser generated ok ) cr |
Line 383 warnings @ [IF]
|
Line 386 warnings @ [IF]
|
>r |
>r |
." FETCH_DCELL(" |
." FETCH_DCELL(" |
r@ item-name 2@ type ." , " |
r@ item-name 2@ type ." , " |
r@ item-in-index r@ item-stack @ 2dup stack-access |
r@ item-in-index r@ item-stack @ 2dup ." (Cell)" stack-access |
." , " -1 under+ stack-access |
." , " -1 under+ ." (Cell)" stack-access |
." );" cr |
." );" cr |
rdrop ; |
rdrop ; |
|
|
Line 626 does> ( item -- )
|
Line 629 does> ( item -- )
|
repeat |
repeat |
2drop type ; |
2drop type ; |
|
|
|
: print-type-prefix ( type -- ) |
|
body> >head .name ; |
|
|
|
: print-debug-arg { item -- } |
|
." fputs(" quote space item item-name 2@ type ." =" quote ." , vm_out); " |
|
." printarg_" item item-type @ print-type-prefix |
|
." (" item item-name 2@ type ." );" cr ; |
|
|
|
: print-debug-args ( -- ) |
|
." #ifdef VM_DEBUG" cr |
|
." if (vm_debug) {" cr |
|
effect-in-end @ effect-in ?do |
|
i print-debug-arg |
|
item% %size +loop |
|
." fputc('\n', vm_out);" cr |
|
." }" cr |
|
." #endif" cr ; |
|
|
: output-c ( -- ) |
: output-c ( -- ) |
." I_" c-name 2@ type ." : /* " forth-name 2@ type ." ( " stack-string 2@ type ." ) */" cr |
." I_" c-name 2@ type ." : /* " forth-name 2@ type ." ( " stack-string 2@ type ." ) */" cr |
." /* " doc 2@ type ." */" cr |
." /* " doc 2@ type ." */" cr |
." NAME(" [char] " emit forth-name 2@ type [char] " emit ." )" cr \ debugging |
." NAME(" quote forth-name 2@ type quote ." )" cr \ debugging |
." {" cr |
." {" cr |
." DEF_CA" cr |
." DEF_CA" cr |
declarations |
declarations |
Line 637 does> ( item -- )
|
Line 658 does> ( item -- )
|
." NEXT_P0;" cr |
." NEXT_P0;" cr |
flush-tos |
flush-tos |
fetches |
fetches |
|
print-debug-args |
stack-pointer-updates |
stack-pointer-updates |
." {" cr |
." {" cr |
." #line " c-line @ . [char] " emit c-filename 2@ type [char] " emit cr |
." #line " c-line @ . quote c-filename 2@ type quote cr |
c-code 2@ type-c |
c-code 2@ type-c |
." }" cr |
." }" cr |
output-c-tail |
output-c-tail |
Line 647 does> ( item -- )
|
Line 669 does> ( item -- )
|
cr |
cr |
; |
; |
|
|
: print-type-prefix ( type -- ) |
|
body> >head .name ; |
|
|
|
: disasm-arg { item -- } |
: disasm-arg { item -- } |
item item-stack @ inst-stream = if |
item item-stack @ inst-stream = if |
." printarg_" item item-type @ print-type-prefix |
." fputc(' ', vm_out); " |
." (ip[" item item-offset @ 1+ 0 .r ." ]);" cr |
." printarg_" item item-type @ print-type-prefix |
|
." ((" item item-type @ type-c-name 2@ type ." )" |
|
." ip[" item item-offset @ 1+ 0 .r ." ]);" cr |
endif ; |
endif ; |
|
|
: disasm-args ( -- ) |
: disasm-args ( -- ) |
Line 664 does> ( item -- )
|
Line 685 does> ( item -- )
|
: output-disasm ( -- ) |
: output-disasm ( -- ) |
\ generate code for disassembling VM instructions |
\ generate code for disassembling VM instructions |
." if (ip[0] == prim[" function-number @ 0 .r ." ]) {" cr |
." if (ip[0] == prim[" function-number @ 0 .r ." ]) {" cr |
." fputs(" [char] " emit forth-name 2@ type [char] " emit ." ,stdout);" cr |
." fputs(" quote forth-name 2@ type quote ." , vm_out);" cr |
." /* " declarations ." */" cr |
." /* " declarations ." */" cr |
compute-offsets |
compute-offsets |
disasm-args |
disasm-args |
Line 672 does> ( item -- )
|
Line 693 does> ( item -- )
|
." } else " |
." } else " |
1 function-number +! ; |
1 function-number +! ; |
|
|
|
: gen-arg-parm { item -- } |
|
item item-stack @ inst-stream = if |
|
." , " item item-type @ type-c-name 2@ type space |
|
item item-name 2@ type |
|
endif ; |
|
|
|
: gen-args-parm ( -- ) |
|
effect-in-end @ effect-in ?do |
|
i gen-arg-parm |
|
item% %size +loop ; |
|
|
|
: gen-arg-gen { item -- } |
|
item item-stack @ inst-stream = if |
|
." genarg_" item item-type @ print-type-prefix |
|
." (ctp, " item item-name 2@ type ." );" cr |
|
endif ; |
|
|
|
: gen-args-gen ( -- ) |
|
effect-in-end @ effect-in ?do |
|
i gen-arg-gen |
|
item% %size +loop ; |
|
|
|
: output-gen ( -- ) |
|
\ generate C code for generating VM instructions |
|
." /* " declarations ." */" cr |
|
compute-offsets |
|
." void gen_" c-name 2@ type ." (Inst **ctp" gen-args-parm ." )" cr |
|
." {" cr |
|
." gen_inst(ctp, vm_prim[" function-number @ 0 .r ." ]);" cr |
|
gen-args-gen |
|
." }" cr |
|
1 function-number +! ; |
|
|
: stack-used? { stack -- f } |
: stack-used? { stack -- f } |
stack stack-in @ stack stack-out @ or 0<> ; |
stack stack-in @ stack stack-out @ or 0<> ; |
|
|
Line 689 does> ( item -- )
|
Line 743 does> ( item -- )
|
." Cell * I_" c-name 2@ type ." (Cell *SP, Cell **FP) /* " forth-name 2@ type |
." Cell * I_" c-name 2@ type ." (Cell *SP, Cell **FP) /* " forth-name 2@ type |
." ( " stack-string 2@ type ." ) */" cr |
." ( " stack-string 2@ type ." ) */" cr |
." /* " doc 2@ type ." */" cr |
." /* " doc 2@ type ." */" cr |
." NAME(" [char] " emit forth-name 2@ type [char] " emit ." )" cr |
." NAME(" quote forth-name 2@ type quote ." )" cr |
\ debugging |
\ debugging |
." {" cr |
." {" cr |
declarations |
declarations |
Line 703 does> ( item -- )
|
Line 757 does> ( item -- )
|
stack-pointer-updates |
stack-pointer-updates |
fp-stack stack-used? IF ." *FP=fp;" cr THEN |
fp-stack stack-used? IF ." *FP=fp;" cr THEN |
." {" cr |
." {" cr |
." #line " c-line @ . [char] " emit c-filename 2@ type [char] " emit cr |
." #line " c-line @ . quote c-filename 2@ type quote cr |
c-code 2@ type |
c-code 2@ type |
." }" cr |
." }" cr |
stores |
stores |
Line 762 does> ( item -- )
|
Line 816 does> ( item -- )
|
|
|
: process-file ( addr u xt -- ) |
: process-file ( addr u xt -- ) |
>r |
>r |
2dup filename 2! |
save-mem 2dup filename 2! |
0 function-number ! |
0 function-number ! |
r/o open-file abort" cannot open file" |
r/o open-file abort" cannot open file" |
warnings @ if |
warnings @ if |