improved override

master
Ondřej Hruška 3 years ago
parent 3c57373992
commit f013e52c94
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 1
      overwrite.forth
  2. 9
      src/fh_builtins.c

@ -3,4 +3,5 @@ a
: call_a a a a ;
call_a
: a 7 . ;
a
call_a

@ -302,13 +302,6 @@ static enum fh_error w_colon(struct fh_thread_s *fh, const struct fh_word_s *w)
return FH_OK;
}
static enum fh_error w_redirect(struct fh_thread_s *fh, const struct fh_word_s *w)
{
const struct fh_word_s *w2 = &fh->dict[w->param];
LOG("REDIRECT to %s", w2->name);
return w2->handler(fh, w2);
}
static enum fh_error w_semicolon(struct fh_thread_s *fh, const struct fh_word_s *w0)
{
(void) w0;
@ -331,7 +324,7 @@ static enum fh_error w_semicolon(struct fh_thread_s *fh, const struct fh_word_s
if (0 == strncasecmp(new_word->name, old_word->name, MAX_NAME_LEN)) {
// We can't move the new definition because of RECURSE already using its address.
// Instead, redirect and wipe the old name.
old_word->handler = w_redirect;
// Note that this leaks compile memory!
old_word->start = new_word->start;
old_word->name[0] = 0;
break;

Loading…
Cancel
Save