aboutsummaryrefslogtreecommitdiff
path: root/src/ir.cpp
diff options
context:
space:
mode:
authorVexu <git@vexu.eu>2020-01-16 13:55:39 +0200
committerAndrew Kelley <andrew@ziglang.org>2020-01-16 13:22:30 -0500
commitbac27731e30cbea76997fa3547791b3462ac8697 (patch)
tree1e14fcb22dc0957dda325fbc058989609c48b5a0 /src/ir.cpp
parentdf03fcf5f07e0d5d16e5b837658265f6c468cbe4 (diff)
downloadzig-bac27731e30cbea76997fa3547791b3462ac8697.tar.gz
zig-bac27731e30cbea76997fa3547791b3462ac8697.zip
add struct field default value to typeinfo
Diffstat (limited to 'src/ir.cpp')
-rw-r--r--src/ir.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/ir.cpp b/src/ir.cpp
index c3ca366456..818644f501 100644
--- a/src/ir.cpp
+++ b/src/ir.cpp
@@ -23338,7 +23338,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
struct_field_val->special = ConstValSpecialStatic;
struct_field_val->type = type_info_struct_field_type;
- ZigValue **inner_fields = alloc_const_vals_ptrs(3);
+ ZigValue **inner_fields = alloc_const_vals_ptrs(4);
inner_fields[1]->special = ConstValSpecialStatic;
inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int);
@@ -23361,6 +23361,12 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr
inner_fields[2]->type = ira->codegen->builtin_types.entry_type;
inner_fields[2]->data.x_type = struct_field->type_entry;
+ // default_value: var
+ inner_fields[3]->special = ConstValSpecialStatic;
+ inner_fields[3]->type = get_optional_type(ira->codegen, struct_field->type_entry);
+ memoize_field_init_val(ira->codegen, type_entry, struct_field);
+ set_optional_payload(inner_fields[3], struct_field->init_val);
+
ZigValue *name = create_const_str_lit(ira->codegen, struct_field->name)->data.x_ptr.data.ref.pointee;
init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true);