--- gforth/prims2x.fs 2001/01/24 13:53:32 1.75 +++ gforth/prims2x.fs 2001/02/07 09:58:46 1.78 @@ -50,6 +50,7 @@ warnings off include ./search.fs include ./extend.fs [THEN] +include ./stuff.fs [IFUNDEF] environment? include ./environ.fs @@ -178,6 +179,11 @@ create stacks max-stacks cells allot \ a i xt execute item% %size +loop ; +\ types + +: print-type-prefix ( type -- ) + body> >head name>string type ; + \ various variables for storing stuff of one primitive struct% @@ -253,20 +259,25 @@ Variable function-number 0 function-numb item item-stack @ dup >r stack-in @ ( in-size r:stack ) item r> stack-in-index-xt @ execute ; +: item-stack-type-name ( item -- addr u ) + item-stack @ stack-type @ type-c-name 2@ ; + : fetch-single ( item -- ) \ fetch a single stack item from its stack >r r@ item-name 2@ type - ." = (" - r@ item-type @ type-c-name 2@ type ." ) " + ." = vm_" r@ item-stack-type-name type + ." 2" r@ item-type @ print-type-prefix ." (" r@ item-in-index r@ item-stack @ stack-access - ." ;" cr + ." );" cr rdrop ; : fetch-double ( item -- ) \ fetch a double stack item from its stack >r - ." FETCH_DCELL(" + ." vm_two" + r@ item-stack-type-name type ." 2" + r@ item-type @ print-type-prefix ." (" r@ item-name 2@ type ." , " r@ item-in-index r@ item-stack @ 2dup ." (Cell)" stack-access ." , " -1 under+ ." (Cell)" stack-access @@ -296,9 +307,10 @@ Variable function-number 0 function-numb : really-store-single ( item -- ) >r - r@ item-out-index r@ item-stack @ stack-access ." = " - r@ item-stack @ stack-cast 2@ type - r@ item-name 2@ type ." ;" + r@ item-out-index r@ item-stack @ stack-access ." = vm_" + r@ item-type @ print-type-prefix ." 2" + r@ item-stack-type-name type ." (" + r@ item-name 2@ type ." );" rdrop ; : store-single ( item -- ) @@ -318,7 +330,10 @@ Variable function-number 0 function-numb : store-double ( item -- ) \ !! store optimization is not performed, because it is not yet needed >r - ." STORE_DCELL(" r@ item-name 2@ type ." , " + ." vm_" + r@ item-type @ print-type-prefix ." 2two" + r@ item-stack-type-name type ." (" + r@ item-name 2@ type ." , " r@ item-out-index r@ item-stack @ 2dup stack-access ." , " -1 under+ stack-access ." );" cr @@ -422,8 +437,8 @@ s" Cell" single 0 create-type cell-type s" Float" single 0 create-type float-type s" sp" save-mem cell-type s" (Cell)" make-stack data-stack -s" fp" save-mem cell-type s" " make-stack fp-stack -s" rp" save-mem float-type s" (Cell)" make-stack return-stack +s" fp" save-mem float-type s" " make-stack fp-stack +s" rp" save-mem cell-type s" (Cell)" make-stack return-stack s" IP" save-mem cell-type s" error don't use # on results" make-stack inst-stream ' inst-in-index inst-stream stack-in-index-xt ! \ !! initialize stack-in and stack-out @@ -530,9 +545,6 @@ s" IP" save-mem cell-type s" error don' repeat 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