--- gforth/prims2x.fs 2002/06/02 15:46:16 1.106 +++ gforth/prims2x.fs 2002/08/19 07:38:15 1.109 @@ -625,30 +625,40 @@ stack inst-stream IP Cell endif 2drop ; -: output-c-tail ( -- ) - \ the final part of the generated C code +: output-c-tail1 ( -- ) + \ the final part of the generated C code except LABEL2 and NEXT_P2 output-super-end print-debug-results ." NEXT_P1;" cr stores - fill-tos + fill-tos ; + +: output-c-tail ( -- ) + \ the final part of the generated C code, without LABEL2 + output-c-tail1 ." NEXT_P2;" ; +: output-c-tail2 ( -- ) + \ the final part of the generated C code, including LABEL2 + output-c-tail1 + ." LABEL2(" prim prim-c-name 2@ type ." )" cr + ." NEXT_P2;" cr ; + : type-c-code ( c-addr u xt -- ) - \ like TYPE, but replaces "TAIL;" with tail code produced by xt + \ like TYPE, but replaces "INST_TAIL;" with tail code produced by xt { xt } begin ( c-addr1 u1 ) - 2dup s" TAIL;" search + 2dup s" INST_TAIL;" search while ( c-addr1 u1 c-addr3 u3 ) 2dup 2>r drop nip over - type xt execute - 2r> 5 /string + 2r> 10 /string \ !! resync #line missing repeat 2drop type ; : print-entry ( -- ) - ." LABEL(" prim prim-c-name 2@ type ." ):" ; + ." LABEL(" prim prim-c-name 2@ type ." )" ; : output-c ( -- ) print-entry ." /* " prim prim-name 2@ type ." ( " prim prim-stack-string 2@ type ." ) */" cr @@ -666,19 +676,18 @@ stack inst-stream IP Cell ." #line " c-line @ . quote c-filename 2@ type quote cr prim prim-c-code 2@ ['] output-c-tail type-c-code ." }" cr - output-c-tail + output-c-tail2 ." }" cr cr ; : disasm-arg { item -- } item item-stack @ inst-stream = if - ." fputc(' ', vm_out); " - \ !! change this to first convert args to the right type and - \ then print them - ." /* printarg_" item item-type @ print-type-prefix - ." ((" item item-type @ type-c-name 2@ type ." )" - ." ip[" item item-offset @ 1+ 0 .r ." ]); */" cr + ." {" cr + item print-declaration + item fetch + item print-debug-arg + ." }" cr endif ; : disasm-args ( -- ) @@ -900,9 +909,7 @@ stack inst-stream IP Cell \ #line 516 "./prim" \ n = n1+n2; \ } -\ NEXT_P1; \ _x_sp0 = (Cell)n; -\ NEXT_P2; \ } \ NEXT_P1; \ spTOS = (Cell)_x_sp0; @@ -1047,7 +1054,7 @@ stack inst-stream IP Cell \ print-debug-args stack-pointer-updates output-parts - output-c-tail + output-c-tail2 ." }" cr cr ;