mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-03-10 11:11:51 +00:00
Better error message for unknown nested types
This commit is contained in:
parent
66460bfeb8
commit
4c6d0e4209
2 changed files with 33 additions and 2 deletions
|
@ -1994,10 +1994,36 @@ PType *ZCCCompiler::ResolveUserType(ZCC_BasicType *type, ZCC_Identifier *id, PSy
|
||||||
}
|
}
|
||||||
if (!nativetype) return ptype;
|
if (!nativetype) return ptype;
|
||||||
}
|
}
|
||||||
Error(type, "Unable to resolve %s%s as type.", nativetype? "@" : "", FName(type->UserType->Id).GetChars());
|
Error(type, "Unable to resolve %s%s as a type.", nativetype? "@" : "", UserTypeName(type).GetChars());
|
||||||
return TypeError;
|
return TypeError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
// ZCCCompiler :: UserTypeName STATIC
|
||||||
|
//
|
||||||
|
// Returns the full name for a UserType node.
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
FString ZCCCompiler::UserTypeName(ZCC_BasicType *type)
|
||||||
|
{
|
||||||
|
FString out;
|
||||||
|
ZCC_Identifier *id = type->UserType;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
assert(id->NodeType == AST_Identifier);
|
||||||
|
if (out.Len() > 0)
|
||||||
|
{
|
||||||
|
out += '.';
|
||||||
|
}
|
||||||
|
out += FName(id->Id).GetChars();
|
||||||
|
} while ((id = static_cast<ZCC_Identifier *>(id->SiblingNext)) != type->UserType);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// ZCCCompiler :: ResolveArraySize
|
// ZCCCompiler :: ResolveArraySize
|
||||||
|
@ -2338,9 +2364,13 @@ void ZCCCompiler::CompileFunction(ZCC_StructWork *c, ZCC_FuncDeclarator *f, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type->GetRegType() == REGT_NIL && type != TypeVector2 && type != TypeVector3 && type != TypeFVector2 && type != TypeFVector3)
|
if (type->GetRegType() == REGT_NIL && type != TypeVector2 && type != TypeVector3 && type != TypeFVector2 && type != TypeFVector3)
|
||||||
|
{
|
||||||
|
// If it's TypeError, then an error was already given
|
||||||
|
if (type != TypeError)
|
||||||
{
|
{
|
||||||
Error(p, "Invalid type %s for function parameter", type->DescriptiveName());
|
Error(p, "Invalid type %s for function parameter", type->DescriptiveName());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (p->Default != nullptr)
|
else if (p->Default != nullptr)
|
||||||
{
|
{
|
||||||
if (flags & VARF_Out)
|
if (flags & VARF_Out)
|
||||||
|
|
|
@ -135,6 +135,7 @@ protected:
|
||||||
PType *DetermineType(PType *outertype, ZCC_TreeNode *field, FName name, ZCC_Type *ztype, bool allowarraytypes, bool formember);
|
PType *DetermineType(PType *outertype, ZCC_TreeNode *field, FName name, ZCC_Type *ztype, bool allowarraytypes, bool formember);
|
||||||
PType *ResolveArraySize(PType *baseType, ZCC_Expression *arraysize, PContainerType *cls, bool *nosize);
|
PType *ResolveArraySize(PType *baseType, ZCC_Expression *arraysize, PContainerType *cls, bool *nosize);
|
||||||
PType *ResolveUserType(ZCC_BasicType *type, ZCC_Identifier *id, PSymbolTable *sym, bool nativetype);
|
PType *ResolveUserType(ZCC_BasicType *type, ZCC_Identifier *id, PSymbolTable *sym, bool nativetype);
|
||||||
|
static FString UserTypeName(ZCC_BasicType *type);
|
||||||
TArray<ZCC_StructWork *> OrderStructs();
|
TArray<ZCC_StructWork *> OrderStructs();
|
||||||
void AddStruct(TArray<ZCC_StructWork *> &new_order, ZCC_StructWork *struct_def);
|
void AddStruct(TArray<ZCC_StructWork *> &new_order, ZCC_StructWork *struct_def);
|
||||||
ZCC_StructWork *StructTypeToWork(const PStruct *type) const;
|
ZCC_StructWork *StructTypeToWork(const PStruct *type) const;
|
||||||
|
|
Loading…
Reference in a new issue