Skip to content

Commit

Permalink
Fix super context calls
Browse files Browse the repository at this point in the history
  • Loading branch information
LunaTheFoxgirl committed Nov 28, 2024
1 parent c9bed7a commit 7423d0a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions gen/objcgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ LLConstant *ObjCState::getClassRoTable(ClassDeclaration *decl) {
LLGlobalVariable *protocolList = nullptr;
LLGlobalVariable *methodList = nullptr;

if (auto baseMethods = createMethodList(decl, false)) {
if (auto baseMethods = createMethodList(decl)) {
methodList = getOrCreate(objcGetClassMethodListSymbol(name, meta), baseMethods->getType(), OBJC_SECNAME_CONST);
methodList->setInitializer(baseMethods);
}
Expand Down Expand Up @@ -569,7 +569,7 @@ LLConstant *ObjCState::getClassRef(ClassDeclaration *decl) {
return it->second;
}

auto retval = getOrCreate("OBJC_CLASSLIST_REFERENCES_$_", getOpaquePtrType(), OBJC_SECNAME_CLASSREFS);
auto retval = makeGlobal("OBJC_CLASSLIST_REFERENCES_$_", getOpaquePtrType(), OBJC_SECNAME_CLASSREFS);
classRefs[className] = retval;
this->retain(retval);
return retval;
Expand Down
4 changes: 2 additions & 2 deletions gen/objcgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ObjCState {
// used in method lists.
ObjcMap<FuncDeclaration *, ObjcMethodInfo> methods;
LLConstant *createMethodInfo(FuncDeclaration *decl);
LLConstant *createMethodList(ClassDeclaration *decl, bool optional);
LLConstant *createMethodList(ClassDeclaration *decl, bool optional = false);

// class_t and class_ro_t generation.
ObjcMap<ClassDeclaration *, ObjcClassInfo> classes;
Expand All @@ -200,7 +200,7 @@ class ObjCState {
LLConstant *createProtocolList(ClassDeclaration *decl);

// Private helpers
ObjcList<FuncDeclaration *> getMethodsForType(ClassDeclaration *decl, bool optional);
ObjcList<FuncDeclaration *> getMethodsForType(ClassDeclaration *decl, bool optional = false);

ObjcList<LLConstant *> retainedSymbols;
void retain(LLConstant *symbol);
Expand Down
7 changes: 4 additions & 3 deletions gen/tocall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -738,16 +738,17 @@ class ImplicitArgumentsBuilder {
if (objccall && directcall) {

// ... or a Objective-c direct call argument
if (auto parentfd = dfnval->func->isFuncDeclaration()) {
if (auto cls = parentfd->parent->isClassDeclaration()) {
if (auto func = dfnval->func->isFuncDeclaration()) {
if (auto klass = func->isThis()->isClassDeclaration()) {

// Create obj_super struct with (this, <class ref>)
auto obj_super = DtoAggrPair(
DtoBitCast(dfnval->vthis, argtype),
gIR->objc.deref(cls, getOpaquePtrType()),
gIR->objc.deref(klass, getOpaquePtrType()),
"super"
);


// Allocate and store obj_super struct into a new variable.
auto clsaddr = DtoRawAlloca(obj_super->getType(), 16, "super");
DtoStore(obj_super, clsaddr);
Expand Down

0 comments on commit 7423d0a

Please sign in to comment.