add in a "d:source" field to the dictionary header
FossilOrigin-Name: d6c27c49b054c022fad6d2898d173f0a2705925a97bb139c1c6fbdb48f896da7
This commit is contained in:
parent
b2cb56d3c8
commit
ce91454df1
20 changed files with 1527 additions and 1370 deletions
|
@ -571,6 +571,9 @@ Lookup the specified address in the dictionary and return a pointer to its dicti
|
|||
d:name D: d-s A: - F: -
|
||||
Given a dictionary header, return the name field.
|
||||
|
||||
d:source D: d-a A: - F: -
|
||||
Given a dictionary header, return the source field.
|
||||
|
||||
d:words D: - A: - F: -
|
||||
Display a list of all named items in the `Dictionary`.
|
||||
|
||||
|
|
|
@ -189,6 +189,7 @@ d:link D: d-a A: - F: -
|
|||
d:lookup D: s-d A: - F: -
|
||||
d:lookup-xt D: a-d A: - F: -
|
||||
d:name D: d-s A: - F: -
|
||||
d:source D: d-a A: - F: -
|
||||
d:words D: - A: - F: -
|
||||
d:words-beginning-with D: s- A: - F: -
|
||||
d:words-with D: s- A: - F: -
|
||||
|
|
|
@ -1414,6 +1414,13 @@
|
|||
</div>
|
||||
<p>Given a dictionary header, return the name field.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:word</td></tr><tr><td><b>Namespace:</b> </td><td>d</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>d:source</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> d-a<br>
|
||||
<b>Addr:</b> -<br>
|
||||
<b>Float:</b> -</p>
|
||||
</div>
|
||||
<p>Given a dictionary header, return the source field.</p>
|
||||
<table><tr><td><b>Class:</b> </td><td>class:word</td></tr><tr><td><b>Namespace:</b> </td><td>d</td></tr><tr><td><b>Interface Layer:</b> </td><td>all</td></tr></table><hr/>
|
||||
<h2>d:words</h2>
|
||||
<div style='margin-left: 1em;'><p><b>Data:</b> -<br>
|
||||
<b>Addr:</b> -<br>
|
||||
|
|
|
@ -2191,6 +2191,17 @@ Given a dictionary header, return the name field.
|
|||
Class: class:word | Namespace: d | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
d:source
|
||||
|
||||
Data: d-a
|
||||
Addr: -
|
||||
Float: -
|
||||
|
||||
Given a dictionary header, return the source field.
|
||||
|
||||
Class: class:word | Namespace: d | Interface Layer: all
|
||||
------------------------------------------------------------------------
|
||||
|
||||
d:words
|
||||
|
||||
Data: -
|
||||
|
|
|
@ -1780,7 +1780,8 @@ Each entry follows the following structure:
|
|||
0000 Link to Prior Header
|
||||
0001 Link to XT
|
||||
0002 Link to Class Handler
|
||||
0003+ Word name (null terminated)
|
||||
0003 Source Identifier
|
||||
0004+ Word name (null terminated)
|
||||
|
||||
RETRO provides words for accessing the fields in a portable
|
||||
manner. It's recommended to use these to allow for future
|
||||
|
|
|
@ -21,7 +21,8 @@ Each entry follows the following structure:
|
|||
0000 Link to Prior Header
|
||||
0001 Link to XT
|
||||
0002 Link to Class Handler
|
||||
0003+ Word name (null terminated)
|
||||
0003 Source Identifier
|
||||
0004+ Word name (null terminated)
|
||||
|
||||
RETRO provides words for accessing the fields in a portable
|
||||
manner. It's recommended to use these to allow for future
|
||||
|
|
|
@ -66,7 +66,8 @@ Each entry follows the following structure:
|
|||
<tt class='indentedcode'>0000 Link to Prior Header</tt>
|
||||
<tt class='indentedcode'>0001 Link to XT</tt>
|
||||
<tt class='indentedcode'>0002 Link to Class Handler</tt>
|
||||
<tt class='indentedcode'>0003+ Word name (null terminated)</tt>
|
||||
<tt class='indentedcode'>0003 Source Identifier</tt>
|
||||
<tt class='indentedcode'>0004+ Word name (null terminated)</tt>
|
||||
<br/><br/>
|
||||
RETRO provides words for accessing the fields in a portable
|
||||
manner. It's recommended to use these to allow for future
|
||||
|
|
|
@ -189,6 +189,7 @@ d:link d-a - - Given a dictionary header, return the link field. class:word {n
|
|||
d:lookup s-d - - Lookup the specified name in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found. This also sets an internal variable ('which' in retro.muri) to the header address. class:word {n/a} {n/a} d all
|
||||
d:lookup-xt a-d - - Lookup the specified address in the dictionary and return a pointer to its dictionary header. This returns zero if the word is not found. class:word {n/a} {n/a} d all
|
||||
d:name d-s - - Given a dictionary header, return the name field. class:word {n/a} {n/a} d all
|
||||
d:source d-a - - Given a dictionary header, return the source field. class:word {n/a} {n/a} d all
|
||||
d:words - - - Display a list of all named items in the `Dictionary`. class:word {n/a} {n/a} d rre
|
||||
d:words-beginning-with s- - - Display a list of all named items in the `Dictionary` that begin with the provided substring. class:word {n/a} {n/a} d rre
|
||||
d:words-with s- - - Display a list of all named items in the `Dictionary` that contain the provided substring. class:word {n/a} {n/a} d rre
|
||||
|
|
|
101
image/retro.muri
101
image/retro.muri
|
@ -685,12 +685,13 @@ RETRO has a single dictionary consisting of a linked list of
|
|||
headers. The current form of a header is shown in the chart
|
||||
below.
|
||||
|
||||
| field | holds | accessor |
|
||||
| ----- | ---------------------------------- | -------- |
|
||||
| link | link to the previous entry | d:link |
|
||||
| xt | link to start of the function | d:xt |
|
||||
| class | link to the class handler function | d:class |
|
||||
| name | zero terminated string | d:name |
|
||||
| field | holds | accessor |
|
||||
| ------ | ---------------------------------- | -------- |
|
||||
| link | link to the previous entry | d:link |
|
||||
| xt | link to start of the function | d:xt |
|
||||
| class | link to the class handler function | d:class |
|
||||
| source | source identifier | d:source |
|
||||
| name | zero terminated string | d:name |
|
||||
|
||||
The initial dictionary is constructed at the end of this file.
|
||||
It'll take a form like this:
|
||||
|
@ -699,25 +700,29 @@ It'll take a form like this:
|
|||
d 0
|
||||
r _dup
|
||||
r class:primitive
|
||||
d 0
|
||||
s dup
|
||||
|
||||
: 0001
|
||||
r 0000
|
||||
r _drop
|
||||
r class:primitive
|
||||
d 0
|
||||
s drop
|
||||
|
||||
: 0002
|
||||
r 0001
|
||||
r _swap
|
||||
r class:primitive
|
||||
d 0
|
||||
s swap
|
||||
|
||||
Each entry starts with a pointer to the prior entry (with a
|
||||
pointer to zero marking the first entry in the dictionary), a
|
||||
pointer to the start of the function, a pointer to the class
|
||||
handler, and a null terminated string indicating the name
|
||||
exposed to the RETRO interpreter.
|
||||
handler, a value indicating the source of the entry, and a null
|
||||
terminated string indicating the name exposed to the RETRO
|
||||
interpreter.
|
||||
|
||||
RETRO stores the pointer to the most recent entry in a variable
|
||||
called `Dictionary`. For simplicity, I just assign the last
|
||||
|
@ -740,9 +745,13 @@ d 1
|
|||
i liadre..
|
||||
d 2
|
||||
|
||||
: d:name
|
||||
: d:source
|
||||
i liadre..
|
||||
d 3
|
||||
|
||||
: d:name
|
||||
i liadre..
|
||||
d 4
|
||||
~~~
|
||||
|
||||
A traditional Forth has `create` to make a new dictionary entry
|
||||
|
@ -771,6 +780,9 @@ i lica....
|
|||
r comma
|
||||
i lica....
|
||||
r comma
|
||||
i lilica..
|
||||
d 0
|
||||
r comma
|
||||
i lica....
|
||||
r comma:string
|
||||
i polistre
|
||||
|
@ -1510,316 +1522,385 @@ or remove new functions in the kernel.
|
|||
d 0
|
||||
r _dup
|
||||
r class:primitive
|
||||
d 0
|
||||
s dup
|
||||
: 0001
|
||||
r 0000
|
||||
r _drop
|
||||
r class:primitive
|
||||
d 0
|
||||
s drop
|
||||
: 0002
|
||||
r 0001
|
||||
r _swap
|
||||
r class:primitive
|
||||
d 0
|
||||
s swap
|
||||
: 0003
|
||||
r 0002
|
||||
r _call
|
||||
r class:primitive
|
||||
d 0
|
||||
s call
|
||||
: 0004
|
||||
r 0003
|
||||
r _eq
|
||||
r class:primitive
|
||||
d 0
|
||||
s eq?
|
||||
: 0005
|
||||
r 0004
|
||||
r _neq
|
||||
r class:primitive
|
||||
d 0
|
||||
s -eq?
|
||||
: 0006
|
||||
r 0005
|
||||
r _lt
|
||||
r class:primitive
|
||||
d 0
|
||||
s lt?
|
||||
: 0007
|
||||
r 0006
|
||||
r _gt
|
||||
r class:primitive
|
||||
d 0
|
||||
s gt?
|
||||
: 0008
|
||||
r 0007
|
||||
r _fetch
|
||||
r class:primitive
|
||||
d 0
|
||||
s fetch
|
||||
: 0009
|
||||
r 0008
|
||||
r _store
|
||||
r class:primitive
|
||||
d 0
|
||||
s store
|
||||
: 0010
|
||||
r 0009
|
||||
r _add
|
||||
r class:primitive
|
||||
d 0
|
||||
s +
|
||||
: 0011
|
||||
r 0010
|
||||
r _sub
|
||||
r class:primitive
|
||||
d 0
|
||||
s -
|
||||
: 0012
|
||||
r 0011
|
||||
r _mul
|
||||
r class:primitive
|
||||
d 0
|
||||
s *
|
||||
: 0013
|
||||
r 0012
|
||||
r _divmod
|
||||
r class:primitive
|
||||
d 0
|
||||
s /mod
|
||||
: 0014
|
||||
r 0013
|
||||
r _and
|
||||
r class:primitive
|
||||
d 0
|
||||
s and
|
||||
: 0015
|
||||
r 0014
|
||||
r _or
|
||||
r class:primitive
|
||||
d 0
|
||||
s or
|
||||
: 0016
|
||||
r 0015
|
||||
r _xor
|
||||
r class:primitive
|
||||
d 0
|
||||
s xor
|
||||
: 0017
|
||||
r 0016
|
||||
r _shift
|
||||
r class:primitive
|
||||
d 0
|
||||
s shift
|
||||
: 0018
|
||||
r 0017
|
||||
r push
|
||||
r class:macro
|
||||
d 0
|
||||
s push
|
||||
: 0019
|
||||
r 0018
|
||||
r pop
|
||||
r class:macro
|
||||
d 0
|
||||
s pop
|
||||
: 0020
|
||||
r 0019
|
||||
r 0;
|
||||
r class:macro
|
||||
d 0
|
||||
s 0;
|
||||
: 0021
|
||||
r 0020
|
||||
r fetch-next
|
||||
r class:word
|
||||
d 0
|
||||
s fetch-next
|
||||
: 0022
|
||||
r 0021
|
||||
r store-next
|
||||
r class:word
|
||||
d 0
|
||||
s store-next
|
||||
: 0023
|
||||
r 0022
|
||||
r s:to-number
|
||||
r class:word
|
||||
d 0
|
||||
s s:to-number
|
||||
: 0024
|
||||
r 0023
|
||||
r s:eq
|
||||
r class:word
|
||||
d 0
|
||||
s s:eq?
|
||||
: 0025
|
||||
r 0024
|
||||
r s:length
|
||||
r class:word
|
||||
d 0
|
||||
s s:length
|
||||
: 0026
|
||||
r 0025
|
||||
r choose
|
||||
r class:word
|
||||
d 0
|
||||
s choose
|
||||
: 0027
|
||||
r 0026
|
||||
r if
|
||||
r class:primitive
|
||||
d 0
|
||||
s if
|
||||
: 0028
|
||||
r 0027
|
||||
r -if
|
||||
r class:word
|
||||
d 0
|
||||
s -if
|
||||
: 0029
|
||||
r 0028
|
||||
r sigil:(
|
||||
r class:macro
|
||||
d 0
|
||||
s sigil:(
|
||||
: 0030
|
||||
r 0029
|
||||
r Compiler
|
||||
r class:data
|
||||
d 0
|
||||
s Compiler
|
||||
: 0031
|
||||
r 0030
|
||||
r Heap
|
||||
r class:data
|
||||
d 0
|
||||
s Heap
|
||||
: 0032
|
||||
r 0031
|
||||
r comma
|
||||
r class:word
|
||||
d 0
|
||||
s ,
|
||||
: 0033
|
||||
r 0032
|
||||
r comma:string
|
||||
r class:word
|
||||
d 0
|
||||
s s,
|
||||
: 0034
|
||||
r 0033
|
||||
r ;
|
||||
r class:macro
|
||||
d 0
|
||||
s ;
|
||||
: 0035
|
||||
r 0034
|
||||
r [
|
||||
r class:macro
|
||||
d 0
|
||||
s [
|
||||
: 0036
|
||||
r 0035
|
||||
r ]
|
||||
r class:macro
|
||||
d 0
|
||||
s ]
|
||||
: 0037
|
||||
r 0036
|
||||
r Dictionary
|
||||
r class:data
|
||||
d 0
|
||||
s Dictionary
|
||||
: 0038
|
||||
r 0037
|
||||
r d:link
|
||||
r class:word
|
||||
d 0
|
||||
s d:link
|
||||
: 0039
|
||||
r 0038
|
||||
r d:xt
|
||||
r class:word
|
||||
d 0
|
||||
s d:xt
|
||||
: 0040
|
||||
r 0039
|
||||
r d:class
|
||||
r class:word
|
||||
d 0
|
||||
s d:class
|
||||
: 0041
|
||||
r 0040
|
||||
r d:name
|
||||
r class:word
|
||||
d 0
|
||||
s d:name
|
||||
: 0042
|
||||
r 0041
|
||||
r class:word
|
||||
r class:word
|
||||
d 0
|
||||
s class:word
|
||||
: 0043
|
||||
r 0042
|
||||
r class:macro
|
||||
r class:word
|
||||
d 0
|
||||
s class:macro
|
||||
: 0044
|
||||
r 0043
|
||||
r class:data
|
||||
r class:word
|
||||
d 0
|
||||
s class:data
|
||||
: 0045
|
||||
r 0044
|
||||
r d:add-header
|
||||
r class:word
|
||||
d 0
|
||||
s d:add-header
|
||||
: 0046
|
||||
r 0045
|
||||
r sigil:#
|
||||
r class:macro
|
||||
d 0
|
||||
s sigil:#
|
||||
: 0047
|
||||
r 0046
|
||||
r sigil::
|
||||
r class:macro
|
||||
d 0
|
||||
s sigil::
|
||||
: 0048
|
||||
r 0047
|
||||
r sigil:&
|
||||
r class:macro
|
||||
d 0
|
||||
s sigil:&
|
||||
: 0049
|
||||
r 0048
|
||||
r sigil:$
|
||||
r class:macro
|
||||
d 0
|
||||
s sigil:$
|
||||
: 0050
|
||||
r 0049
|
||||
r repeat
|
||||
r class:macro
|
||||
d 0
|
||||
s repeat
|
||||
: 0051
|
||||
r 0050
|
||||
r again
|
||||
r class:macro
|
||||
d 0
|
||||
s again
|
||||
: 0052
|
||||
r 0051
|
||||
r interpret
|
||||
r class:word
|
||||
d 0
|
||||
s interpret
|
||||
: 0053
|
||||
r 0052
|
||||
r d:lookup
|
||||
r class:word
|
||||
d 0
|
||||
s d:lookup
|
||||
: 0054
|
||||
r 0053
|
||||
r class:primitive
|
||||
r class:word
|
||||
d 0
|
||||
s class:primitive
|
||||
: 0055
|
||||
r 0054
|
||||
r Version
|
||||
r class:data
|
||||
d 0
|
||||
s Version
|
||||
: 0056
|
||||
r 0055
|
||||
r muri:i
|
||||
r class:word
|
||||
d 0
|
||||
s i
|
||||
: 0057
|
||||
r 0056
|
||||
r comma
|
||||
r class:word
|
||||
d 0
|
||||
s d
|
||||
: 0058
|
||||
r 0057
|
||||
r muri:r
|
||||
r class:word
|
||||
d 0
|
||||
s r
|
||||
: 0059
|
||||
r 0058
|
||||
r Base
|
||||
r class:data
|
||||
d 0
|
||||
s Base
|
||||
: 0060
|
||||
r 0059
|
||||
r pack
|
||||
r class:word
|
||||
d 0
|
||||
s pack
|
||||
: 0061
|
||||
r 0060
|
||||
r unpack
|
||||
r class:word
|
||||
d 0
|
||||
s unpack
|
||||
: 9999
|
||||
: 0062
|
||||
r 0061
|
||||
r d:source
|
||||
r class:word
|
||||
d 0
|
||||
s d:source
|
||||
: 9999
|
||||
r 0062
|
||||
r err:notfound
|
||||
r class:word
|
||||
d 0
|
||||
s err:notfound
|
||||
~~~
|
||||
|
||||
|
|
BIN
ngaImage
BIN
ngaImage
Binary file not shown.
|
@ -33,7 +33,7 @@
|
|||
#define D_OFFSET_LINK 0
|
||||
#define D_OFFSET_XT 1
|
||||
#define D_OFFSET_CLASS 2
|
||||
#define D_OFFSET_NAME 3
|
||||
#define D_OFFSET_NAME 4
|
||||
|
||||
|
||||
/* These settings can be overridden at compile time. */
|
||||
|
|
|
@ -353,7 +353,7 @@ class Retro:
|
|||
Dictionary = dict()
|
||||
header = self.memory[2]
|
||||
while header != 0:
|
||||
named = self.extract_string(header + 3)
|
||||
named = self.extract_string(header + 4)
|
||||
if not named in Dictionary:
|
||||
Dictionary[named] = header
|
||||
header = self.memory[header]
|
||||
|
@ -366,7 +366,7 @@ class Retro:
|
|||
header = self.memory[2]
|
||||
Done = False
|
||||
while header != 0 and not Done:
|
||||
if named == self.extract_string(header + 3):
|
||||
if named == self.extract_string(header + 4):
|
||||
self.Dictionary[named] = header
|
||||
Done = True
|
||||
else:
|
||||
|
|
File diff suppressed because it is too large
Load diff
1478
vm/nga-c/image.c
1478
vm/nga-c/image.c
File diff suppressed because it is too large
Load diff
|
@ -49,7 +49,7 @@
|
|||
#define D_OFFSET_LINK 0 /* Dictionary Format Info. Update if */
|
||||
#define D_OFFSET_XT 1 /* you change the dictionary fields. */
|
||||
#define D_OFFSET_CLASS 2
|
||||
#define D_OFFSET_NAME 3
|
||||
#define D_OFFSET_NAME 4
|
||||
|
||||
#define NUM_DEVICES 1 /* Set the number of I/O devices */
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ namespace Nga
|
|||
int i = memory[2]; // Dictionary
|
||||
string target;
|
||||
while (memory[i] != 0 && i != 0) {
|
||||
target = rxGetString(i + 3);
|
||||
target = rxGetString(i + 4);
|
||||
if (name.Equals(target)) {
|
||||
dt = i;
|
||||
i = 0;
|
||||
|
|
|
@ -400,7 +400,7 @@ function d_xt(dt) {
|
|||
}
|
||||
|
||||
function d_name(dt) {
|
||||
return dt + 3;
|
||||
return dt + 4;
|
||||
}
|
||||
|
||||
function d_lookup(name) {
|
||||
|
|
|
@ -83,7 +83,7 @@ proc go() =
|
|||
proc lookup(name: string): CELL =
|
||||
var i = im[2]
|
||||
while im[i] != 0:
|
||||
let target = extract(i + 3)
|
||||
let target = extract(i + 4)
|
||||
if name == target:
|
||||
return i
|
||||
else:
|
||||
|
|
|
@ -17,7 +17,7 @@ const
|
|||
D_OFFSET_LINK = 0;
|
||||
D_OFFSET_XT = 1;
|
||||
D_OFFSET_CLASS = 2;
|
||||
D_OFFSET_NAME = 3;
|
||||
D_OFFSET_NAME = 4;
|
||||
TIB = 1471;
|
||||
|
||||
var
|
||||
|
|
|
@ -469,7 +469,7 @@ loadImage()
|
|||
var i = memory[2]
|
||||
var interpret: Int = 0
|
||||
while i != 0 {
|
||||
let name = extractString(at: Int(i + 3))
|
||||
let name = extractString(at: Int(i + 4))
|
||||
// print(name)
|
||||
if name == "interpret" {
|
||||
interpret = Int(memory[Int(i) + 1])
|
||||
|
|
Loading…
Reference in a new issue