From bc9bc44e5d6b78223ba3280a9c1377045ec26e9c Mon Sep 17 00:00:00 2001 From: tocariimaa Date: Wed, 5 Feb 2025 19:18:46 -0300 Subject: [PATCH] this should be handled in the compile end nat --- pila.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/pila.c b/pila.c index 4141ccd..94ebca1 100644 --- a/pila.c +++ b/pila.c @@ -393,8 +393,14 @@ compile_end_nat(Pila *st) return; } Assert(st->cur_compw != nil); + if (!Str_empty(st->cur_compw->name)) + add_word(st, st->cur_compw); + else /* for an anonymous word */ + push_val(st, BOX_INTN((u64)st->cur_compw)); + st->compiling = false; - add_word(st, st->cur_compw); + st->cur_compw = nil; + st->cur_compw_cap = 0; } Str @@ -499,14 +505,10 @@ branch_nat(Pila *st) void add_word(Pila *st, Word *w) { - if (!Str_empty(w->name)) { - DictionaryEntry *de = malloc(sizeof(*de)); - de->word = w; - de->next = st->dict != nil ? st->dict : nil; - st->dict = de; - } else { - push_val(st, BOX_INTN((u64)w)); - } + DictionaryEntry *de = malloc(sizeof(*de)); + de->word = w; + de->next = st->dict != nil ? st->dict : nil; + st->dict = de; } Word *