--- gforth/prims2x.fs 2005/07/28 19:15:00 1.158 +++ gforth/prims2x.fs 2006/10/25 22:01:16 1.162 @@ -1,6 +1,6 @@ \ converts primitives to, e.g., C code -\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,1998,2000,2003,2004,2005 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -51,6 +51,7 @@ \ (stack-in-index-xt and a test for stack==instruction-stream); there \ should be only one. + \ for backwards compatibility, jaw require compat/strcomp.fs @@ -102,6 +103,9 @@ variable include-skipped-insts \ inline arguments (false) include-skipped-insts off +2variable threaded-code-pointer-type \ type used for geninst etc. +s" Inst **" threaded-code-pointer-type 2! + variable immarg \ values for immediate arguments (to be used in IMM_ARG macros) $12340000 immarg ! @@ -201,6 +205,7 @@ struct% end-struct ss% \ stack-state struct% + cell% field state-enabled cell% field state-number cell% max-stacks * field state-sss end-struct state% @@ -500,8 +505,8 @@ defer inst-stream-f ( -- stack ) ." vm_two" r@ item-stack-type-name type ." 2" r@ item-type @ print-type-prefix ." (" - r@ item-in-index r@ item-stack @ 2dup ." (Cell)" stack-read - ." , " -1 under+ ." (Cell)" stack-read + r@ item-in-index r@ item-stack @ 2dup stack-read + ." , " -1 under+ stack-read ." , " r@ item-name 2@ type ." )" cr rdrop ; @@ -751,11 +756,18 @@ stack inst-stream IP Cell : state ( "name" -- ) \ create a state initialized with default-sss create state% %allot { s } + s state-enabled on next-state-number @ s state-number ! 1 next-state-number +! max-stacks 0 ?do default-ss s state-sss i th ! loop ; +: state-disable ( state -- ) + state-enabled off ; + +: state-enabled? ( state -- f ) + state-enabled @ ; + : .state ( state -- ) 0 >body - >name .name ; @@ -1169,9 +1181,10 @@ variable tail-nextp2 \ xt to execute for : output-gen ( -- ) \ generate C code for generating VM instructions - ." void gen_" prim prim-c-name 2@ type ." (Inst **ctp" gen-args-parm ." )" cr + ." void gen_" prim prim-c-name 2@ type ." (" + threaded-code-pointer-type 2@ type ." ctp" gen-args-parm ." )" cr ." {" cr - ." gen_inst(ctp, vm_prim[" function-number @ 0 .r ." ]);" cr + ." gen_inst(ctp, " function-number @ 0 .r ." );" cr gen-args-gen ." }" cr ; @@ -1457,6 +1470,7 @@ variable reprocessed-num 0 reprocessed-n : state-prim1 { in-state out-state prim -- } in-state out-state state-default dup d= ?EXIT + in-state state-enabled? out-state state-enabled? and 0= ?EXIT in-state to state-in out-state to state-out prim reprocess-simple ;