Correct #soa type creation

This commit is contained in:
gingerBill
2021-06-08 11:23:23 +01:00
parent 16eaa17ed9
commit e79fb68291

View File

@@ -2235,11 +2235,17 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el
};
for (i64 i = 0; i < old_array->Array.count; i++) {
Type *array_type = alloc_type_array(old_array->Array.elem, count);
Type *field_type = nullptr;
if (soa_kind == StructSoa_Fixed) {
GB_ASSERT(count >= 0);
field_type = alloc_type_array(old_array->Array.elem, count);
} else {
field_type = alloc_type_pointer(old_array->Array.elem);
}
Token token = {};
token.string = params_xyzw[i];
Entity *new_field = alloc_entity_field(scope, token, array_type, false, cast(i32)i);
Entity *new_field = alloc_entity_field(scope, token, field_type, false, cast(i32)i);
soa_struct->Struct.fields[i] = new_field;
add_entity(ctx->checker, scope, nullptr, new_field);
add_entity_use(ctx, nullptr, new_field);
@@ -2266,8 +2272,14 @@ Type *make_soa_struct_internal(CheckerContext *ctx, Ast *array_typ_expr, Ast *el
for_array(i, old_struct->Struct.fields) {
Entity *old_field = old_struct->Struct.fields[i];
if (old_field->kind == Entity_Variable) {
Type *array_type = alloc_type_array(old_field->type, count);
Entity *new_field = alloc_entity_field(scope, old_field->token, array_type, false, old_field->Variable.field_src_index);
Type *field_type = nullptr;
if (soa_kind == StructSoa_Fixed) {
GB_ASSERT(count >= 0);
field_type = alloc_type_array(old_field->type, count);
} else {
field_type = alloc_type_pointer(old_field->type);
}
Entity *new_field = alloc_entity_field(scope, old_field->token, field_type, false, old_field->Variable.field_src_index);
soa_struct->Struct.fields[i] = new_field;
add_entity(ctx->checker, scope, nullptr, new_field);
add_entity_use(ctx, nullptr, new_field);