version 1.4, 1995/10/16 18:33:05
|
version 1.5, 1995/11/07 18:06:32
|
Line 1
|
Line 1
|
\ assertions |
\ assertions |
|
|
\ !! factor out line number printing, share with debugging.fs |
\ Copyright (C) 1995 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 |
|
\ of the License, or (at your option) any later version. |
|
|
|
\ This program is distributed in the hope that it will be useful, |
|
\ but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
\ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
\ 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., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
|
require source.fs |
|
|
variable assert-level ( -- a-addr ) \ gforth |
variable assert-level ( -- a-addr ) \ gforth |
\G all assertions above this level are turned off |
\G all assertions above this level are turned off |
Line 31 variable assert-level ( -- a-addr ) \ gf
|
Line 49 variable assert-level ( -- a-addr ) \ gf
|
POSTPONE assert1( ; immediate |
POSTPONE assert1( ; immediate |
|
|
: (endassert) ( flag -- ) \ gforth-internal |
: (endassert) ( flag -- ) \ gforth-internal |
\ three inline arguments |
\ inline argument sourcepos |
if |
if |
r> 3 cells + >r EXIT |
r> sourcepos drop + >r EXIT |
else |
else |
r> |
r> print-sourcepos ." : failed assertion" |
dup 2@ type ." :" cell+ cell+ |
|
@ 0 .r ." : failed assertion" |
|
true abort" assertion failed" \ !! or use a new throw code? |
true abort" assertion failed" \ !! or use a new throw code? |
then ; |
then ; |
|
|
: ) ( -- ) \ gforth close-paren |
: ) ( -- ) \ gforth close-paren |
\G end an assertion |
\G end an assertion |
POSTPONE (endassert) loadfilename 2@ 2, loadline @ , ; immediate |
POSTPONE (endassert) sourcepos, ; immediate |