From 44e0e96612fe7f08361ee3014d1230ccd9a2e39d Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 19 Nov 2019 23:54:36 +0000 Subject: Prepare SOA Struct code for slices and dynamic arrays *to be implemented* --- src/check_expr.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 22f27939e..85ac17300 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -3631,10 +3631,13 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 type = t_untyped_integer; } else if (is_type_struct(op_type)) { Type *bt = base_type(op_type); - if (bt->Struct.is_soa) { + if (bt->Struct.soa_kind == StructSoa_Fixed) { mode = Addressing_Constant; value = exact_value_i64(bt->Struct.soa_count); type = t_untyped_integer; + } else if ((bt->Struct.soa_kind == StructSoa_Slice && id == BuiltinProc_len) || + bt->Struct.soa_kind == StructSoa_Dynamic) { + mode = Addressing_Value; } } @@ -4801,7 +4804,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 soa_struct->Struct.fields = array_make(heap_allocator(), old_array->Array.count); soa_struct->Struct.tags = array_make(heap_allocator(), old_array->Array.count); soa_struct->Struct.node = operand->expr; - soa_struct->Struct.is_soa = true; + soa_struct->Struct.soa_kind = StructSoa_Fixed; soa_struct->Struct.soa_elem = elem; soa_struct->Struct.soa_count = count; @@ -4834,7 +4837,7 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 soa_struct->Struct.fields = array_make(heap_allocator(), old_struct->Struct.fields.count); soa_struct->Struct.tags = array_make(heap_allocator(), old_struct->Struct.tags.count); soa_struct->Struct.node = operand->expr; - soa_struct->Struct.is_soa = true; + soa_struct->Struct.soa_kind = StructSoa_Fixed; soa_struct->Struct.soa_elem = elem; soa_struct->Struct.soa_count = count; @@ -6778,8 +6781,10 @@ bool check_set_index_data(Operand *o, Type *t, bool indirection, i64 *max_count) } return true; case Type_Struct: - if (t->Struct.is_soa) { - *max_count = t->Struct.soa_count; + if (t->Struct.soa_kind != StructSoa_None) { + if (t->Struct.soa_kind == StructSoa_Fixed) { + *max_count = t->Struct.soa_count; + } o->type = t->Struct.soa_elem; if (o->mode == Addressing_SoaVariable || o->mode == Addressing_Variable) { o->mode = Addressing_SoaVariable; -- cgit v1.2.3