Using separate keyword 'nonew' as reverse abstract; nonew is inherited, and nonew class can only be created from the first nonew class in the hierarchy

This commit is contained in:
ZZYZX 2017-02-16 12:40:09 +02:00
commit 5e5d0d3e57
9 changed files with 40 additions and 7 deletions

View file

@ -599,9 +599,11 @@ void ZCCCompiler::CreateClassTypes()
}
}
if (c->Type() == nullptr) c->cls->Type = parent->FindClassTentative(c->NodeName());
// [ZZ] if parent class is abstract, this one should be abstract as well - otherwise we can subclass Actor and be able to new() our subclass
if ((c->cls->Flags & ZCC_Abstract) || (parent && parent->ObjectFlags & OF_Abstract))
if (c->cls->Flags & ZCC_Abstract)
c->Type()->ObjectFlags |= OF_Abstract;
// [ZZ] inherit nonew keyword
if (c->cls->Flags & ZCC_NoNew || (parent && parent->ObjectFlags & OF_NoNew))
c->Type()->ObjectFlags |= OF_NoNew;
c->Type()->bExported = true; // this class is accessible to script side type casts. (The reason for this flag is that types like PInt need to be skipped.)
c->cls->Symbol = new PSymbolType(c->NodeName(), c->Type());
OutNamespace->Symbols.AddSymbol(c->cls->Symbol);