diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2020-06-17 04:29:54 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2020-06-18 17:12:56 -0400 |
| commit | 7e58c56ca72099f6e71752289be7165947bfaa04 (patch) | |
| tree | d4b5def4b5fd17caba14e88f5bdc3673449e8fdd /src/codegen.cpp | |
| parent | b4eac0414a01b1096e8dd7e89455db88f19789cf (diff) | |
| download | zig-7e58c56ca72099f6e71752289be7165947bfaa04.tar.gz zig-7e58c56ca72099f6e71752289be7165947bfaa04.zip | |
self-hosted: implement Decl lookup
* Take advantage of coercing anonymous struct literals to struct types.
* Reworks Module to favor Zig source as the primary use case.
Breaks ZIR compilation, which will have to be restored in a future commit.
* Decl uses src_index rather then src, pointing to an AST Decl node
index, or ZIR Module Decl index, rather than a byte offset.
* ZIR instructions have an `analyzed_inst` field instead of Module
having a hash table.
* Module.Fn loses the `fn_type` field since it is redundant with
its `owner_decl` `TypedValue` type.
* Implement Type and Value copying. A ZIR Const instruction's TypedValue
is copied to the Decl arena during analysis, which allows freeing the
ZIR text instructions post-analysis.
* Don't flush the ELF file if there are compilation errors.
* Function return types allow arbitrarily complex expressions.
* AST->ZIR for function calls and return statements.
Diffstat (limited to 'src/codegen.cpp')
| -rw-r--r-- | src/codegen.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/codegen.cpp b/src/codegen.cpp index e20d6d60f5..75d126eaf6 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -7473,6 +7473,12 @@ static LLVMValueRef gen_const_val(CodeGen *g, ZigValue *const_val, const char *n continue; } ZigValue *field_val = const_val->data.x_struct.fields[i]; + if (field_val == nullptr) { + add_node_error(g, type_struct_field->decl_node, + buf_sprintf("compiler bug: generating const value for struct field '%s'", + buf_ptr(type_struct_field->name))); + codegen_report_errors_and_exit(g); + } ZigType *field_type = field_val->type; assert(field_type != nullptr); if ((err = ensure_const_val_repr(nullptr, g, nullptr, field_val, field_type))) { |
