aboutsummaryrefslogtreecommitdiff
path: root/src/check_expr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/check_expr.cpp')
-rw-r--r--src/check_expr.cpp14
1 files changed, 14 insertions, 0 deletions
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) {