virtual public void VisitFromClause(Linq.FromClause x) { foreach (Linq.Generator g in x.Generators) { VisitElement(g); } }
public LinqExpression(Position p, FromClause/*!*/ from, QueryBody/*!*/ body) : base(p) { Debug.Assert(from != null && body != null); body.FromWhere.Insert(0, from); this.body = body; }
private void FromWhereToGenerators(List <Generator> /*!*/ generators) { // query is the inner-most query - it will be converted to OpChain // int i = 0; for (; ;) { // convert from clauses to generators if there are any; // (the query can start with where-clause if there was an into-clause): while (i < fromWhere.Count && fromWhere[i].IsFromClause) { FromClause f = (FromClause)fromWhere[i]; // each from-clause contains at least one generator: Debug.Assert(f.Generators.Count > 0); // adds generators contained in the from clause (Rule #2): foreach (Generator generator in f.Generators) { generators.Add(generator); } i++; } // no more clauses: if (i == fromWhere.Count) { break; } // where-clause follows; at least one generator has been added: Debug.Assert(fromWhere[i].IsWhereClause && generators.Count > 0); Generator last_generator = generators[generators.Count - 1]; DirectVarUse x_key = last_generator.KeyVar; DirectVarUse x_value = last_generator.ValueVar; LinqOpChain chain = null; LinqOp last_op = null; // embeds where-clauses imediately preceded by a from-clause to // the last generator of the from-clause (Rule #3): do { LinqOp.Where where_op = new LinqOp.Where(x_key, x_value, ((WhereClause)fromWhere[i]).Expression); if (last_op == null) { chain = new LinqOpChain(last_generator.Expression, where_op); } else { last_op.Next = where_op; } last_op = where_op; i++; }while (i < fromWhere.Count && fromWhere[i].IsWhereClause); Debug.Assert(chain != null); last_generator.Expression = chain; // no more clauses: if (i == fromWhere.Count) { break; } } }