version 1.181, 2011/11/11 18:29:10
|
version 1.182, 2011/11/13 20:54:56
|
Line 448 const Create ??? 0 , 3 , char ? c, char
|
Line 448 const Create ??? 0 , 3 , char ? c, char
|
|
|
: head? ( addr -- f ) |
: head? ( addr -- f ) |
\G heuristic check whether addr is a name token; may deliver false |
\G heuristic check whether addr is a name token; may deliver false |
\G positives; addr must be a valid address; returns 1 for |
\G positives; addr must be a valid address |
\G particularly unsafe positives |
dup dup aligned <> |
\ we follow the link fields and check for plausibility; two |
if |
\ iterations should catch most false addresses: on the first |
drop false exit \ heads are aligned |
\ iteration, we may get an xt, on the second a code address (or |
then |
\ some code), which is typically not in the dictionary. |
name>string dup $1F > if |
\ we added a third iteration for working with code and ;code words. |
2drop false exit \ realistically the name is short |
3 0 do |
then |
dup dup aligned <> if \ protect @ against unaligned accesses |
+ cfaligned @ here forthstart within ; \ and the cfa is outside |
drop false unloop exit |
|
then |
|
dup @ dup |
|
if ( addr addr1 ) |
|
dup rot forthstart within |
|
if \ addr1 is outside forthstart..addr, not a head |
|
drop false unloop exit |
|
then ( addr1 ) |
|
else \ 0 in the link field, no further checks |
|
2drop 1 unloop exit \ this is very unsure, so return 1 |
|
then |
|
loop |
|
\ in dubio pro: |
|
drop true ; |
|
|
|
: >head-noprim ( cfa -- nt ) \ gforth to-head-noprim |
: >head-noprim ( cfa -- nt ) \ gforth to-head-noprim |
\ also heuristic |
\ also heuristic |