--- gforth/kernel/cond.fs 2002/09/24 17:57:29 1.13 +++ gforth/kernel/cond.fs 2007/12/31 18:40:26 1.22 @@ -1,12 +1,12 @@ \ Structural Conditionals 12dec92py -\ Copyright (C) 1995,1996,1997,2000 Free Software Foundation, Inc. +\ Copyright (C) 1995,1996,1997,2000,2003,2004,2007 Free Software Foundation, Inc. \ This file is part of Gforth. \ Gforth is free software; you can redistribute it and/or \ modify it under the terms of the GNU General Public License -\ as published by the Free Software Foundation; either version 2 +\ as published by the Free Software Foundation, either version 3 \ of the License, or (at your option) any later version. \ This program is distributed in the hope that it will be useful, @@ -15,8 +15,7 @@ \ GNU General Public License for more details. \ 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., 59 Temple Place, Suite 330, Boston, MA 02111, USA. +\ along with this program. If not, see http://www.gnu.org/licenses/. 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 @@ -105,10 +104,13 @@ 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 , ; + cs-push-orig 0 , other-control-flow ; : >resolve ( addr -- ) here swap ! basic-block-end ; @@ -122,18 +124,18 @@ variable backedge-locals \ Structural Conditionals 12dec92py : AHEAD ( compilation -- orig ; run-time -- ) \ tools-ext - POSTPONE abranch >mark POSTPONE unreachable ; immediate restrict + POSTPONE branch >mark POSTPONE unreachable ; immediate restrict : IF ( compilation -- orig ; run-time f -- ) \ core - POSTPONE a?branch >mark ; immediate restrict + POSTPONE ?branch >mark ; immediate restrict : ?DUP-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-if \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 a?dup-?branch >mark ; immediate restrict + POSTPONE ?dup-?branch >mark ; immediate restrict : ?DUP-0=-IF ( compilation -- orig ; run-time n -- n| ) \ gforth question-dupe-zero-equals-if - POSTPONE a?dup-0=-?branch >mark ; immediate restrict + POSTPONE ?dup-0=-?branch >mark ; immediate restrict Defer then-like ( orig -- ) : cs>addr ( orig/dest -- ) drop >resolve drop ; @@ -148,7 +150,7 @@ immediate restrict \ people who have not been brought up with Forth (or who have been \ brought up with fig-Forth). -: ELSE ( compilation orig1 -- orig2 ; run-time f -- ) \ core +: ELSE ( compilation orig1 -- orig2 ; run-time -- ) \ core POSTPONE ahead 1 cs-roll POSTPONE then ; immediate restrict @@ -164,7 +166,7 @@ Defer again-like ( dest -- addr ) ' nip IS again-like : AGAIN ( compilation dest -- ; run-time -- ) \ core-ext - dest? again-like POSTPONE abranch