From bac27731e30cbea76997fa3547791b3462ac8697 Mon Sep 17 00:00:00 2001 From: Vexu Date: Thu, 16 Jan 2020 13:55:39 +0200 Subject: add struct field default value to typeinfo --- src/ir.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/ir.cpp') 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); -- cgit v1.2.3