summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--compiler.c11
-rw-r--r--tests/test_method.tnsl (renamed from tests/test_method)0
-rw-r--r--tests/test_module.tnsl7
4 files changed, 14 insertions, 5 deletions
diff --git a/.gitignore b/.gitignore
index e19a730..14f23a8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,2 @@
ctc
out
-*.tnsl
diff --git a/compiler.c b/compiler.c
index b2ddcf9..7bab5c8 100644
--- a/compiler.c
+++ b/compiler.c
@@ -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;
diff --git a/tests/test_method b/tests/test_method.tnsl
index 0f79400..0f79400 100644
--- a/tests/test_method
+++ b/tests/test_method.tnsl
diff --git a/tests/test_module.tnsl b/tests/test_module.tnsl
new file mode 100644
index 0000000..394662b
--- /dev/null
+++ b/tests/test_module.tnsl
@@ -0,0 +1,7 @@
+/; module Mod
+ int i = 69
+;/
+
+/; main [int]
+ return Mod.i
+;/