ZoneCodeGenerator: Make setting a dynamic array size only possible if the targeted member is the last entry of its structure

This commit is contained in:
Jan 2019-12-22 16:15:45 +01:00
parent 57ef79692a
commit ec8c00a4b9

View File

@ -26,7 +26,6 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
public TestArraySize() : base(matchers)
{
}
protected override void ProcessMatch(ICommandParserState state)
@ -62,6 +61,13 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
var reference = referencedMember.Member.VariableType.References.OfType<ReferenceTypeArray>()
.FirstOrDefault();
if (!referencedMember.Parent.IsUnion &&
referencedMember.Parent.Type.Members.Last() != referencedMember.Member)
{
throw new TestFailedException(
"Cannot change the array size of a member that is not the last member of its structure.");
}
if (reference != null)
reference.DynamicSize = evaluation;
else