| ... | @@ -240,7 +240,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c | ... | @@ -240,7 +240,7 @@ static ConstExprValue *const_ptr_pointee_unchecked(CodeGen *g, ConstExprValue *c |
| 240 | case ConstPtrSpecialBaseStruct: { | 240 | case ConstPtrSpecialBaseStruct: { |
| 241 | ConstExprValue *struct_val = const_val->data.x_ptr.data.base_struct.struct_val; | 241 | ConstExprValue *struct_val = const_val->data.x_ptr.data.base_struct.struct_val; |
| 242 | expand_undef_struct(g, struct_val); | 242 | expand_undef_struct(g, struct_val); |
| 243 | result = &struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index]; | 243 | result = struct_val->data.x_struct.fields[const_val->data.x_ptr.data.base_struct.field_index]; |
| 244 | break; | 244 | break; |
| 245 | } | 245 | } |
| 246 | case ConstPtrSpecialBaseErrorUnionCode: | 246 | case ConstPtrSpecialBaseErrorUnionCode: |
| ... | @@ -10784,9 +10784,9 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ | ... | @@ -10784,9 +10784,9 @@ static void copy_const_val(ConstExprValue *dest, ConstExprValue *src, bool same_ |
| 10784 | if (src->special != ConstValSpecialStatic) | 10784 | if (src->special != ConstValSpecialStatic) |
| 10785 | return; | 10785 | return; |
| 10786 | if (dest->type->id == ZigTypeIdStruct) { | 10786 | if (dest->type->id == ZigTypeIdStruct) { |
| 10787 | dest->data.x_struct.fields = create_const_vals(dest->type->data.structure.src_field_count); | 10787 | dest->data.x_struct.fields = alloc_const_vals_ptrs(dest->type->data.structure.src_field_count); |
| 10788 | for (size_t i = 0; i < dest->type->data.structure.src_field_count; i += 1) { | 10788 | for (size_t i = 0; i < dest->type->data.structure.src_field_count; i += 1) { |
| 10789 | copy_const_val(&dest->data.x_struct.fields[i], &src->data.x_struct.fields[i], false); | 10789 | copy_const_val(dest->data.x_struct.fields[i], src->data.x_struct.fields[i], false); |
| 10790 | } | 10790 | } |
| 10791 | } | 10791 | } |
| 10792 | } | 10792 | } |
| ... | @@ -10982,8 +10982,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc | ... | @@ -10982,8 +10982,7 @@ static IrInstruction *ir_resolve_ptr_of_array_to_slice(IrAnalyze *ira, IrInstruc |
| 10982 | | 10982 | |
| 10983 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); | 10983 | IrInstruction *result = ir_const(ira, source_instr, wanted_type); |
| 10984 | init_const_slice(ira->codegen, &result->value, pointee, 0, array_type->data.array.len, is_const); | 10984 | init_const_slice(ira->codegen, &result->value, pointee, 0, array_type->data.array.len, is_const); |
| 10985 | result->value.data.x_struct.fields[slice_ptr_index].data.x_ptr.mut = | 10985 | result->value.data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = value->value.data.x_ptr.mut; |
| 10986 | value->value.data.x_ptr.mut; | | |
| 10987 | result->value.type = wanted_type; | 10986 | result->value.type = wanted_type; |
| 10988 | return result; | 10987 | return result; |
| 10989 | } | 10988 | } |
| ... | @@ -13491,8 +13490,8 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { | ... | @@ -13491,8 +13490,8 @@ static Buf *ir_resolve_str(IrAnalyze *ira, IrInstruction *value) { |
| 13491 | if (!const_val) | 13490 | if (!const_val) |
| 13492 | return nullptr; | 13491 | return nullptr; |
| 13493 | | 13492 | |
| 13494 | ConstExprValue *ptr_field = &const_val->data.x_struct.fields[slice_ptr_index]; | 13493 | ConstExprValue *ptr_field = const_val->data.x_struct.fields[slice_ptr_index]; |
| 13495 | ConstExprValue *len_field = &const_val->data.x_struct.fields[slice_len_index]; | 13494 | ConstExprValue *len_field = const_val->data.x_struct.fields[slice_len_index]; |
| 13496 | | 13495 | |
| 13497 | assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray); | 13496 | assert(ptr_field->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 13498 | ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val; | 13497 | ConstExprValue *array_val = ptr_field->data.x_ptr.data.base_array.array_val; |
| ... | @@ -14820,11 +14819,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -14820,11 +14819,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 14820 | } else if (is_slice(op1_type)) { | 14819 | } else if (is_slice(op1_type)) { |
| 14821 | ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry; | 14820 | ZigType *ptr_type = op1_type->data.structure.fields[slice_ptr_index].type_entry; |
| 14822 | child_type = ptr_type->data.pointer.child_type; | 14821 | child_type = ptr_type->data.pointer.child_type; |
| 14823 | ConstExprValue *ptr_val = &op1_val->data.x_struct.fields[slice_ptr_index]; | 14822 | ConstExprValue *ptr_val = op1_val->data.x_struct.fields[slice_ptr_index]; |
| 14824 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); | 14823 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 14825 | op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 14824 | op1_array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 14826 | op1_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; | 14825 | op1_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; |
| 14827 | ConstExprValue *len_val = &op1_val->data.x_struct.fields[slice_len_index]; | 14826 | ConstExprValue *len_val = op1_val->data.x_struct.fields[slice_len_index]; |
| 14828 | op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); | 14827 | op1_array_end = op1_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 14829 | } else { | 14828 | } else { |
| 14830 | ir_add_error(ira, op1, | 14829 | ir_add_error(ira, op1, |
| ... | @@ -14853,11 +14852,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -14853,11 +14852,11 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 14853 | } else if (is_slice(op2_type)) { | 14852 | } else if (is_slice(op2_type)) { |
| 14854 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry; | 14853 | ZigType *ptr_type = op2_type->data.structure.fields[slice_ptr_index].type_entry; |
| 14855 | op2_type_valid = ptr_type->data.pointer.child_type == child_type; | 14854 | op2_type_valid = ptr_type->data.pointer.child_type == child_type; |
| 14856 | ConstExprValue *ptr_val = &op2_val->data.x_struct.fields[slice_ptr_index]; | 14855 | ConstExprValue *ptr_val = op2_val->data.x_struct.fields[slice_ptr_index]; |
| 14857 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); | 14856 | assert(ptr_val->data.x_ptr.special == ConstPtrSpecialBaseArray); |
| 14858 | op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val; | 14857 | op2_array_val = ptr_val->data.x_ptr.data.base_array.array_val; |
| 14859 | op2_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; | 14858 | op2_array_index = ptr_val->data.x_ptr.data.base_array.elem_index; |
| 14860 | ConstExprValue *len_val = &op2_val->data.x_struct.fields[slice_len_index]; | 14859 | ConstExprValue *len_val = op2_val->data.x_struct.fields[slice_len_index]; |
| 14861 | op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint); | 14860 | op2_array_end = op2_array_index + bigint_as_usize(&len_val->data.x_bigint); |
| 14862 | } else { | 14861 | } else { |
| 14863 | ir_add_error(ira, op2, | 14862 | ir_add_error(ira, op2, |
| ... | @@ -14889,17 +14888,17 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i | ... | @@ -14889,17 +14888,17 @@ static IrInstruction *ir_analyze_array_cat(IrAnalyze *ira, IrInstructionBinOp *i |
| 14889 | out_array_val->special = ConstValSpecialStatic; | 14888 | out_array_val->special = ConstValSpecialStatic; |
| 14890 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len); | 14889 | out_array_val->type = get_array_type(ira->codegen, child_type, new_len); |
| 14891 | | 14890 | |
| 14892 | out_val->data.x_struct.fields = create_const_vals(2); | 14891 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 14893 | | 14892 | |
| 14894 | out_val->data.x_struct.fields[slice_ptr_index].type = ptr_type; | 14893 | out_val->data.x_struct.fields[slice_ptr_index]->type = ptr_type; |
| 14895 | out_val->data.x_struct.fields[slice_ptr_index].special = ConstValSpecialStatic; | 14894 | out_val->data.x_struct.fields[slice_ptr_index]->special = ConstValSpecialStatic; |
| 14896 | out_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.special = ConstPtrSpecialBaseArray; | 14895 | out_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.special = ConstPtrSpecialBaseArray; |
| 14897 | out_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.data.base_array.array_val = out_array_val; | 14896 | out_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.data.base_array.array_val = out_array_val; |
| 14898 | out_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.data.base_array.elem_index = 0; | 14897 | out_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.data.base_array.elem_index = 0; |
| 14899 | | 14898 | |
| 14900 | out_val->data.x_struct.fields[slice_len_index].type = ira->codegen->builtin_types.entry_usize; | 14899 | out_val->data.x_struct.fields[slice_len_index]->type = ira->codegen->builtin_types.entry_usize; |
| 14901 | out_val->data.x_struct.fields[slice_len_index].special = ConstValSpecialStatic; | 14900 | out_val->data.x_struct.fields[slice_len_index]->special = ConstValSpecialStatic; |
| 14902 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index].data.x_bigint, new_len); | 14901 | bigint_init_unsigned(&out_val->data.x_struct.fields[slice_len_index]->data.x_bigint, new_len); |
| 14903 | } else { | 14902 | } else { |
| 14904 | new_len += 1; // null byte | 14903 | new_len += 1; // null byte |
| 14905 | | 14904 | |
| ... | @@ -16496,17 +16495,10 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source | ... | @@ -16496,17 +16495,10 @@ static IrInstruction *ir_analyze_store_ptr(IrAnalyze *ira, IrInstruction *source |
| 16496 | ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, | 16495 | ConstExprValue *struct_val = const_ptr_pointee(ira, ira->codegen, ptr_val, |
| 16497 | source_instr->source_node); | 16496 | source_instr->source_node); |
| 16498 | struct_val->special = ConstValSpecialStatic; | 16497 | struct_val->special = ConstValSpecialStatic; |
| 16499 | if (new_field_count > 16) { | 16498 | struct_val->data.x_struct.fields = realloc_const_vals_ptrs(struct_val->data.x_struct.fields, |
| 16500 | // This thing with 16 is a hack to allow this functionality to work without | 16499 | old_field_count, new_field_count); |
| 16501 | // modifying the ConstExprValue layout of structs. That reworking needs to be | | |
| 16502 | // done, but this hack lets us do it separately, in the future. | | |
| 16503 | zig_panic("TODO need to rework the layout of ConstExprValue for structs. This realloc would have caused invalid pointer references"); | | |
| 16504 | } | | |
| 16505 | if (struct_val->data.x_struct.fields == nullptr) { | | |
| 16506 | struct_val->data.x_struct.fields = create_const_vals(16); | | |
| 16507 | } | | |
| 16508 | | 16500 | |
| 16509 | ConstExprValue *field_val = &struct_val->data.x_struct.fields[old_field_count]; | 16501 | ConstExprValue *field_val = struct_val->data.x_struct.fields[old_field_count]; |
| 16510 | field_val->special = ConstValSpecialUndef; | 16502 | field_val->special = ConstValSpecialUndef; |
| 16511 | field_val->type = field->type_entry; | 16503 | field_val->type = field->type_entry; |
| 16512 | field_val->parent.id = ConstParentIdStruct; | 16504 | field_val->parent.id = ConstParentIdStruct; |
| ... | @@ -18156,7 +18148,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18156,7 +18148,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18156 | | 18148 | |
| 18157 | init_const_slice(ira->codegen, array_ptr_val, array_init_val, 0, actual_array_type->data.array.len, | 18149 | init_const_slice(ira->codegen, array_ptr_val, array_init_val, 0, actual_array_type->data.array.len, |
| 18158 | false); | 18150 | false); |
| 18159 | array_ptr_val->data.x_struct.fields[slice_ptr_index].data.x_ptr.mut = ConstPtrMutInfer; | 18151 | array_ptr_val->data.x_struct.fields[slice_ptr_index]->data.x_ptr.mut = ConstPtrMutInfer; |
| 18160 | } else { | 18152 | } else { |
| 18161 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, | 18153 | ir_add_error_node(ira, elem_ptr_instruction->init_array_type_source_node, |
| 18162 | buf_sprintf("expected array type or [_], found '%s'", | 18154 | buf_sprintf("expected array type or [_], found '%s'", |
| ... | @@ -18228,7 +18220,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18228,7 +18220,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18228 | } | 18220 | } |
| 18229 | return result; | 18221 | return result; |
| 18230 | } else if (is_slice(array_type)) { | 18222 | } else if (is_slice(array_type)) { |
| 18231 | ConstExprValue *ptr_field = &array_ptr_val->data.x_struct.fields[slice_ptr_index]; | 18223 | ConstExprValue *ptr_field = array_ptr_val->data.x_struct.fields[slice_ptr_index]; |
| 18232 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); | 18224 | ir_assert(ptr_field != nullptr, &elem_ptr_instruction->base); |
| 18233 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { | 18225 | if (ptr_field->data.x_ptr.special == ConstPtrSpecialHardCodedAddr) { |
| 18234 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, | 18226 | IrInstruction *result = ir_build_elem_ptr(&ira->new_irb, elem_ptr_instruction->base.scope, |
| ... | @@ -18237,7 +18229,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct | ... | @@ -18237,7 +18229,7 @@ static IrInstruction *ir_analyze_instruction_elem_ptr(IrAnalyze *ira, IrInstruct |
| 18237 | result->value.type = return_type; | 18229 | result->value.type = return_type; |
| 18238 | return result; | 18230 | return result; |
| 18239 | } | 18231 | } |
| 18240 | ConstExprValue *len_field = &array_ptr_val->data.x_struct.fields[slice_len_index]; | 18232 | ConstExprValue *len_field = array_ptr_val->data.x_struct.fields[slice_len_index]; |
| 18241 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); | 18233 | IrInstruction *result = ir_const(ira, &elem_ptr_instruction->base, return_type); |
| 18242 | ConstExprValue *out_val = &result->value; | 18234 | ConstExprValue *out_val = &result->value; |
| 18243 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); | 18235 | uint64_t slice_len = bigint_as_u64(&len_field->data.x_bigint); |
| ... | @@ -18466,10 +18458,10 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction | ... | @@ -18466,10 +18458,10 @@ static IrInstruction *ir_analyze_struct_field_ptr(IrAnalyze *ira, IrInstruction |
| 18466 | if (type_is_invalid(struct_val->type)) | 18458 | if (type_is_invalid(struct_val->type)) |
| 18467 | return ira->codegen->invalid_instruction; | 18459 | return ira->codegen->invalid_instruction; |
| 18468 | if (initializing && struct_val->special == ConstValSpecialUndef) { | 18460 | if (initializing && struct_val->special == ConstValSpecialUndef) { |
| 18469 | struct_val->data.x_struct.fields = create_const_vals(struct_type->data.structure.src_field_count); | 18461 | struct_val->data.x_struct.fields = alloc_const_vals_ptrs(struct_type->data.structure.src_field_count); |
| 18470 | struct_val->special = ConstValSpecialStatic; | 18462 | struct_val->special = ConstValSpecialStatic; |
| 18471 | for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { | 18463 | for (size_t i = 0; i < struct_type->data.structure.src_field_count; i += 1) { |
| 18472 | ConstExprValue *field_val = &struct_val->data.x_struct.fields[i]; | 18464 | ConstExprValue *field_val = struct_val->data.x_struct.fields[i]; |
| 18473 | field_val->special = ConstValSpecialUndef; | 18465 | field_val->special = ConstValSpecialUndef; |
| 18474 | field_val->type = resolve_struct_field_type(ira->codegen, | 18466 | field_val->type = resolve_struct_field_type(ira->codegen, |
| 18475 | &struct_type->data.structure.fields[i]); | 18467 | &struct_type->data.structure.fields[i]); |
| ... | @@ -21005,17 +20997,17 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21005,17 +20997,17 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21005 | declaration_val->special = ConstValSpecialStatic; | 20997 | declaration_val->special = ConstValSpecialStatic; |
| 21006 | declaration_val->type = type_info_declaration_type; | 20998 | declaration_val->type = type_info_declaration_type; |
| 21007 | | 20999 | |
| 21008 | ConstExprValue *inner_fields = create_const_vals(3); | 21000 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); |
| 21009 | ConstExprValue *name = create_const_str_lit(ira->codegen, curr_entry->key); | 21001 | ConstExprValue *name = create_const_str_lit(ira->codegen, curr_entry->key); |
| 21010 | init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(curr_entry->key), true); | 21002 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(curr_entry->key), true); |
| 21011 | inner_fields[1].special = ConstValSpecialStatic; | 21003 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21012 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; | 21004 | inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; |
| 21013 | inner_fields[1].data.x_bool = curr_entry->value->visib_mod == VisibModPub; | 21005 | inner_fields[1]->data.x_bool = curr_entry->value->visib_mod == VisibModPub; |
| 21014 | inner_fields[2].special = ConstValSpecialStatic; | 21006 | inner_fields[2]->special = ConstValSpecialStatic; |
| 21015 | inner_fields[2].type = type_info_declaration_data_type; | 21007 | inner_fields[2]->type = type_info_declaration_data_type; |
| 21016 | inner_fields[2].parent.id = ConstParentIdStruct; | 21008 | inner_fields[2]->parent.id = ConstParentIdStruct; |
| 21017 | inner_fields[2].parent.data.p_struct.struct_val = declaration_val; | 21009 | inner_fields[2]->parent.data.p_struct.struct_val = declaration_val; |
| 21018 | inner_fields[2].parent.data.p_struct.field_index = 1; | 21010 | inner_fields[2]->parent.data.p_struct.field_index = 1; |
| 21019 | | 21011 | |
| 21020 | switch (curr_entry->value->id) { | 21012 | switch (curr_entry->value->id) { |
| 21021 | case TldIdVar: | 21013 | case TldIdVar: |
| ... | @@ -21027,19 +21019,19 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21027,19 +21019,19 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21027 | if (var->const_value->type->id == ZigTypeIdMetaType) { | 21019 | if (var->const_value->type->id == ZigTypeIdMetaType) { |
| 21028 | // We have a variable of type 'type', so it's actually a type declaration. | 21020 | // We have a variable of type 'type', so it's actually a type declaration. |
| 21029 | // 0: Data.Type: type | 21021 | // 0: Data.Type: type |
| 21030 | bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0); | 21022 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); |
| 21031 | inner_fields[2].data.x_union.payload = var->const_value; | 21023 | inner_fields[2]->data.x_union.payload = var->const_value; |
| 21032 | } else { | 21024 | } else { |
| 21033 | // We have a variable of another type, so we store the type of the variable. | 21025 | // We have a variable of another type, so we store the type of the variable. |
| 21034 | // 1: Data.Var: type | 21026 | // 1: Data.Var: type |
| 21035 | bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 1); | 21027 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 1); |
| 21036 | | 21028 | |
| 21037 | ConstExprValue *payload = create_const_vals(1); | 21029 | ConstExprValue *payload = create_const_vals(1); |
| 21038 | payload->special = ConstValSpecialStatic; | 21030 | payload->special = ConstValSpecialStatic; |
| 21039 | payload->type = ira->codegen->builtin_types.entry_type; | 21031 | payload->type = ira->codegen->builtin_types.entry_type; |
| 21040 | payload->data.x_type = var->const_value->type; | 21032 | payload->data.x_type = var->const_value->type; |
| 21041 | | 21033 | |
| 21042 | inner_fields[2].data.x_union.payload = payload; | 21034 | inner_fields[2]->data.x_union.payload = payload; |
| 21043 | } | 21035 | } |
| 21044 | | 21036 | |
| 21045 | break; | 21037 | break; |
| ... | @@ -21047,7 +21039,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21047,7 +21039,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21047 | case TldIdFn: | 21039 | case TldIdFn: |
| 21048 | { | 21040 | { |
| 21049 | // 2: Data.Fn: Data.FnDecl | 21041 | // 2: Data.Fn: Data.FnDecl |
| 21050 | bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 2); | 21042 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 2); |
| 21051 | | 21043 | |
| 21052 | ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; | 21044 | ZigFn *fn_entry = ((TldFn *)curr_entry->value)->fn_entry; |
| 21053 | assert(!fn_entry->is_test); | 21045 | assert(!fn_entry->is_test); |
| ... | @@ -21063,63 +21055,63 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21063,63 +21055,63 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21063 | fn_decl_val->special = ConstValSpecialStatic; | 21055 | fn_decl_val->special = ConstValSpecialStatic; |
| 21064 | fn_decl_val->type = type_info_fn_decl_type; | 21056 | fn_decl_val->type = type_info_fn_decl_type; |
| 21065 | fn_decl_val->parent.id = ConstParentIdUnion; | 21057 | fn_decl_val->parent.id = ConstParentIdUnion; |
| 21066 | fn_decl_val->parent.data.p_union.union_val = &inner_fields[2]; | 21058 | fn_decl_val->parent.data.p_union.union_val = inner_fields[2]; |
| 21067 | | 21059 | |
| 21068 | ConstExprValue *fn_decl_fields = create_const_vals(9); | 21060 | ConstExprValue **fn_decl_fields = alloc_const_vals_ptrs(9); |
| 21069 | fn_decl_val->data.x_struct.fields = fn_decl_fields; | 21061 | fn_decl_val->data.x_struct.fields = fn_decl_fields; |
| 21070 | | 21062 | |
| 21071 | // fn_type: type | 21063 | // fn_type: type |
| 21072 | ensure_field_index(fn_decl_val->type, "fn_type", 0); | 21064 | ensure_field_index(fn_decl_val->type, "fn_type", 0); |
| 21073 | fn_decl_fields[0].special = ConstValSpecialStatic; | 21065 | fn_decl_fields[0]->special = ConstValSpecialStatic; |
| 21074 | fn_decl_fields[0].type = ira->codegen->builtin_types.entry_type; | 21066 | fn_decl_fields[0]->type = ira->codegen->builtin_types.entry_type; |
| 21075 | fn_decl_fields[0].data.x_type = fn_entry->type_entry; | 21067 | fn_decl_fields[0]->data.x_type = fn_entry->type_entry; |
| 21076 | // inline_type: Data.FnDecl.Inline | 21068 | // inline_type: Data.FnDecl.Inline |
| 21077 | ensure_field_index(fn_decl_val->type, "inline_type", 1); | 21069 | ensure_field_index(fn_decl_val->type, "inline_type", 1); |
| 21078 | fn_decl_fields[1].special = ConstValSpecialStatic; | 21070 | fn_decl_fields[1]->special = ConstValSpecialStatic; |
| 21079 | fn_decl_fields[1].type = type_info_fn_decl_inline_type; | 21071 | fn_decl_fields[1]->type = type_info_fn_decl_inline_type; |
| 21080 | bigint_init_unsigned(&fn_decl_fields[1].data.x_enum_tag, fn_entry->fn_inline); | 21072 | bigint_init_unsigned(&fn_decl_fields[1]->data.x_enum_tag, fn_entry->fn_inline); |
| 21081 | // calling_convention: TypeInfo.CallingConvention | 21073 | // calling_convention: TypeInfo.CallingConvention |
| 21082 | ensure_field_index(fn_decl_val->type, "calling_convention", 2); | 21074 | ensure_field_index(fn_decl_val->type, "calling_convention", 2); |
| 21083 | fn_decl_fields[2].special = ConstValSpecialStatic; | 21075 | fn_decl_fields[2]->special = ConstValSpecialStatic; |
| 21084 | fn_decl_fields[2].type = ir_type_info_get_type(ira, "CallingConvention", nullptr); | 21076 | fn_decl_fields[2]->type = ir_type_info_get_type(ira, "CallingConvention", nullptr); |
| 21085 | bigint_init_unsigned(&fn_decl_fields[2].data.x_enum_tag, fn_node->cc); | 21077 | bigint_init_unsigned(&fn_decl_fields[2]->data.x_enum_tag, fn_node->cc); |
| 21086 | // is_var_args: bool | 21078 | // is_var_args: bool |
| 21087 | ensure_field_index(fn_decl_val->type, "is_var_args", 3); | 21079 | ensure_field_index(fn_decl_val->type, "is_var_args", 3); |
| 21088 | bool is_varargs = fn_node->is_var_args; | 21080 | bool is_varargs = fn_node->is_var_args; |
| 21089 | fn_decl_fields[3].special = ConstValSpecialStatic; | 21081 | fn_decl_fields[3]->special = ConstValSpecialStatic; |
| 21090 | fn_decl_fields[3].type = ira->codegen->builtin_types.entry_bool; | 21082 | fn_decl_fields[3]->type = ira->codegen->builtin_types.entry_bool; |
| 21091 | fn_decl_fields[3].data.x_bool = is_varargs; | 21083 | fn_decl_fields[3]->data.x_bool = is_varargs; |
| 21092 | // is_extern: bool | 21084 | // is_extern: bool |
| 21093 | ensure_field_index(fn_decl_val->type, "is_extern", 4); | 21085 | ensure_field_index(fn_decl_val->type, "is_extern", 4); |
| 21094 | fn_decl_fields[4].special = ConstValSpecialStatic; | 21086 | fn_decl_fields[4]->special = ConstValSpecialStatic; |
| 21095 | fn_decl_fields[4].type = ira->codegen->builtin_types.entry_bool; | 21087 | fn_decl_fields[4]->type = ira->codegen->builtin_types.entry_bool; |
| 21096 | fn_decl_fields[4].data.x_bool = fn_node->is_extern; | 21088 | fn_decl_fields[4]->data.x_bool = fn_node->is_extern; |
| 21097 | // is_export: bool | 21089 | // is_export: bool |
| 21098 | ensure_field_index(fn_decl_val->type, "is_export", 5); | 21090 | ensure_field_index(fn_decl_val->type, "is_export", 5); |
| 21099 | fn_decl_fields[5].special = ConstValSpecialStatic; | 21091 | fn_decl_fields[5]->special = ConstValSpecialStatic; |
| 21100 | fn_decl_fields[5].type = ira->codegen->builtin_types.entry_bool; | 21092 | fn_decl_fields[5]->type = ira->codegen->builtin_types.entry_bool; |
| 21101 | fn_decl_fields[5].data.x_bool = fn_node->is_export; | 21093 | fn_decl_fields[5]->data.x_bool = fn_node->is_export; |
| 21102 | // lib_name: ?[]const u8 | 21094 | // lib_name: ?[]const u8 |
| 21103 | ensure_field_index(fn_decl_val->type, "lib_name", 6); | 21095 | ensure_field_index(fn_decl_val->type, "lib_name", 6); |
| 21104 | fn_decl_fields[6].special = ConstValSpecialStatic; | 21096 | fn_decl_fields[6]->special = ConstValSpecialStatic; |
| 21105 | ZigType *u8_ptr = get_pointer_to_type_extra( | 21097 | ZigType *u8_ptr = get_pointer_to_type_extra( |
| 21106 | ira->codegen, ira->codegen->builtin_types.entry_u8, | 21098 | ira->codegen, ira->codegen->builtin_types.entry_u8, |
| 21107 | true, false, PtrLenUnknown, | 21099 | true, false, PtrLenUnknown, |
| 21108 | 0, 0, 0, false); | 21100 | 0, 0, 0, false); |
| 21109 | fn_decl_fields[6].type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr)); | 21101 | fn_decl_fields[6]->type = get_optional_type(ira->codegen, get_slice_type(ira->codegen, u8_ptr)); |
| 21110 | if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) { | 21102 | if (fn_node->is_extern && fn_node->lib_name != nullptr && buf_len(fn_node->lib_name) > 0) { |
| 21111 | fn_decl_fields[6].data.x_optional = create_const_vals(1); | 21103 | fn_decl_fields[6]->data.x_optional = create_const_vals(1); |
| 21112 | ConstExprValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name); | 21104 | ConstExprValue *lib_name = create_const_str_lit(ira->codegen, fn_node->lib_name); |
| 21113 | init_const_slice(ira->codegen, fn_decl_fields[6].data.x_optional, lib_name, 0, | 21105 | init_const_slice(ira->codegen, fn_decl_fields[6]->data.x_optional, lib_name, 0, |
| 21114 | buf_len(fn_node->lib_name), true); | 21106 | buf_len(fn_node->lib_name), true); |
| 21115 | } else { | 21107 | } else { |
| 21116 | fn_decl_fields[6].data.x_optional = nullptr; | 21108 | fn_decl_fields[6]->data.x_optional = nullptr; |
| 21117 | } | 21109 | } |
| 21118 | // return_type: type | 21110 | // return_type: type |
| 21119 | ensure_field_index(fn_decl_val->type, "return_type", 7); | 21111 | ensure_field_index(fn_decl_val->type, "return_type", 7); |
| 21120 | fn_decl_fields[7].special = ConstValSpecialStatic; | 21112 | fn_decl_fields[7]->special = ConstValSpecialStatic; |
| 21121 | fn_decl_fields[7].type = ira->codegen->builtin_types.entry_type; | 21113 | fn_decl_fields[7]->type = ira->codegen->builtin_types.entry_type; |
| 21122 | fn_decl_fields[7].data.x_type = fn_entry->type_entry->data.fn.fn_type_id.return_type; | 21114 | fn_decl_fields[7]->data.x_type = fn_entry->type_entry->data.fn.fn_type_id.return_type; |
| 21123 | // arg_names: [][] const u8 | 21115 | // arg_names: [][] const u8 |
| 21124 | ensure_field_index(fn_decl_val->type, "arg_names", 8); | 21116 | ensure_field_index(fn_decl_val->type, "arg_names", 8); |
| 21125 | size_t fn_arg_count = fn_entry->variable_list.length; | 21117 | size_t fn_arg_count = fn_entry->variable_list.length; |
| ... | @@ -21130,7 +21122,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21130,7 +21122,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21130 | fn_arg_name_array->data.x_array.special = ConstArraySpecialNone; | 21122 | fn_arg_name_array->data.x_array.special = ConstArraySpecialNone; |
| 21131 | fn_arg_name_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count); | 21123 | fn_arg_name_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count); |
| 21132 | | 21124 | |
| 21133 | init_const_slice(ira->codegen, &fn_decl_fields[8], fn_arg_name_array, 0, fn_arg_count, false); | 21125 | init_const_slice(ira->codegen, fn_decl_fields[8], fn_arg_name_array, 0, fn_arg_count, false); |
| 21134 | | 21126 | |
| 21135 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 21127 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { |
| 21136 | ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index); | 21128 | ZigVar *arg_var = fn_entry->variable_list.at(fn_arg_index); |
| ... | @@ -21143,7 +21135,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21143,7 +21135,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21143 | fn_arg_name_val->parent.data.p_array.elem_index = fn_arg_index; | 21135 | fn_arg_name_val->parent.data.p_array.elem_index = fn_arg_index; |
| 21144 | } | 21136 | } |
| 21145 | | 21137 | |
| 21146 | inner_fields[2].data.x_union.payload = fn_decl_val; | 21138 | inner_fields[2]->data.x_union.payload = fn_decl_val; |
| 21147 | break; | 21139 | break; |
| 21148 | } | 21140 | } |
| 21149 | case TldIdContainer: | 21141 | case TldIdContainer: |
| ... | @@ -21153,14 +21145,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21153,14 +21145,14 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21153 | return ErrorSemanticAnalyzeFail; | 21145 | return ErrorSemanticAnalyzeFail; |
| 21154 | | 21146 | |
| 21155 | // This is a type. | 21147 | // This is a type. |
| 21156 | bigint_init_unsigned(&inner_fields[2].data.x_union.tag, 0); | 21148 | bigint_init_unsigned(&inner_fields[2]->data.x_union.tag, 0); |
| 21157 | | 21149 | |
| 21158 | ConstExprValue *payload = create_const_vals(1); | 21150 | ConstExprValue *payload = create_const_vals(1); |
| 21159 | payload->special = ConstValSpecialStatic; | 21151 | payload->special = ConstValSpecialStatic; |
| 21160 | payload->type = ira->codegen->builtin_types.entry_type; | 21152 | payload->type = ira->codegen->builtin_types.entry_type; |
| 21161 | payload->data.x_type = type_entry; | 21153 | payload->data.x_type = type_entry; |
| 21162 | | 21154 | |
| 21163 | inner_fields[2].data.x_union.payload = payload; | 21155 | inner_fields[2]->data.x_union.payload = payload; |
| 21164 | | 21156 | |
| 21165 | break; | 21157 | break; |
| 21166 | } | 21158 | } |
| ... | @@ -21169,7 +21161,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21169,7 +21161,7 @@ static Error ir_make_type_info_decls(IrAnalyze *ira, IrInstruction *source_instr |
| 21169 | } | 21161 | } |
| 21170 | | 21162 | |
| 21171 | declaration_val->data.x_struct.fields = inner_fields; | 21163 | declaration_val->data.x_struct.fields = inner_fields; |
| 21172 | declaration_index++; | 21164 | declaration_index += 1; |
| 21173 | } | 21165 | } |
| 21174 | | 21166 | |
| 21175 | assert(declaration_index == declaration_count); | 21167 | assert(declaration_index == declaration_count); |
| ... | @@ -21225,42 +21217,42 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty | ... | @@ -21225,42 +21217,42 @@ static ConstExprValue *create_ptr_like_type_info(IrAnalyze *ira, ZigType *ptr_ty |
| 21225 | result->special = ConstValSpecialStatic; | 21217 | result->special = ConstValSpecialStatic; |
| 21226 | result->type = type_info_pointer_type; | 21218 | result->type = type_info_pointer_type; |
| 21227 | | 21219 | |
| 21228 | ConstExprValue *fields = create_const_vals(6); | 21220 | ConstExprValue **fields = alloc_const_vals_ptrs(6); |
| 21229 | result->data.x_struct.fields = fields; | 21221 | result->data.x_struct.fields = fields; |
| 21230 | | 21222 | |
| 21231 | // size: Size | 21223 | // size: Size |
| 21232 | ensure_field_index(result->type, "size", 0); | 21224 | ensure_field_index(result->type, "size", 0); |
| 21233 | ZigType *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type); | 21225 | ZigType *type_info_pointer_size_type = ir_type_info_get_type(ira, "Size", type_info_pointer_type); |
| 21234 | assertNoError(type_resolve(ira->codegen, type_info_pointer_size_type, ResolveStatusSizeKnown)); | 21226 | assertNoError(type_resolve(ira->codegen, type_info_pointer_size_type, ResolveStatusSizeKnown)); |
| 21235 | fields[0].special = ConstValSpecialStatic; | 21227 | fields[0]->special = ConstValSpecialStatic; |
| 21236 | fields[0].type = type_info_pointer_size_type; | 21228 | fields[0]->type = type_info_pointer_size_type; |
| 21237 | bigint_init_unsigned(&fields[0].data.x_enum_tag, size_enum_index); | 21229 | bigint_init_unsigned(&fields[0]->data.x_enum_tag, size_enum_index); |
| 21238 | | 21230 | |
| 21239 | // is_const: bool | 21231 | // is_const: bool |
| 21240 | ensure_field_index(result->type, "is_const", 1); | 21232 | ensure_field_index(result->type, "is_const", 1); |
| 21241 | fields[1].special = ConstValSpecialStatic; | 21233 | fields[1]->special = ConstValSpecialStatic; |
| 21242 | fields[1].type = ira->codegen->builtin_types.entry_bool; | 21234 | fields[1]->type = ira->codegen->builtin_types.entry_bool; |
| 21243 | fields[1].data.x_bool = attrs_type->data.pointer.is_const; | 21235 | fields[1]->data.x_bool = attrs_type->data.pointer.is_const; |
| 21244 | // is_volatile: bool | 21236 | // is_volatile: bool |
| 21245 | ensure_field_index(result->type, "is_volatile", 2); | 21237 | ensure_field_index(result->type, "is_volatile", 2); |
| 21246 | fields[2].special = ConstValSpecialStatic; | 21238 | fields[2]->special = ConstValSpecialStatic; |
| 21247 | fields[2].type = ira->codegen->builtin_types.entry_bool; | 21239 | fields[2]->type = ira->codegen->builtin_types.entry_bool; |
| 21248 | fields[2].data.x_bool = attrs_type->data.pointer.is_volatile; | 21240 | fields[2]->data.x_bool = attrs_type->data.pointer.is_volatile; |
| 21249 | // alignment: u32 | 21241 | // alignment: u32 |
| 21250 | ensure_field_index(result->type, "alignment", 3); | 21242 | ensure_field_index(result->type, "alignment", 3); |
| 21251 | fields[3].special = ConstValSpecialStatic; | 21243 | fields[3]->special = ConstValSpecialStatic; |
| 21252 | fields[3].type = ira->codegen->builtin_types.entry_num_lit_int; | 21244 | fields[3]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21253 | bigint_init_unsigned(&fields[3].data.x_bigint, get_ptr_align(ira->codegen, attrs_type)); | 21245 | bigint_init_unsigned(&fields[3]->data.x_bigint, get_ptr_align(ira->codegen, attrs_type)); |
| 21254 | // child: type | 21246 | // child: type |
| 21255 | ensure_field_index(result->type, "child", 4); | 21247 | ensure_field_index(result->type, "child", 4); |
| 21256 | fields[4].special = ConstValSpecialStatic; | 21248 | fields[4]->special = ConstValSpecialStatic; |
| 21257 | fields[4].type = ira->codegen->builtin_types.entry_type; | 21249 | fields[4]->type = ira->codegen->builtin_types.entry_type; |
| 21258 | fields[4].data.x_type = attrs_type->data.pointer.child_type; | 21250 | fields[4]->data.x_type = attrs_type->data.pointer.child_type; |
| 21259 | // is_allowzero: bool | 21251 | // is_allowzero: bool |
| 21260 | ensure_field_index(result->type, "is_allowzero", 5); | 21252 | ensure_field_index(result->type, "is_allowzero", 5); |
| 21261 | fields[5].special = ConstValSpecialStatic; | 21253 | fields[5]->special = ConstValSpecialStatic; |
| 21262 | fields[5].type = ira->codegen->builtin_types.entry_bool; | 21254 | fields[5]->type = ira->codegen->builtin_types.entry_bool; |
| 21263 | fields[5].data.x_bool = attrs_type->data.pointer.allow_zero; | 21255 | fields[5]->data.x_bool = attrs_type->data.pointer.allow_zero; |
| 21264 | | 21256 | |
| 21265 | return result; | 21257 | return result; |
| 21266 | }; | 21258 | }; |
| ... | @@ -21271,14 +21263,14 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, | ... | @@ -21271,14 +21263,14 @@ static void make_enum_field_val(IrAnalyze *ira, ConstExprValue *enum_field_val, |
| 21271 | enum_field_val->special = ConstValSpecialStatic; | 21263 | enum_field_val->special = ConstValSpecialStatic; |
| 21272 | enum_field_val->type = type_info_enum_field_type; | 21264 | enum_field_val->type = type_info_enum_field_type; |
| 21273 | | 21265 | |
| 21274 | ConstExprValue *inner_fields = create_const_vals(2); | 21266 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(2); |
| 21275 | inner_fields[1].special = ConstValSpecialStatic; | 21267 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21276 | inner_fields[1].type = ira->codegen->builtin_types.entry_num_lit_int; | 21268 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21277 | | 21269 | |
| 21278 | ConstExprValue *name = create_const_str_lit(ira->codegen, enum_field->name); | 21270 | ConstExprValue *name = create_const_str_lit(ira->codegen, enum_field->name); |
| 21279 | init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(enum_field->name), true); | 21271 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(enum_field->name), true); |
| 21280 | | 21272 | |
| 21281 | bigint_init_bigint(&inner_fields[1].data.x_bigint, &enum_field->value); | 21273 | bigint_init_bigint(&inner_fields[1]->data.x_bigint, &enum_field->value); |
| 21282 | | 21274 | |
| 21283 | enum_field_val->data.x_struct.fields = inner_fields; | 21275 | enum_field_val->data.x_struct.fields = inner_fields; |
| 21284 | } | 21276 | } |
| ... | @@ -21322,19 +21314,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21322,19 +21314,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21322 | result->special = ConstValSpecialStatic; | 21314 | result->special = ConstValSpecialStatic; |
| 21323 | result->type = ir_type_info_get_type(ira, "Int", nullptr); | 21315 | result->type = ir_type_info_get_type(ira, "Int", nullptr); |
| 21324 | | 21316 | |
| 21325 | ConstExprValue *fields = create_const_vals(2); | 21317 | ConstExprValue **fields = alloc_const_vals_ptrs(2); |
| 21326 | result->data.x_struct.fields = fields; | 21318 | result->data.x_struct.fields = fields; |
| 21327 | | 21319 | |
| 21328 | // is_signed: bool | 21320 | // is_signed: bool |
| 21329 | ensure_field_index(result->type, "is_signed", 0); | 21321 | ensure_field_index(result->type, "is_signed", 0); |
| 21330 | fields[0].special = ConstValSpecialStatic; | 21322 | fields[0]->special = ConstValSpecialStatic; |
| 21331 | fields[0].type = ira->codegen->builtin_types.entry_bool; | 21323 | fields[0]->type = ira->codegen->builtin_types.entry_bool; |
| 21332 | fields[0].data.x_bool = type_entry->data.integral.is_signed; | 21324 | fields[0]->data.x_bool = type_entry->data.integral.is_signed; |
| 21333 | // bits: u8 | 21325 | // bits: u8 |
| 21334 | ensure_field_index(result->type, "bits", 1); | 21326 | ensure_field_index(result->type, "bits", 1); |
| 21335 | fields[1].special = ConstValSpecialStatic; | 21327 | fields[1]->special = ConstValSpecialStatic; |
| 21336 | fields[1].type = ira->codegen->builtin_types.entry_num_lit_int; | 21328 | fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21337 | bigint_init_unsigned(&fields[1].data.x_bigint, type_entry->data.integral.bit_count); | 21329 | bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.integral.bit_count); |
| 21338 | | 21330 | |
| 21339 | break; | 21331 | break; |
| 21340 | } | 21332 | } |
| ... | @@ -21344,14 +21336,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21344,14 +21336,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21344 | result->special = ConstValSpecialStatic; | 21336 | result->special = ConstValSpecialStatic; |
| 21345 | result->type = ir_type_info_get_type(ira, "Float", nullptr); | 21337 | result->type = ir_type_info_get_type(ira, "Float", nullptr); |
| 21346 | | 21338 | |
| 21347 | ConstExprValue *fields = create_const_vals(1); | 21339 | ConstExprValue **fields = alloc_const_vals_ptrs(1); |
| 21348 | result->data.x_struct.fields = fields; | 21340 | result->data.x_struct.fields = fields; |
| 21349 | | 21341 | |
| 21350 | // bits: u8 | 21342 | // bits: u8 |
| 21351 | ensure_field_index(result->type, "bits", 0); | 21343 | ensure_field_index(result->type, "bits", 0); |
| 21352 | fields[0].special = ConstValSpecialStatic; | 21344 | fields[0]->special = ConstValSpecialStatic; |
| 21353 | fields[0].type = ira->codegen->builtin_types.entry_num_lit_int; | 21345 | fields[0]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21354 | bigint_init_unsigned(&fields->data.x_bigint, type_entry->data.floating.bit_count); | 21346 | bigint_init_unsigned(&fields[0]->data.x_bigint, type_entry->data.floating.bit_count); |
| 21355 | | 21347 | |
| 21356 | break; | 21348 | break; |
| 21357 | } | 21349 | } |
| ... | @@ -21368,19 +21360,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21368,19 +21360,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21368 | result->special = ConstValSpecialStatic; | 21360 | result->special = ConstValSpecialStatic; |
| 21369 | result->type = ir_type_info_get_type(ira, "Array", nullptr); | 21361 | result->type = ir_type_info_get_type(ira, "Array", nullptr); |
| 21370 | | 21362 | |
| 21371 | ConstExprValue *fields = create_const_vals(2); | 21363 | ConstExprValue **fields = alloc_const_vals_ptrs(2); |
| 21372 | result->data.x_struct.fields = fields; | 21364 | result->data.x_struct.fields = fields; |
| 21373 | | 21365 | |
| 21374 | // len: usize | 21366 | // len: usize |
| 21375 | ensure_field_index(result->type, "len", 0); | 21367 | ensure_field_index(result->type, "len", 0); |
| 21376 | fields[0].special = ConstValSpecialStatic; | 21368 | fields[0]->special = ConstValSpecialStatic; |
| 21377 | fields[0].type = ira->codegen->builtin_types.entry_num_lit_int; | 21369 | fields[0]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21378 | bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.array.len); | 21370 | bigint_init_unsigned(&fields[0]->data.x_bigint, type_entry->data.array.len); |
| 21379 | // child: type | 21371 | // child: type |
| 21380 | ensure_field_index(result->type, "child", 1); | 21372 | ensure_field_index(result->type, "child", 1); |
| 21381 | fields[1].special = ConstValSpecialStatic; | 21373 | fields[1]->special = ConstValSpecialStatic; |
| 21382 | fields[1].type = ira->codegen->builtin_types.entry_type; | 21374 | fields[1]->type = ira->codegen->builtin_types.entry_type; |
| 21383 | fields[1].data.x_type = type_entry->data.array.child_type; | 21375 | fields[1]->data.x_type = type_entry->data.array.child_type; |
| 21384 | | 21376 | |
| 21385 | break; | 21377 | break; |
| 21386 | } | 21378 | } |
| ... | @@ -21389,19 +21381,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21389,19 +21381,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21389 | result->special = ConstValSpecialStatic; | 21381 | result->special = ConstValSpecialStatic; |
| 21390 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); | 21382 | result->type = ir_type_info_get_type(ira, "Vector", nullptr); |
| 21391 | | 21383 | |
| 21392 | ConstExprValue *fields = create_const_vals(2); | 21384 | ConstExprValue **fields = alloc_const_vals_ptrs(2); |
| 21393 | result->data.x_struct.fields = fields; | 21385 | result->data.x_struct.fields = fields; |
| 21394 | | 21386 | |
| 21395 | // len: usize | 21387 | // len: usize |
| 21396 | ensure_field_index(result->type, "len", 0); | 21388 | ensure_field_index(result->type, "len", 0); |
| 21397 | fields[0].special = ConstValSpecialStatic; | 21389 | fields[0]->special = ConstValSpecialStatic; |
| 21398 | fields[0].type = ira->codegen->builtin_types.entry_num_lit_int; | 21390 | fields[0]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21399 | bigint_init_unsigned(&fields[0].data.x_bigint, type_entry->data.vector.len); | 21391 | bigint_init_unsigned(&fields[0]->data.x_bigint, type_entry->data.vector.len); |
| 21400 | // child: type | 21392 | // child: type |
| 21401 | ensure_field_index(result->type, "child", 1); | 21393 | ensure_field_index(result->type, "child", 1); |
| 21402 | fields[1].special = ConstValSpecialStatic; | 21394 | fields[1]->special = ConstValSpecialStatic; |
| 21403 | fields[1].type = ira->codegen->builtin_types.entry_type; | 21395 | fields[1]->type = ira->codegen->builtin_types.entry_type; |
| 21404 | fields[1].data.x_type = type_entry->data.vector.elem_type; | 21396 | fields[1]->data.x_type = type_entry->data.vector.elem_type; |
| 21405 | | 21397 | |
| 21406 | break; | 21398 | break; |
| 21407 | } | 21399 | } |
| ... | @@ -21411,14 +21403,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21411,14 +21403,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21411 | result->special = ConstValSpecialStatic; | 21403 | result->special = ConstValSpecialStatic; |
| 21412 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); | 21404 | result->type = ir_type_info_get_type(ira, "Optional", nullptr); |
| 21413 | | 21405 | |
| 21414 | ConstExprValue *fields = create_const_vals(1); | 21406 | ConstExprValue **fields = alloc_const_vals_ptrs(1); |
| 21415 | result->data.x_struct.fields = fields; | 21407 | result->data.x_struct.fields = fields; |
| 21416 | | 21408 | |
| 21417 | // child: type | 21409 | // child: type |
| 21418 | ensure_field_index(result->type, "child", 0); | 21410 | ensure_field_index(result->type, "child", 0); |
| 21419 | fields[0].special = ConstValSpecialStatic; | 21411 | fields[0]->special = ConstValSpecialStatic; |
| 21420 | fields[0].type = ira->codegen->builtin_types.entry_type; | 21412 | fields[0]->type = ira->codegen->builtin_types.entry_type; |
| 21421 | fields[0].data.x_type = type_entry->data.maybe.child_type; | 21413 | fields[0]->data.x_type = type_entry->data.maybe.child_type; |
| 21422 | | 21414 | |
| 21423 | break; | 21415 | break; |
| 21424 | } | 21416 | } |
| ... | @@ -21427,14 +21419,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21427,14 +21419,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21427 | result->special = ConstValSpecialStatic; | 21419 | result->special = ConstValSpecialStatic; |
| 21428 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); | 21420 | result->type = ir_type_info_get_type(ira, "AnyFrame", nullptr); |
| 21429 | | 21421 | |
| 21430 | ConstExprValue *fields = create_const_vals(1); | 21422 | ConstExprValue **fields = alloc_const_vals_ptrs(1); |
| 21431 | result->data.x_struct.fields = fields; | 21423 | result->data.x_struct.fields = fields; |
| 21432 | | 21424 | |
| 21433 | // child: ?type | 21425 | // child: ?type |
| 21434 | ensure_field_index(result->type, "child", 0); | 21426 | ensure_field_index(result->type, "child", 0); |
| 21435 | fields[0].special = ConstValSpecialStatic; | 21427 | fields[0]->special = ConstValSpecialStatic; |
| 21436 | fields[0].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); | 21428 | fields[0]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 21437 | fields[0].data.x_optional = (type_entry->data.any_frame.result_type == nullptr) ? nullptr : | 21429 | fields[0]->data.x_optional = (type_entry->data.any_frame.result_type == nullptr) ? nullptr : |
| 21438 | create_const_type(ira->codegen, type_entry->data.any_frame.result_type); | 21430 | create_const_type(ira->codegen, type_entry->data.any_frame.result_type); |
| 21439 | break; | 21431 | break; |
| 21440 | } | 21432 | } |
| ... | @@ -21444,19 +21436,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21444,19 +21436,19 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21444 | result->special = ConstValSpecialStatic; | 21436 | result->special = ConstValSpecialStatic; |
| 21445 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); | 21437 | result->type = ir_type_info_get_type(ira, "Enum", nullptr); |
| 21446 | | 21438 | |
| 21447 | ConstExprValue *fields = create_const_vals(4); | 21439 | ConstExprValue **fields = alloc_const_vals_ptrs(4); |
| 21448 | result->data.x_struct.fields = fields; | 21440 | result->data.x_struct.fields = fields; |
| 21449 | | 21441 | |
| 21450 | // layout: ContainerLayout | 21442 | // layout: ContainerLayout |
| 21451 | ensure_field_index(result->type, "layout", 0); | 21443 | ensure_field_index(result->type, "layout", 0); |
| 21452 | fields[0].special = ConstValSpecialStatic; | 21444 | fields[0]->special = ConstValSpecialStatic; |
| 21453 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr); | 21445 | fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr); |
| 21454 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.enumeration.layout); | 21446 | bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.enumeration.layout); |
| 21455 | // tag_type: type | 21447 | // tag_type: type |
| 21456 | ensure_field_index(result->type, "tag_type", 1); | 21448 | ensure_field_index(result->type, "tag_type", 1); |
| 21457 | fields[1].special = ConstValSpecialStatic; | 21449 | fields[1]->special = ConstValSpecialStatic; |
| 21458 | fields[1].type = ira->codegen->builtin_types.entry_type; | 21450 | fields[1]->type = ira->codegen->builtin_types.entry_type; |
| 21459 | fields[1].data.x_type = type_entry->data.enumeration.tag_int_type; | 21451 | fields[1]->data.x_type = type_entry->data.enumeration.tag_int_type; |
| 21460 | // fields: []TypeInfo.EnumField | 21452 | // fields: []TypeInfo.EnumField |
| 21461 | ensure_field_index(result->type, "fields", 2); | 21453 | ensure_field_index(result->type, "fields", 2); |
| 21462 | | 21454 | |
| ... | @@ -21472,7 +21464,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21472,7 +21464,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21472 | enum_field_array->data.x_array.special = ConstArraySpecialNone; | 21464 | enum_field_array->data.x_array.special = ConstArraySpecialNone; |
| 21473 | enum_field_array->data.x_array.data.s_none.elements = create_const_vals(enum_field_count); | 21465 | enum_field_array->data.x_array.data.s_none.elements = create_const_vals(enum_field_count); |
| 21474 | | 21466 | |
| 21475 | init_const_slice(ira->codegen, &fields[2], enum_field_array, 0, enum_field_count, false); | 21467 | init_const_slice(ira->codegen, fields[2], enum_field_array, 0, enum_field_count, false); |
| 21476 | | 21468 | |
| 21477 | for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++) | 21469 | for (uint32_t enum_field_index = 0; enum_field_index < enum_field_count; enum_field_index++) |
| 21478 | { | 21470 | { |
| ... | @@ -21485,7 +21477,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21485,7 +21477,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21485 | } | 21477 | } |
| 21486 | // decls: []TypeInfo.Declaration | 21478 | // decls: []TypeInfo.Declaration |
| 21487 | ensure_field_index(result->type, "decls", 3); | 21479 | ensure_field_index(result->type, "decls", 3); |
| 21488 | if ((err = ir_make_type_info_decls(ira, source_instr, &fields[3], | 21480 | if ((err = ir_make_type_info_decls(ira, source_instr, fields[3], |
| 21489 | type_entry->data.enumeration.decls_scope))) | 21481 | type_entry->data.enumeration.decls_scope))) |
| 21490 | { | 21482 | { |
| 21491 | return err; | 21483 | return err; |
| ... | @@ -21528,17 +21520,17 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21528,17 +21520,17 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21528 | error_val->special = ConstValSpecialStatic; | 21520 | error_val->special = ConstValSpecialStatic; |
| 21529 | error_val->type = type_info_error_type; | 21521 | error_val->type = type_info_error_type; |
| 21530 | | 21522 | |
| 21531 | ConstExprValue *inner_fields = create_const_vals(2); | 21523 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(2); |
| 21532 | inner_fields[1].special = ConstValSpecialStatic; | 21524 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21533 | inner_fields[1].type = ira->codegen->builtin_types.entry_num_lit_int; | 21525 | inner_fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21534 | | 21526 | |
| 21535 | ConstExprValue *name = nullptr; | 21527 | ConstExprValue *name = nullptr; |
| 21536 | if (error->cached_error_name_val != nullptr) | 21528 | if (error->cached_error_name_val != nullptr) |
| 21537 | name = error->cached_error_name_val; | 21529 | name = error->cached_error_name_val; |
| 21538 | if (name == nullptr) | 21530 | if (name == nullptr) |
| 21539 | name = create_const_str_lit(ira->codegen, &error->name); | 21531 | name = create_const_str_lit(ira->codegen, &error->name); |
| 21540 | init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(&error->name), true); | 21532 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(&error->name), true); |
| 21541 | bigint_init_unsigned(&inner_fields[1].data.x_bigint, error->value); | 21533 | bigint_init_unsigned(&inner_fields[1]->data.x_bigint, error->value); |
| 21542 | | 21534 | |
| 21543 | error_val->data.x_struct.fields = inner_fields; | 21535 | error_val->data.x_struct.fields = inner_fields; |
| 21544 | error_val->parent.id = ConstParentIdArray; | 21536 | error_val->parent.id = ConstParentIdArray; |
| ... | @@ -21554,20 +21546,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21554,20 +21546,20 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21554 | result->special = ConstValSpecialStatic; | 21546 | result->special = ConstValSpecialStatic; |
| 21555 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); | 21547 | result->type = ir_type_info_get_type(ira, "ErrorUnion", nullptr); |
| 21556 | | 21548 | |
| 21557 | ConstExprValue *fields = create_const_vals(2); | 21549 | ConstExprValue **fields = alloc_const_vals_ptrs(2); |
| 21558 | result->data.x_struct.fields = fields; | 21550 | result->data.x_struct.fields = fields; |
| 21559 | | 21551 | |
| 21560 | // error_set: type | 21552 | // error_set: type |
| 21561 | ensure_field_index(result->type, "error_set", 0); | 21553 | ensure_field_index(result->type, "error_set", 0); |
| 21562 | fields[0].special = ConstValSpecialStatic; | 21554 | fields[0]->special = ConstValSpecialStatic; |
| 21563 | fields[0].type = ira->codegen->builtin_types.entry_type; | 21555 | fields[0]->type = ira->codegen->builtin_types.entry_type; |
| 21564 | fields[0].data.x_type = type_entry->data.error_union.err_set_type; | 21556 | fields[0]->data.x_type = type_entry->data.error_union.err_set_type; |
| 21565 | | 21557 | |
| 21566 | // payload: type | 21558 | // payload: type |
| 21567 | ensure_field_index(result->type, "payload", 1); | 21559 | ensure_field_index(result->type, "payload", 1); |
| 21568 | fields[1].special = ConstValSpecialStatic; | 21560 | fields[1]->special = ConstValSpecialStatic; |
| 21569 | fields[1].type = ira->codegen->builtin_types.entry_type; | 21561 | fields[1]->type = ira->codegen->builtin_types.entry_type; |
| 21570 | fields[1].data.x_type = type_entry->data.error_union.payload_type; | 21562 | fields[1]->data.x_type = type_entry->data.error_union.payload_type; |
| 21571 | | 21563 | |
| 21572 | break; | 21564 | break; |
| 21573 | } | 21565 | } |
| ... | @@ -21577,18 +21569,18 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21577,18 +21569,18 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21577 | result->special = ConstValSpecialStatic; | 21569 | result->special = ConstValSpecialStatic; |
| 21578 | result->type = ir_type_info_get_type(ira, "Union", nullptr); | 21570 | result->type = ir_type_info_get_type(ira, "Union", nullptr); |
| 21579 | | 21571 | |
| 21580 | ConstExprValue *fields = create_const_vals(4); | 21572 | ConstExprValue **fields = alloc_const_vals_ptrs(4); |
| 21581 | result->data.x_struct.fields = fields; | 21573 | result->data.x_struct.fields = fields; |
| 21582 | | 21574 | |
| 21583 | // layout: ContainerLayout | 21575 | // layout: ContainerLayout |
| 21584 | ensure_field_index(result->type, "layout", 0); | 21576 | ensure_field_index(result->type, "layout", 0); |
| 21585 | fields[0].special = ConstValSpecialStatic; | 21577 | fields[0]->special = ConstValSpecialStatic; |
| 21586 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr); | 21578 | fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr); |
| 21587 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.unionation.layout); | 21579 | bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.unionation.layout); |
| 21588 | // tag_type: ?type | 21580 | // tag_type: ?type |
| 21589 | ensure_field_index(result->type, "tag_type", 1); | 21581 | ensure_field_index(result->type, "tag_type", 1); |
| 21590 | fields[1].special = ConstValSpecialStatic; | 21582 | fields[1]->special = ConstValSpecialStatic; |
| 21591 | fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); | 21583 | fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 21592 | | 21584 | |
| 21593 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; | 21585 | AstNode *union_decl_node = type_entry->data.unionation.decl_node; |
| 21594 | if (union_decl_node->data.container_decl.auto_enum || | 21586 | if (union_decl_node->data.container_decl.auto_enum || |
| ... | @@ -21598,9 +21590,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21598,9 +21590,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21598 | tag_type->special = ConstValSpecialStatic; | 21590 | tag_type->special = ConstValSpecialStatic; |
| 21599 | tag_type->type = ira->codegen->builtin_types.entry_type; | 21591 | tag_type->type = ira->codegen->builtin_types.entry_type; |
| 21600 | tag_type->data.x_type = type_entry->data.unionation.tag_type; | 21592 | tag_type->data.x_type = type_entry->data.unionation.tag_type; |
| 21601 | fields[1].data.x_optional = tag_type; | 21593 | fields[1]->data.x_optional = tag_type; |
| 21602 | } else { | 21594 | } else { |
| 21603 | fields[1].data.x_optional = nullptr; | 21595 | fields[1]->data.x_optional = nullptr; |
| 21604 | } | 21596 | } |
| 21605 | // fields: []TypeInfo.UnionField | 21597 | // fields: []TypeInfo.UnionField |
| 21606 | ensure_field_index(result->type, "fields", 2); | 21598 | ensure_field_index(result->type, "fields", 2); |
| ... | @@ -21616,7 +21608,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21616,7 +21608,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21616 | union_field_array->data.x_array.special = ConstArraySpecialNone; | 21608 | union_field_array->data.x_array.special = ConstArraySpecialNone; |
| 21617 | union_field_array->data.x_array.data.s_none.elements = create_const_vals(union_field_count); | 21609 | union_field_array->data.x_array.data.s_none.elements = create_const_vals(union_field_count); |
| 21618 | | 21610 | |
| 21619 | init_const_slice(ira->codegen, &fields[2], union_field_array, 0, union_field_count, false); | 21611 | init_const_slice(ira->codegen, fields[2], union_field_array, 0, union_field_count, false); |
| 21620 | | 21612 | |
| 21621 | ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr); | 21613 | ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr); |
| 21622 | | 21614 | |
| ... | @@ -21627,23 +21619,23 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21627,23 +21619,23 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21627 | union_field_val->special = ConstValSpecialStatic; | 21619 | union_field_val->special = ConstValSpecialStatic; |
| 21628 | union_field_val->type = type_info_union_field_type; | 21620 | union_field_val->type = type_info_union_field_type; |
| 21629 | | 21621 | |
| 21630 | ConstExprValue *inner_fields = create_const_vals(3); | 21622 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); |
| 21631 | inner_fields[1].special = ConstValSpecialStatic; | 21623 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21632 | inner_fields[1].type = get_optional_type(ira->codegen, type_info_enum_field_type); | 21624 | inner_fields[1]->type = get_optional_type(ira->codegen, type_info_enum_field_type); |
| 21633 | | 21625 | |
| 21634 | if (fields[1].data.x_optional == nullptr) { | 21626 | if (fields[1]->data.x_optional == nullptr) { |
| 21635 | inner_fields[1].data.x_optional = nullptr; | 21627 | inner_fields[1]->data.x_optional = nullptr; |
| 21636 | } else { | 21628 | } else { |
| 21637 | inner_fields[1].data.x_optional = create_const_vals(1); | 21629 | inner_fields[1]->data.x_optional = create_const_vals(1); |
| 21638 | make_enum_field_val(ira, inner_fields[1].data.x_optional, union_field->enum_field, type_info_enum_field_type); | 21630 | make_enum_field_val(ira, inner_fields[1]->data.x_optional, union_field->enum_field, type_info_enum_field_type); |
| 21639 | } | 21631 | } |
| 21640 | | 21632 | |
| 21641 | inner_fields[2].special = ConstValSpecialStatic; | 21633 | inner_fields[2]->special = ConstValSpecialStatic; |
| 21642 | inner_fields[2].type = ira->codegen->builtin_types.entry_type; | 21634 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 21643 | inner_fields[2].data.x_type = union_field->type_entry; | 21635 | inner_fields[2]->data.x_type = union_field->type_entry; |
| 21644 | | 21636 | |
| 21645 | ConstExprValue *name = create_const_str_lit(ira->codegen, union_field->name); | 21637 | ConstExprValue *name = create_const_str_lit(ira->codegen, union_field->name); |
| 21646 | init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(union_field->name), true); | 21638 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(union_field->name), true); |
| 21647 | | 21639 | |
| 21648 | union_field_val->data.x_struct.fields = inner_fields; | 21640 | union_field_val->data.x_struct.fields = inner_fields; |
| 21649 | union_field_val->parent.id = ConstParentIdArray; | 21641 | union_field_val->parent.id = ConstParentIdArray; |
| ... | @@ -21652,7 +21644,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21652,7 +21644,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21652 | } | 21644 | } |
| 21653 | // decls: []TypeInfo.Declaration | 21645 | // decls: []TypeInfo.Declaration |
| 21654 | ensure_field_index(result->type, "decls", 3); | 21646 | ensure_field_index(result->type, "decls", 3); |
| 21655 | if ((err = ir_make_type_info_decls(ira, source_instr, &fields[3], | 21647 | if ((err = ir_make_type_info_decls(ira, source_instr, fields[3], |
| 21656 | type_entry->data.unionation.decls_scope))) | 21648 | type_entry->data.unionation.decls_scope))) |
| 21657 | { | 21649 | { |
| 21658 | return err; | 21650 | return err; |
| ... | @@ -21673,14 +21665,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21673,14 +21665,14 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21673 | result->special = ConstValSpecialStatic; | 21665 | result->special = ConstValSpecialStatic; |
| 21674 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); | 21666 | result->type = ir_type_info_get_type(ira, "Struct", nullptr); |
| 21675 | | 21667 | |
| 21676 | ConstExprValue *fields = create_const_vals(3); | 21668 | ConstExprValue **fields = alloc_const_vals_ptrs(3); |
| 21677 | result->data.x_struct.fields = fields; | 21669 | result->data.x_struct.fields = fields; |
| 21678 | | 21670 | |
| 21679 | // layout: ContainerLayout | 21671 | // layout: ContainerLayout |
| 21680 | ensure_field_index(result->type, "layout", 0); | 21672 | ensure_field_index(result->type, "layout", 0); |
| 21681 | fields[0].special = ConstValSpecialStatic; | 21673 | fields[0]->special = ConstValSpecialStatic; |
| 21682 | fields[0].type = ir_type_info_get_type(ira, "ContainerLayout", nullptr); | 21674 | fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr); |
| 21683 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.structure.layout); | 21675 | bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.structure.layout); |
| 21684 | // fields: []TypeInfo.StructField | 21676 | // fields: []TypeInfo.StructField |
| 21685 | ensure_field_index(result->type, "fields", 1); | 21677 | ensure_field_index(result->type, "fields", 1); |
| 21686 | | 21678 | |
| ... | @@ -21696,7 +21688,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21696,7 +21688,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21696 | struct_field_array->data.x_array.special = ConstArraySpecialNone; | 21688 | struct_field_array->data.x_array.special = ConstArraySpecialNone; |
| 21697 | struct_field_array->data.x_array.data.s_none.elements = create_const_vals(struct_field_count); | 21689 | struct_field_array->data.x_array.data.s_none.elements = create_const_vals(struct_field_count); |
| 21698 | | 21690 | |
| 21699 | init_const_slice(ira->codegen, &fields[1], struct_field_array, 0, struct_field_count, false); | 21691 | init_const_slice(ira->codegen, fields[1], struct_field_array, 0, struct_field_count, false); |
| 21700 | | 21692 | |
| 21701 | for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) { | 21693 | for (uint32_t struct_field_index = 0; struct_field_index < struct_field_count; struct_field_index++) { |
| 21702 | TypeStructField *struct_field = &type_entry->data.structure.fields[struct_field_index]; | 21694 | TypeStructField *struct_field = &type_entry->data.structure.fields[struct_field_index]; |
| ... | @@ -21705,9 +21697,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21705,9 +21697,9 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21705 | struct_field_val->special = ConstValSpecialStatic; | 21697 | struct_field_val->special = ConstValSpecialStatic; |
| 21706 | struct_field_val->type = type_info_struct_field_type; | 21698 | struct_field_val->type = type_info_struct_field_type; |
| 21707 | | 21699 | |
| 21708 | ConstExprValue *inner_fields = create_const_vals(3); | 21700 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); |
| 21709 | inner_fields[1].special = ConstValSpecialStatic; | 21701 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21710 | inner_fields[1].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); | 21702 | inner_fields[1]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_num_lit_int); |
| 21711 | | 21703 | |
| 21712 | ZigType *field_type = resolve_struct_field_type(ira->codegen, struct_field); | 21704 | ZigType *field_type = resolve_struct_field_type(ira->codegen, struct_field); |
| 21713 | if (field_type == nullptr) | 21705 | if (field_type == nullptr) |
| ... | @@ -21715,21 +21707,21 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21715,21 +21707,21 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21715 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) | 21707 | if ((err = type_resolve(ira->codegen, field_type, ResolveStatusZeroBitsKnown))) |
| 21716 | return err; | 21708 | return err; |
| 21717 | if (!type_has_bits(struct_field->type_entry)) { | 21709 | if (!type_has_bits(struct_field->type_entry)) { |
| 21718 | inner_fields[1].data.x_optional = nullptr; | 21710 | inner_fields[1]->data.x_optional = nullptr; |
| 21719 | } else { | 21711 | } else { |
| 21720 | size_t byte_offset = struct_field->offset; | 21712 | size_t byte_offset = struct_field->offset; |
| 21721 | inner_fields[1].data.x_optional = create_const_vals(1); | 21713 | inner_fields[1]->data.x_optional = create_const_vals(1); |
| 21722 | inner_fields[1].data.x_optional->special = ConstValSpecialStatic; | 21714 | inner_fields[1]->data.x_optional->special = ConstValSpecialStatic; |
| 21723 | inner_fields[1].data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int; | 21715 | inner_fields[1]->data.x_optional->type = ira->codegen->builtin_types.entry_num_lit_int; |
| 21724 | bigint_init_unsigned(&inner_fields[1].data.x_optional->data.x_bigint, byte_offset); | 21716 | bigint_init_unsigned(&inner_fields[1]->data.x_optional->data.x_bigint, byte_offset); |
| 21725 | } | 21717 | } |
| 21726 | | 21718 | |
| 21727 | inner_fields[2].special = ConstValSpecialStatic; | 21719 | inner_fields[2]->special = ConstValSpecialStatic; |
| 21728 | inner_fields[2].type = ira->codegen->builtin_types.entry_type; | 21720 | inner_fields[2]->type = ira->codegen->builtin_types.entry_type; |
| 21729 | inner_fields[2].data.x_type = struct_field->type_entry; | 21721 | inner_fields[2]->data.x_type = struct_field->type_entry; |
| 21730 | | 21722 | |
| 21731 | ConstExprValue *name = create_const_str_lit(ira->codegen, struct_field->name); | 21723 | ConstExprValue *name = create_const_str_lit(ira->codegen, struct_field->name); |
| 21732 | init_const_slice(ira->codegen, &inner_fields[0], name, 0, buf_len(struct_field->name), true); | 21724 | init_const_slice(ira->codegen, inner_fields[0], name, 0, buf_len(struct_field->name), true); |
| 21733 | | 21725 | |
| 21734 | struct_field_val->data.x_struct.fields = inner_fields; | 21726 | struct_field_val->data.x_struct.fields = inner_fields; |
| 21735 | struct_field_val->parent.id = ConstParentIdArray; | 21727 | struct_field_val->parent.id = ConstParentIdArray; |
| ... | @@ -21738,7 +21730,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21738,7 +21730,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21738 | } | 21730 | } |
| 21739 | // decls: []TypeInfo.Declaration | 21731 | // decls: []TypeInfo.Declaration |
| 21740 | ensure_field_index(result->type, "decls", 2); | 21732 | ensure_field_index(result->type, "decls", 2); |
| 21741 | if ((err = ir_make_type_info_decls(ira, source_instr, &fields[2], | 21733 | if ((err = ir_make_type_info_decls(ira, source_instr, fields[2], |
| 21742 | type_entry->data.structure.decls_scope))) | 21734 | type_entry->data.structure.decls_scope))) |
| 21743 | { | 21735 | { |
| 21744 | return err; | 21736 | return err; |
| ... | @@ -21752,38 +21744,38 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21752,38 +21744,38 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21752 | result->special = ConstValSpecialStatic; | 21744 | result->special = ConstValSpecialStatic; |
| 21753 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); | 21745 | result->type = ir_type_info_get_type(ira, "Fn", nullptr); |
| 21754 | | 21746 | |
| 21755 | ConstExprValue *fields = create_const_vals(5); | 21747 | ConstExprValue **fields = alloc_const_vals_ptrs(5); |
| 21756 | result->data.x_struct.fields = fields; | 21748 | result->data.x_struct.fields = fields; |
| 21757 | | 21749 | |
| 21758 | // calling_convention: TypeInfo.CallingConvention | 21750 | // calling_convention: TypeInfo.CallingConvention |
| 21759 | ensure_field_index(result->type, "calling_convention", 0); | 21751 | ensure_field_index(result->type, "calling_convention", 0); |
| 21760 | fields[0].special = ConstValSpecialStatic; | 21752 | fields[0]->special = ConstValSpecialStatic; |
| 21761 | fields[0].type = ir_type_info_get_type(ira, "CallingConvention", nullptr); | 21753 | fields[0]->type = ir_type_info_get_type(ira, "CallingConvention", nullptr); |
| 21762 | bigint_init_unsigned(&fields[0].data.x_enum_tag, type_entry->data.fn.fn_type_id.cc); | 21754 | bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.fn.fn_type_id.cc); |
| 21763 | // is_generic: bool | 21755 | // is_generic: bool |
| 21764 | ensure_field_index(result->type, "is_generic", 1); | 21756 | ensure_field_index(result->type, "is_generic", 1); |
| 21765 | bool is_generic = type_entry->data.fn.is_generic; | 21757 | bool is_generic = type_entry->data.fn.is_generic; |
| 21766 | fields[1].special = ConstValSpecialStatic; | 21758 | fields[1]->special = ConstValSpecialStatic; |
| 21767 | fields[1].type = ira->codegen->builtin_types.entry_bool; | 21759 | fields[1]->type = ira->codegen->builtin_types.entry_bool; |
| 21768 | fields[1].data.x_bool = is_generic; | 21760 | fields[1]->data.x_bool = is_generic; |
| 21769 | // is_varargs: bool | 21761 | // is_varargs: bool |
| 21770 | ensure_field_index(result->type, "is_var_args", 2); | 21762 | ensure_field_index(result->type, "is_var_args", 2); |
| 21771 | bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args; | 21763 | bool is_varargs = type_entry->data.fn.fn_type_id.is_var_args; |
| 21772 | fields[2].special = ConstValSpecialStatic; | 21764 | fields[2]->special = ConstValSpecialStatic; |
| 21773 | fields[2].type = ira->codegen->builtin_types.entry_bool; | 21765 | fields[2]->type = ira->codegen->builtin_types.entry_bool; |
| 21774 | fields[2].data.x_bool = type_entry->data.fn.fn_type_id.is_var_args; | 21766 | fields[2]->data.x_bool = type_entry->data.fn.fn_type_id.is_var_args; |
| 21775 | // return_type: ?type | 21767 | // return_type: ?type |
| 21776 | ensure_field_index(result->type, "return_type", 3); | 21768 | ensure_field_index(result->type, "return_type", 3); |
| 21777 | fields[3].special = ConstValSpecialStatic; | 21769 | fields[3]->special = ConstValSpecialStatic; |
| 21778 | fields[3].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); | 21770 | fields[3]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 21779 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) | 21771 | if (type_entry->data.fn.fn_type_id.return_type == nullptr) |
| 21780 | fields[3].data.x_optional = nullptr; | 21772 | fields[3]->data.x_optional = nullptr; |
| 21781 | else { | 21773 | else { |
| 21782 | ConstExprValue *return_type = create_const_vals(1); | 21774 | ConstExprValue *return_type = create_const_vals(1); |
| 21783 | return_type->special = ConstValSpecialStatic; | 21775 | return_type->special = ConstValSpecialStatic; |
| 21784 | return_type->type = ira->codegen->builtin_types.entry_type; | 21776 | return_type->type = ira->codegen->builtin_types.entry_type; |
| 21785 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; | 21777 | return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type; |
| 21786 | fields[3].data.x_optional = return_type; | 21778 | fields[3]->data.x_optional = return_type; |
| 21787 | } | 21779 | } |
| 21788 | // args: []TypeInfo.FnArg | 21780 | // args: []TypeInfo.FnArg |
| 21789 | ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr); | 21781 | ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "FnArg", nullptr); |
| ... | @@ -21799,7 +21791,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21799,7 +21791,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21799 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; | 21791 | fn_arg_array->data.x_array.special = ConstArraySpecialNone; |
| 21800 | fn_arg_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count); | 21792 | fn_arg_array->data.x_array.data.s_none.elements = create_const_vals(fn_arg_count); |
| 21801 | | 21793 | |
| 21802 | init_const_slice(ira->codegen, &fields[4], fn_arg_array, 0, fn_arg_count, false); | 21794 | init_const_slice(ira->codegen, fields[4], fn_arg_array, 0, fn_arg_count, false); |
| 21803 | | 21795 | |
| 21804 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { | 21796 | for (size_t fn_arg_index = 0; fn_arg_index < fn_arg_count; fn_arg_index++) { |
| 21805 | FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; | 21797 | FnTypeParamInfo *fn_param_info = &type_entry->data.fn.fn_type_id.param_info[fn_arg_index]; |
| ... | @@ -21811,24 +21803,24 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr | ... | @@ -21811,24 +21803,24 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInstruction *source_instr |
| 21811 | bool arg_is_generic = fn_param_info->type == nullptr; | 21803 | bool arg_is_generic = fn_param_info->type == nullptr; |
| 21812 | if (arg_is_generic) assert(is_generic); | 21804 | if (arg_is_generic) assert(is_generic); |
| 21813 | | 21805 | |
| 21814 | ConstExprValue *inner_fields = create_const_vals(3); | 21806 | ConstExprValue **inner_fields = alloc_const_vals_ptrs(3); |
| 21815 | inner_fields[0].special = ConstValSpecialStatic; | 21807 | inner_fields[0]->special = ConstValSpecialStatic; |
| 21816 | inner_fields[0].type = ira->codegen->builtin_types.entry_bool; | 21808 | inner_fields[0]->type = ira->codegen->builtin_types.entry_bool; |
| 21817 | inner_fields[0].data.x_bool = arg_is_generic; | 21809 | inner_fields[0]->data.x_bool = arg_is_generic; |
| 21818 | inner_fields[1].special = ConstValSpecialStatic; | 21810 | inner_fields[1]->special = ConstValSpecialStatic; |
| 21819 | inner_fields[1].type = ira->codegen->builtin_types.entry_bool; | 21811 | inner_fields[1]->type = ira->codegen->builtin_types.entry_bool; |
| 21820 | inner_fields[1].data.x_bool = fn_param_info->is_noalias; | 21812 | inner_fields[1]->data.x_bool = fn_param_info->is_noalias; |
| 21821 | inner_fields[2].special = ConstValSpecialStatic; | 21813 | inner_fields[2]->special = ConstValSpecialStatic; |
| 21822 | inner_fields[2].type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); | 21814 | inner_fields[2]->type = get_optional_type(ira->codegen, ira->codegen->builtin_types.entry_type); |
| 21823 | | 21815 | |
| 21824 | if (arg_is_generic) | 21816 | if (arg_is_generic) |
| 21825 | inner_fields[2].data.x_optional = nullptr; | 21817 | inner_fields[2]->data.x_optional = nullptr; |
| 21826 | else { | 21818 | else { |
| 21827 | ConstExprValue *arg_type = create_const_vals(1); | 21819 | ConstExprValue *arg_type = create_const_vals(1); |
| 21828 | arg_type->special = ConstValSpecialStatic; | 21820 | arg_type->special = ConstValSpecialStatic; |
| 21829 | arg_type->type = ira->codegen->builtin_types.entry_type; | 21821 | arg_type->type = ira->codegen->builtin_types.entry_type; |
| 21830 | arg_type->data.x_type = fn_param_info->type; | 21822 | arg_type->data.x_type = fn_param_info->type; |
| 21831 | inner_fields[2].data.x_optional = arg_type; | 21823 | inner_fields[2]->data.x_optional = arg_type; |
| 21832 | } | 21824 | } |
| 21833 | | 21825 | |
| 21834 | fn_arg_val->data.x_struct.fields = inner_fields; | 21826 | fn_arg_val->data.x_struct.fields = inner_fields; |
| ... | @@ -21889,8 +21881,8 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, | ... | @@ -21889,8 +21881,8 @@ static IrInstruction *ir_analyze_instruction_type_info(IrAnalyze *ira, |
| 21889 | static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 21881 | static ConstExprValue *get_const_field(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) |
| 21890 | { | 21882 | { |
| 21891 | ensure_field_index(struct_value->type, name, field_index); | 21883 | ensure_field_index(struct_value->type, name, field_index); |
| 21892 | assert(struct_value->data.x_struct.fields[field_index].special == ConstValSpecialStatic); | 21884 | assert(struct_value->data.x_struct.fields[field_index]->special == ConstValSpecialStatic); |
| 21893 | return &struct_value->data.x_struct.fields[field_index]; | 21885 | return struct_value->data.x_struct.fields[field_index]; |
| 21894 | } | 21886 | } |
| 21895 | | 21887 | |
| 21896 | static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) | 21888 | static bool get_const_field_bool(IrAnalyze *ira, ConstExprValue *struct_value, const char *name, size_t field_index) |
| ... | @@ -22698,7 +22690,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru | ... | @@ -22698,7 +22690,7 @@ static IrInstruction *ir_analyze_instruction_from_bytes(IrAnalyze *ira, IrInstru |
| 22698 | if (!val) | 22690 | if (!val) |
| 22699 | return ira->codegen->invalid_instruction; | 22691 | return ira->codegen->invalid_instruction; |
| 22700 | | 22692 | |
| 22701 | ConstExprValue *len_val = &val->data.x_struct.fields[slice_len_index]; | 22693 | ConstExprValue *len_val = val->data.x_struct.fields[slice_len_index]; |
| 22702 | if (value_is_comptime(len_val)) { | 22694 | if (value_is_comptime(len_val)) { |
| 22703 | known_len = bigint_as_u64(&len_val->data.x_bigint); | 22695 | known_len = bigint_as_u64(&len_val->data.x_bigint); |
| 22704 | have_known_len = true; | 22696 | have_known_len = true; |
| ... | @@ -22765,17 +22757,17 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct | ... | @@ -22765,17 +22757,17 @@ static IrInstruction *ir_analyze_instruction_to_bytes(IrAnalyze *ira, IrInstruct |
| 22765 | return ira->codegen->invalid_instruction; | 22757 | return ira->codegen->invalid_instruction; |
| 22766 | | 22758 | |
| 22767 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); | 22759 | IrInstruction *result = ir_const(ira, &instruction->base, dest_slice_type); |
| 22768 | result->value.data.x_struct.fields = create_const_vals(2); | 22760 | result->value.data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 22769 | | 22761 | |
| 22770 | ConstExprValue *ptr_val = &result->value.data.x_struct.fields[slice_ptr_index]; | 22762 | ConstExprValue *ptr_val = result->value.data.x_struct.fields[slice_ptr_index]; |
| 22771 | ConstExprValue *target_ptr_val = &target_val->data.x_struct.fields[slice_ptr_index]; | 22763 | ConstExprValue *target_ptr_val = target_val->data.x_struct.fields[slice_ptr_index]; |
| 22772 | copy_const_val(ptr_val, target_ptr_val, false); | 22764 | copy_const_val(ptr_val, target_ptr_val, false); |
| 22773 | ptr_val->type = dest_ptr_type; | 22765 | ptr_val->type = dest_ptr_type; |
| 22774 | | 22766 | |
| 22775 | ConstExprValue *len_val = &result->value.data.x_struct.fields[slice_len_index]; | 22767 | ConstExprValue *len_val = result->value.data.x_struct.fields[slice_len_index]; |
| 22776 | len_val->special = ConstValSpecialStatic; | 22768 | len_val->special = ConstValSpecialStatic; |
| 22777 | len_val->type = ira->codegen->builtin_types.entry_usize; | 22769 | len_val->type = ira->codegen->builtin_types.entry_usize; |
| 22778 | ConstExprValue *target_len_val = &target_val->data.x_struct.fields[slice_len_index]; | 22770 | ConstExprValue *target_len_val = target_val->data.x_struct.fields[slice_len_index]; |
| 22779 | ZigType *elem_type = src_ptr_type->data.pointer.child_type; | 22771 | ZigType *elem_type = src_ptr_type->data.pointer.child_type; |
| 22780 | BigInt elem_size_bigint; | 22772 | BigInt elem_size_bigint; |
| 22781 | bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type)); | 22773 | bigint_init_unsigned(&elem_size_bigint, type_size(ira->codegen, elem_type)); |
| ... | @@ -23664,13 +23656,13 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -23664,13 +23656,13 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 23664 | return ira->codegen->invalid_instruction; | 23656 | return ira->codegen->invalid_instruction; |
| 23665 | } | 23657 | } |
| 23666 | | 23658 | |
| 23667 | parent_ptr = &slice_ptr->data.x_struct.fields[slice_ptr_index]; | 23659 | parent_ptr = slice_ptr->data.x_struct.fields[slice_ptr_index]; |
| 23668 | if (parent_ptr->special == ConstValSpecialUndef) { | 23660 | if (parent_ptr->special == ConstValSpecialUndef) { |
| 23669 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined")); | 23661 | ir_add_error(ira, &instruction->base, buf_sprintf("slice of undefined")); |
| 23670 | return ira->codegen->invalid_instruction; | 23662 | return ira->codegen->invalid_instruction; |
| 23671 | } | 23663 | } |
| 23672 | | 23664 | |
| 23673 | ConstExprValue *len_val = &slice_ptr->data.x_struct.fields[slice_len_index]; | 23665 | ConstExprValue *len_val = slice_ptr->data.x_struct.fields[slice_len_index]; |
| 23674 | | 23666 | |
| 23675 | switch (parent_ptr->data.x_ptr.special) { | 23667 | switch (parent_ptr->data.x_ptr.special) { |
| 23676 | case ConstPtrSpecialInvalid: | 23668 | case ConstPtrSpecialInvalid: |
| ... | @@ -23742,9 +23734,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -23742,9 +23734,9 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 23742 | | 23734 | |
| 23743 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); | 23735 | IrInstruction *result = ir_const(ira, &instruction->base, return_type); |
| 23744 | ConstExprValue *out_val = &result->value; | 23736 | ConstExprValue *out_val = &result->value; |
| 23745 | out_val->data.x_struct.fields = create_const_vals(2); | 23737 | out_val->data.x_struct.fields = alloc_const_vals_ptrs(2); |
| 23746 | | 23738 | |
| 23747 | ConstExprValue *ptr_val = &out_val->data.x_struct.fields[slice_ptr_index]; | 23739 | ConstExprValue *ptr_val = out_val->data.x_struct.fields[slice_ptr_index]; |
| 23748 | | 23740 | |
| 23749 | if (array_val) { | 23741 | if (array_val) { |
| 23750 | size_t index = abs_offset + start_scalar; | 23742 | size_t index = abs_offset + start_scalar; |
| ... | @@ -23791,7 +23783,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction | ... | @@ -23791,7 +23783,7 @@ static IrInstruction *ir_analyze_instruction_slice(IrAnalyze *ira, IrInstruction |
| 23791 | zig_panic("TODO"); | 23783 | zig_panic("TODO"); |
| 23792 | } | 23784 | } |
| 23793 | | 23785 | |
| 23794 | ConstExprValue *len_val = &out_val->data.x_struct.fields[slice_len_index]; | 23786 | ConstExprValue *len_val = out_val->data.x_struct.fields[slice_len_index]; |
| 23795 | init_const_usize(ira->codegen, len_val, end_scalar - start_scalar); | 23787 | init_const_usize(ira->codegen, len_val, end_scalar - start_scalar); |
| 23796 | | 23788 | |
| 23797 | return result; | 23789 | return result; |
| ... | @@ -25141,7 +25133,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -25141,7 +25133,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 25141 | TypeStructField *struct_field = &val->type->data.structure.fields[field_i]; | 25133 | TypeStructField *struct_field = &val->type->data.structure.fields[field_i]; |
| 25142 | if (struct_field->gen_index == SIZE_MAX) | 25134 | if (struct_field->gen_index == SIZE_MAX) |
| 25143 | continue; | 25135 | continue; |
| 25144 | ConstExprValue *field_val = &val->data.x_struct.fields[field_i]; | 25136 | ConstExprValue *field_val = val->data.x_struct.fields[field_i]; |
| 25145 | size_t offset = struct_field->offset; | 25137 | size_t offset = struct_field->offset; |
| 25146 | buf_write_value_bytes(codegen, buf + offset, field_val); | 25138 | buf_write_value_bytes(codegen, buf + offset, field_val); |
| 25147 | } | 25139 | } |
| ... | @@ -25172,7 +25164,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue | ... | @@ -25172,7 +25164,7 @@ static void buf_write_value_bytes(CodeGen *codegen, uint8_t *buf, ConstExprValue |
| 25172 | if (field->gen_index != gen_i) | 25164 | if (field->gen_index != gen_i) |
| 25173 | break; | 25165 | break; |
| 25174 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); | 25166 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); |
| 25175 | buf_write_value_bytes(codegen, child_buf, &val->data.x_struct.fields[src_i]); | 25167 | buf_write_value_bytes(codegen, child_buf, val->data.x_struct.fields[src_i]); |
| 25176 | BigInt child_val; | 25168 | BigInt child_val; |
| 25177 | bigint_read_twos_complement(&child_val, child_buf, packed_bits_size, is_big_endian, | 25169 | bigint_read_twos_complement(&child_val, child_buf, packed_bits_size, is_big_endian, |
| 25178 | false); | 25170 | false); |
| ... | @@ -25310,9 +25302,9 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25310,9 +25302,9 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 25310 | } | 25302 | } |
| 25311 | case ContainerLayoutExtern: { | 25303 | case ContainerLayoutExtern: { |
| 25312 | size_t src_field_count = val->type->data.structure.src_field_count; | 25304 | size_t src_field_count = val->type->data.structure.src_field_count; |
| 25313 | val->data.x_struct.fields = create_const_vals(src_field_count); | 25305 | val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count); |
| 25314 | for (size_t field_i = 0; field_i < src_field_count; field_i += 1) { | 25306 | for (size_t field_i = 0; field_i < src_field_count; field_i += 1) { |
| 25315 | ConstExprValue *field_val = &val->data.x_struct.fields[field_i]; | 25307 | ConstExprValue *field_val = val->data.x_struct.fields[field_i]; |
| 25316 | field_val->special = ConstValSpecialStatic; | 25308 | field_val->special = ConstValSpecialStatic; |
| 25317 | TypeStructField *struct_field = &val->type->data.structure.fields[field_i]; | 25309 | TypeStructField *struct_field = &val->type->data.structure.fields[field_i]; |
| 25318 | field_val->type = struct_field->type_entry; | 25310 | field_val->type = struct_field->type_entry; |
| ... | @@ -25327,7 +25319,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25327,7 +25319,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 25327 | } | 25319 | } |
| 25328 | case ContainerLayoutPacked: { | 25320 | case ContainerLayoutPacked: { |
| 25329 | size_t src_field_count = val->type->data.structure.src_field_count; | 25321 | size_t src_field_count = val->type->data.structure.src_field_count; |
| 25330 | val->data.x_struct.fields = create_const_vals(src_field_count); | 25322 | val->data.x_struct.fields = alloc_const_vals_ptrs(src_field_count); |
| 25331 | size_t gen_field_count = val->type->data.structure.gen_field_count; | 25323 | size_t gen_field_count = val->type->data.structure.gen_field_count; |
| 25332 | size_t gen_i = 0; | 25324 | size_t gen_i = 0; |
| 25333 | size_t src_i = 0; | 25325 | size_t src_i = 0; |
| ... | @@ -25349,7 +25341,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou | ... | @@ -25349,7 +25341,7 @@ static Error buf_read_value_bytes(IrAnalyze *ira, CodeGen *codegen, AstNode *sou |
| 25349 | src_assert(field->gen_index != SIZE_MAX, source_node); | 25341 | src_assert(field->gen_index != SIZE_MAX, source_node); |
| 25350 | if (field->gen_index != gen_i) | 25342 | if (field->gen_index != gen_i) |
| 25351 | break; | 25343 | break; |
| 25352 | ConstExprValue *field_val = &val->data.x_struct.fields[src_i]; | 25344 | ConstExprValue *field_val = val->data.x_struct.fields[src_i]; |
| 25353 | field_val->special = ConstValSpecialStatic; | 25345 | field_val->special = ConstValSpecialStatic; |
| 25354 | field_val->type = field->type_entry; | 25346 | field_val->type = field->type_entry; |
| 25355 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); | 25347 | uint32_t packed_bits_size = type_size_bits(codegen, field->type_entry); |