From 667aa3671e585fb348a2e05ddf0992c637b40ec4 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 1 Mar 2021 17:54:49 +0000 Subject: Fix Addressing for SOA on store; Add intrinsics.type_struct_field_count(T) --- src/check_expr.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/check_expr.cpp') diff --git a/src/check_expr.cpp b/src/check_expr.cpp index f3a042bd9..a31f1c871 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -5768,6 +5768,20 @@ bool check_builtin_procedure(CheckerContext *c, Operand *operand, Ast *call, i32 } break; + case BuiltinProc_type_struct_field_count: + operand->value = exact_value_i64(0); + if (operand->mode != Addressing_Type) { + error(operand->expr, "Expected a struct type for '%.*s'", LIT(builtin_name)); + } else if (!is_type_struct(operand->type)) { + error(operand->expr, "Expected a struct type for '%.*s'", LIT(builtin_name)); + } else { + Type *bt = base_type(operand->type); + operand->value = exact_value_i64(bt->Struct.fields.count); + } + operand->mode = Addressing_Constant; + operand->type = t_untyped_integer; + break; + case BuiltinProc_type_proc_parameter_count: operand->value = exact_value_i64(0); if (operand->mode != Addressing_Type) { -- cgit v1.2.3