| : stores ( -- ) |
: stores ( -- ) |
| prim prim-effect-out prim prim-effect-out-end @ ['] store map-items ; |
prim prim-effect-out prim prim-effect-out-end @ ['] store map-items ; |
| |
|
| |
: 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 |
| |
prim prim-effect-in prim prim-effect-in-end @ ['] print-debug-arg map-items |
| |
\ ." fputc('\n', vm_out);" cr |
| |
." }" cr |
| |
." #endif" cr ; |
| |
|
| |
: print-debug-result { item -- } |
| |
item item-first @ if |
| |
item print-debug-arg |
| |
endif ; |
| |
|
| |
: print-debug-results ( -- ) |
| |
cr |
| |
." #ifdef VM_DEBUG" cr |
| |
." if (vm_debug) {" cr |
| |
." fputs(" quote ." -- " quote ." , vm_out); " |
| |
prim prim-effect-out prim prim-effect-out-end @ ['] print-debug-result map-items |
| |
." fputc('\n', vm_out);" cr |
| |
." }" cr |
| |
." #endif" cr ; |
| |
|
| : output-super-end ( -- ) |
: output-super-end ( -- ) |
| prim prim-c-code 2@ s" SET_IP" search if |
prim prim-c-code 2@ s" SET_IP" search if |
| ." SUPER_END;" cr |
." SUPER_END;" cr |
| : output-c-tail ( -- ) |
: output-c-tail ( -- ) |
| \ the final part of the generated C code |
\ the final part of the generated C code |
| output-super-end |
output-super-end |
| |
print-debug-results |
| ." NEXT_P1;" cr |
." NEXT_P1;" cr |
| stores |
stores |
| fill-tos |
fill-tos |
| repeat |
repeat |
| 2drop type ; |
2drop type ; |
| |
|
| : 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 |
|
| prim prim-effect-in prim prim-effect-in-end @ ['] print-debug-arg map-items |
|
| ." fputc('\n', vm_out);" cr |
|
| ." }" cr |
|
| ." #endif" cr ; |
|
| |
|
| : print-entry ( -- ) |
: print-entry ( -- ) |
| ." I_" prim prim-c-name 2@ type ." :" ; |
." I_" prim prim-c-name 2@ type ." :" ; |
| |
|
| ." fputs(" quote prim prim-name 2@ type quote ." , vm_out);" cr |
." fputs(" quote prim prim-name 2@ type quote ." , vm_out);" cr |
| disasm-args |
disasm-args |
| ." ip += " inst-stream stack-in @ 1+ 0 .r ." ;" cr |
." ip += " inst-stream stack-in @ 1+ 0 .r ." ;" cr |
| ." } else " ; |
." goto _endif_;" cr |
| |
." }" cr ; |
| |
|
| : output-profile ( -- ) |
: output-profile ( -- ) |
| \ generate code for postprocessing the VM block profile stuff |
\ generate code for postprocessing the VM block profile stuff |
| prim prim-c-code 2@ s" SET_IP" search nip nip |
prim prim-c-code 2@ s" SET_IP" search nip nip |
| prim prim-c-code 2@ s" SUPER_END" search nip nip or if |
prim prim-c-code 2@ s" SUPER_END" search nip nip or if |
| ." return;" cr |
." return;" cr |
| |
else |
| |
." goto _endif_;" cr |
| endif |
endif |
| ." } else " cr ; |
." }" cr ; |
| |
|
| : gen-arg-parm { item -- } |
: gen-arg-parm { item -- } |
| item item-stack @ inst-stream = if |
item item-stack @ inst-stream = if |
| fetches ; |
fetches ; |
| |
|
| : part-output-c-tail ( -- ) |
: part-output-c-tail ( -- ) |
| |
print-debug-results |
| stores ; |
stores ; |
| |
|
| : output-combined-tail ( -- ) |
: output-combined-tail ( -- ) |