Loading ans-report.fs +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading code.fs +3 −3 Original line number Diff line number Diff line Loading @@ -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 ) Loading @@ -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 ; debug.fs +1 −1 Original line number Diff line number Diff line Loading @@ -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 ; Loading doc/gforth.ds +31 −18 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 ) Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading doc/makedoc.fs +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading
ans-report.fs +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading
code.fs +3 −3 Original line number Diff line number Diff line Loading @@ -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 ) Loading @@ -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 ;
debug.fs +1 −1 Original line number Diff line number Diff line Loading @@ -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 ; Loading
doc/gforth.ds +31 −18 Original line number Diff line number Diff line Loading @@ -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 Loading Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 ) Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading Loading @@ -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 Loading
doc/makedoc.fs +2 −2 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading