From 32c7e817450e8f089eec81a147d20b919db088ff Mon Sep 17 00:00:00 2001 From: gingerBill Date: Mon, 14 Feb 2022 18:32:10 +0000 Subject: [PATCH] Use `objc_allocateClassPair` for `intrinsics.objc_register_class` --- core/runtime/procs_darwin.odin | 1 + src/check_builtin.cpp | 1 + src/llvm_backend_utility.cpp | 8 +++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/runtime/procs_darwin.odin b/core/runtime/procs_darwin.odin index 79fd777d7..b54a28dcc 100644 --- a/core/runtime/procs_darwin.odin +++ b/core/runtime/procs_darwin.odin @@ -12,6 +12,7 @@ objc_SEL :: ^intrinsics.objc_selector foreign Foundation { objc_lookUpClass :: proc "c" (name: cstring) -> objc_Class --- sel_registerName :: proc "c" (name: cstring) -> objc_SEL --- + objc_allocateClassPair :: proc "c" (superclass: objc_Class, name: cstring, extraBytes: uint) --- objc_msgSend :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) --- objc_msgSend_fpret :: proc "c" (self: objc_id, op: objc_SEL, #c_vararg args: ..any) -> f64 --- diff --git a/src/check_builtin.cpp b/src/check_builtin.cpp index a6b1759f5..c7ada8e03 100644 --- a/src/check_builtin.cpp +++ b/src/check_builtin.cpp @@ -225,6 +225,7 @@ void add_objc_proc_type(CheckerContext *c, Ast *call, Type *return_type, Slice(permanent_allocator(), 1); - args[0] = lb_const_value(m, t_cstring, exact_value_string(name)); - lbValue ptr = lb_emit_runtime_call(p, "objc_lookUpClass", args); + auto args = array_make(permanent_allocator(), 3); + args[0] = lb_const_nil(m, t_objc_Class); + args[1] = lb_const_nil(m, t_objc_Class); + args[2] = lb_const_int(m, t_uint, 0); + lbValue ptr = lb_emit_runtime_call(p, "objc_allocateClassPair", args); lb_addr_store(p, dst, ptr); return lb_addr_load(p, dst);