mcs/error recovery: handle errors caused by closing braces after a statement expressi...
[mono.git] / mcs / mcs / linq.cs
index 205242d9faf971b0ff6800abed36644380f634aa..37bf43622ac38702f5ab7b016f15d0893d11cd66 100644 (file)
@@ -6,6 +6,7 @@
 // Dual licensed under the terms of the MIT X11 or GNU GPL
 //
 // Copyright 2007-2008 Novell, Inc
+// Copyright 2011 Xamarin Inc
 //
 
 using System;
@@ -16,7 +17,7 @@ namespace Mono.CSharp.Linq
        public class QueryExpression : AQueryClause
        {
                public QueryExpression (AQueryClause start)
-                       : base (null, null, Location.Null)
+                       : base (null, null, start.Location)
                {
                        this.next = start;
                }
@@ -275,6 +276,12 @@ namespace Mono.CSharp.Linq
                        this.identifier = identifier;
                }
 
+               public RangeVariable Identifier {
+                       get {
+                               return identifier;
+                       }
+               }
+
                public FullNamedExpression IdentifierType { get; set; }
 
                protected Invocation CreateCastExpression (Expression lSide)
@@ -341,6 +348,12 @@ namespace Mono.CSharp.Linq
                        }
                }
 
+               public bool IsParameter {
+                       get {
+                               return false;
+                       }
+               }
+
                public Location Location { get; private set; }
 
                public string Name { get; private set; }
@@ -388,7 +401,7 @@ namespace Mono.CSharp.Linq
                }
        }
 
-       class QueryStartClause : ARangeVariableQueryClause
+       public class QueryStartClause : ARangeVariableQueryClause
        {
                public QueryStartClause (QueryBlock block, Expression expr, RangeVariable identifier, Location loc)
                        : base (block, identifier, expr, loc)
@@ -448,6 +461,12 @@ namespace Mono.CSharp.Linq
                        }
                }
 
+               public Expression SelectorExpression {
+                       get {
+                               return element_selector;
+                       }
+               }
+
                protected override void CreateArguments (ResolveContext ec, Parameter parameter, ref Arguments args)
                {
                        base.CreateArguments (ec, parameter, ref args);
@@ -476,6 +495,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "GroupBy"; }
                }
+               
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class Join : SelectMany
@@ -489,6 +513,18 @@ namespace Mono.CSharp.Linq
                        this.inner_selector = innerSelector;
                }
 
+               public QueryBlock InnerSelector {
+                       get {
+                               return inner_selector;
+                       }
+               }
+               
+               public QueryBlock OuterSelector {
+                       get {
+                               return outer_selector;
+                       }
+               }
+
                protected override void CreateArguments (ResolveContext ec, Parameter parameter, ref Arguments args)
                {
                        args = new Arguments (4);
@@ -522,6 +558,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "Join"; }
                }
+               
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class GroupJoin : Join
@@ -543,6 +584,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "GroupJoin"; }
                }
+               
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class Let : ARangeVariableQueryClause
@@ -561,6 +607,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "Select"; }
                }
+               
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class Select : AQueryClause
@@ -586,6 +637,12 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "Select"; }
                }
+               
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
+
        }
 
        public class SelectMany : ARangeVariableQueryClause
@@ -637,6 +694,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "SelectMany"; }
                }
+
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class Where : AQueryClause
@@ -649,6 +711,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "Where"; }
                }
+
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class OrderByAscending : AQueryClause
@@ -661,6 +728,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "OrderBy"; }
                }
+
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class OrderByDescending : AQueryClause
@@ -673,6 +745,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "OrderByDescending"; }
                }
+
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class ThenByAscending : OrderByAscending
@@ -685,6 +762,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "ThenBy"; }
                }
+
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        public class ThenByDescending : OrderByDescending
@@ -697,6 +779,11 @@ namespace Mono.CSharp.Linq
                protected override string MethodName {
                        get { return "ThenByDescending"; }
                }
+
+               public override object Accept (StructuralVisitor visitor)
+               {
+                       return visitor.Visit (this);
+               }
        }
 
        //
@@ -738,7 +825,7 @@ namespace Mono.CSharp.Linq
                public void AddRangeVariable (RangeVariable variable)
                {
                        variable.Block = this;
-                       AddLocalName (variable.Name, variable);
+                       TopBlock.AddLocalName (variable.Name, variable, true);
                }
 
                public override void Error_AlreadyDeclared (string name, INamedBlockVariable variable, string reason)