--- gforth/assert.fs 1995/10/16 18:33:05 1.4 +++ gforth/assert.fs 1995/11/07 18:06:32 1.5 @@ -1,6 +1,24 @@ \ 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 \G all assertions above this level are turned off @@ -31,16 +49,14 @@ variable assert-level ( -- a-addr ) \ gf POSTPONE assert1( ; immediate : (endassert) ( flag -- ) \ gforth-internal - \ three inline arguments + \ inline argument sourcepos if - r> 3 cells + >r EXIT + r> sourcepos drop + >r EXIT else - r> - dup 2@ type ." :" cell+ cell+ - @ 0 .r ." : failed assertion" + r> print-sourcepos ." : failed assertion" true abort" assertion failed" \ !! or use a new throw code? then ; : ) ( -- ) \ gforth close-paren \G end an assertion - POSTPONE (endassert) loadfilename 2@ 2, loadline @ , ; immediate + POSTPONE (endassert) sourcepos, ; immediate