diff --git a/src/ZoneCodeGenerator/Generating/Templates/Common.stg b/src/ZoneCodeGenerator/Generating/Templates/Common.stg index b1dc6b9f..64f39a8e 100644 --- a/src/ZoneCodeGenerator/Generating/Templates/Common.stg +++ b/src/ZoneCodeGenerator/Generating/Templates/Common.stg @@ -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) ::= <% diff --git a/src/ZoneCodeGenerator/Parsing/CommandFile/Tests/TestWithEvaluation.cs b/src/ZoneCodeGenerator/Parsing/CommandFile/Tests/TestWithEvaluation.cs index bed7e9f0..fd90c7f5 100644 --- a/src/ZoneCodeGenerator/Parsing/CommandFile/Tests/TestWithEvaluation.cs +++ b/src/ZoneCodeGenerator/Parsing/CommandFile/Tests/TestWithEvaluation.cs @@ -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) { diff --git a/test/ZoneCodeGeneratorTests/Parsing/CommandFile/Tests/TestCountTest.cs b/test/ZoneCodeGeneratorTests/Parsing/CommandFile/Tests/TestCountTest.cs index 6da3bbaa..f7ee4f23 100644 --- a/test/ZoneCodeGeneratorTests/Parsing/CommandFile/Tests/TestCountTest.cs +++ b/test/ZoneCodeGeneratorTests/Parsing/CommandFile/Tests/TestCountTest.cs @@ -397,11 +397,11 @@ namespace ZoneCodeGeneratorTests.Parsing.CommandFile.Tests } [TestMethod] - public void EnsureFailsWhenReferencingNoMembersAsDynamicOperands() + public void EnsureCanReferenceNoMembersAsDynamicOperands() { tokens.AddRange(new List { - "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(() => 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]