Commit cee94c11 authored by anton's avatar anton

added LATEST, replaced uses of LAST @ with uses of LATEST

renamed LASTXT to LATESTXT, and changed the uses
made >NAME the primary name for >HEAD
documentation changes
parent 64d36394
......@@ -42,11 +42,11 @@
vocabulary ans-report-words ans-report-words definitions
: wordset ( "name" -- )
lastxt >body
latestxt >body
create
0 , \ link to next wordset
0 0 2, \ array of nfas
( lastlinkp ) last @ swap ! \ set link ptr of last wordset
( lastlinkp ) latest swap ! \ set link ptr of last wordset
;
wordlist constant wordsets wordsets set-current
......
......@@ -35,10 +35,10 @@ vocabulary assembler ( -- ) \ tools-ext
: (;code) ( -- ) \ gforth
\ execution semantics of @code{;code}
r> lastxt code-address! ;
r> latestxt code-address! ;
:noname ( -- colon-sys )
align here lastxt code-address!
align here latestxt code-address!
defstart init-asm ;
:noname ( colon-sys1 -- colon-sys2 ) \ tools-ext semicolon-code
( create the [;code] part of a low level defining word )
......@@ -48,6 +48,6 @@ interpret/compile: ;code ( compilation. colon-sys1 -- colon-sys2 ) \ tools-ext s
: end-code ( colon-sys -- ) \ gforth end_code
( end a code definition )
lastxt here over - flush-icache
latestxt here over - flush-icache
previous ?struc reveal ;
......@@ -183,7 +183,7 @@ VARIABLE Unnest
' NestXT IF EXIT THEN (debug) Leave-D ;
: break:, ( -- )
lastxt postpone literal ;
latestxt postpone literal ;
: (break:)
r> ['] (_debug) >body >r ;
......
......@@ -5958,29 +5958,29 @@ words:
doc-noname
@cindex execution token of last defined word
doc-lastxt
doc-latestxt
@noindent
The previous example can be rewritten using @code{noname} and
@code{lastxt}:
@code{latestxt}:
@example
Defer deferred
noname : ( ... -- ... )
... ;
lastxt IS deferred
latestxt IS deferred
@end example
@noindent
@code{noname} works with any defining word, not just @code{:}.
@code{lastxt} also works when the last word was not defined as
@code{latestxt} also works when the last word was not defined as
@code{noname}. It does not work for combined words, though. It also has
the useful property that is is valid as soon as the header for a
definition has been built. Thus:
@example
lastxt . : foo [ lastxt . ] ; ' foo .
latestxt . : foo [ latestxt . ] ; ' foo .
@end example
@noindent
......@@ -6038,7 +6038,7 @@ make a call to @code{stats}. You can define and use a new version of
: stats ( xt -- ) DUP ." (Gathering statistics for " . ." )"
... ; \ other code
: my: : lastxt postpone literal ['] stats compile, ;
: my: : latestxt postpone literal ['] stats compile, ;
my: foo + - ;
@end example
......@@ -6050,11 +6050,11 @@ When @code{foo} is defined using @code{my:} these steps occur:
@code{my:} is executed.
@item
The @code{:} within the definition (the one between @code{my:} and
@code{lastxt}) is executed, and does just what it always does; it parses
@code{latestxt}) is executed, and does just what it always does; it parses
the input stream for a name, builds a dictionary header for the name
@code{foo} and switches @code{state} from interpret to compile.
@item
The word @code{lastxt} is executed. It puts the @i{xt} for the word that is
The word @code{latestxt} is executed. It puts the @i{xt} for the word that is
being defined -- @code{foo} -- onto the stack.
@item
The code that was produced by @code{postpone literal} is executed; this
......@@ -6394,7 +6394,7 @@ An alternative would have been to write this using
: @var{inst-format} ( entry-num "name" -- )
here name string, ( entry-num c-addr ) \ parse and save "name"
noname create , ( entry-num )
lastxt swap cells @var{table} + !
latestxt swap cells @var{table} + !
does> ( addr w -- )
\ disassemble instruction w at addr
@@ >r
......@@ -6429,7 +6429,7 @@ does> ( u "inst" -- )
\ and enters it as u-th entry into table-xt
2@@ swap here name string, ( u table-xt disasm-xt c-addr ) \ remember string
noname create 2, \ define anonymous word
execute lastxt swap ! \ enter xt of defined word into table-xt
execute latestxt swap ! \ enter xt of defined word into table-xt
does> ( addr w -- )
\ disassemble instruction w at addr
2@@ >r ( addr w disasm-xt R: c-addr )
......@@ -6897,10 +6897,10 @@ semantics). You might get what you want by using @code{COMP' @i{word}
DROP} or @code{[COMP'] @i{word} DROP} (for details @pxref{Compilation
token}).
Another way to get an XT is @code{:noname} or @code{lastxt}
Another way to get an XT is @code{:noname} or @code{latestxt}
(@pxref{Anonymous Definitions}). For anonymous words this gives an xt
for the only behaviour the word has (the execution semantics). For
named words, @code{lastxt} produces an XT for the same behaviour it
named words, @code{latestxt} produces an XT for the same behaviour it
would produce if the word was defined anonymously.
@example
......@@ -6954,13 +6954,26 @@ doc-postpone,
@subsection Name token
@cindex name token
Gforth represents named words by the @dfn{name token}, (@i{nt}). Name
token is an abstract data type that occurs as argument or result of the
words below.
@c !! put this elswhere?
@cindex name field address
@cindex NFA
Gforth represents named words by the @dfn{name token}, (@i{nt}). In
Gforth, the abstract data type @emph{name token} is implemented as a
name field address (NFA).
The closest thing to the nt in older Forth systems is the name field
address (NFA), but there are significant differences: in older Forth
systems each word had a unique NFA, LFA, CFA and PFA (in this order, or
LFA, NFA, CFA, PFA) and there were words for getting from one to the
next. In contrast, in Gforth 0@dots{}n nts correspond to one xt; there
is a link field in the structure identified by the name token, but
searching usually uses a hash table external to these structures; the
name in Gforth has a cell-wide count-and-flags field, and the nt is not
implemented as the address of that count field.
doc-find-name
doc-latest
doc->name
doc-name>int
doc-name?int
doc-name>comp
......@@ -11604,7 +11617,7 @@ is given in a comment before the instruction.
because the recognition of the end of the code is unreliable. You can
use @code{disasm} if it did not display enough. It may display more, if
the code word is not immediately followed by a named word. If you have
something else there, you can follow the word with @code{align last @ ,}
something else there, you can follow the word with @code{align latest ,}
to ensure that the end is recognized.
@node 386 Assembler, Alpha Assembler, Common Disassembler, Assembler and Code Words
......@@ -13395,8 +13408,8 @@ Not implemented (yet).
The word is entered into the word list that was the compilation word list
at the start of the definition. Any changes to the name field (e.g.,
@code{immediate}) or the code field (e.g., when executing @code{DOES>})
are applied to the latest defined word (as reported by @code{last} or
@code{lastxt}), if possible, irrespective of the compilation word list.
are applied to the latest defined word (as reported by @code{latest} or
@code{latestxt}), if possible, irrespective of the compilation word list.
@item search order empty (@code{previous}):
@cindex @code{previous}, search order empty
......
......@@ -68,7 +68,7 @@ s" \ automatically generated by makedoc.fs" doc-file-id write-line throw
: put-doc-entry ( -- )
locals-list @ 0= \ not in a colon def, i.e., not a local name
last @ 0<> and \ not an anonymous (i.e. noname) header
latest 0<> and \ not an anonymous (i.e. noname) header
if
s" " >fileCR
s" make-doc " >file
......@@ -89,7 +89,7 @@ s" \ automatically generated by makedoc.fs" doc-file-id write-line throw
ELSE
drop >in !
THEN
last @ name>string >file
latest name>string >file
>file
s" )" >file
POSTPONE \g
......
......@@ -94,14 +94,14 @@ create description-buffer 4096 chars allot
: make-doc ( -- )
get-current documentation set-current
create
last @ name>string skip-prefix 2, \ name
latest name>string skip-prefix 2, \ name
[char] ) parse save-mem 2, \ stack-effect
bl sword condition-wordset 2, \ wordset
bl sword dup \ pronounciation
if
condition-pronounciation
else
2drop last @ name>string skip-prefix
2drop latest name>string skip-prefix
endif
2,
get-description save-mem 2,
......
......@@ -92,14 +92,14 @@ create tags-line 128 chars allot
\ if the input is from a file and it is not a local name
source-id dup 0<> swap -1 <> and \ input from a file
current @ locals-list <> and \ not a local name
last @ 0<> and \ not an anonymous (i.e. noname) header
latest 0<> and \ not an anonymous (i.e. noname) header
if
tags-file-id >r
r@ put-load-file-name
source drop >in @ r@ write-file throw
127 r@ emit-file throw
\ bl r@ emit-file throw
last @ name>string r@ write-file throw
latest name>string r@ write-file throw
\ bl r@ emit-file throw
1 r@ emit-file throw
base @ decimal sourceline# 0 <# #s #> r@ write-file throw base !
......
......@@ -349,10 +349,10 @@ new-locals-map mappedwordlist Constant new-locals-wl
variable old-dpp
\ and now, finally, the user interface words
: { ( -- lastxt wid 0 ) \ gforth open-brace
: { ( -- latestxt wid 0 ) \ gforth open-brace
dp old-dpp !
locals-dp dpp !
lastxt get-current
latestxt get-current
get-order new-locals-wl swap 1+ set-order
also locals definitions locals-types
0 TO locals-wordlist
......@@ -360,7 +360,7 @@ variable old-dpp
locals-types definitions
: } ( lastxt wid 0 a-addr1 xt1 ... -- ) \ gforth close-brace
: } ( latestxt wid 0 a-addr1 xt1 ... -- ) \ gforth close-brace
\ ends locals definitions
] old-dpp @ dpp !
begin
......@@ -489,7 +489,7 @@ forth definitions
: locals-:-hook ( sys -- sys addr xt n )
\ addr is the nfa of the defined word, xt its xt
DEFERS :-hook
last @ lastcfa @
latest latestxt
clear-leave-stack
0 locals-size !
locals-buffer locals-dp !
......
......@@ -26,32 +26,32 @@
noname create
does> abort" interpreting word without interpretation semantics" ;
lastxt >does-code
latestxt >does-code
does> abort" compiling word without compilation semantics" ;
lastxt >does-code
latestxt >does-code
constant no-compilation-does-code
constant no-interpretation-does-code
: create-interpret/compile ( "name" -- ) \ gforth
0 0 interpret/compile:
here lastxt interpret/compile-comp !
here latestxt interpret/compile-comp !
no-compilation-does-code here does-code!
[ 0 >body ] literal allot
here lastxt interpret/compile-int !
here latestxt interpret/compile-int !
no-interpretation-does-code here does-code!
[ 0 >body ] literal allot ; \ restrict?
: fix-does-code ( addr ret-addr -- )
lastxt [ interpret/compile-struct %size ] literal + >r
lastxt interpret/compile?
lastxt interpret/compile-int @ r@ >body = and
lastxt interpret/compile-comp @ r> = and
latestxt [ interpret/compile-struct %size ] literal + >r
latestxt interpret/compile?
latestxt interpret/compile-int @ r@ >body = and
latestxt interpret/compile-comp @ r> = and
0= abort" not created with create-interpret/compile"
cell+ cell+ maxaligned /does-handler + \ to does-code
swap @ does-code! ;
: (interpretation>) ( -- )
lastxt interpret/compile-int r@ fix-does-code ;
latestxt interpret/compile-int r@ fix-does-code ;
: interpretation> ( compilation. -- orig colon-sys ) \ gforth
POSTPONE (interpretation>) POSTPONE ahead
......@@ -62,7 +62,7 @@ constant no-interpretation-does-code
POSTPONE then ; immediate restrict
: (compilation>) ( -- )
lastxt interpret/compile-comp r@ fix-does-code ;
latestxt interpret/compile-comp r@ fix-does-code ;
: compilation> ( compilation. -- orig colon-sys ) \ gforth
POSTPONE (compilation>) POSTPONE ahead
......
......@@ -157,14 +157,22 @@ has? OS [IF]
: noname ( -- ) \ gforth
\g The next defined word will be anonymous. The defining word will
\g leave the input stream alone. The xt of the defined word will
\g be given by @code{lastxt}.
\g be given by @code{latestxt}.
['] noname-header IS (header) ;
: lastxt ( -- xt ) \ gforth
: latestxt ( -- xt ) \ gforth
\G @i{xt} is the execution token of the last word defined.
\ The main purpose of this word is to get the xt of words defined using noname
lastcfa @ ;
' latestxt alias lastxt \ gforth-obsolete
\G old name for @code{latestxt}.
: latest ( -- nt ) \ gforth
\G @var{nt} is the name token of the last word defined; it is 0 if the
\G last word has no name.
last @ ;
\ \ literals 17dec92py
: Literal ( compilation n -- ; run-time -- n ) \ core
......@@ -289,7 +297,7 @@ has? peephole [IF]
[THEN]
: !does ( addr -- ) \ gforth store-does
lastxt does-code! ;
latestxt does-code! ;
: (does>) ( R: addr -- )
r> cfaligned /does-handler + !does ;
......@@ -351,7 +359,7 @@ has? peephole [IF]
: recurse ( compilation -- ; run-time ?? -- ?? ) \ core
\g Call the current definition.
lastxt compile, ; immediate restrict
latestxt compile, ; immediate restrict
\ \ compiler loop
......@@ -409,7 +417,7 @@ has? peephole [IF]
: lastflags ( -- c-addr )
\ the address of the flags byte in the last header
\ aborts if the last defined word was headerless
last @ dup 0= abort" last word was headerless" cell+ ;
latest dup 0= abort" last word was headerless" cell+ ;
: immediate ( -- ) \ core
\G Make the compilation semantics of a word be to @code{execute}
......@@ -609,7 +617,7 @@ defer ;-hook ( sys2 -- sys1 )
\ \ Search list handling: reveal words, recursive 23feb93py
: last? ( -- false / nfa nfa )
last @ ?dup ;
latest ?dup ;
: (reveal) ( nt wid -- )
wordlist-id dup >r
......
......@@ -35,10 +35,10 @@ Variable locals here locals ! 100 ( some) cells allot
: <local ( -- sys1 ) current @ @ loffset @ locals @
over 0= IF postpone ralign THEN ; immediate
: local: ( -- ) postpone >r last @ lastcfa @ here locals @ dp !
: local: ( -- ) postpone >r latest latestxt here locals @ dp !
cell loffset +! Create loffset @ , immediate (local
here locals ! dp ! lastcfa ! last ! ; immediate
: flocal: ( -- ) last @ lastcfa @ here locals @ dp !
: flocal: ( -- ) latest latestxt here locals @ dp !
BEGIN loffset @ 0 1 floats fm/mod drop WHILE
0 postpone Literal postpone >r 1 cells loffset +! REPEAT
postpone f>r Create loffset @ , immediate (flocal
......
......@@ -113,11 +113,12 @@ has? rom
: threaded>name ( ca -- nt|0 )
threaded>xt prim>name ;
: >head ( cfa -- nt|0 ) \ gforth to-head
\G tries to find the name token nt of the word represented by cfa;
\G returns 0 if it fails. This word is not absolutely reliable,
\G it may give false positives and produce wrong nts.
: >name ( xt -- nt|0 ) \ gforth to-name
\G tries to find the name token @var{nt} of the word represented
\G by @var{xt}; returns 0 if it fails. This word is not
\G absolutely reliable, it may give false positives and produce
\G wrong nts.
look and ;
' >head ALIAS >name \ gforth to-name
\G old name of @code{>head}
' >name ALIAS >head \ gforth to-head
\G another name of @code{>name}
......@@ -608,7 +608,7 @@ wordlist constant type-names \ this is here just to meet the requirement
get-current type-names set-current
stack-type 2dup nextname stack-type-name
set-current
stack-pointer lastxt >body stack-name nextname make-stack ;
stack-pointer latestxt >body stack-name nextname make-stack ;
stack inst-stream IP Cell
' inst-in-index inst-stream stack-in-index-xt !
......
......@@ -721,7 +721,7 @@ Defer discode ( addr u -- ) \ gforth
>name ?dup-if
." IS " .name cr
else
." lastxt >body !"
." latestxt >body !"
then ;
: see-threaded ( addr -- )
C-Pass @ DebugMode = IF
......@@ -773,7 +773,7 @@ Defer discode ( addr u -- ) \ gforth
ENDCASE ;
: (xt-see-xt) ( xt -- )
xt-see cr ." lastxt" ;
xt-see cr ." latestxt" ;
' (xt-see-xt) is xt-see-xt
: (.immediate) ( xt -- )
......
......@@ -29,7 +29,7 @@
\ a field that makes no change
\ to enable accessing the offset with "['] <field> >body @" this
\ is not implemented with "['] noop alias"
last @
latest
if
immediate
then
......
......@@ -106,7 +106,7 @@ AUser CSP
POSTPONE (const-does>)
POSTPONE ;
noname : POSTPONE rdrop
lastxt r> cell+ ! \ patch the literal
latestxt r> cell+ ! \ patch the literal
; immediate
\ !! rewrite slurp-file using slurp-fid
......
......@@ -91,10 +91,10 @@ create tags-line 128 chars allot
\ if the input is from a file and it is not a local name
source-id dup 0<> swap -1 <> and \ input from a file
current @ locals-list <> and \ not a local name
last @ 0<> and \ not an anonymous (i.e. noname) header
latest 0<> and \ not an anonymous (i.e. noname) header
if
tags-file-id >r
last @ name>string r@ write-file throw
latest name>string r@ write-file throw
#tab r@ emit-file throw
r@ put-load-file-name
s" /^" r@ write-file throw
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment