-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Less use of heads #15
Open
nickd4
wants to merge
49
commits into
uho:master
Choose a base branch
from
nickd4:less_use_of_heads
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
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
…to bss rather than text section which avoids the need to call mprotect(), rename things
… be wrapped with PROGRAM / END, also removes automatic bye token that was generated by END
…time.seedsource, so that we can run textual forth code without the tests or the banner
… writes to stderr, fix self-hosted tokenizer termination issue (was debugged with eemit)
…ng the nonstandard words on top of gForth's standard words, produces redefinition warnings
…seedForth-i386.pre containing some compiler words so we can do special handling for DTC
…sticated tracing and symbolic debug (via annotated trace) system used to debug the 65C02 port, the trace is also available for the Z80 port and can be used for comparison
…e caller's responsibility to do so if they need to, in the case of "new" this is done by replacing "new drop" with "new h," in the seedForth kernel, whereas in the case of "create" it is done by having the tokenizer prefix the body of the user's Definer-definition with "here h," -- or could make the latter a user responsibility
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background: The heads table is like a cut-down version of the Forth dictionary, that only records the entry point of each word, rather than the entry point, name and backlink. Heads are needed for mapping token numbers in
*.seed
files to addresses.As mentioned in the previous PR, I wanted to make it so that heads are not created during seedForthInteractive -- because now that execution tokens are simply addresses, heads are not needed once we have loaded and started the
*.seed
file.To do this, I have modified the
new
andcreate
words so that creation of heads is now a caller responsibility. The revisednew
andcreate
words simply return thehere
address as it was before creating the code field of the newly created token.For reference see, for example,
/i386/seedForth-i386.pre
where it defines thenew
andcreate
words. The updated way:And then see
/common/seedForth.pre
where it refers to thenew
word. The updated way:It's pleasing that we can now do something sensible with the address returned by
new
, rather than the oldnew drop
.Inserting a call to
h,
aftercreate
is harder. Consider the seedForth code in/common/seedForthRuntime.seedsource
:Compare with the corresponding textual Forth code in
/common/runtime.forth
which is used withseedForthInteractive
:My analysis is that
Definer
is a seedForthism, which does not exist in standard Forth, and which behaves like:
, but gives the tokenizer a hook so that it can capture the name of the new word being defined, hereVariable
, create a token for it, and thus keep the token numbering in sync. And we can see that the usage is identical, i.e. the two definitions are the same, except that:
is replaced withDefiner
in the seedForth source. To preserve this equivalence, what I've done is to have the tokenizer insert the sequencehere h,
in the start of the Definer-body, somewhat as if the user had executed the following definition:Of course we could make this a user responsibility, in which case the user would have to write this (somewhat more pleasing):
But, I considered it too difficult for the user if they have to deviate too much from standard Forth. What do you think about it?
Update: I have just noticed that the
create ( x ) drop
sequence is also a seedForthism, as compared with standard Forth whereCreate
doesn't seem to return an execution token (see the/common/runtime.forth
snippet I showed above). Because of this we might have some more latitude to change things, such as requiring the user to callcreate (x) h,
. But I'm not sure.