/// <summary> /// Sets the <see cref="ICSharpOutputNode.WriteDown"/> flag. /// </summary> public override void SetWriteDown() { if (WriteDown) { return; } WriteDown = true; OverList.SetWriteDown(); foreach (ICSharpScopeAttributeFeature Item in IndexerList) { Item.SetWriteDown(); } LoopInstructions.SetWriteDown(); foreach (ICSharpAssertion Assertion in InvariantList) { Assertion.SetWriteDown(); } }
/// <summary> /// Writes down the C# instruction. /// </summary> /// <param name="writer">The stream on which to write.</param> public override void WriteCSharp(ICSharpWriter writer) { Debug.Assert(WriteDown); ICSharpExpressionContext SourceExpressionContext = new CSharpExpressionContext(); OverList.WriteCSharp(writer, SourceExpressionContext, -1); string OverListString = SourceExpressionContext.ReturnValue; ICSharpScopeAttributeFeature Indexer = IndexerList[0]; string IndexerNameString = Indexer.Name; string TypeString = Indexer.Type.Type2CSharpString(writer, CSharpTypeFormats.Normal, CSharpNamespaceFormats.None); //TODO: support multiple indexers and IterationType if (ExitEntityName != null) { string ExitEntityNameString = CSharpNames.ToCSharpIdentifier(ExitEntityName); writer.WriteIndentedLine($"{ExitEntityNameString} = false;"); writer.WriteIndentedLine($"foreach ({TypeString} {IndexerNameString} in {OverListString})"); writer.WriteIndentedLine("{"); LoopInstructions.WriteCSharp(writer, CSharpCurlyBracketsInsertions.AlreadyInserted, false); WriteCSharpInvariant(writer); writer.WriteEmptyLine(); writer.IncreaseIndent(); writer.WriteIndentedLine($"if ({ExitEntityNameString})"); writer.IncreaseIndent(); writer.WriteIndentedLine("break;"); writer.DecreaseIndent(); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } else if (InvariantList.Count > 0) { writer.WriteIndentedLine($"foreach ({TypeString} {IndexerNameString} in {OverListString})"); writer.WriteIndentedLine("{"); LoopInstructions.WriteCSharp(writer, CSharpCurlyBracketsInsertions.AlreadyInserted, false); writer.IncreaseIndent(); WriteCSharpInvariant(writer); writer.DecreaseIndent(); writer.WriteIndentedLine("}"); } else { writer.WriteIndentedLine($"foreach ({TypeString} {IndexerNameString} in {OverListString})"); LoopInstructions.WriteCSharp(writer, CSharpCurlyBracketsInsertions.Indifferent, false); } //TODO: InvariantBlocks //TODO: Variant }