--- gforth/kernel/cond.fs 1998/12/08 22:03:09 1.4 +++ gforth/kernel/cond.fs 2004/12/31 13:24:04 1.19 @@ -1,6 +1,6 @@ \ Structural Conditionals 12dec92py -\ Copyright (C) 1995,1996,1997 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,2000,2003,2004 Free Software Foundation, Inc. \ This file is part of Gforth. @@ -16,7 +16,7 @@ \ You should have received a copy of the GNU General Public License \ along with this program; if not, write to the Free Software -\ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +\ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. here 0 , \ just a dummy, the real value of locals-list is patched into it in glocals.fs AConstant locals-list \ acts like a variable that contains @@ -48,7 +48,9 @@ variable backedge-locals \ locals-list (valid at address) (third) \ types -0 constant defstart +[IFUNDEF] defstart +0 constant defstart \ usally defined in comp.fs +[THEN] 1 constant live-orig 2 constant dead-orig 3 constant dest \ the loopback branch is always assumed live @@ -78,13 +80,13 @@ variable backedge-locals 3 constant cs-item-size -: CS-PICK ( ... u -- ... destu ) \ tools-ext +: CS-PICK ( ... u -- ... destu ) \ tools-ext c-s-pick 1+ cs-item-size * 1- >r r@ pick r@ pick r@ pick rdrop dup non-orig? ; -: CS-ROLL ( destu/origu .. dest0/orig0 u -- .. dest0/orig0 destu/origu ) \ tools-ext +: CS-ROLL ( destu/origu .. dest0/orig0 u -- .. dest0/orig0 destu/origu ) \ tools-ext c-s-roll 1+ cs-item-size * 1- >r r@ roll r@ roll r@ roll rdrop @@ -103,12 +105,17 @@ variable backedge-locals \ Structural Conditionals 12dec92py +defer other-control-flow ( -- ) +\ hook for control-flow stuff that's not handled by begin-like etc. + : ?struc ( flag -- ) abort" unstructured " ; : sys? ( sys -- ) dup 0= ?struc ; : >mark ( -- orig ) - cs-push-orig 0 , ; -: >resolve ( addr -- ) here over - swap ! ; -: resolve ( addr -- ) + here swap ! + basic-block-end ; +: mark ; immediate restrict : ?DUP-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-if -\G This is the preferred alternative to the idiom "?DUP IF", since it can be +\G This is the preferred alternative to the idiom "@code{?DUP IF}", since it can be \G better handled by tools like stack checkers. Besides, it's faster. POSTPONE ?dup-?branch >mark ; immediate restrict @@ -153,7 +160,8 @@ Defer begin-like ( -- ) ' noop IS begin-like : BEGIN ( compilation -- dest ; run-time -- ) \ core - begin-like cs-push-part dest ; immediate restrict + begin-like cs-push-part dest + basic-block-end ; immediate restrict Defer again-like ( dest -- addr ) ' nip IS again-like @@ -161,9 +169,10 @@ Defer again-like ( dest -- addr ) : AGAIN ( compilation dest -- ; run-time -- ) \ core-ext dest? again-like POSTPONE branch