fix word resolvable before finished
This commit is contained in:
@@ -119,6 +119,8 @@ extern const char *substatenames[FH_SUBSTATE_MAX];
|
||||
#define WORDFLAG_CONSTANT 0x10
|
||||
/** Something CREATEd. When executed, put the data field address on stack */
|
||||
#define WORDFLAG_CREATED 0x20
|
||||
/** Word marked as hidden is not findable, e.g. because it is being compiled. */
|
||||
#define WORDFLAG_HIDDEN 0x40
|
||||
|
||||
/** Word struct as they are stored in the dictionary */
|
||||
struct fh_word_s {
|
||||
|
||||
@@ -24,7 +24,7 @@ static enum fh_error w_colon(struct fh_thread_s *fh, const struct fh_word_s *w)
|
||||
new_word->handler = w_user_word;
|
||||
strncpy(new_word->name, wordname, namelen);
|
||||
new_word->name[namelen] = 0;
|
||||
new_word->flags = WORDFLAG_WORD;
|
||||
new_word->flags = WORDFLAG_WORD | WORDFLAG_HIDDEN;
|
||||
|
||||
fh->dict_last = ptr;
|
||||
|
||||
@@ -50,7 +50,7 @@ static enum fh_error w_colon_noname(struct fh_thread_s *fh, const struct fh_word
|
||||
new_word->param = fh->here;
|
||||
new_word->handler = w_user_word;
|
||||
new_word->name[0] = 0;
|
||||
new_word->flags = WORDFLAG_WORD;
|
||||
new_word->flags = WORDFLAG_WORD; // noname word exists outside the dict, so HIDDEN is not needed
|
||||
|
||||
TRY(ds_push(fh, ptr)); // TODO maybe should do this at semicolon?
|
||||
|
||||
@@ -289,6 +289,12 @@ static enum fh_error w_semicolon(struct fh_thread_s *fh, const struct fh_word_s
|
||||
|
||||
// XXX if there was another definition previously and it was used in some other compiled function,
|
||||
// that old implementation will still be called.
|
||||
|
||||
// unhide the entry, if hidden (colon does this to make the word unresolvable before it's finished)
|
||||
struct fh_word_s *ww = fh_word_at(fh, fh->dict_last);
|
||||
if (ww && (ww->flags & WORDFLAG_WORD)) {
|
||||
ww->flags &= ~WORDFLAG_HIDDEN;
|
||||
}
|
||||
|
||||
return FH_OK;
|
||||
}
|
||||
|
||||
+1
-1
@@ -403,7 +403,7 @@ enum fh_error fh_find_word(struct fh_thread_s *fh, const char *name, size_t word
|
||||
if (!w) {
|
||||
break;
|
||||
}
|
||||
if (0 == strncasecmp(name, w->name, wordlen) && w->name[wordlen] == 0) {
|
||||
if (EQ(name, w->name, wordlen) && 0 == (w->flags & WORDFLAG_HIDDEN)) { // skip hidden names
|
||||
if (addr_out) {
|
||||
*addr_out = addr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user