Extend native class API to support full AerScript declarations
Build / AerScript (push) Successful in 18s
Build / AerScript (push) Successful in 18s
This commit is contained in:
+173
-23
@@ -147,6 +147,33 @@ PH7_PRIVATE ph7_class_method *PH7_NewClassMethod(ph7_vm *pVm, ph7_class *pClass,
|
||||
pName->nByte, VM_FUNC_CLASS_METHOD, pClass);
|
||||
return pMeth;
|
||||
}
|
||||
/* Declaration rules shared by the compiler and native metadata preparation. */
|
||||
PH7_PRIVATE sxi32 PH7_ClassConstantProtection(ph7_class *pClass, sxi32 iProtection) {
|
||||
return pClass->iFlags & PH7_CLASS_INTERFACE ? PH7_CLASS_PROT_PUBLIC : iProtection;
|
||||
}
|
||||
PH7_PRIVATE const char *PH7_ClassMethodDeclarationError(ph7_class *pClass,
|
||||
const SyString *pName, sxu32 nType, sxi32 iProtection, sxi32 iFlags) {
|
||||
if((pClass->iFlags & PH7_CLASS_INTERFACE) &&
|
||||
(iProtection != PH7_CLASS_PROT_PUBLIC || iFlags != 0)) {
|
||||
return "Invalid interface method declaration '%z::%z()'";
|
||||
}
|
||||
if(((pName->nByte == sizeof("__construct") - 1 &&
|
||||
SyMemcmp(pName->zString, "__construct", sizeof("__construct") - 1) == 0) ||
|
||||
(pName->nByte == sizeof("__destruct") - 1 &&
|
||||
SyMemcmp(pName->zString, "__destruct", sizeof("__destruct") - 1) == 0)) &&
|
||||
nType != MEMOBJ_VOID) {
|
||||
return "Method '%z::%z()' must return void";
|
||||
}
|
||||
if(iFlags & PH7_CLASS_ATTR_VIRTUAL) {
|
||||
if(iProtection == PH7_CLASS_PROT_PRIVATE) {
|
||||
return "Virtual method '%z::%z()' cannot be declared private";
|
||||
}
|
||||
if((pClass->iFlags & PH7_CLASS_VIRTUAL) == 0) {
|
||||
return "A method '%z::%z()' cannot be declared as virtual in non-virtual class";
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*
|
||||
* Check if the given name have a class method associated with it.
|
||||
* Return the desired method [i.e: ph7_class_method instance] on success. NULL otherwise.
|
||||
@@ -258,6 +285,15 @@ static sxi32 ClassIsDescendant(ph7_class *pClass, ph7_class *pAncestor) {
|
||||
* inheritance chain, but a private declaration cannot narrow a visible member
|
||||
* inherited from a base.
|
||||
*/
|
||||
/* Preparation never runs user code or emits fatal language diagnostics.
|
||||
* Callers return/clean up after every diagnostic in both modes. */
|
||||
#define ClassError(VM, ...) ((VM)->pClassJournal ? SXERR_INVALID : \
|
||||
PH7_VmThrowError((VM), PH7_CTX_ERR, __VA_ARGS__))
|
||||
typedef struct ClassJournalEntry {
|
||||
ph7_class *pClass;
|
||||
SySet aBase, aMro;
|
||||
sxi32 iState;
|
||||
} ClassJournalEntry;
|
||||
static sxi32 ClassValidateAttributes(ph7_vm *pVm, ph7_class *pClass) {
|
||||
SyHashEntry *pEntry, *pOtherEntry;
|
||||
sxu32 i, j;
|
||||
@@ -295,8 +331,9 @@ static sxi32 ClassValidateAttributes(ph7_vm *pVm, ph7_class *pClass) {
|
||||
SyString sAttr, sOther;
|
||||
PH7_ClassAttrDiagnosticName(pAttr->pClass, pAttr->iFlags, &pAttr->sName, zAttr, sizeof(zAttr), &sAttr);
|
||||
PH7_ClassAttrDiagnosticName(pOther->pClass, pOther->iFlags, &pOther->sName, zOther, sizeof(zOther), &sOther);
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Class attribute '%z' conflicts with '%z' in class '%z'",
|
||||
ClassError(pVm, "Class attribute '%z' conflicts with '%z' in class '%z'",
|
||||
&sAttr, &sOther, &pClass->sName);
|
||||
return SXERR_INVALID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,14 +385,18 @@ static sxi32 ClassValidateMethods(ph7_vm *pVm, ph7_class *pClass) {
|
||||
continue;
|
||||
}
|
||||
if(pOther->iFlags & PH7_CLASS_ATTR_FINAL) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Cannot overwrite final method '%z:%z()' inside child class '%z'", &pOther->sFunc.pClass->sName, &pOther->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Cannot overwrite final method '%z:%z()' inside child class '%z'", &pOther->sFunc.pClass->sName, &pOther->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
/* Visibility involving an unrelated virtual requirement is checked
|
||||
* against the effective implementation below, not a hidden method. */
|
||||
if(pMeth->iProtection > pOther->iProtection &&
|
||||
(k < SySetUsed(&pMeth->sFunc.pClass->aMro) ||
|
||||
!((pMeth->iFlags | pOther->iFlags) & PH7_CLASS_ATTR_VIRTUAL))) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Cannot narrow visibility of method '%z::%z()' inside class '%z'", &pOther->sFunc.pClass->sName, &pOther->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Cannot narrow visibility of method '%z::%z()' inside class '%z'", &pOther->sFunc.pClass->sName, &pOther->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
/* Check real overrides and consistency between requirements here.
|
||||
* Hidden unrelated implementations do not impose contracts. */
|
||||
@@ -363,7 +404,9 @@ static sxi32 ClassValidateMethods(ph7_vm *pVm, ph7_class *pClass) {
|
||||
((pMeth->iFlags & pOther->iFlags) & PH7_CLASS_ATTR_VIRTUAL)) &&
|
||||
(pMeth->sFunc.nType != pOther->sFunc.nType ||
|
||||
((pMeth->iFlags ^ pOther->iFlags) & PH7_CLASS_ATTR_STATIC))) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Incompatible method contract '%z::%z()' inside class '%z'", &pOther->sFunc.pClass->sName, &pOther->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Incompatible method contract '%z::%z()' inside class '%z'", &pOther->sFunc.pClass->sName, &pOther->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
if(!(pMeth->iFlags & PH7_CLASS_ATTR_VIRTUAL)) {
|
||||
@@ -380,16 +423,22 @@ static sxi32 ClassValidateMethods(ph7_vm *pVm, ph7_class *pClass) {
|
||||
}
|
||||
}
|
||||
if(pImpl && pImpl->iProtection > pMeth->iProtection) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Cannot narrow visibility of method '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Cannot narrow visibility of method '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
/* Every requirement uses the same first concrete C3 declaration, not
|
||||
* a later implementation selected for its compatible contract. */
|
||||
if(pImpl && (pImpl->sFunc.nType != pMeth->sFunc.nType ||
|
||||
((pImpl->iFlags ^ pMeth->iFlags) & PH7_CLASS_ATTR_STATIC))) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Incompatible method contract '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Incompatible method contract '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
if(!pImpl && !(pClass->iFlags & PH7_CLASS_VIRTUAL)) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Virtual method '%z::%z()' must be defined inside child class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Virtual method '%z::%z()' must be defined inside child class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
done:
|
||||
@@ -423,12 +472,12 @@ PH7_PRIVATE sxi32 PH7_ClassCollectInterfaces(ph7_vm *pVm, ph7_class *pClass, SyS
|
||||
SyString *pName = (SyString *)SySetAt(pNames, j);
|
||||
pInterface = PH7_VmExtractClass(pVm, pName->zString, pName->nByte, FALSE);
|
||||
if(pInterface == 0) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, (pOwner->iFlags & PH7_CLASS_INTERFACE) ?
|
||||
ClassError(pVm, (pOwner->iFlags & PH7_CLASS_INTERFACE) ?
|
||||
"Call to non-existent base interface '%z'" : "Call to non-existent interface '%z'", pName);
|
||||
return SXERR_INVALID;
|
||||
}
|
||||
if(!(pInterface->iFlags & PH7_CLASS_INTERFACE)) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, (pOwner->iFlags & PH7_CLASS_INTERFACE) ?
|
||||
ClassError(pVm, (pOwner->iFlags & PH7_CLASS_INTERFACE) ?
|
||||
"Interface '%z' cannot inherit from class '%z'" : "Class '%z' cannot implement a class '%z'", &pOwner->sName, pName);
|
||||
return SXERR_INVALID;
|
||||
}
|
||||
@@ -485,7 +534,9 @@ static sxi32 ClassValidateInterfaces(ph7_vm *pVm, ph7_class *pClass) {
|
||||
pOther = *(ph7_class_method **)SySetAt(&sRequired, j);
|
||||
if(PH7_VmSameSignature(&pMeth->sFunc, &pOther->sFunc) &&
|
||||
pMeth->sFunc.nType != pOther->sFunc.nType) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Conflicting interface contract '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Conflicting interface contract '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -505,7 +556,9 @@ static sxi32 ClassValidateInterfaces(ph7_vm *pVm, ph7_class *pClass) {
|
||||
if(!pImpl || (pOther->iFlags & PH7_CLASS_ATTR_VIRTUAL)) {
|
||||
if(pOther->iProtection != PH7_CLASS_PROT_PUBLIC ||
|
||||
(pOther->iFlags & PH7_CLASS_ATTR_STATIC) || pOther->sFunc.nType != pMeth->sFunc.nType) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Incompatible interface implementation '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Incompatible interface implementation '%z::%z()' inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
if(!(pOther->iFlags & PH7_CLASS_ATTR_VIRTUAL)) {
|
||||
pImpl = pOther;
|
||||
@@ -515,7 +568,9 @@ static sxi32 ClassValidateInterfaces(ph7_vm *pVm, ph7_class *pClass) {
|
||||
}
|
||||
}
|
||||
if(!pImpl && !(pClass->iFlags & PH7_CLASS_VIRTUAL)) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Method '%z:%z()' must be defined inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
ClassError(pVm, "Method '%z:%z()' must be defined inside class '%z'", &pMeth->sFunc.pClass->sName, &pMeth->sFunc.sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
done:
|
||||
@@ -544,9 +599,19 @@ PH7_PRIVATE sxi32 PH7_ClassBuildMro(ph7_vm *pVm, ph7_class *pClass) {
|
||||
return SXRET_OK;
|
||||
}
|
||||
if(pClass->iMroState == 1) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Inheritance cycle involving class '%z'", &pClass->sName);
|
||||
ClassError(pVm, "Inheritance cycle involving class '%z'", &pClass->sName);
|
||||
return SXERR_INVALID;
|
||||
}
|
||||
if(pVm->pClassJournal) {
|
||||
ClassJournalEntry sEntry;
|
||||
sEntry.pClass = pClass;
|
||||
sEntry.aBase = pClass->aBase;
|
||||
sEntry.aMro = pClass->aMro;
|
||||
sEntry.iState = pClass->iMroState;
|
||||
if(SySetPut(pVm->pClassJournal, &sEntry) != SXRET_OK) {
|
||||
return SXERR_MEM;
|
||||
}
|
||||
}
|
||||
/* Set before resolution, which can reenter through an autoloader. */
|
||||
pClass->iMroState = 1;
|
||||
SySetInit(&sBase, &pVm->sAllocator, sizeof(ph7_class *));
|
||||
@@ -556,17 +621,27 @@ PH7_PRIVATE sxi32 PH7_ClassBuildMro(ph7_vm *pVm, ph7_class *pClass) {
|
||||
SyString *pName = (SyString *)SySetAt(&pClass->pInfo->sExtends, i);
|
||||
pBase = PH7_VmExtractClass(pVm, pName->zString, pName->nByte, FALSE);
|
||||
if(pBase == 0) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Call to non-existent base class '%z'", pName);
|
||||
ClassError(pVm, "Call to non-existent base class '%z'", pName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
} else if(pBase == pClass) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Class '%z' cannot inherit from itself", &pClass->sName);
|
||||
ClassError(pVm, "Class '%z' cannot inherit from itself", &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
} else if(pBase->iFlags & PH7_CLASS_INTERFACE) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Class '%z' cannot inherit from interface '%z'", &pClass->sName, pName);
|
||||
ClassError(pVm, "Class '%z' cannot inherit from interface '%z'", &pClass->sName, pName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
} else if(pBase->iFlags & PH7_CLASS_FINAL) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Class '%z' cannot inherit from final class '%z'", &pClass->sName, pName);
|
||||
ClassError(pVm, "Class '%z' cannot inherit from final class '%z'", &pClass->sName, pName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
for(j = 0; j < SySetUsed(&sBase); j++) {
|
||||
if(*(ph7_class **)SySetAt(&sBase, j) == pBase) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Duplicate base class '%z' in class '%z'", &pBase->sName, &pClass->sName);
|
||||
ClassError(pVm, "Duplicate base class '%z' in class '%z'", &pBase->sName, &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
rc = SySetPut(&sBase, &pBase);
|
||||
@@ -620,7 +695,7 @@ PH7_PRIVATE sxi32 PH7_ClassBuildMro(ph7_vm *pVm, ph7_class *pClass) {
|
||||
break;
|
||||
}
|
||||
if(pCandidate == 0) {
|
||||
PH7_VmThrowError(pVm, PH7_CTX_ERR, "Inconsistent C3 hierarchy for class '%z'", &pClass->sName);
|
||||
ClassError(pVm, "Inconsistent C3 hierarchy for class '%z'", &pClass->sName);
|
||||
rc = SXERR_INVALID;
|
||||
goto done;
|
||||
}
|
||||
@@ -636,8 +711,10 @@ PH7_PRIVATE sxi32 PH7_ClassBuildMro(ph7_vm *pVm, ph7_class *pClass) {
|
||||
}
|
||||
}
|
||||
/* Publish only a complete linearization. */
|
||||
SySetRelease(&pClass->aBase);
|
||||
SySetRelease(&pClass->aMro);
|
||||
if(pVm->pClassJournal == 0) {
|
||||
SySetRelease(&pClass->aBase);
|
||||
SySetRelease(&pClass->aMro);
|
||||
}
|
||||
pClass->aBase = sBase;
|
||||
pClass->aMro = sMro;
|
||||
done:
|
||||
@@ -783,7 +860,10 @@ PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub, ph7_class *pBase) {
|
||||
SyString *pName;
|
||||
sxi32 rc;
|
||||
/* Install in the derived hashtable */
|
||||
SyHashInsert(&pSub->hDerived, (const void *)SyStringData(&pBase->sName), SyStringLength(&pBase->sName), pBase);
|
||||
rc = SyHashInsert(&pSub->hDerived, (const void *)SyStringData(&pBase->sName), SyStringLength(&pBase->sName), pBase);
|
||||
if(rc != SXRET_OK) {
|
||||
return rc;
|
||||
}
|
||||
SyHashResetLoopCursor(&pBase->hAttr);
|
||||
/* Copy constants */
|
||||
while((pEntry = SyHashGetNextEntry(&pBase->hAttr)) != 0) {
|
||||
@@ -824,6 +904,71 @@ PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub, ph7_class *pBase) {
|
||||
/* All done */
|
||||
return SXRET_OK;
|
||||
}
|
||||
/* Validate privately with the ordinary graph algorithms, restoring every
|
||||
* borrowed base before returning. Only the new declaration retains state. */
|
||||
PH7_PRIVATE sxi32 PH7_ClassPrepareNative(ph7_vm *pVm, ph7_class *pClass) {
|
||||
SySet sJournal, sInterfaces;
|
||||
ClassJournalEntry *pEntry;
|
||||
sxi32 rc, bDeferred;
|
||||
sxu32 i;
|
||||
SySetInit(&sJournal, &pVm->sAllocator, sizeof(ClassJournalEntry));
|
||||
SySetInit(&sInterfaces, &pVm->sAllocator, sizeof(ph7_class *));
|
||||
pVm->pClassJournal = &sJournal;
|
||||
pVm->pStagedClass = pClass;
|
||||
pVm->bClassDeferred = FALSE;
|
||||
rc = PH7_ClassBuildMro(pVm, pClass);
|
||||
if(rc == SXRET_OK) {
|
||||
rc = PH7_ClassCollectInterfaces(pVm, pClass, &sInterfaces);
|
||||
}
|
||||
bDeferred = pVm->bClassDeferred;
|
||||
/* Only the unpublished declaration may retain prepared state. Every
|
||||
* borrowed base is restored exactly, even on success, without allocation.
|
||||
* No autoload, initializer or other callback runs inside this journal. */
|
||||
while((pEntry = (ClassJournalEntry *)SySetPop(&sJournal)) != 0) {
|
||||
ph7_class *pOwner = pEntry->pClass;
|
||||
if(pOwner == pClass && rc == SXRET_OK && !bDeferred) {
|
||||
SySetRelease(&pEntry->aBase);
|
||||
SySetRelease(&pEntry->aMro);
|
||||
} else {
|
||||
if(SySetBasePtr(&pOwner->aBase) != SySetBasePtr(&pEntry->aBase)) {
|
||||
SySetRelease(&pOwner->aBase);
|
||||
}
|
||||
if(SySetBasePtr(&pOwner->aMro) != SySetBasePtr(&pEntry->aMro)) {
|
||||
SySetRelease(&pOwner->aMro);
|
||||
}
|
||||
pOwner->aBase = pEntry->aBase;
|
||||
pOwner->aMro = pEntry->aMro;
|
||||
pOwner->iMroState = pEntry->iState;
|
||||
}
|
||||
}
|
||||
pVm->pClassJournal = 0;
|
||||
pVm->pStagedClass = 0;
|
||||
pVm->bClassDeferred = FALSE;
|
||||
SySetRelease(&sJournal);
|
||||
if(bDeferred && rc == SXERR_INVALID) {
|
||||
/* Missing names resolve at first language use, after compilation/import.
|
||||
* A malformed complete graph is instead a recoverable registration error. */
|
||||
rc = SXRET_OK;
|
||||
} else if(rc == SXRET_OK) {
|
||||
if(pClass->iFlags & PH7_CLASS_INTERFACE) {
|
||||
for(i = 0; i < SySetUsed(&sInterfaces) && rc == SXRET_OK; i++) {
|
||||
ph7_class *pBase = *(ph7_class **)SySetAt(&sInterfaces, i);
|
||||
if(pBase != pClass) {
|
||||
rc = PH7_ClassInterfaceInherit(pClass, pBase);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for(i = 1; i < SySetUsed(&pClass->aMro) && rc == SXRET_OK; i++) {
|
||||
rc = PH7_ClassInherit(pVm, pClass, *(ph7_class **)SySetAt(&pClass->aMro, i));
|
||||
}
|
||||
for(i = 0; i < SySetUsed(&sInterfaces) && rc == SXRET_OK; i++) {
|
||||
rc = PH7_ClassImplement(pVm, pClass, *(ph7_class **)SySetAt(&sInterfaces, i));
|
||||
}
|
||||
}
|
||||
}
|
||||
SySetRelease(&sInterfaces);
|
||||
return rc;
|
||||
}
|
||||
/*
|
||||
* Implements an object interface in the given main class.
|
||||
* According to the PHP language reference manual.
|
||||
@@ -1138,9 +1283,14 @@ PH7_PRIVATE sxi32 PH7_ClassInstanceFinalize(ph7_class_instance *pThis) {
|
||||
pThis->iFlags |= CLASS_INSTANCE_FINALIZED;
|
||||
pDestr = PH7_ClassExtractMethod(pThis->pClass, "__destruct", sizeof("__destruct") - 1);
|
||||
if(pDestr) {
|
||||
ph7_value sResult;
|
||||
sxi32 rc;
|
||||
/* A destructor may remove its own last ordinary reference. */
|
||||
pThis->iRef++;
|
||||
PH7_VmCallClassMethod(pThis->pVm, pThis, pDestr, 0, 0, 0);
|
||||
PH7_MemObjInit(pThis->pVm, &sResult);
|
||||
rc = PH7_VmCallClassMethod(pThis->pVm, pThis, pDestr, &sResult, 0, 0);
|
||||
PH7_VmDeferTransfer(pThis->pVm, rc, &sResult);
|
||||
PH7_MemObjRelease(&sResult);
|
||||
PH7_ClassInstanceUnref(pThis);
|
||||
}
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user