Basic check if all methods declared in interface are also defined in class.
All checks were successful
The build was successful.

This commit is contained in:
2019-03-20 09:24:30 +01:00
parent 3d23d43040
commit 7b1ed59f41
3 changed files with 18 additions and 3 deletions

View File

@@ -383,7 +383,8 @@ PH7_PRIVATE sxi32 PH7_ClassInterfaceInherit(ph7_class *pSub, ph7_class *pBase) {
* Any other return value indicates failure and the upper layer must generate an appropriate
* error message.
*/
PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_class *pMain, ph7_class *pInterface) {
PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_vm *pVm, ph7_class *pMain, ph7_class *pInterface) {
ph7_class_method *pMeth;
ph7_class_attr *pAttr;
SyHashEntry *pEntry;
SyString *pName;
@@ -403,6 +404,20 @@ PH7_PRIVATE sxi32 PH7_ClassImplement(ph7_class *pMain, ph7_class *pInterface) {
}
}
}
SyHashResetLoopCursor(&pInterface->hMethod);
while((pEntry = SyHashGetNextEntry(&pInterface->hMethod)) != 0) {
pMeth = (ph7_class_method *)pEntry->pUserData;
pName = &pMeth->sFunc.sName;
if((pEntry = SyHashGet(&pMain->hMethod, (const void *)pName->zString, pName->nByte)) != 0) {
continue;
} else {
rc = PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Method '%z:%z()' must be defined inside class '%z'", &pInterface->sName, pName, &pMain->sName);
if(rc == SXERR_ABORT) {
return SXERR_ABORT;
}
continue;
}
}
/* Install in the interface container */
SySetPut(&pMain->aInterface, (const void *)&pInterface);
/* TICKET 1433-49/1: Symisc eXtension

View File

@@ -4220,7 +4220,7 @@ static sxi32 VmByteCodeExec(
/* Trying to implement a class */
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot implement a class '%z'", &pClass->sName.zString, &apImplements->zString);
}
rc = PH7_ClassImplement(pClass, pBase);
rc = PH7_ClassImplement(pVm, pClass, pBase);
if(rc != SXRET_OK) {
break;
}