public override Ast Reduce()
{
MSAst.ParameterExpression res = MakeParameter();
// 1. Initialization code - create list and store it in the temp variable
MSAst.Expression initialize =
Ast.Assign(
res,
Ast.Call(Factory())
);
// 2. Create body from LHS: res.Append(item), res.Add(key, value), etc.
MSAst.Expression body = Body(res);
// 3. Transform all iterators in reverse order, building the true bodies
for (int current = Iterators.Count - 1; current >= 0; current--)
{
ComprehensionIterator iterator = Iterators[current];
body = iterator.Transform(body);
}
return(Ast.Block(
new[] { res },
initialize,
body,
res
));
}