authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-01-10 16:33:43+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-10 16:44:15-05:00
log9cc7fb66bc00d54d8e4ff77cb6a0327488ceb59d
treed2ed86ee6d0a8a941e7ceab3ae18f6c081248ac9
parent84e98405de5f97101475000a95cd2293507e967d

Don't special-case `builtin` too much

Let's use the usual declaration-searching mechanism that resolves the `usingnamespace` declarations on the go instead of directly peeking into the symbol table. Fixes #4134

1 files changed, 8 insertions(+), 4 deletions(-)

src/analyze.cpp+8-4
...@@ -3622,9 +3622,11 @@ void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source...@@ -3622,9 +3622,11 @@ void init_tld(Tld *tld, TldId id, Buf *name, VisibMod visib_mod, AstNode *source
3622}3622}
36233623
3624void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) {3624void update_compile_var(CodeGen *g, Buf *name, ZigValue *value) {
3625 Tld *tld = get_container_scope(g->compile_var_import)->decl_table.get(name);3625 ScopeDecls *builtin_scope = get_container_scope(g->compile_var_import);
3626 Tld *tld = find_container_decl(g, builtin_scope, name);
3627 assert(tld != nullptr);
3626 resolve_top_level_decl(g, tld, tld->source_node, false);3628 resolve_top_level_decl(g, tld, tld->source_node, false);
3627 assert(tld->id == TldIdVar);3629 assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk);
3628 TldVar *tld_var = (TldVar *)tld;3630 TldVar *tld_var = (TldVar *)tld;
3629 copy_const_val(tld_var->var->const_value, value);3631 copy_const_val(tld_var->var->const_value, value);
3630 tld_var->var->var_type = value->type;3632 tld_var->var->var_type = value->type;
...@@ -7588,9 +7590,11 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) {...@@ -7588,9 +7590,11 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) {
7588}7590}
75897591
7590ZigValue *get_builtin_value(CodeGen *codegen, const char *name) {7592ZigValue *get_builtin_value(CodeGen *codegen, const char *name) {
7591 Tld *tld = get_container_scope(codegen->compile_var_import)->decl_table.get(buf_create_from_str(name));7593 ScopeDecls *builtin_scope = get_container_scope(codegen->compile_var_import);
7594 Tld *tld = find_container_decl(codegen, builtin_scope, buf_create_from_str(name));
7595 assert(tld != nullptr);
7592 resolve_top_level_decl(codegen, tld, nullptr, false);7596 resolve_top_level_decl(codegen, tld, nullptr, false);
7593 assert(tld->id == TldIdVar);7597 assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk);
7594 TldVar *tld_var = (TldVar *)tld;7598 TldVar *tld_var = (TldVar *)tld;
7595 ZigValue *var_value = tld_var->var->const_value;7599 ZigValue *var_value = tld_var->var->const_value;
7596 assert(var_value != nullptr);7600 assert(var_value != nullptr);