struct ulas_tok *ulas_tokbufget(struct ulas_tokbuf *tb, int i);
void ulas_tokbufclear(struct ulas_tokbuf *tb);
void ulas_tokbuffree(struct ulas_tokbuf *tb);
+void ulas_tokfree(struct ulas_tok *t);
struct ulas_exprbuf ulas_exprbuf(void);
ASSERT_SYMSCOPE(0, "@t1:", -1, 1);
ASSERT_SYMSCOPE(-1, "@t1:", -1, 1);
- // manual scoping
+ // manual scoping
ASSERT_SYMSCOPE(0, "t2:", 5, 1);
ASSERT_SYMSCOPE(-1, "t2:", 5, 1);
ASSERT_SYMSCOPE(0, "t2:", 6, 1);
int ulas_symbolset(const char *cname, int scope, struct ulas_tok tok,
int constant) {
- // remove : from name
+ // remove : from name
char name[ULAS_SYMNAMEMAX];
long len = strlen(cname);
assert(len < ULAS_SYMNAMEMAX);
}
}
- struct ulas_sym *exisitng = ulas_symbolresolve(name, scope, &resolve_rc);
- if (!exisitng) {
+ struct ulas_sym *existing = ulas_symbolresolve(name, scope, &resolve_rc);
+ if (!existing) {
// inc scope when symbol is global
if (name[0] != ULAS_TOK_SCOPED_SYMBOL_BEGIN) {
ulas.scope++;
// def new symbol
struct ulas_sym new_sym = {strdup(name), tok, scope, ulas.pass, constant};
ulas_symbufpush(&ulas.syms, new_sym);
- } else if (exisitng->lastdefin != ulas.pass) {
+ } else if (existing->lastdefin != ulas.pass || !existing->constant) {
// redefine if not defined this pass
+ existing->lastdefin = ulas.pass;
+ ulas_tokfree(&existing->tok);
+ existing->tok = tok;
+ existing->constant = constant;
} else {
// exists.. cannot have duplicates!
rc = -1;