Disallow creation of abstract classes outside of their own class (this is so that modders can create their own factory methods, not just for native)
This commit is contained in:
parent
363990a105
commit
7d3663500f
4 changed files with 19 additions and 4 deletions
|
|
@ -787,7 +787,8 @@ begin:
|
|||
{
|
||||
b = B;
|
||||
PClass *cls = (PClass*)(pc->op == OP_NEW ? reg.a[b] : konsta[b].v);
|
||||
if (cls->ObjectFlags & OF_Abstract) ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s", cls->TypeName.GetChars());
|
||||
PClass *callingcls = (PClass*)konsta[C].o; // [ZZ] due to how this is set, it's always const
|
||||
if ((cls->ObjectFlags & OF_Abstract) && callingcls != cls) ThrowAbortException(X_OTHER, "Cannot instantiate abstract class %s outside of that class", cls->TypeName.GetChars());
|
||||
reg.a[a] = cls->CreateNew();
|
||||
reg.atag[a] = ATAG_OBJECT;
|
||||
NEXTOP;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue