diff options
| author | gingerBill <bill@gingerbill.org> | 2021-03-24 14:31:44 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-03-24 14:31:44 +0000 |
| commit | 2ec3326653cfea2ce846305966f8eb5e03c62595 (patch) | |
| tree | 839d6d9d4001574dea9f01352693a8e3571f94cd /src/check_stmt.cpp | |
| parent | bec42e8dd387a6ba2d2543a1fc422a0974f2ae3a (diff) | |
Support #soa array iteration in a `for in` loop for `-llvm-api` backend only
Diffstat (limited to 'src/check_stmt.cpp')
| -rw-r--r-- | src/check_stmt.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp index 61472f97f..46eb1d177 100644 --- a/src/check_stmt.cpp +++ b/src/check_stmt.cpp @@ -1661,6 +1661,7 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { auto entities = array_make<Entity *>(temporary_allocator(), 0, 2); bool is_map = false; bool use_by_reference_for_value = false; + bool is_soa = false; Ast *expr = unparen_expr(rs->expr); @@ -1775,7 +1776,12 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { case Type_Struct: if (t->Struct.soa_kind != StructSoa_None) { - error(operand.expr, "#soa structures do not yet support for in loop iteration"); + is_soa = true; + array_add(&vals, t->Struct.soa_elem); + array_add(&vals, t_int); + if (!build_context.use_llvm_api) { + error(operand.expr, "#soa structures do not yet support for in loop iteration"); + } } break; } @@ -1836,6 +1842,11 @@ void check_stmt_internal(CheckerContext *ctx, Ast *node, u32 flags) { entity->flags &= ~EntityFlag_Value; } } + if (is_soa) { + if (i == 0) { + entity->flags |= EntityFlag_SoaPtrField; + } + } add_entity_definition(&ctx->checker->info, name, entity); } else { |