| author | |
| committer | |
| log | 262e09c482d98a78531c049a18b7f24146fe157f |
| tree | 1846cfba5b5194c4c4eda4215b50f8dbd8ccf58c |
| parent | c4c7cb252a4a9c54a1c4eac6c990dec4b61024d4 |
rather than via `@import("builtin")`. This helps avoid the need for
`usingnamespace` used in builtin.zig or in std.builtin.3 files changed, 9 insertions(+), 4 deletions(-)
src/stage1/all_types.hpp+1| ... | @@ -2077,6 +2077,7 @@ struct CodeGen { | ... | @@ -2077,6 +2077,7 @@ struct CodeGen { |
| 2077 | ZigType *compile_var_import; | 2077 | ZigType *compile_var_import; |
| 2078 | ZigType *root_import; | 2078 | ZigType *root_import; |
| 2079 | ZigType *start_import; | 2079 | ZigType *start_import; |
| 2080 | ZigType *std_builtin_import; | ||
| 2080 | 2081 | ||
| 2081 | struct { | 2082 | struct { |
| 2082 | ZigType *entry_bool; | 2083 | ZigType *entry_bool; |
src/stage1/analyze.cpp+6-2| ... | @@ -8185,14 +8185,18 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) { | ... | @@ -8185,14 +8185,18 @@ bool err_ptr_eql(const ErrorTableEntry *a, const ErrorTableEntry *b) { |
| 8185 | } | 8185 | } |
| 8186 | 8186 | ||
| 8187 | ZigValue *get_builtin_value(CodeGen *codegen, const char *name) { | 8187 | ZigValue *get_builtin_value(CodeGen *codegen, const char *name) { |
| 8188 | ScopeDecls *builtin_scope = get_container_scope(codegen->compile_var_import); | 8188 | Buf *buf_name = buf_create_from_str(name); |
| 8189 | Tld *tld = find_container_decl(codegen, builtin_scope, buf_create_from_str(name)); | 8189 | |
| 8190 | ScopeDecls *builtin_scope = get_container_scope(codegen->std_builtin_import); | ||
| 8191 | Tld *tld = find_container_decl(codegen, builtin_scope, buf_name); | ||
| 8190 | assert(tld != nullptr); | 8192 | assert(tld != nullptr); |
| 8191 | resolve_top_level_decl(codegen, tld, nullptr, false); | 8193 | resolve_top_level_decl(codegen, tld, nullptr, false); |
| 8192 | assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk); | 8194 | assert(tld->id == TldIdVar && tld->resolution == TldResolutionOk); |
| 8193 | TldVar *tld_var = (TldVar *)tld; | 8195 | TldVar *tld_var = (TldVar *)tld; |
| 8194 | ZigValue *var_value = tld_var->var->const_value; | 8196 | ZigValue *var_value = tld_var->var->const_value; |
| 8195 | assert(var_value != nullptr); | 8197 | assert(var_value != nullptr); |
| 8198 | |||
| 8199 | buf_destroy(buf_name); | ||
| 8196 | return var_value; | 8200 | return var_value; |
| 8197 | } | 8201 | } |
| 8198 | 8202 |
src/stage1/codegen.cpp+2-2| ... | @@ -9495,9 +9495,9 @@ static void gen_root_source(CodeGen *g) { | ... | @@ -9495,9 +9495,9 @@ static void gen_root_source(CodeGen *g) { |
| 9495 | TldVar *builtin_tld_var = (TldVar*)builtin_tld; | 9495 | TldVar *builtin_tld_var = (TldVar*)builtin_tld; |
| 9496 | ZigValue *builtin_val = builtin_tld_var->var->const_value; | 9496 | ZigValue *builtin_val = builtin_tld_var->var->const_value; |
| 9497 | assert(builtin_val->type->id == ZigTypeIdMetaType); | 9497 | assert(builtin_val->type->id == ZigTypeIdMetaType); |
| 9498 | ZigType *builtin_type = builtin_val->data.x_type; | 9498 | g->std_builtin_import = builtin_val->data.x_type; |
| 9499 | 9499 | ||
| 9500 | Tld *panic_tld = find_decl(g, &get_container_scope(builtin_type)->base, | 9500 | Tld *panic_tld = find_decl(g, &get_container_scope(g->std_builtin_import)->base, |
| 9501 | buf_create_from_str("panic")); | 9501 | buf_create_from_str("panic")); |
| 9502 | assert(panic_tld != nullptr); | 9502 | assert(panic_tld != nullptr); |
| 9503 | resolve_top_level_decl(g, panic_tld, nullptr, false); | 9503 | resolve_top_level_decl(g, panic_tld, nullptr, false); |