protected override IStatement ConvertFor(IForStatement ifs) { var loopSize = Recognizer.LoopSizeExpression(ifs); if (!((loopSize is IVariableReferenceExpression) || (loopSize is IArrayIndexerExpression) || (loopSize is IArgumentReferenceExpression) || (loopSize is ILiteralExpression) || (loopSize is IPropertyReferenceExpression))) { Error("Invalid expression type for the size of a loop (" + loopSize.GetType().Name + "): " + loopSize); return(ifs); } if (loopSize is ILiteralExpression) { // remove loops that execute for 0 iterations int loopSizeAsInt = (int)((ILiteralExpression)loopSize).Value; if (loopSizeAsInt == 0) { return(null); } } Containers c = Containers.GetContainersNeededForExpression(context, loopSize); c.Add(ifs); IVariableDeclaration loopVar = Recognizer.LoopVariable(ifs); context.InputAttributes.Remove <Containers>(loopVar); context.InputAttributes.Set(loopVar, c); return(base.ConvertFor(ifs)); }