TESTEND("asminstr");
}
+#define ASSERT_SYMSCOPE(expect_ret, name, scope, constant) \
+ { \
+ struct ulas_tok tok = {ULAS_INT, {0}}; \
+ assert(ulas_symbolset((name), (scope), tok, constant) == (expect_ret)); \
+ }
+
+void test_symscope(void) {
+ TESTBEGIN("symscope");
+
+ ASSERT_SYMSCOPE(0, "t1", -1, 1);
+ ASSERT_SYMSCOPE(-1, "t1", -1, 1);
+
+ TESTEND("symscope");
+}
+
#define ULAS_FULLEN 0xFFFF
#define ASSERT_FULL(expect_rc, in_path, expect_path) \
test_totok();
test_intexpr();
test_asminstr();
+ test_symscope();
ulas_free();
struct ulas_sym *sym = &ulas.syms.buf[i];
// when scope is the same as the current one, or scope 0 (global)
if ((sym->scope & ulas.scope) == 0 && strcmp(name, sym->name) == 0) {
+ puts("scope");
return sym;
}
}
// def new symbol
struct ulas_sym new_sym = {strdup(name), tok, scope, ulas.pass, constant};
- // last char of name has to be : so we trim it away
+ // last char of name has to be : so we trim it away
new_sym.name[strlen(new_sym.name) - 1] = '\0';
ulas_symbufpush(&ulas.syms, new_sym);
} else if (exisitng->lastdefin != ulas.pass) {