mirror of
https://github.com/odin-lang/Odin.git
synced 2026-08-14 09:44:26 +00:00
Merge pull request #7270 from corleypc/soa-array-elem-indexing-fix
Fixes chain indexing for array elements in soa containers
This commit is contained in:
@@ -3004,8 +3004,13 @@ gb_internal void check_unary_expr(CheckerContext *c, Operand *o, Token op, Ast *
|
||||
if (ast_node_expect(index_expr, Ast_IndexExpr)) {
|
||||
ast_node(ie, IndexExpr, index_expr);
|
||||
Type *soa_type = type_deref(type_of_expr(ie->expr));
|
||||
GB_ASSERT(is_type_soa_struct(soa_type));
|
||||
o->type = alloc_type_soa_pointer(soa_type);
|
||||
if (is_type_soa_struct(soa_type)) {
|
||||
o->type = alloc_type_soa_pointer(soa_type);
|
||||
} else {
|
||||
// &soa[i][j]
|
||||
GB_ASSERT_MSG(is_type_array(soa_type), "%s", type_to_string(soa_type));
|
||||
o->type = alloc_type_pointer(o->type);
|
||||
}
|
||||
} else {
|
||||
o->type = alloc_type_pointer(o->type);
|
||||
}
|
||||
@@ -9167,7 +9172,11 @@ gb_internal bool check_set_index_data(Operand *o, Type *t, bool indirection, i64
|
||||
if (indirection) {
|
||||
o->mode = Addressing_Variable;
|
||||
} else if (o->mode != Addressing_Variable &&
|
||||
o->mode != Addressing_SoaVariable &&
|
||||
o->mode != Addressing_Constant) {
|
||||
// NOTE: an #soa element of array type keeps SoaVariable, so soa[i][j] stays an
|
||||
// lvalue. Its components are one per lane rather than contiguous, but a single
|
||||
// component still has a real address, the same one soa[i].y denotes.
|
||||
o->mode = Addressing_Value;
|
||||
}
|
||||
o->type = t->Array.elem;
|
||||
|
||||
Reference in New Issue
Block a user