Browse Source

Removing a debug printf calls and improve error handling.

pull/21/head
Rafal Kupiec 3 years ago
parent
commit
33ab488ace
Signed by: belliash GPG Key ID: 4E829243E0CFE6B4
1 changed files with 6 additions and 9 deletions
  1. +6
    -9
      engine/vm.c

+ 6
- 9
engine/vm.c View File

@ -4518,22 +4518,20 @@ static sxi32 VmByteCodeExec(
ph7_class *pClassInfo = (ph7_class *)pInstr->p3;
ph7_class *pClass = PH7_VmExtractClass(pVm, pClassInfo->sName.zString, pClassInfo->sName.nByte, FALSE, 0);
ph7_class *pBase = 0;
printf("Called by class: '%s'\n", pClass->sName.zString);
if(pInstr->iP1) {
/* This class inherits from other classes */
SyString *apExtends;
while(SySetGetNextEntry(&pClassInfo->sExtends, (void **)&apExtends) == SXRET_OK) {
printf("Class '%s' inherits from '%s'\n", pClass->sName.zString, apExtends->zString);
pBase = PH7_VmExtractClass(pVm, apExtends->zString, apExtends->nByte, FALSE, 0);
if(pBase == 0) {
/* Non-existent base class */
PH7_VmThrowError(pVm, 0, PH7_CTX_ERR, "Call to non-existent base class");
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Call to non-existent base class '%z'", &apExtends->zString);
} else if(pBase->iFlags & PH7_CLASS_INTERFACE) {
/* Trying to inherit from interface */
PH7_VmThrowError(pVm, 0, PH7_CTX_ERR, "Class cannot inherit from interface");
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from interface '%z'", &pClass->sName.zString, &apExtends->zString);
} else if(pBase->iFlags & PH7_CLASS_FINAL) {
/* Trying to inherit from final class */
PH7_VmThrowError(pVm, 0, PH7_CTX_ERR, "Class cannot inherit from final class");
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot inherit from final class '%z'", &pClass->sName.zString, &apExtends->zString);
}
rc = PH7_ClassInherit(pClass, pBase);
if(rc != SXRET_OK) {
@ -4545,14 +4543,13 @@ static sxi32 VmByteCodeExec(
/* This class implements some interfaces */
SyString *apImplements;
while(SySetGetNextEntry(&pClassInfo->sImplements, (void **)&apImplements) == SXRET_OK) {
printf("Class '%s' implements '%s'\n", pClass->sName.zString, apImplements->zString);
pBase = PH7_VmExtractClass(pVm, apImplements->zString, apImplements->nByte, FALSE, 0);
if(pBase == 0) {
/* Non-existent interface */
PH7_VmThrowError(pVm, 0, PH7_CTX_ERR, "Call to non-existent interface");
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Call to non-existent interface '%z'", &apImplements->zString);
} else if((pBase->iFlags & PH7_CLASS_INTERFACE) == 0) {
/* Trying to extend a class */
PH7_VmThrowError(pVm, 0, PH7_CTX_ERR, "Interface cannot inherit from a class");
/* Trying to implement a class */
VmErrorFormat(&(*pVm), PH7_CTX_ERR, "Class '%z' cannot implement a class '%z'", &pClass->sName.zString, &apImplements->zString);
}
rc = PH7_ClassImplement(pClass, pBase);
if(rc != SXRET_OK) {


Loading…
Cancel
Save