Author: marek
Date: 2007-09-17 12:40:51 -0400 (Mon, 17 Sep 2007)
New Revision: 85902
Modified:
trunk/mcs/gmcs/ChangeLog
trunk/mcs/gmcs/cs-parser.jay
trunk/mcs/gmcs/linq.cs
Log:
2007-09-17 Marek Safar <[EMAIL PROTECTED]>
* cs-parser.jay, linq: Implemented query continuation.
Modified: trunk/mcs/gmcs/ChangeLog
===================================================================
--- trunk/mcs/gmcs/ChangeLog 2007-09-17 16:40:18 UTC (rev 85901)
+++ trunk/mcs/gmcs/ChangeLog 2007-09-17 16:40:51 UTC (rev 85902)
@@ -1,3 +1,7 @@
+2007-09-17 Marek Safar <[EMAIL PROTECTED]>
+
+ * cs-parser.jay, linq: Implemented query continuation.
+
2007-09-12 Marek Safar <[EMAIL PROTECTED]>
* cs-parser.jay: GroupJoin clause connected.
Modified: trunk/mcs/gmcs/cs-parser.jay
===================================================================
--- trunk/mcs/gmcs/cs-parser.jay 2007-09-17 16:40:18 UTC (rev 85901)
+++ trunk/mcs/gmcs/cs-parser.jay 2007-09-17 16:40:51 UTC (rev 85902)
@@ -5415,13 +5415,16 @@
{
Linq.AQueryClause head = (Linq.AQueryClause)$2;
+ if ($3 != null)
+ head.Next = (Linq.AQueryClause)$3;
+
if ($1 != null) {
Linq.AQueryClause clause = (Linq.AQueryClause)$1;
clause.Tail.Next = head;
head = clause;
- }
+ }
- $$ = head;
+ $$ = head;
}
;
@@ -5591,13 +5594,19 @@
opt_query_continuation
: /* empty */
- | query_continuation
+ | INTO IDENTIFIER
+ {
+ start_block (GetLocation ($1));
+ LocatedToken lt = (LocatedToken) $2;
+ current_block.AddVariable
(Linq.ImplicitQueryParameter.ImplicitType.Instance, lt.Value, lt.Location);
+ }
+ query_body
+ {
+ $$ = new Linq.QueryExpression (current_block,
(Linq.AQueryClause)$4);
+ end_block (lexer.Location);
+ }
;
-query_continuation
- : INTO IDENTIFIER query_body
- ;
-
%%
// <summary>
Modified: trunk/mcs/gmcs/linq.cs
===================================================================
--- trunk/mcs/gmcs/linq.cs 2007-09-17 16:40:18 UTC (rev 85901)
+++ trunk/mcs/gmcs/linq.cs 2007-09-17 16:40:51 UTC (rev 85902)
@@ -20,14 +20,23 @@
//
//
- public class QueryExpression : ARangeVariableQueryClause
+ public class QueryExpression : AQueryClause
{
+ readonly Block block;
+
public QueryExpression (Block block, AQueryClause query)
- : base (block, null, query.Location)
+ : base (null, query.Location)
{
+ this.block = block;
this.next = query;
}
+ public override Expression BuildQueryClause (EmitContext ec,
Expression lSide, Parameter parentParameter, TransparentIdentifiersScope ti)
+ {
+ Parameter p = CreateBlockParameter (block);
+ return next.BuildQueryClause (ec, lSide, p, ti);
+ }
+
public override Expression DoResolve (EmitContext ec)
{
Expression e = BuildQueryClause (ec, null, null, null);
@@ -108,11 +117,28 @@
Select s = next as Select;
if (s == null || s.IsRequired (parameter))
return next.BuildQueryClause (ec,
lSide, parameter, ti);
+
+ // Skip transparent select clause if any clause
follows
+ if (next.next != null)
+ return next.next.BuildQueryClause (ec,
lSide, parameter, ti);
}
return lSide;
}
+ protected static Parameter CreateBlockParameter (Block block)
+ {
+ ICollection values = block.Variables.Values;
+ if (values.Count != 1)
+ throw new NotImplementedException ("Count !=
1");
+
+ IEnumerator enumerator = values.GetEnumerator ();
+ enumerator.MoveNext ();
+ LocalInfo li = (LocalInfo) enumerator.Current;
+
+ return new ImplicitQueryParameter (li);
+ }
+
protected Invocation CreateQueryExpression (Expression lSide,
ArrayList arguments)
{
return new QueryExpressionInvocation (
@@ -170,7 +196,7 @@
//
public abstract class ARangeVariableQueryClause : AQueryClause
{
- public readonly Block block;
+ readonly Block block;
protected Expression element_selector;
protected ARangeVariableQueryClause (Block block, Expression
expr, Location loc)
@@ -193,18 +219,8 @@
//
public override Expression BuildQueryClause (EmitContext ec,
Expression lSide, Parameter parentParameter, TransparentIdentifiersScope ti)
{
- ICollection values = block.Variables.Values;
- if (values.Count != 1)
- throw new NotImplementedException ("Count !=
1");
+ Parameter parameter = CreateBlockParameter (block);
- IEnumerator enumerator = values.GetEnumerator ();
- enumerator.MoveNext ();
- LocalInfo li = (LocalInfo) enumerator.Current;
-
- Parameter parameter = new ImplicitQueryParameter (li);
- if (parentParameter == null)
- return next.BuildQueryClause (ec, expr,
parameter, ti);
-
if (next != null) {
//
// Builds transparent identifiers, each
identifier includes its parent
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches