Remove the zonecodegenerator requirement to reference members in a type reference because IW did nasty things in their game that require me to do so.

This commit is contained in:
Jan 2020-09-16 10:18:11 +02:00
parent 6437d8daa4
commit c952aacda1
3 changed files with 12 additions and 8 deletions

View File

@ -34,9 +34,11 @@ $endif$
PrintOperandDynamic(op) ::= <%
$TypeVarName(op.Structure.Type)$
$if(first(op.ReferencedMemberChain))$
->$trunc(op.ReferencedMemberChain):{member | $member.Member.Name$$if(member.Computations.ContainsNonEmbeddedReference)$->$else$.$endif$}$
$last(op.ReferencedMemberChain):{member | $member.Member.Name$}$
$op.ArrayIndices:{ arrayIndex | [$PrintEvaluation(arrayIndex)$]}$
$endif$
%>
PrintOperation(operation) ::= <%

View File

@ -138,11 +138,6 @@ namespace ZoneCodeGenerator.Parsing.CommandFile.Tests
}
}
if (!referencedMemberChain.Any())
{
throw new TestFailedException($"Typename '{typenameString}' needs to reference a member at this place.");
}
var operandDynamic = new OperandDynamic(referencedType, referencedMemberChain);
foreach (var indexEvaluation in arrayIndexEvaluations)
{

View File

@ -397,11 +397,11 @@ namespace ZoneCodeGeneratorTests.Parsing.CommandFile.Tests
}
[TestMethod]
public void EnsureFailsWhenReferencingNoMembersAsDynamicOperands()
public void EnsureCanReferenceNoMembersAsDynamicOperands()
{
tokens.AddRange(new List<string>
{
"set", "count", "test_struct", ":", ":", "ptrEntry", "1", "+", "test_struct", ";"
"set", "count", "test_struct", ":", ":", "ptrEntry", "test_struct", ";"
});
var test = new TestCount();
@ -420,7 +420,14 @@ namespace ZoneCodeGeneratorTests.Parsing.CommandFile.Tests
repository.Add(testStruct);
Assert.ThrowsException<TestFailedException>(() => test.PerformTest(parserState, lexerMock.Object));
Assert.AreEqual(TokenTestResult.Match, test.PerformTest(parserState, lexerMock.Object));
Assert.AreEqual(8, test.ConsumedTokenCount);
Assert.AreNotEqual(ReferenceTypePointer.DefaultCount, pointerReference.Count);
Assert.IsFalse(pointerReference.Count.IsStatic);
Assert.IsInstanceOfType(pointerReference.Count, typeof(OperandDynamic));
Assert.AreEqual("test_struct", ((OperandDynamic)pointerReference.Count).Structure.Type.Name);
}
[TestMethod]