aboutsummaryrefslogtreecommitdiff
path: root/src/check_builtin.cpp
diff options
context:
space:
mode:
authorHarold Brenes <harold@hbrenes.com>2025-05-03 00:58:33 -0400
committerHarold Brenes <harold@hbrenes.com>2025-05-03 00:59:33 -0400
commit5f0b47c373e34c231879b2700e78ab1bbd6219b5 (patch)
tree4e9057eb33276486cdcaded3bb1db56ec4660ff7 /src/check_builtin.cpp
parent0746127654aaa980c3a35039c636b3ca1b794fc8 (diff)
Implement all checker specification for Objective-C class implementations and `objc_ivar_get` intrinsic
Diffstat (limited to 'src/check_builtin.cpp')
-rw-r--r--src/check_builtin.cpp28
1 files changed, 4 insertions, 24 deletions
diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp
index 3e531a309..024289169 100644
--- a/src/check_builtin.cpp
+++ b/src/check_builtin.cpp
@@ -391,7 +391,6 @@ gb_internal bool check_builtin_objc_procedure(CheckerContext *c, Operand *operan
case BuiltinProc_objc_ivar_get:
{
Type *self_type = nullptr;
- Type *ivar_type = nullptr;
Operand self = {};
check_expr_or_type(c, &self, ce->args[0]);
@@ -416,40 +415,21 @@ gb_internal bool check_builtin_objc_procedure(CheckerContext *c, Operand *operan
if (!(self_type->kind == Type_Named &&
self_type->Named.type_name != nullptr &&
- self_type->Named.type_name->TypeName.objc_class_name != "")) {
+ self_type->Named.type_name->TypeName.objc_class_name != "")) {
gbString t = type_to_string(self_type);
error(self.expr, "'%.*s' expected a named type with the attribute @(objc_class=<string>) , got type %s", LIT(builtin_name), t);
gb_string_free(t);
return false;
}
- if (self_type->Named.type_name->TypeName.objc_ivar == nullptr) {
+ Type *ivar_type = self_type->Named.type_name->TypeName.objc_ivar;
+ if (ivar_type == nullptr) {
gbString t = type_to_string(self_type);
error(self.expr, "'%.*s' requires that type %s have the attribute @(objc_ivar=<ivar_type_name>).", LIT(builtin_name), t);
gb_string_free(t);
return false;
}
- Operand ivar = {};
- check_expr_or_type(c, &ivar, ce->args[1]);
- if (ivar.mode == Addressing_Type) {
- ivar_type = ivar.type;
- } else {
- return false;
- }
-
- if (self_type->Named.type_name->TypeName.objc_ivar != ivar_type) {
- gbString name_self = type_to_string(self_type);
- gbString name_expected = type_to_string(self_type->Named.type_name->TypeName.objc_ivar);
- gbString name_given = type_to_string(ivar_type);
- error(self.expr, "'%.*s' ivar type %s does not match @objc_ivar type %s on Objective-C class %s.",
- LIT(builtin_name), name_given, name_expected, name_self);
- gb_string_free(name_self);
- gb_string_free(name_expected);
- gb_string_free(name_given);
- return false;
- }
-
if (type_hint != nullptr && type_hint->kind == Type_Pointer && type_hint->Pointer.elem == ivar_type) {
operand->type = type_hint;
} else {
@@ -457,8 +437,8 @@ gb_internal bool check_builtin_objc_procedure(CheckerContext *c, Operand *operan
}
operand->mode = Addressing_Value;
-
return true;
+
} break;
}
}