|
@@ -12100,13 +12100,13 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
|
|
|
|
|
int dimensions = 1;
|
|
int dimensions = 1;
|
|
|
|
|
|
|
|
+ bool commaExpected = false;
|
|
if (arrayTypeRef->mParams.size() != 0)
|
|
if (arrayTypeRef->mParams.size() != 0)
|
|
{
|
|
{
|
|
auto intType = mModule->ResolveTypeDef(mModule->mSystem->mTypeIntPtr);
|
|
auto intType = mModule->ResolveTypeDef(mModule->mSystem->mTypeIntPtr);
|
|
-
|
|
|
|
- for (int argIdx = 0; argIdx < (int)arrayTypeRef->mParams.size(); argIdx++)
|
|
|
|
|
|
+
|
|
|
|
+ for (auto arg : arrayTypeRef->mParams)
|
|
{
|
|
{
|
|
- auto arg = arrayTypeRef->mParams[argIdx];
|
|
|
|
if (auto tokenNode = BfNodeDynCastExact<BfTokenNode>(arg))
|
|
if (auto tokenNode = BfNodeDynCastExact<BfTokenNode>(arg))
|
|
{
|
|
{
|
|
if (tokenNode->GetToken() == BfToken_Comma)
|
|
if (tokenNode->GetToken() == BfToken_Comma)
|
|
@@ -12114,11 +12114,19 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
|
if (isRawArrayAlloc)
|
|
if (isRawArrayAlloc)
|
|
{
|
|
{
|
|
mModule->Fail("Sized arrays cannot be multidimensional.", tokenNode);
|
|
mModule->Fail("Sized arrays cannot be multidimensional.", tokenNode);
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ dimensions++;
|
|
|
|
+
|
|
|
|
+ if (dimensions == 5)
|
|
|
|
+ {
|
|
|
|
+ mModule->Fail("Too many array dimensions, consider using a jagged array.", tokenNode);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ commaExpected = false;
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
auto expr = BfNodeDynCast<BfExpression>(arg);
|
|
auto expr = BfNodeDynCast<BfExpression>(arg);
|
|
if ((isRawArrayAlloc) && (!dimLengthVals.IsEmpty()))
|
|
if ((isRawArrayAlloc) && (!dimLengthVals.IsEmpty()))
|
|
{
|
|
{
|
|
@@ -12126,15 +12134,6 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
|
|
- if (argIdx != 0)
|
|
|
|
- {
|
|
|
|
- dimensions++;
|
|
|
|
- if (dimensions == 5)
|
|
|
|
- {
|
|
|
|
- mModule->Fail("Too many array dimensions, consider using a jagged array.", arg);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
dimLengthRefs.Add(expr);
|
|
dimLengthRefs.Add(expr);
|
|
|
|
|
|
BfTypedValue dimLength;
|
|
BfTypedValue dimLength;
|
|
@@ -12160,11 +12159,18 @@ void BfExprEvaluator::Visit(BfObjectCreateExpression* objCreateExpr)
|
|
dimLength = mModule->Cast(expr, dimLength, intType, castFlags);
|
|
dimLength = mModule->Cast(expr, dimLength, intType, castFlags);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (commaExpected)
|
|
|
|
+ {
|
|
|
|
+ mModule->AssertErrorState();
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
if (!dimLength)
|
|
if (!dimLength)
|
|
{
|
|
{
|
|
dimLength = mModule->GetDefaultTypedValue(intType);
|
|
dimLength = mModule->GetDefaultTypedValue(intType);
|
|
}
|
|
}
|
|
dimLengthVals.push_back(dimLength.mValue);
|
|
dimLengthVals.push_back(dimLength.mValue);
|
|
|
|
+ commaExpected = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|