- first stage of simplifying the type system.

Let's use inline checkers in PType instead of constantly having to do clumsy IsKindOf checks etc. Once complete this also means that the types can be taken out of the class hierarchy, freeing up some common names.
This commit is contained in:
Christoph Oelckers 2017-04-13 12:47:41 +02:00
commit b2d944974e
16 changed files with 152 additions and 137 deletions

View file

@ -104,9 +104,9 @@ unsigned PFunction::AddVariant(PPrototype *proto, TArray<uint32_t> &argflags, TA
if (flags & VARF_Method)
{
assert(proto->ArgumentTypes.Size() > 0);
auto selftypeptr = dyn_cast<PPointer>(proto->ArgumentTypes[0]);
auto selftypeptr = proto->ArgumentTypes[0]->toPointer();
assert(selftypeptr != nullptr);
variant.SelfClass = dyn_cast<PContainerType>(selftypeptr->PointedType);
variant.SelfClass = selftypeptr->PointedType->toContainer();
assert(variant.SelfClass != nullptr);
}
else
@ -155,7 +155,7 @@ PField::PField(FName name, PType *type, uint32_t flags, size_t offset, int bitva
unsigned val = bitvalue;
while ((val >>= 1)) BitValue++;
if (type->IsA(RUNTIME_CLASS(PInt)) && unsigned(BitValue) < 8u * type->Size)
if (type->isInt() && unsigned(BitValue) < 8u * type->Size)
{
// map to the single bytes in the actual variable. The internal bit instructions operate on 8 bit values.
#ifndef __BIG_ENDIAN__
@ -582,7 +582,7 @@ void RemoveUnusedSymbols()
{
for (PType *ty = TypeTable.TypeHash[i]; ty != nullptr; ty = ty->HashNext)
{
if (ty->IsKindOf(RUNTIME_CLASS(PContainerType)))
if (ty->isContainer())
{
auto it = ty->Symbols.GetIterator();
PSymbolTable::MapType::Pair *pair;