diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2024-03-07 04:53:40 -0500 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2024-03-07 04:53:40 -0500 |
commit | 234c99226ca1699832d411d0c326120607620ece (patch) | |
tree | 441a02b058960ad3a58edb9d699660a0413e370f /compiler.c | |
parent | 567eed5e49a927a31b2692c586da1246519fb1a9 (diff) |
fix a couple issues with dot eval
Diffstat (limited to 'compiler.c')
-rw-r--r-- | compiler.c | 11 |
1 files changed, 7 insertions, 4 deletions
@@ -3435,6 +3435,8 @@ void p1_resolve_types(Module *root) { for (size_t i = 0; i < root->vars.count; i++) { Variable *v = vect_get(&root->vars, i); + // when created, the module was on the stack. Make sure it is not anymore. + v->mod = root; char *n_end = strchr(v->name, ' '); if (n_end == NULL) { @@ -3973,29 +3975,30 @@ Variable _eval_dot(Scope *s, CompData *data, Vector *tokens, size_t start, size_ return v; } - Variable v = {0}; - v.name = NULL; + Variable v = scope_get_var(s, &name); // Match with first possible variable start = tnsl_next_non_nl(tokens, start); for (; start < end; start = tnsl_next_non_nl(tokens, start)) { // Try match variable - v = scope_get_var(s, &name); - if (v.name != NULL) { + art_end(&name); + name = art_from_str("", '.'); break; } // Try expand artifact, or call t = vect_get(tokens, start); if (tok_str_eq(t, ".")) { + start++; t = vect_get(tokens, start); if (t->type != TT_DEFWORD) { printf("ERROR: Expected defword after '.' operator but found \"%s\" (%d:%d)\n\n", t->data, t->line, t->col); return v; } art_add_str(&name, t->data); + v = scope_get_var(s, &name); } else if (tok_str_eq(t, "(")) { // Call break; |