* do not automatically mark class as virtual when at least one virtual method found * force non-virtual method to contain body * force non-virtual class to implement all methods
This commit is contained in:
parent
3f46f01805
commit
576edc6c20
|
@ -3678,12 +3678,20 @@ static sxi32 GenStateCompileClassMethod(
|
||||||
/* Virtual method */
|
/* Virtual method */
|
||||||
if(iProtection == PH7_CLASS_PROT_PRIVATE) {
|
if(iProtection == PH7_CLASS_PROT_PRIVATE) {
|
||||||
rc = PH7_GenCompileError(pGen, E_ERROR, nLine,
|
rc = PH7_GenCompileError(pGen, E_ERROR, nLine,
|
||||||
"Access type for virtual method '%z::%z' cannot be 'private'",
|
"Access type for virtual method '%z::%z()' cannot be 'private'",
|
||||||
&pClass->sName, pName);
|
&pClass->sName, pName);
|
||||||
if(rc == SXERR_ABORT) {
|
if(rc == SXERR_ABORT) {
|
||||||
return SXERR_ABORT;
|
return SXERR_ABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if((pClass->iFlags & PH7_CLASS_VIRTUAL) == 0) {
|
||||||
|
rc = PH7_GenCompileError(pGen, E_ERROR, nLine,
|
||||||
|
"Class '%z' contains virtual method and must therefore be declared virtual or implement the remaining method '%z::%z()'",
|
||||||
|
&pClass->sName, &pClass->sName, pName);
|
||||||
|
if(rc == SXERR_ABORT) {
|
||||||
|
return SXERR_ABORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
/* Assemble method signature only */
|
/* Assemble method signature only */
|
||||||
doBody = FALSE;
|
doBody = FALSE;
|
||||||
}
|
}
|
||||||
|
@ -3726,6 +3734,15 @@ static sxi32 GenStateCompileClassMethod(
|
||||||
/* Point beyond method signature */
|
/* Point beyond method signature */
|
||||||
pGen->pIn = &pEnd[1];
|
pGen->pIn = &pEnd[1];
|
||||||
if(doBody) {
|
if(doBody) {
|
||||||
|
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_OCB /* '{'*/) == 0) {
|
||||||
|
rc = PH7_GenCompileError(pGen, E_ERROR, pGen->pIn->nLine,
|
||||||
|
"Non-virtual method '%z::%z()' must contain body", &pClass->sName, pName);
|
||||||
|
if(rc == SXERR_ABORT) {
|
||||||
|
/* Error count limit reached,abort immediately */
|
||||||
|
return SXERR_ABORT;
|
||||||
|
}
|
||||||
|
return SXERR_CORRUPT;
|
||||||
|
}
|
||||||
/* Compile method body */
|
/* Compile method body */
|
||||||
rc = GenStateCompileFuncBody(&(*pGen), &pMeth->sFunc);
|
rc = GenStateCompileFuncBody(&(*pGen), &pMeth->sFunc);
|
||||||
if(rc == SXERR_ABORT) {
|
if(rc == SXERR_ABORT) {
|
||||||
|
@ -4244,8 +4261,6 @@ static sxi32 GenStateCompileClass(ph7_gen_state *pGen, sxi32 iFlags) {
|
||||||
} else if(nKwrd == PH7_TKWRD_VIRTUAL) {
|
} else if(nKwrd == PH7_TKWRD_VIRTUAL) {
|
||||||
/* Virtual method,record that */
|
/* Virtual method,record that */
|
||||||
iAttrflags |= PH7_CLASS_ATTR_VIRTUAL;
|
iAttrflags |= PH7_CLASS_ATTR_VIRTUAL;
|
||||||
/* Mark the whole class as virtual */
|
|
||||||
pClass->iFlags |= PH7_CLASS_VIRTUAL;
|
|
||||||
/* Advance the stream cursor */
|
/* Advance the stream cursor */
|
||||||
pGen->pIn++;
|
pGen->pIn++;
|
||||||
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD)) {
|
if(pGen->pIn < pGen->pEnd && (pGen->pIn->nType & PH7_TK_KEYWORD)) {
|
||||||
|
|
Loading…
Reference in New Issue