Report an error when trying to create an instance on interface or virtual class.
All checks were successful
The build was successful.
All checks were successful
The build was successful.
This commit is contained in:
parent
5948c3a5b6
commit
9cc0f203ca
|
@ -4437,7 +4437,7 @@ static sxi32 VmByteCodeExec(
|
||||||
if((pTos->nType & MEMOBJ_STRING) && SyBlobLength(&pTos->sBlob) > 0) {
|
if((pTos->nType & MEMOBJ_STRING) && SyBlobLength(&pTos->sBlob) > 0) {
|
||||||
/* Try to extract the desired class */
|
/* Try to extract the desired class */
|
||||||
pClass = PH7_VmExtractClass(&(*pVm), (const char *)SyBlobData(&pTos->sBlob),
|
pClass = PH7_VmExtractClass(&(*pVm), (const char *)SyBlobData(&pTos->sBlob),
|
||||||
SyBlobLength(&pTos->sBlob), TRUE /* Only loadable class but not 'interface' or 'virtual' class*/);
|
SyBlobLength(&pTos->sBlob), FALSE);
|
||||||
} else if(pTos->nType & MEMOBJ_OBJ) {
|
} else if(pTos->nType & MEMOBJ_OBJ) {
|
||||||
/* Take the base class from the loaded instance */
|
/* Take the base class from the loaded instance */
|
||||||
pClass = ((ph7_class_instance *)pTos->x.pOther)->pClass;
|
pClass = ((ph7_class_instance *)pTos->x.pOther)->pClass;
|
||||||
|
@ -4448,6 +4448,10 @@ static sxi32 VmByteCodeExec(
|
||||||
SyBlobLength(&pTos->sBlob), (const char *)SyBlobData(&pTos->sBlob)
|
SyBlobLength(&pTos->sBlob), (const char *)SyBlobData(&pTos->sBlob)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
if(pClass->iFlags & (PH7_CLASS_INTERFACE | PH7_CLASS_VIRTUAL)) {
|
||||||
|
PH7_VmThrowError(&(*pVm), PH7_CTX_ERR, "Cannot create an instance of the virtual class or interface '%z'",
|
||||||
|
&pClass->sName);
|
||||||
|
}
|
||||||
ph7_class_method *pCons;
|
ph7_class_method *pCons;
|
||||||
/* Create a new class instance */
|
/* Create a new class instance */
|
||||||
pNew = PH7_NewClassInstance(&(*pVm), pClass);
|
pNew = PH7_NewClassInstance(&(*pVm), pClass);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user