diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index 4e8eed1fc..96feb6701 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -1789,7 +1789,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 elem = alloc_type_struct(); elem->Struct.scope = s; elem->Struct.fields = slice_from_array(fields); - elem->Struct.tags = slice_make(permanent_allocator(), fields.count); + elem->Struct.tags = gb_alloc_array(permanent_allocator(), String, fields.count); elem->Struct.node = dummy_node_struct; type_set_offsets(elem); } @@ -1939,7 +1939,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 Type *old_array = base_type(elem); soa_struct = alloc_type_struct(); soa_struct->Struct.fields = slice_make(heap_allocator(), cast(isize)old_array->Array.count); - soa_struct->Struct.tags = slice_make(heap_allocator(), cast(isize)old_array->Array.count); + soa_struct->Struct.tags = gb_alloc_array(permanent_allocator(), String, cast(isize)old_array->Array.count); soa_struct->Struct.node = operand->expr; soa_struct->Struct.soa_kind = StructSoa_Fixed; soa_struct->Struct.soa_elem = elem; @@ -1972,7 +1972,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 Type *old_struct = base_type(elem); soa_struct = alloc_type_struct(); soa_struct->Struct.fields = slice_make(heap_allocator(), old_struct->Struct.fields.count); - soa_struct->Struct.tags = slice_make(heap_allocator(), old_struct->Struct.tags.count); + soa_struct->Struct.tags = gb_alloc_array(permanent_allocator(), String, old_struct->Struct.fields.count); soa_struct->Struct.node = operand->expr; soa_struct->Struct.soa_kind = StructSoa_Fixed; soa_struct->Struct.soa_elem = elem; diff --git a/src/check_type.cpp b/src/check_type.cpp index 55c931ab4..ccd426322 100644 --- a/src/check_type.cpp +++ b/src/check_type.cpp @@ -92,7 +92,7 @@ bool does_field_type_allow_using(Type *t) { return false; } -void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields, Slice *tags, Slice const ¶ms, +void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields, String **tags, Slice const ¶ms, isize init_field_capacity, Type *struct_type, String context) { auto fields_array = array_make(heap_allocator(), 0, init_field_capacity); auto tags_array = array_make(heap_allocator(), 0, init_field_capacity); @@ -184,7 +184,7 @@ void check_struct_fields(CheckerContext *ctx, Ast *node, Slice *fields } *fields = slice_from_array(fields_array); - *tags = slice_from_array(tags_array); + *tags = tags_array.data; } @@ -2234,7 +2234,7 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el soa_struct = alloc_type_struct(); soa_struct->Struct.fields = slice_make(heap_allocator(), field_count+extra_field_count); - soa_struct->Struct.tags = slice_make(heap_allocator(), field_count+extra_field_count); + soa_struct->Struct.tags = gb_alloc_array(heap_allocator(), String, field_count+extra_field_count); soa_struct->Struct.node = array_typ_expr; soa_struct->Struct.soa_kind = soa_kind; soa_struct->Struct.soa_elem = elem; @@ -2249,7 +2249,7 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el soa_struct = alloc_type_struct(); soa_struct->Struct.fields = slice_make(heap_allocator(), field_count+extra_field_count); - soa_struct->Struct.tags = slice_make(heap_allocator(), field_count+extra_field_count); + soa_struct->Struct.tags = gb_alloc_array(heap_allocator(), String, field_count+extra_field_count); soa_struct->Struct.node = array_typ_expr; soa_struct->Struct.soa_kind = soa_kind; soa_struct->Struct.soa_elem = elem; @@ -2291,11 +2291,10 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el Type *old_struct = base_type(elem); field_count = old_struct->Struct.fields.count; - GB_ASSERT(old_struct->Struct.tags.count == field_count); soa_struct = alloc_type_struct(); soa_struct->Struct.fields = slice_make(heap_allocator(), field_count+extra_field_count); - soa_struct->Struct.tags = slice_make(heap_allocator(), field_count+extra_field_count); + soa_struct->Struct.tags = gb_alloc_array(heap_allocator(), String, field_count+extra_field_count); soa_struct->Struct.node = array_typ_expr; soa_struct->Struct.soa_kind = soa_kind; soa_struct->Struct.soa_elem = elem; diff --git a/src/llvm_backend_type.cpp b/src/llvm_backend_type.cpp index f5665c718..f17b8df6a 100644 --- a/src/llvm_backend_type.cpp +++ b/src/llvm_backend_type.cpp @@ -721,7 +721,7 @@ void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info da lb_emit_store(p, offset, lb_const_int(m, t_uintptr, foffset)); lb_emit_store(p, is_using, lb_const_bool(m, t_bool, (f->flags&EntityFlag_Using) != 0)); - if (t->Struct.tags.count > 0) { + if (t->Struct.tags != nullptr) { String tag_string = t->Struct.tags[source_index]; if (tag_string.len > 0) { lbValue tag_ptr = lb_emit_ptr_offset(p, memory_tags, index); diff --git a/src/types.cpp b/src/types.cpp index 570851124..23834bfc1 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -130,7 +130,7 @@ enum StructSoaKind : u8 { struct TypeStruct { Slice fields; - Slice tags; + String * tags; // count == fields.count i64 * offsets; // count == fields.count Ast * node; @@ -140,7 +140,6 @@ struct TypeStruct { Type * polymorphic_params; // Type_Tuple Type * polymorphic_parent; - Type * soa_elem; i32 soa_count; StructSoaKind soa_kind; @@ -2174,12 +2173,6 @@ bool are_types_identical(Type *x, Type *y) { if (xf_is_using ^ yf_is_using) { return false; } - if (x->Struct.tags.count != y->Struct.tags.count) { - return false; - } - if (x->Struct.tags.count > 0 && x->Struct.tags[i] != y->Struct.tags[i]) { - return false; - } } return true; }