private void FixSpacingAroundKeywordForeach(IForEachStatement item) { List<string> keywordSearch = new List<string> { "foreach" }; foreach (var key in keywordSearch) { item.Text = this.whiteSpaceHelper.RemoveWhiteSpaceAroundKeyword(item.Text, key); } }
private void CheckIssuesForReferencedLocalOrField(CheckCodeIssuesEventArgs ea, IForEachStatement loop, IAnonymousMethodExpression lambda, IElement element) { if (element.ElementType == LanguageElementType.ElementReferenceExpression) { IElement declaration = element.GetDeclaration(); if (declaration.ElementType == LanguageElementType.Variable || declaration.ElementType == LanguageElementType.InitializedVariable) { bool isLoopVariable = loop.LoopVariable == declaration; bool declarationIsParentedByLoop = declaration.IsParentedBy(loop); if (isLoopVariable || !declarationIsParentedByLoop) { ea.AddWarning(element.ToLanguageElement().Range, "Possible unintended closure scope misuse"); } } return; } foreach (IElement child in element.Children) { CheckIssuesForReferencedLocalOrField(ea, loop, lambda, child); } }
public void Visit(IForEachStatement forEachStatement) { this.traverser.Traverse(forEachStatement); }
/// <summary> /// Traverses the foreach statement. /// </summary> public void Traverse(IForEachStatement forEachStatement) { Contract.Requires(forEachStatement != null); if (this.preorderVisitor != null) this.preorderVisitor.Visit(forEachStatement); if (this.StopTraversal) return; this.TraverseChildren(forEachStatement); if (this.StopTraversal) return; if (this.postorderVisitor != null) this.postorderVisitor.Visit(forEachStatement); }
//^ ensures this.path.Count == old(this.path.Count); /// <summary> /// Traverses the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public virtual void Visit(IForEachStatement forEachStatement) { if (this.stopTraversal) return; //^ int oldCount = this.path.Count; this.path.Push(forEachStatement); this.Visit(forEachStatement.Collection); this.Visit(forEachStatement.Body); //^ assume this.path.Count == oldCount+1; //True because all of the virtual methods of this class promise not decrease this.path.Count. this.path.Pop(); }
/// <summary> /// Returns a shallow copy of the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public ForEachStatement Copy(IForEachStatement forEachStatement) { return new ForEachStatement(forEachStatement); }
public override void TraverseChildren(IForEachStatement forEachStatement) { throw new TranslationException("ForEach statements are not handled"); }
public override void Visit(IForEachStatement forEachStatement) { if(Process(forEachStatement)){visitor.Visit(forEachStatement);} base.Visit(forEachStatement); }
// For the first assignment to a local variable in a block before a control statement is hit, // if the local variable is not mentioned previously, we turn this assignment into a local declaration. private void AddDeclarationsWithInitialValues(IEnumerable <ILocalDefinition> localVariables, BasicBlock block) { List <ILocalDefinition> topLevelLocals = new List <ILocalDefinition>(localVariables); List <ILocalDefinition> localsMet = new List <ILocalDefinition>(); for (int i = 0; i < block.Statements.Count; i++) { if (topLevelLocals.Count == 0) { break; } IExpressionStatement expressionStatement = block.Statements[i] as IExpressionStatement; if (expressionStatement != null) { IAssignment assignment = expressionStatement.Expression as IAssignment; if (assignment != null) { ILocalDefinition localDef = assignment.Target.Definition as ILocalDefinition; if (localDef != null && topLevelLocals.Contains(localDef) && !localsMet.Contains(localDef) && !this.declaredLocals.ContainsKey(localDef)) { LocalDeclarationStatement localDecl = new LocalDeclarationStatement() { LocalVariable = localDef, InitialValue = assignment.Source, Locations = new List <ILocation>(expressionStatement.Locations), }; this.declaredLocals.Add(localDef, true); block.Statements[i] = localDecl; topLevelLocals.Remove(localDef); localsMet.Add(localDef); } } } LocalFinder finder = new LocalFinder(); finder.Traverse(block.Statements[i]); foreach (ILocalDefinition local in finder.FoundLocals) { if (!localsMet.Contains(local)) { localsMet.Add(local); } } //Once we see a statement that can transfer control somewhere else, we //no longer know that any subsequent assignment dominates all references //and hence cannot postpone adding the declaration until we can unify it with the assignment. IGotoStatement gotoStatement = block.Statements[i] as IGotoStatement; if (gotoStatement != null) { break; } IConditionalStatement conditionalStatement = block.Statements[i] as IConditionalStatement; if (conditionalStatement != null) { break; } ISwitchStatement switchStatement = block.Statements[i] as ISwitchStatement; if (switchStatement != null) { break; } IForEachStatement foreachStatement = block.Statements[i] as IForEachStatement; if (foreachStatement != null) { break; } IForStatement forStatement = block.Statements[i] as IForStatement; if (forStatement != null) { break; } ITryCatchFinallyStatement tryStatement = block.Statements[i] as ITryCatchFinallyStatement; if (tryStatement != null) { break; } } }
private void WriteForEachStatement(IForEachStatement value, IFormatter formatter) { // TODO statement.Variable declaration needs to be rendered some where this.WriteStatementSeparator(formatter); TextFormatter description = new TextFormatter(); this.WriteVariableDeclaration(value.Variable, description); formatter.WriteLine(); formatter.WriteKeyword("foreach"); formatter.Write(" ("); formatter.WriteReference(value.Variable.Name, description.ToString(), null); formatter.WriteKeyword(" in "); this.WriteExpression(value.Expression, formatter); formatter.Write(") {"); formatter.WriteLine(); formatter.WriteIndent(); if (value.Body != null) { this.WriteStatement(value.Body, formatter); } formatter.WriteLine(); formatter.WriteOutdent(); formatter.WriteKeyword("}"); }
public DebugInfo GetDebugInfo(ICodeTransform transform) { CodeBuilder Builder = CodeBuilder.Instance; IBlockStatement block = Builder.BlockStmt(); bool includeStatementNumbers = false; if (includeStatementNumbers) { List <List <IStatement> > stmts = new List <List <IStatement> >(); foreach (var entry in indexOf) { IStatement ist = entry.Key; int index = entry.Value; while (stmts.Count <= index) { stmts.Add(new List <IStatement>()); } stmts[index].Add(ist); } for (int i = 0; i < stmts.Count; i++) { block.Statements.Add(Builder.CommentStmt(i.ToString())); foreach (var ist in stmts[i]) { block.Statements.Add(ist); } } } for (int edge = 0; edge < graph.EdgeCount(); edge++) { ICollection <IVariableDeclaration> list = prohibitedLoopVars[edge]; IBlockStatement body = Builder.BlockStmt(); body.Statements.Add(GetStatement(graph.SourceOf(edge))); body.Statements.Add(GetStatement(graph.TargetOf(edge))); if (list != null) { foreach (IVariableDeclaration ivd in list) { IForEachStatement ifes = Builder.ForEachStmt(); ifes.Variable = ivd; ifes.Expression = null; ifes.Body = body; body = Builder.BlockStmt(); body.Statements.Add(ifes); } } if (body.Statements.Count == 1) { block.Statements.Add(body.Statements[0]); } else { block.Statements.Add(body); } } DebugInfo info = new DebugInfo(); info.Transform = transform; info.Name = "LoopMergingInfo"; info.Value = block; return(info); }
/// <summary /> public override IStatement Rewrite(IForEachStatement forEachStatement) { ILocalDefinition foreachLocal; var key = forEachStatement.Collection.Type.InternedKey; ITypeReference enumeratorType; IMethodReference getEnumerator; IMethodReference getCurrent; var gtir = forEachStatement.Collection.Type as IGenericTypeInstanceReference; if (gtir != null) { var typeArguments = gtir.GenericArguments; ITypeReference genericEnumeratorType = new Immutable.GenericTypeInstanceReference(this.host.PlatformType.SystemCollectionsGenericIEnumerator, typeArguments, this.host.InternFactory); ITypeReference genericEnumerableType = new Immutable.GenericTypeInstanceReference(this.host.PlatformType.SystemCollectionsGenericIEnumerable, typeArguments, this.host.InternFactory); enumeratorType = genericEnumeratorType; getEnumerator = new SpecializedMethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = genericEnumerableType, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("GetEnumerator"), Parameters = new List <IParameterTypeInformation>(), Type = genericEnumeratorType, UnspecializedVersion = new MethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = this.host.PlatformType.SystemCollectionsGenericIEnumerable, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("GetEnumerator"), Parameters = new List <IParameterTypeInformation>(), Type = this.host.PlatformType.SystemCollectionsGenericIEnumerator, }, }; var getEnumerator2 = (IMethodReference) IteratorHelper.First(genericEnumerableType.ResolvedType.GetMembersNamed(this.host.NameTable.GetNameFor("GetEnumerator"), false)); getEnumerator = getEnumerator2; getCurrent = (IMethodReference)IteratorHelper.First(genericEnumeratorType.ResolvedType.GetMembersNamed(this.host.NameTable.GetNameFor("get_Current"), false)); } else { enumeratorType = this.host.PlatformType.SystemCollectionsIEnumerator; getEnumerator = new MethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = enumeratorType, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("GetEnumerator"), Parameters = new List <IParameterTypeInformation>(), Type = this.host.PlatformType.SystemCollectionsIEnumerable, }; getCurrent = new MethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = enumeratorType, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("get_Current"), Parameters = new List <IParameterTypeInformation>(), Type = this.host.PlatformType.SystemObject, }; } var initializer = new MethodCall() { Arguments = new List <IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = getEnumerator, ThisArgument = forEachStatement.Collection, Type = enumeratorType, }; IStatement initialization; if (!this.foreachLocals.TryGetValue(key, out foreachLocal)) { foreachLocal = new LocalDefinition() { Type = enumeratorType, Name = this.host.NameTable.GetNameFor("CS$5$" + this.foreachLocals.Count) }; this.foreachLocals.Add(key, foreachLocal); initialization = new LocalDeclarationStatement() { InitialValue = initializer, LocalVariable = foreachLocal, }; } else { initialization = new ExpressionStatement() { Expression = new Assignment() { Source = initializer, Target = new TargetExpression() { Definition = foreachLocal, Instance = null, Type = foreachLocal.Type, }, Type = foreachLocal.Type, }, }; } var newStmts = new List <IStatement>(); newStmts.Add(new ExpressionStatement() { Expression = new Assignment() { Source = new MethodCall() { Arguments = new List <IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = getCurrent, ThisArgument = new BoundExpression() { Definition = foreachLocal, Instance = null, }, Type = forEachStatement.Variable.Type, }, Target = new TargetExpression() { Definition = forEachStatement.Variable, Instance = null, }, Type = forEachStatement.Variable.Type, }, }); newStmts.Add(forEachStatement.Body); var newBody = new BlockStatement() { Statements = newStmts, }; var result = new BlockStatement() { Statements = new List <IStatement>() { initialization, new TryCatchFinallyStatement() { TryBody = new BlockStatement() { Statements = new List <IStatement>() { new WhileDoStatement() { Body = newBody, Condition = new MethodCall() { Arguments = new List <IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = moveNext, ThisArgument = new BoundExpression() { Definition = foreachLocal, Instance = null, }, Type = this.host.PlatformType.SystemBoolean, }, }, }, }, FinallyBody = new BlockStatement() { Statements = new List <IStatement>() { new ConditionalStatement() { Condition = new Equality() { LeftOperand = new BoundExpression() { Definition = foreachLocal, Instance = null, Type = foreachLocal.Type, }, RightOperand = new CompileTimeConstant() { Type = foreachLocal.Type, Value = null, }, Type = this.host.PlatformType.SystemBoolean, }, FalseBranch = new EmptyStatement(), TrueBranch = new ExpressionStatement() { Expression = new MethodCall() { Arguments = new List <IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = this.disposeMethod, ThisArgument = new BoundExpression() { Definition = foreachLocal, Instance = null, }, Type = this.host.PlatformType.SystemVoid, }, }, }, }, }, }, }, }; return(result); }
public void Visit(IForEachStatement forEachStatement) { Contract.Requires(forEachStatement != null); throw new NotImplementedException(); }
public override void TraverseChildren(IForEachStatement forEachStatement) { base.TraverseChildren(forEachStatement); }
/// <summary> /// /// </summary> /// <param name="forEachStatement"></param> public ForEachStatement(IForEachStatement forEachStatement) : base(forEachStatement) { this.body = forEachStatement.Body; this.collection = forEachStatement.Collection; this.variable = forEachStatement.Variable; }
/// <summary> /// Generates IL code for the given for each statement for the special case where the collection is known /// to be vector type. /// </summary> /// <param name="forEachStatement">The foreach statement to visit.</param> /// <param name="arrayType">The vector type of the collection.</param> public virtual void VisitForeachArrayElement(IForEachStatement forEachStatement, IArrayTypeReference arrayType) { Contract.Requires(arrayType.IsVector); ILGeneratorLabel savedCurrentBreakTarget = this.currentBreakTarget; ILGeneratorLabel savedCurrentContinueTarget = this.currentContinueTarget; this.currentBreakTarget = new ILGeneratorLabel(); this.currentContinueTarget = new ILGeneratorLabel(); if (this.currentTryCatch != null) { this.mostNestedTryCatchFor.Add(this.currentBreakTarget, this.currentTryCatch); this.mostNestedTryCatchFor.Add(this.currentContinueTarget, this.currentTryCatch); } ILGeneratorLabel conditionCheck = new ILGeneratorLabel(); ILGeneratorLabel loopStart = new ILGeneratorLabel(); this.EmitSequencePoint(forEachStatement.Variable.Locations); this.Traverse(forEachStatement.Collection); this.generator.Emit(OperationCode.Dup); var array = new TemporaryVariable(arrayType, this.method); this.VisitAssignmentTo(array); var length = new TemporaryVariable(this.host.PlatformType.SystemInt32, this.method); this.generator.Emit(OperationCode.Ldlen); this.generator.Emit(OperationCode.Conv_I4); this.VisitAssignmentTo(length); var counter = new TemporaryVariable(this.host.PlatformType.SystemInt32, this.method); this.generator.Emit(OperationCode.Ldc_I4_0); this.StackSize++; this.VisitAssignmentTo(counter); this.generator.Emit(OperationCode.Br, conditionCheck); this.generator.MarkLabel(loopStart); this.LoadLocal(array); this.LoadLocal(counter); this.LoadVectorElement(arrayType.ElementType); this.VisitAssignmentTo(forEachStatement.Variable); this.Traverse(forEachStatement.Body); this.generator.MarkLabel(this.currentContinueTarget); this.LoadLocal(counter); this.generator.Emit(OperationCode.Ldc_I4_1); this.StackSize++; this.generator.Emit(OperationCode.Add); this.StackSize--; this.VisitAssignmentTo(counter); this.generator.MarkLabel(conditionCheck); this.EmitSequencePoint(forEachStatement.Collection.Locations); this.LoadLocal(counter); this.LoadLocal(length); this.generator.Emit(OperationCode.Blt, loopStart); this.generator.MarkLabel(this.currentBreakTarget); this.currentBreakTarget = savedCurrentBreakTarget; this.currentContinueTarget = savedCurrentContinueTarget; }
public override void TraverseChildren(IForEachStatement forEachStatement) { if (this.currentAnonymousDelegate != null) this.definitionsToIgnore[forEachStatement.Variable] = true; base.TraverseChildren(forEachStatement); }
/// <summary> /// Generates IL for the specified for each statement. /// </summary> /// <param name="forEachStatement">For each statement.</param> public override void TraverseChildren(IForEachStatement forEachStatement) { var arrayType = forEachStatement.Collection.Type as IArrayTypeReference; if (arrayType != null && arrayType.IsVector) { this.VisitForeachArrayElement(forEachStatement, arrayType); return; } //TODO: special case for enumerator that is sealed and does not implement IDisposable base.TraverseChildren(forEachStatement); this.lastStatementWasUnconditionalTransfer = false; }
/// <summary> /// Returns a deep copy of the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public ForEachStatement Copy(IForEachStatement forEachStatement) { var mutableCopy = this.shallowCopier.Copy(forEachStatement); mutableCopy.Variable = this.Copy(mutableCopy.Variable); this.LocalsInsideCone.Add(forEachStatement.Variable, mutableCopy.Variable); mutableCopy.Collection = this.Copy(mutableCopy.Collection); mutableCopy.Body = this.Copy(mutableCopy.Body); return mutableCopy; }
public override void Visit(IForEachStatement forEachStatement) { allElements.Add(new InvokInfo(Traverser, "IForEachStatement", forEachStatement)); }
public void Visit(IForEachStatement forEachStatement) { this.result = this.copier.Copy(forEachStatement); }
public override void TraverseChildren(IForEachStatement forEachStatement) { MethodEnter(forEachStatement); base.TraverseChildren(forEachStatement); MethodExit(); }
/// <summary /> public override IStatement Rewrite(IForEachStatement forEachStatement) { ILocalDefinition foreachLocal; var key = forEachStatement.Collection.Type.InternedKey; ITypeReference enumeratorType; IMethodReference getEnumerator; IMethodReference getCurrent; var gtir = forEachStatement.Collection.Type as IGenericTypeInstanceReference; if (gtir != null) { var typeArguments = gtir.GenericArguments; ITypeReference genericEnumeratorType = new Immutable.GenericTypeInstanceReference(this.host.PlatformType.SystemCollectionsGenericIEnumerator, typeArguments, this.host.InternFactory); ITypeReference genericEnumerableType = new Immutable.GenericTypeInstanceReference(this.host.PlatformType.SystemCollectionsGenericIEnumerable, typeArguments, this.host.InternFactory); enumeratorType = genericEnumeratorType; getEnumerator = new SpecializedMethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = genericEnumerableType, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("GetEnumerator"), Parameters = new List<IParameterTypeInformation>(), Type = genericEnumeratorType, UnspecializedVersion = new MethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = this.host.PlatformType.SystemCollectionsGenericIEnumerable, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("GetEnumerator"), Parameters = new List<IParameterTypeInformation>(), Type = this.host.PlatformType.SystemCollectionsGenericIEnumerator, }, }; var getEnumerator2 = (IMethodReference) IteratorHelper.First(genericEnumerableType.ResolvedType.GetMembersNamed(this.host.NameTable.GetNameFor("GetEnumerator"), false)); getEnumerator = getEnumerator2; getCurrent = (IMethodReference) IteratorHelper.First(genericEnumeratorType.ResolvedType.GetMembersNamed(this.host.NameTable.GetNameFor("get_Current"), false)); } else { enumeratorType = this.host.PlatformType.SystemCollectionsIEnumerator; getEnumerator = new MethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = enumeratorType, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("GetEnumerator"), Parameters = new List<IParameterTypeInformation>(), Type = this.host.PlatformType.SystemCollectionsIEnumerable, }; getCurrent = new MethodReference() { CallingConvention = CallingConvention.HasThis, ContainingType = enumeratorType, InternFactory = this.host.InternFactory, Name = this.host.NameTable.GetNameFor("get_Current"), Parameters = new List<IParameterTypeInformation>(), Type = this.host.PlatformType.SystemObject, }; } var initializer = new MethodCall() { Arguments = new List<IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = getEnumerator, ThisArgument = forEachStatement.Collection, Type = enumeratorType, }; IStatement initialization; if (!this.foreachLocals.TryGetValue(key, out foreachLocal)) { foreachLocal = new LocalDefinition() { Type = enumeratorType, Name = this.host.NameTable.GetNameFor("CS$5$" + this.foreachLocals.Count) }; this.foreachLocals.Add(key, foreachLocal); initialization = new LocalDeclarationStatement() { InitialValue = initializer, LocalVariable = foreachLocal, }; } else { initialization = new ExpressionStatement() { Expression = new Assignment() { Source = initializer, Target = new TargetExpression() { Definition = foreachLocal, Instance = null, Type = foreachLocal.Type, }, Type = foreachLocal.Type, }, }; } var newStmts = new List<IStatement>(); newStmts.Add(new ExpressionStatement(){ Expression = new Assignment(){ Source = new MethodCall(){ Arguments = new List<IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = getCurrent, ThisArgument = new BoundExpression(){ Definition = foreachLocal, Instance = null, }, Type = forEachStatement.Variable.Type, }, Target = new TargetExpression(){ Definition = forEachStatement.Variable, Instance = null, }, Type = forEachStatement.Variable.Type, }, }); newStmts.Add(forEachStatement.Body); var newBody = new BlockStatement(){ Statements = newStmts,}; var result = new BlockStatement() { Statements = new List<IStatement>(){ initialization, new TryCatchFinallyStatement(){ TryBody = new BlockStatement() { Statements = new List<IStatement>(){ new WhileDoStatement(){ Body = newBody, Condition = new MethodCall(){ Arguments = new List<IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = moveNext, ThisArgument = new BoundExpression(){ Definition = foreachLocal, Instance = null, }, Type = this.host.PlatformType.SystemBoolean, }, }, }, }, FinallyBody = new BlockStatement() { Statements = new List<IStatement>(){ new ConditionalStatement(){ Condition = new Equality(){ LeftOperand = new BoundExpression(){ Definition = foreachLocal, Instance = null, Type = foreachLocal.Type, }, RightOperand = new CompileTimeConstant(){ Type = foreachLocal.Type, Value = null, }, Type = this.host.PlatformType.SystemBoolean, }, FalseBranch = new EmptyStatement(), TrueBranch = new ExpressionStatement(){ Expression = new MethodCall(){ Arguments = new List<IExpression>(), IsStaticCall = false, IsVirtualCall = true, MethodToCall = this.disposeMethod, ThisArgument = new BoundExpression(){ Definition = foreachLocal, Instance = null, }, Type = this.host.PlatformType.SystemVoid, }, }, }, }, }, }, }, }; return result; }
/// <summary> /// Performs some computation with the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public virtual void Visit(IForEachStatement forEachStatement) { }
/// <summary> /// Traverses the children of the foreach statement. /// </summary> public virtual void TraverseChildren(IForEachStatement forEachStatement) { Contract.Requires(forEachStatement != null); this.TraverseChildren((IStatement)forEachStatement); if (this.StopTraversal) return; this.Traverse(forEachStatement.Variable); if (this.StopTraversal) return; this.Traverse(forEachStatement.Collection); if (this.StopTraversal) return; this.Traverse(forEachStatement.Body); }
/// <summary> /// Rewrites the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public virtual IStatement Rewrite(IForEachStatement forEachStatement) { return forEachStatement; }
/// <summary> /// Performs some computation with the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public virtual void Visit(IForEachStatement forEachStatement) { this.Visit((IStatement)forEachStatement); }
/// <summary> /// Returns a deep copy of the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public ForEachStatement Copy(IForEachStatement forEachStatement) { Contract.Requires(forEachStatement != null); Contract.Ensures(Contract.Result<ForEachStatement>() != null); var mutableCopy = this.shallowCopier.Copy(forEachStatement); mutableCopy.Variable = this.Copy(mutableCopy.Variable); this.LocalsInsideCone.Add(forEachStatement.Variable, mutableCopy.Variable); mutableCopy.Collection = this.Copy(mutableCopy.Collection); mutableCopy.Body = this.Copy(mutableCopy.Body); return mutableCopy; }
public void Visit(IForEachStatement forEachStatement) { throw new NotImplementedException(); }
/// <summary> /// Returns a shallow copy of the given foreach statement. /// </summary> /// <param name="forEachStatement"></param> public ForEachStatement Copy(IForEachStatement forEachStatement) { Contract.Requires(forEachStatement != null); Contract.Ensures(Contract.Result<ForEachStatement>() != null); return new ForEachStatement(forEachStatement); }
private void FixSpacingForEach(IForEachStatement item) { }
public override void TraverseChildren(IForEachStatement forEachStatement) { this.sourceEmitterOutput.Write("foreach (", true); this.PrintLocalDefinition(forEachStatement.Variable); this.sourceEmitterOutput.Write(" in "); this.Traverse(forEachStatement.Collection); this.sourceEmitterOutput.WriteLine(")"); this.Traverse(forEachStatement.Body); }
public override void TraverseChildren(IForEachStatement forEachStatement) { if (this.captures.ContainsKey(forEachStatement.Variable)) this.scopesWithCapturedLocals[forEachStatement] = true; base.TraverseChildren(forEachStatement); }
/// <summary> /// Visits the specified for each statement. /// </summary> /// <param name="forEachStatement">For each statement.</param> public override void Visit(IForEachStatement forEachStatement) { ForEachStatement mutableForEachStatement = new ForEachStatement(forEachStatement); this.resultStatement = this.myCodeCopier.DeepCopy(mutableForEachStatement); }
public virtual void onASTElement(IForEachStatement forEachStatement) { }