From f013e52c949569dd692d301285ba91db628101b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 13 Nov 2021 22:39:09 +0100 Subject: [PATCH] improved override --- overwrite.forth | 1 + src/fh_builtins.c | 9 +-------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/overwrite.forth b/overwrite.forth index 522b091..8aa471e 100644 --- a/overwrite.forth +++ b/overwrite.forth @@ -3,4 +3,5 @@ a : call_a a a a ; call_a : a 7 . ; +a call_a diff --git a/src/fh_builtins.c b/src/fh_builtins.c index 4a315ae..6540163 100644 --- a/src/fh_builtins.c +++ b/src/fh_builtins.c @@ -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;