Refactor SYMTAB_*

suggested by phk
parent 3c68fa77
...@@ -382,7 +382,11 @@ extern const struct symxref XREF_NONE[1]; ...@@ -382,7 +382,11 @@ extern const struct symxref XREF_NONE[1];
extern const struct symxref XREF_DEF[1]; extern const struct symxref XREF_DEF[1];
extern const struct symxref XREF_REF[1]; extern const struct symxref XREF_REF[1];
struct symmode { const char *name; }; struct symmode {
const char *name;
unsigned noerr;
unsigned partial;
};
extern const struct symmode SYMTAB_NOERR[1]; extern const struct symmode SYMTAB_NOERR[1];
extern const struct symmode SYMTAB_CREATE[1]; extern const struct symmode SYMTAB_CREATE[1];
extern const struct symmode SYMTAB_EXISTING[1]; extern const struct symmode SYMTAB_EXISTING[1];
......
...@@ -250,11 +250,26 @@ vcc_sym_in_tab(struct vcc *tl, struct symtab *st, ...@@ -250,11 +250,26 @@ vcc_sym_in_tab(struct vcc *tl, struct symtab *st,
const struct symxref XREF_NONE[1] = {{"xref_none"}}; const struct symxref XREF_NONE[1] = {{"xref_none"}};
const struct symxref XREF_DEF[1] = {{"xref_def"}}; const struct symxref XREF_DEF[1] = {{"xref_def"}};
const struct symxref XREF_REF[1] = {{"xref_ref"}}; const struct symxref XREF_REF[1] = {{"xref_ref"}};
const struct symmode SYMTAB_NOERR[1] = {{"sym_noerror"}};
const struct symmode SYMTAB_CREATE[1] = {{"sym_create"}}; const struct symmode SYMTAB_NOERR[1] = {{
const struct symmode SYMTAB_EXISTING[1] = {{"Symbol not found"}}; .name = "sym_noerror",
const struct symmode SYMTAB_PARTIAL[1] = {{"Symbol not found"}}; .noerr = 1
const struct symmode SYMTAB_PARTIAL_NOERR[1] = {{"Symbol not found"}}; }};
const struct symmode SYMTAB_CREATE[1] = {{
.name = "sym_create"
}};
const struct symmode SYMTAB_EXISTING[1] = {{
.name = "Symbol not found"
}};
const struct symmode SYMTAB_PARTIAL[1] = {{
.name = "Symbol not found",
.partial = 1
}};
const struct symmode SYMTAB_PARTIAL_NOERR[1] = {{
.name = "Symbol not found",
.partial = 1,
.noerr = 1
}};
struct symbol * struct symbol *
VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind, VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind,
...@@ -300,15 +315,15 @@ VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind, ...@@ -300,15 +315,15 @@ VCC_SymbolGet(struct vcc *tl, vcc_ns_t ns, vcc_kind_t kind,
break; break;
tn = tn1; tn = tn1;
} }
if (sym != NULL && sym->kind == SYM_VMOD && e == SYMTAB_PARTIAL) if (sym != NULL && sym->kind == SYM_VMOD && e->partial)
e = SYMTAB_EXISTING; e = SYMTAB_EXISTING;
if (sym != NULL && (e == SYMTAB_PARTIAL || e == SYMTAB_PARTIAL_NOERR)) { if (sym != NULL && e->partial) {
st = st2; st = st2;
tn = tn2; tn = tn2;
} else if (st != st2) { } else if (st != st2) {
sym = NULL; sym = NULL;
} }
if (sym == NULL && (e == SYMTAB_NOERR || e == SYMTAB_PARTIAL_NOERR)) if (sym == NULL && e->noerr)
return (sym); return (sym);
AN(st); AN(st);
AN(tn); AN(tn);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment