|
Win32Forth
链表 Chains 和它的使用方法
链表 Chains 用于执行一定数目的字序列。不像通常的冒号定义,您可以向链表的首部或者尾部加入一个任务,这就很适合初始化或解初始化的要求,您可以根据特殊应用程序的需要向链表中加入一个扩展字。
为了扩展链表,提供了两个字 CHAIN-ADD 和 CHAIN-ADD-BEFORE . 前一个字用于前向链,比如初始化链表,字被加入到链表的尾部。后一个字用于后向链表,比如解初始化链表,字被加入到链表的前面,做事情的顺序正好相反。
词汇表
.CHAIN chain-addr -- Forth SYSTEM
按它们被 DO-CHAIN 执行的顺序打印出已经加入到链表中的字。
.CHAINS Forth SYSTEM
打印出全部的应用区域中的链表和它们的内容,对于每个 .CHAIN ,链表的名字用大写字母在新的一行上打印出来。
?SYS-CHAIN chain_addr xt -- chain_addr xt Forth APPLICATION
如果 xt 在系统空间而把它加入到应用空间的链表,则给出一个警告。警告可以通过将 sys-warning? 关闭而抑制。
CHAIN-ADD chain_addr -<word-to-add>- Forth APPLICATION
加入字 <word-to-add> 的 xt 到地址为 chain_addr 链表的尾部,使得它在加入链表的其它字执行完之后能够被执行。
CHAIN-ADD-BEFORE chain_addr -<word-to-add> Forth APPLICATION
把 <word-to-add> 的 xt 加入到地址为 chain_addr 的链表的前部,使得它在链表中的其它执行之前先被执行。这主要用于解初始化,也就是说后初始化的部分应该最先被解初始化。
CHAIN-LINK Forth APPLICATION
一个变量,它指向应用区域链表的第一个(如果没有链表则为 Null )。被 .CHAINS 使用,并用于 forgetting 。
DO-CHAIN i*x chain_addr -- j*x Forth APPLICATION
顺序执行地址在栈顶的链表中的所有字,传递 i*x 给链表中的第一个字,从最后一个字的返回是 j*x 。
NEW-CHAIN -<name>- Forth APPLICATION
在应用程序区域中创建一个新的链表 <name> 。 如果当前的编译器处于系统区域则退出。链表加入到 .CHAINS 打印的链表中,当它们处于字典的 forgotten 部分时,加入的字都将被截取。
NOOP-CHAIN-ADD chain_addr -- addr Forth APPLICATION
加入 NOOP 的 xt 到地址为 chain_addr 的链表中,并返回包含它的单元的地址。
TRANSIENT-PTR -- f Forth APPLICATION
如果 transienting 值为真。
SYS-NEW-CHAIN -<name>- Forth APPLICATION
在系统区域中创建一个名为 <name> 的新链表。如果编译器在应用区域则抛出一个 abort 。链表并不进入 .CHAINS 打印出的链表中,当它们处于字典的 forgotten 部分时,加入的字都将被截取。
废弃的字
XDO-CHAIN ( 在 Forth 字汇表中 ) 和 EXIT-DO-CHAIN ( 在 HIDDEN 字汇表中 ) 都是早期 WIN32Forth 使用的字,现在已经废弃,使用 DO-CHAIN 替代它们。
Win32Forth 中的预先定义的链表
Win32Forth 使用下面预先定义的链表 :
系统链表(在 Primutil.f中定义):
名称 |
描述 |
调用 |
initialization-chain |
chain of things to initialize |
HELLO DEFAULT-HELLO |
unload-chain |
chain of things to de-initialize |
UNLOAD-Forth |
forget-chain |
chain of types of things to forget |
FORGET |
post-forget-chain |
chain of types of things to forget |
FORGET |
mouse-chain |
chain of things to do on mouse down |
MOUSE-CLICK |
semicolon-chain |
chain of things to do at end of definition |
; ;M EXIT-ASSEMBLER DO-;CHAIN |
forth-io-chain |
chain of things to to to restore forth-io |
Forth-IO |
number?-chain |
chain of number conversion options |
NUMBER |
ledit-chain |
line editor function key chain |
LINEEDITOR |
msg-chain |
chain of forth key messages |
HandleMessages |
forth-msg-chain |
chain of forth window message |
HandleWindowsMessages |
reset-stack-chain |
chain for resetting the stack |
RESET-STACKS |
调试器使用的链表 (在Debug.f中定义):
名称 |
描述 |
调用 |
dbg-next-cell |
|
DBG-NEXT |
dbg-nest-chain |
|
_DBG-NEST |
.word-type-chain |
|
.WORDTYPE |
See 使用的链表 ( 在 See.f 中定义 ):
名称 |
描述 |
调用 |
.execution-class-chain |
|
.EXECUTION-CLASS |
.other-class-chain |
|
.OTHER |
.word-chain |
|
.WORD |
|