Author: | Charles Childers |
---|---|
Version: | 2009.12.20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: :: here ] ; | |
: nv-key ['] key 2 + compile ; immediate ( unvectored key ) | |
:: nv-key dup 27 =if nv-key dup . nip ;then ; is key | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiler macros are often used to lay down code in the calling word. You'll see something like: | |
: foo ['] + compile ['] . compile ; immediate | |
This is fine, but sometimes you need to deal with other macros: | |
: bar 1 literal, 2 literal, ['] foo execute ; immediate | |
This approach has one problem: keeping track of what words need to be compiled and which need to be called. Plus, with Retro's use of word classes, you may have other words that are handled in other ways. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Compiler macros are often used to lay down code in the calling word. You'll see something like: | |
: foo ['] + compile ['] . compile ; immediate | |
This is fine, but sometimes you need to deal with other macros: | |
: bar 1 literal, 2 literal, ['] foo execute ; immediate | |
This approach has one problem: keeping track of what words need to be compiled and which need to be called. Plus, with Retro's use of word classes, you may have other words that are handled in other ways. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: stub create 0 , 0 , 9 , ['] .word last @ d->class ! ; | |
stub foo | |
last @ d->class @ . | |
: stubs for stub next ; | |
stub cursor | |
4 stubs up down left right |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: :: ( -a ) here ] ; | |
: stub create 0 , 0 , 9 , ['] .word last @ d->class ! ; | |
: stubs for stub next ; | |
stub cursor | |
stub scan-for-esc | |
4 stubs up down left right | |
: default: ( "- ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ | |
: (`) | |
dup 0 !if literal, which @ d->class @ compile ;then | |
drop tib >number literal, ['] .data compile ; | |
---reveal--- | |
: '' ; immediate | |
: `` repeat ' dup ['] '' =if drop ;then (`) again ; immediate | |
}} | |
: :: ( -a ) here ] ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable addr | |
::: Power function | |
: pow ( bp-n ) | |
over here ! ::: Store the base for later use. | |
1 - 0; ::: Subtract 1 from the power and exit if the result is 0. | |
for here @ * next ; ::: Fetch the base and multiply it by the number. | |
::: Get the top value from the address stack. | |
: r ( -n ) ` pop ` dup ` push ; immediate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: append ( $$-$ ) | |
swap | |
here push | |
here over getLength dup allot copy | |
here over getLength dup allot copy | |
0 , pop ; | |
: paren-wrap s" (" swap append s" )" append ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
: append ( $$-$ ) | |
swap | |
here push | |
here over getLength dup allot copy | |
here over getLength dup allot copy | |
0 , pop ; | |
: paren-wrap s" (" swap append s" )" append ; |
OlderNewer