mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-10 23:01:59 +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 *mixinDef = nullptr;
|
||||
|
||||
for (auto mx : Mixins)
|
||||
{
|
||||
if (mx->mixin->NodeName == mixinStmt->MixinName)
|
||||
|
@ -109,18 +107,16 @@ ZCC_MixinDef *ZCCCompiler::ResolveMixinStmt(ZCC_MixinStmt *mixinStmt, EZCCMixinT
|
|||
if (mx->mixin->MixinType != type)
|
||||
{
|
||||
Error(mixinStmt, "Mixin %s is a %s mixin cannot be used here.", FName(mixinStmt->MixinName).GetChars(), GetMixinTypeString(type));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
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.
|
||||
if (node != nullptr)
|
||||
{
|
||||
bool mixinError = false;
|
||||
TArray<ZCC_MixinStmt *> mixinStmts;
|
||||
mixinStmts.Clear();
|
||||
|
||||
|
@ -182,6 +179,12 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
|
|||
{
|
||||
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.
|
||||
if (mixinDef->Body != nullptr)
|
||||
{
|
||||
|
@ -230,6 +233,11 @@ void ZCCCompiler::ProcessClass(ZCC_Class *cnode, PSymbolTreeNode *treenode)
|
|||
}
|
||||
|
||||
mixinStmts.Clear();
|
||||
|
||||
if (mixinError)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
node = cnode->Body;
|
||||
|
|
Loading…
Reference in a new issue