kernel: add full stack effects to unless, when, when*, unless* so they give useful stack imbalance errors

db4
Joe Groff 2011-08-09 10:32:12 -07:00
parent 87653c20da
commit 8feb6c68e2
1 changed files with 4 additions and 4 deletions

View File

@ -32,20 +32,20 @@ DEFER: if
: if ( ..a ? true: ( ..a -- ..b ) false: ( ..a -- ..b ) -- ..b ) ? call ;
! Single branch
: unless ( ? false -- )
: unless ( ..a ? false: ( ..a -- ..a ) -- ..a )
swap [ drop ] [ call ] if ; inline
: when ( ? true -- )
: when ( ..a ? true: ( ..a -- ..a ) -- ..a )
swap [ call ] [ drop ] if ; inline
! Anaphoric
: if* ( ..a ? true: ( ..a ? -- ..b ) false: ( ..a -- ..b ) -- ..b )
pick [ drop call ] [ 2nip call ] if ; inline
: when* ( ? true -- )
: when* ( ..a ? true: ( ..a ? -- ..a ) -- ..a )
over [ call ] [ 2drop ] if ; inline
: unless* ( ? false -- )
: unless* ( ..a ? false: ( ..a -- ..a x ) -- ..a x )
over [ drop ] [ nip call ] if ; inline
! Default