mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-13 07:57:58 +00:00
Fixed a crash when trying to include a missing mixin.
This commit is contained in:
parent
bd216695cc
commit
6486380dd1
1 changed files with 15 additions and 7 deletions
|
@ -100,8 +100,6 @@ FString ZCCCompiler::StringConstFromNode(ZCC_TreeNode *node, PContainerType *cls
|
||||||
|
|
||||||
ZCC_MixinDef *ZCCCompiler::ResolveMixinStmt(ZCC_MixinStmt *mixinStmt, EZCCMixinType type)
|
ZCC_MixinDef *ZCCCompiler::ResolveMixinStmt(ZCC_MixinStmt *mixinStmt, EZCCMixinType type)
|
||||||
{
|
{
|
||||||
ZCC_MixinDef *mixinDef = nullptr;
|
|
||||||
|
|
||||||
for (auto mx : Mixins)
|
for (auto mx : Mixins)
|
||||||
{
|
{
|
||||||
if (mx->mixin->NodeName == mixinStmt->MixinName)
|
if (mx->mixin->NodeName == mixinStmt->MixinName)
|
||||||
|
@ -109,18 +107,16 @@ ZCC_MixinDef *ZCCCompiler::ResolveMixinStmt(ZCC_MixinStmt *mixinStmt, EZCCMixinT
|
||||||
if (mx->mixin->MixinType != type)
|
if (mx->mixin->MixinType != type)
|
||||||
{
|
{
|
||||||
Error(mixinStmt, "Mixin %s is a %s mixin cannot be used here.", FName(mixinStmt->MixinName).GetChars(), GetMixinTypeString(type));
|
Error(mixinStmt, "Mixin %s is a %s mixin cannot be used here.", FName(mixinStmt->MixinName).GetChars(), GetMixinTypeString(type));
|
||||||
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
return mx->mixin;
|
return mx->mixin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mixinDef == nullptr)
|
Error(mixinStmt, "Mixin %s does not exist.", FName(mixinStmt->MixinName).GetChars());
|
||||||
{
|
|
||||||
Error(mixinStmt, "Mixin %s does not exist.", FName(mixinStmt->MixinName).GetChars());
|
|
||||||
}
|
|
||||||
|
|
||||||
return mixinDef;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -163,6 +159,7 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
|
||||||
// [pbeta] Handle mixins here for the sake of simplifying things.
|
// [pbeta] Handle mixins here for the sake of simplifying things.
|
||||||
if (node != nullptr)
|
if (node != nullptr)
|
||||||
{
|
{
|
||||||
|
bool mixinError = false;
|
||||||
TArray<ZCC_MixinStmt *> mixinStmts;
|
TArray<ZCC_MixinStmt *> mixinStmts;
|
||||||
mixinStmts.Clear();
|
mixinStmts.Clear();
|
||||||
|
|
||||||
|
@ -182,6 +179,12 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
|
||||||
{
|
{
|
||||||
ZCC_MixinDef *mixinDef = ResolveMixinStmt(mixinStmt, ZCC_Mixin_Class);
|
ZCC_MixinDef *mixinDef = ResolveMixinStmt(mixinStmt, ZCC_Mixin_Class);
|
||||||
|
|
||||||
|
if (mixinDef == nullptr)
|
||||||
|
{
|
||||||
|
mixinError = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Insert the mixin if there's a body. If not, just remove this node.
|
// Insert the mixin if there's a body. If not, just remove this node.
|
||||||
if (mixinDef->Body != nullptr)
|
if (mixinDef->Body != nullptr)
|
||||||
{
|
{
|
||||||
|
@ -230,6 +233,11 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
|
||||||
}
|
}
|
||||||
|
|
||||||
mixinStmts.Clear();
|
mixinStmts.Clear();
|
||||||
|
|
||||||
|
if (mixinError)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
node = cnode->Body;
|
node = cnode->Body;
|
||||||
|
|
Loading…
Reference in a new issue