public override void OnForStatement(ForStatement node) { this.OnLoopBody(node.get_Block()); }
public void TransformIteration(ForStatement node) { string[] textArray1 = new string[] { "iterator" }; InternalLocal iteratorVariable = this.get_CodeBuilder().DeclareLocal(this.get_CurrentMethod(), base._context.GetUniqueName(textArray1), this.get_TypeSystemServices().IEnumeratorType); iteratorVariable.set_IsUsed(true); Block block = new Block(node.get_LexicalInfo()); block.Add(this.get_CodeBuilder().CreateAssignment(node.get_LexicalInfo(), this.get_CodeBuilder().CreateReference(iteratorVariable), node.get_Iterator())); WhileStatement statement = new WhileStatement(node.get_LexicalInfo()); statement.set_Condition(this.get_CodeBuilder().CreateMethodInvocation(this.get_CodeBuilder().CreateReference(iteratorVariable), this.IEnumerator_MoveNext)); MethodInvocationExpression expression = this.get_CodeBuilder().CreateMethodInvocation(this.get_CodeBuilder().CreateReference(iteratorVariable), this.IEnumerator_get_Current); InternalLocal entity = TypeSystemServices.GetEntity(node.get_Declarations().get_Item(0)); statement.get_Block().Add(this.get_CodeBuilder().CreateAssignment(node.get_LexicalInfo(), this.get_CodeBuilder().CreateReference(entity), expression)); statement.get_Block().Add(node.get_Block()); new LoopVariableUpdater(this, base._context, iteratorVariable, entity).Visit(node); block.Add(statement); node.get_ParentNode().Replace(node, block); }