mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 23:21:41 +00:00
- fixed: Type determination of multi-dimensional arrays failed, apparently because ZCCCompiler::Simplify is too broken to leave the node's ring list intact.
Instead of trying to fix Simplify, which seems to be a lost cause, the ring list now gets unraveled into an array which is immune from this type of problem.
This commit is contained in:
parent
b17bd65279
commit
902a4b839c
1 changed files with 12 additions and 6 deletions
|
@ -1583,12 +1583,19 @@ PType *ZCCCompiler::ResolveUserType(ZCC_BasicType *type, PSymbolTable *symt)
|
||||||
|
|
||||||
PType *ZCCCompiler::ResolveArraySize(PType *baseType, ZCC_Expression *arraysize, PSymbolTable *sym)
|
PType *ZCCCompiler::ResolveArraySize(PType *baseType, ZCC_Expression *arraysize, PSymbolTable *sym)
|
||||||
{
|
{
|
||||||
// The duplicate Simplify call is necessary because if the head node gets replaced there is no way to detect the end of the list otherwise.
|
TArray<ZCC_Expression *> indices;
|
||||||
arraysize = Simplify(arraysize, sym, true);
|
|
||||||
ZCC_Expression *val;
|
// Simplify is too broken to resolve this inside the ring list so unravel the list into an array before starting to simplify its components.
|
||||||
|
auto node = arraysize;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
val = Simplify(arraysize, sym, true);
|
indices.Push(node);
|
||||||
|
node = static_cast<ZCC_Expression*>(node->SiblingNext);
|
||||||
|
} while (node != arraysize);
|
||||||
|
|
||||||
|
for (auto node : indices)
|
||||||
|
{
|
||||||
|
auto val = Simplify(node, sym, true);
|
||||||
if (val->Operation != PEX_ConstValue || !val->Type->IsA(RUNTIME_CLASS(PInt)))
|
if (val->Operation != PEX_ConstValue || !val->Type->IsA(RUNTIME_CLASS(PInt)))
|
||||||
{
|
{
|
||||||
Error(arraysize, "Array index must be an integer constant");
|
Error(arraysize, "Array index must be an integer constant");
|
||||||
|
@ -1601,8 +1608,7 @@ PType *ZCCCompiler::ResolveArraySize(PType *baseType, ZCC_Expression *arraysize,
|
||||||
return TypeError;
|
return TypeError;
|
||||||
}
|
}
|
||||||
baseType = NewArray(baseType, size);
|
baseType = NewArray(baseType, size);
|
||||||
val = static_cast<ZCC_Expression *>(val->SiblingNext);
|
}
|
||||||
} while (val != arraysize);
|
|
||||||
return baseType;
|
return baseType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue