version 1.1, 2012/03/09 12:46:46
|
version 1.2, 2012/03/09 12:59:54
|
Line 1
|
Line 1
|
\ smart .s |
\ smart .s 09mar2012py |
|
|
|
\ Copyright (C) 1995,1998,1999,2001,2003,2006,2007,2011 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 3 |
|
\ 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, see http://www.gnu.org/licenses/. |
|
|
|
\ idea: Gerald Wodni |
|
|
: addr? ( addr -- flag ) |
: addr? ( addr -- flag ) |
TRY @ IFERROR 2drop false ELSE drop true THEN ENDTRY ; |
TRY @ IFERROR 2drop false nothrow ELSE drop true THEN ENDTRY ; |
|
|
: string? ( addr u -- flag ) |
: string? ( addr u -- flag ) |
TRY bounds ?DO I c@ bl < IF -1 throw THEN LOOP |
TRY bounds ?DO I c@ bl < IF -1 throw THEN LOOP |
IFERROR 2drop drop false ELSE true THEN ENDTRY ; |
IFERROR 2drop drop false nothrow ELSE true THEN ENDTRY ; |
|
|
: .string. ( addr u -- ) |
: .string. ( addr u -- ) |
'"' emit type '"' emit space ; |
'"' emit type '"' emit space ; |
: .addr. ( addr -- ) hex. ; |
: .addr. ( addr -- ) hex. ; |
|
|
: .s ( -- ) \ tools dot-s |
Variable smart.s-skip |
\G Display the number of items on the data stack, followed by a list |
|
\G of the items (but not more than specified by @code{maxdepth-.s}; |
: smart.s. ( n -- ) |
\G TOS is the right-most item. |
smart.s-skip @ smart.s-skip off IF drop EXIT THEN |
." <" depth 0 .r ." > " |
over r> i swap >r - pick 2dup string? IF |
depth 0 max maxdepth-.s @ min |
.string. smart.s-skip on |
dup 0 |
ELSE drop dup addr? IF .addr. |
?do |
ELSE . THEN |
dup i - pick over i - pick 2dup string? IF .string. 2 |
THEN ; |
ELSE drop dup addr? IF .addr. 1 |
|
ELSE .s. 1 THEN |
' smart.s. IS .s. |
THEN |
|
+loop |
|
drop ; |
|
|
|