void ProcessBlock (BlockStatement node) { for (int i = 0; i < node.Statements.ToList ().Count - 1; i++) { var matcher = new ForeachMatcher (node.Statements [i], node.Statements [i + 1]); if (!matcher.Match ()) continue; context.RemoveVariable (matcher.Enumerator); node.Statements.RemoveAt (i); // enumerator declaration/assignment node.Statements.RemoveAt (i); // try node.Statements.Insert (i, matcher.Foreach); ProcessBlock (matcher.Foreach.Body); } }
void ProcessBlock(BlockStatement node) { for (int i = 0; i < node.Statements.ToList().Count - 1; i++) { var matcher = new ForeachMatcher(node.Statements [i], node.Statements [i + 1]); if (!matcher.Match()) { continue; } context.RemoveVariable(matcher.Enumerator); node.Statements.RemoveAt(i); // enumerator declaration/assignment node.Statements.RemoveAt(i); // try node.Statements.Insert(i, matcher.Foreach); ProcessBlock(matcher.Foreach.Body); } }