Inheritance: ICSharpCode.NRefactory.Ast.Expression
        public override object VisitLambdaExpression(ICSharpCode.NRefactory.Ast.LambdaExpression lambdaExpression, object data)
        {
            var invocationExpression = lambdaExpression.Parent as InvocationExpression;

            if (invocationExpression == null)
            {
                return(base.VisitLambdaExpression(lambdaExpression, data));
            }

            var target = invocationExpression.TargetObject as MemberReferenceExpression;

            if (target == null)
            {
                return(base.VisitLambdaExpression(lambdaExpression, data));
            }

            INode node = lambdaExpression;
            var   parenthesizedlambdaExpression = new ParenthesizedExpression(lambdaExpression);

            switch (target.MemberName)
            {
            case "Sum":
            case "Average":
                node = ModifyLambdaForNumerics(lambdaExpression, parenthesizedlambdaExpression);
                break;

            case "Max":
            case "Min":
                node = ModifyLambdaForMinMax(lambdaExpression, parenthesizedlambdaExpression);
                break;

            case "OrderBy":
            case "OrderByDescending":
            case "GroupBy":
            case "Recurse":
            case "Select":
                node = ModifyLambdaForSelect(parenthesizedlambdaExpression, target);
                break;

            case "SelectMany":
                node = ModifyLambdaForSelectMany(lambdaExpression, parenthesizedlambdaExpression, invocationExpression);
                break;

            case "Any":
            case "all":
            case "First":
            case "FirstOrDefault":
            case "Last":
            case "LastOfDefault":
            case "Single":
            case "Where":
            case "Count":
            case "SingleOrDefault":
                node = new CastExpression(new TypeReference("Func<dynamic, bool>"), parenthesizedlambdaExpression, CastType.Cast);
                break;
            }
            ReplaceCurrentNode(node);

            return(base.VisitLambdaExpression(lambdaExpression, data));
        }
		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			if (lambdaExpression.StatementBody == null || lambdaExpression.StatementBody.IsNull)
				return base.VisitLambdaExpression(lambdaExpression, data);
			var text = QueryParsingUtils.ToText(lambdaExpression);
			throw new SecurityException("Lambda expression can only consist of a single expression, not a statement, but got: " + text);
		}
		private static INode ModifyLambdaForSelectMany(LambdaExpression lambdaExpression,
		                                               ParenthesizedExpression parenthesizedlambdaExpression,
		                                               InvocationExpression invocationExpression)
		{
			INode node = lambdaExpression;
			var argPos = invocationExpression.Arguments.IndexOf(lambdaExpression);
			switch (argPos)
			{
				case 0: // first one, select the collection
					// need to enter a cast for (IEnumerable<dynamic>) on the end of the lambda body
					var selectManyExpression = new LambdaExpression
					{
						ExpressionBody =
							new CastExpression(new TypeReference("IEnumerable<dynamic>"),
							                   new ParenthesizedExpression(lambdaExpression.ExpressionBody), CastType.Cast),
						Parameters = lambdaExpression.Parameters,
					};
					node = new CastExpression(new TypeReference("Func<dynamic, IEnumerable<dynamic>>"),
					                          new ParenthesizedExpression(selectManyExpression), CastType.Cast);
					break;
				case 1: // the transformation func
					node = new CastExpression(new TypeReference("Func<dynamic, dynamic, dynamic>"), parenthesizedlambdaExpression,
					                          CastType.Cast);
					break;
			}
			return node;
		}
		public LocalLookupVariable(string name, TypeReference typeRef, Location startPos, Location endPos, bool isConst, bool isLoopVariable, Expression initializer, LambdaExpression parentLambdaExpression)
		{
			this.Name = name;
			this.TypeRef = typeRef;
			this.StartPos = startPos;
			this.EndPos = endPos;
			this.IsConst = isConst;
			this.IsLoopVariable = isLoopVariable;
			this.Initializer = initializer;
			this.ParentLambdaExpression = parentLambdaExpression;
		}
Exemplo n.º 5
0
 public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
 {
     base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
     if (anonymousMethodExpression.Body.Children.Count == 1) {
         ReturnStatement rs = anonymousMethodExpression.Body.Children[0] as ReturnStatement;
         if (rs != null) {
             LambdaExpression lambda = new LambdaExpression();
             lambda.ExpressionBody = rs.Expression;
             lambda.Parameters = anonymousMethodExpression.Parameters;
             ReplaceCurrentNode(lambda);
         }
     }
     return null;
 }
Exemplo n.º 6
0
        private static void AddDocumentIdFieldToLambdaIfCreatingNewObject(LambdaExpression lambdaExpression)
        {
            if (lambdaExpression.ExpressionBody is ObjectCreateExpression == false)
                return;
            var objectInitializer = ((ObjectCreateExpression)lambdaExpression.ExpressionBody).ObjectInitializer;

            var identifierExpression = new IdentifierExpression(lambdaExpression.Parameters[0].ParameterName);
            objectInitializer.CreateExpressions.Add(
                new NamedArgumentExpression
                {
                    Name = "__document_id",
                    Expression = new MemberReferenceExpression(identifierExpression, "__document_id")
                });
        }
		public LambdaParameterReturnType(LambdaExpression lambda, string name, NRefactoryResolver resolver)
		{
			if (lambda == null)
				throw new ArgumentNullException("lambda");
			if (name == null)
				throw new ArgumentNullException("name");
			if (resolver == null)
				throw new ArgumentNullException("resolver");
			this.lambda = lambda;
			this.parameterName = name;
			this.parameterIndex = lambda.Parameters.FindIndex(p => p.ParameterName == name);
			this.resolver = resolver;
			if (parameterIndex < 0)
				throw new ArgumentException("there is no lambda parameter with that name");
		}
		internal LambdaReturnType(LambdaExpression expression, NRefactoryResolver resolver)
			: base(resolver.CompilationUnit)
		{
			this.resolver = resolver;
			this.lambdaExpression = expression;
			
			base.MethodParameters = new List<IParameter>();
			foreach (ParameterDeclarationExpression param in expression.Parameters) {
				base.MethodParameters.Add(NRefactoryASTConvertVisitor.CreateParameter(param, resolver.CallingMember as IMethod, resolver.CallingClass, resolver.CompilationUnit));
			}
			if (expression.ExpressionBody.IsNull)
				expression.StatementBody.AcceptVisitor(new ReturnStatementFinder(returnExpressions), null);
			else
				returnExpressions.Add(expression.ExpressionBody);
		}
		public void AddVariable(TypeReference typeRef, string name,
		                        Location startPos, Location endPos, bool isConst,
		                        bool isLoopVariable, Expression initializer,
		                        LambdaExpression parentLambdaExpression)
		{
			if (name == null || name.Length == 0) {
				return;
			}
			List<LocalLookupVariable> list;
			if (!variables.ContainsKey(name)) {
				variables[name] = list = new List<LocalLookupVariable>();
			} else {
				list = (List<LocalLookupVariable>)variables[name];
			}
			list.Add(new LocalLookupVariable(name, typeRef, startPos, endPos, isConst, isLoopVariable, initializer, parentLambdaExpression));
		}
Exemplo n.º 10
0
		public virtual object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			throw new global::System.NotImplementedException("LambdaExpression");
		}
Exemplo n.º 11
0
		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			foreach (ParameterDeclarationExpression p in lambdaExpression.Parameters) {
				AddVariable(p.TypeReference, p.ParameterName,
				            lambdaExpression.StartLocation, lambdaExpression.ExtendedEndLocation,
				            false, false, null, lambdaExpression, false, lambdaExpression.StartLocation);
			}
			return base.VisitLambdaExpression(lambdaExpression, data);
		}
Exemplo n.º 12
0
	void LambdaExpr(
#line  1995 "VBNET.ATG" 
out Expression expr) {

#line  1997 "VBNET.ATG" 
		Expression inner = null;
		LambdaExpression lambda = new LambdaExpression();
		lambda.StartLocation = la.Location;
		
		Expect(114);
		if (la.kind == 25) {
			lexer.NextToken();
			if (StartOf(4)) {
				FormalParameterList(
#line  2003 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(26);
		}
		Expr(
#line  2004 "VBNET.ATG" 
out inner);

#line  2006 "VBNET.ATG" 
		lambda.ExpressionBody = inner;
		lambda.EndLocation = t.EndLocation; // la.Location?
		
		expr = lambda;
		
	}
Exemplo n.º 13
0
	void LambdaExpressionBody(
#line  2174 "cs.ATG" 
LambdaExpression lambda) {

#line  2175 "cs.ATG" 
		Expression expr; BlockStatement stmt; 
		if (la.kind == 16) {
			Block(
#line  2178 "cs.ATG" 
out stmt);

#line  2178 "cs.ATG" 
			lambda.StatementBody = stmt; 
		} else if (StartOf(6)) {
			Expr(
#line  2179 "cs.ATG" 
out expr);

#line  2179 "cs.ATG" 
			lambda.ExpressionBody = expr; 
		} else SynErr(214);

#line  2181 "cs.ATG" 
		lambda.EndLocation = t.EndLocation; 

#line  2182 "cs.ATG" 
		lambda.ExtendedEndLocation = la.Location; 
	}
Exemplo n.º 14
0
		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
			LambdaExpression lambda = new LambdaExpression();
			lambda.Parameters = anonymousMethodExpression.Parameters;
			if (anonymousMethodExpression.Body.Children.Count == 1) {
				ReturnStatement rs = anonymousMethodExpression.Body.Children[0] as ReturnStatement;
				if (rs != null)
					lambda.ExpressionBody = rs.Expression;
				else {
					lambda.StatementBody = anonymousMethodExpression.Body.Children[0] as Statement;
					lambda.ReturnType = new TypeReference("System.Void", true);
				}
			} else {
				var visitor = new ReturnStatementVisitor();
				anonymousMethodExpression.AcceptVisitor(visitor, null);
				lambda.StatementBody = anonymousMethodExpression.Body;
				if (!visitor.HasReturn)
					lambda.ReturnType = new TypeReference("System.Void", true);
			}
			ReplaceCurrentNode(lambda);
			return null;
		}
Exemplo n.º 15
0
	void LambdaExpressionBody(
#line  2147 "Frames/cs.ATG" 
LambdaExpression lambda) {

#line  2148 "Frames/cs.ATG" 
		Expression expr; BlockStatement stmt; 
		if (la.kind == 16) {
			BlockInsideExpression(
#line  2151 "Frames/cs.ATG" 
out stmt);

#line  2151 "Frames/cs.ATG" 
			lambda.StatementBody = stmt; 
		} else if (StartOf(6)) {
			Expr(
#line  2152 "Frames/cs.ATG" 
out expr);

#line  2152 "Frames/cs.ATG" 
			lambda.ExpressionBody = expr; 
		} else SynErr(214);

#line  2154 "Frames/cs.ATG" 
		lambda.EndLocation = t.EndLocation; 

#line  2155 "Frames/cs.ATG" 
		lambda.ExtendedEndLocation = la.Location; 
	}
Exemplo n.º 16
0
	void ShortedLambdaExpression(
#line  2138 "cs.ATG" 
IdentifierExpression ident, out Expression pexpr) {

#line  2139 "cs.ATG" 
		LambdaExpression lambda = new LambdaExpression(); pexpr = lambda; 
		Expect(48);

#line  2144 "cs.ATG" 
		lambda.StartLocation = ident.StartLocation;
		SafeAdd(lambda, lambda.Parameters, new ParameterDeclarationExpression(null, ident.Identifier));
		lambda.Parameters[0].StartLocation = ident.StartLocation;
		lambda.Parameters[0].EndLocation = ident.EndLocation;
		
		LambdaExpressionBody(
#line  2149 "cs.ATG" 
lambda);
	}
Exemplo n.º 17
0
		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			return CreateResolveResult(new LambdaReturnType(lambdaExpression, resolver));
		}
Exemplo n.º 18
0
	void SubLambdaExpression(
//#line  2219 "VBNET.ATG" 
out LambdaExpression lambda) {

//#line  2221 "VBNET.ATG" 
		lambda = new LambdaExpression();
		lambda.ReturnType = new TypeReference("System.Void", true);
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		Expect(210);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
//#line  2228 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (StartOf(42)) {
			if (StartOf(24)) {
				Expr(
//#line  2231 "VBNET.ATG" 
out inner);

//#line  2233 "VBNET.ATG" 
				lambda.ExpressionBody = inner;
				lambda.EndLocation = t.EndLocation; // la.Location?
				lambda.ExtendedEndLocation = la.Location;
				
			} else {
				EmbeddedStatement(
//#line  2238 "VBNET.ATG" 
out statement);

//#line  2240 "VBNET.ATG" 
				lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			}
		} else if (la.kind == 1) {
			lexer.NextToken();
			Block(
//#line  2247 "VBNET.ATG" 
out statement);
			Expect(113);
			Expect(210);

//#line  2250 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(296);
	}
		private static INode ModifyLambdaForMinMax(LambdaExpression lambdaExpression,
		                                           ParenthesizedExpression parenthesizedlambdaExpression)
		{
			var node = new CastExpression(new TypeReference("Func<dynamic, int>"), parenthesizedlambdaExpression, CastType.Cast);
			var castExpression = lambdaExpression.ExpressionBody as CastExpression;
			if (castExpression != null)
			{
				node = new CastExpression(new TypeReference("Func", new List<TypeReference>
				{
					new TypeReference("dynamic"),
					castExpression.CastTo
				}), parenthesizedlambdaExpression, CastType.Cast);
			}
			return node;
		}
		public virtual object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			return base.VisitLambdaExpression(lambdaExpression, data);
		}
Exemplo n.º 21
0
	void FunctionLambdaExpression(
#line  2264 "VBNET.ATG" 
out LambdaExpression lambda) {

#line  2266 "VBNET.ATG" 
		lambda = new LambdaExpression();
		TypeReference typeRef = null;
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		while (la.kind == 66 || la.kind == 148) {
			if (la.kind == 66) {
				lexer.NextToken();

#line  2273 "VBNET.ATG" 
				lambda.IsAsync = true; 
			} else {
				lexer.NextToken();

#line  2273 "VBNET.ATG" 
				lambda.IsIterator = true; 
			}
		}
		Expect(129);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
#line  2273 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (la.kind == 63) {
			lexer.NextToken();
			TypeName(
#line  2274 "VBNET.ATG" 
out typeRef);

#line  2274 "VBNET.ATG" 
			lambda.ReturnType = typeRef; 
		}
		if (StartOf(43)) {
			if (StartOf(25)) {
				Expr(
#line  2277 "VBNET.ATG" 
out inner);

#line  2279 "VBNET.ATG" 
				lambda.ExpressionBody = inner;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			} else {
				EmbeddedStatement(
#line  2284 "VBNET.ATG" 
out statement);

#line  2286 "VBNET.ATG" 
				lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			}
		} else if (la.kind == 1) {
			lexer.NextToken();
			Block(
#line  2293 "VBNET.ATG" 
out statement);
			Expect(115);
			Expect(129);

#line  2296 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(301);
	}
Exemplo n.º 22
0
	void SubLambdaExpression(
#line  2226 "VBNET.ATG" 
out LambdaExpression lambda) {

#line  2228 "VBNET.ATG" 
		lambda = new LambdaExpression();
		lambda.ReturnType = new TypeReference("System.Void", true);
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		while (la.kind == 66 || la.kind == 148) {
			if (la.kind == 66) {
				lexer.NextToken();

#line  2235 "VBNET.ATG" 
				lambda.IsAsync = true; 
			} else {
				lexer.NextToken();

#line  2235 "VBNET.ATG" 
				lambda.IsIterator = true; 
			}
		}
		Expect(213);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
#line  2235 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (StartOf(43)) {
			if (StartOf(25)) {
				Expr(
#line  2238 "VBNET.ATG" 
out inner);

#line  2240 "VBNET.ATG" 
				lambda.ExpressionBody = inner;
				lambda.EndLocation = t.EndLocation; // la.Location?
				lambda.ExtendedEndLocation = la.Location;
				
			} else {
				EmbeddedStatement(
#line  2245 "VBNET.ATG" 
out statement);

#line  2247 "VBNET.ATG" 
				lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			}
		} else if (la.kind == 1) {
			lexer.NextToken();
			Block(
#line  2254 "VBNET.ATG" 
out statement);
			Expect(115);
			Expect(213);

#line  2257 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(300);
	}
Exemplo n.º 23
0
		public override object VisitQueryExpression(QueryExpression queryExpression, object data)
		{
			QueryExpressionSelectClause selectClause = queryExpression.SelectOrGroupClause as QueryExpressionSelectClause;
			QueryExpressionGroupClause groupClause = queryExpression.SelectOrGroupClause as QueryExpressionGroupClause;
			if (selectClause != null) {
				// Fake a call to 'Select'
				var fakeInvocation = new InvocationExpression(new MemberReferenceExpression(
					queryExpression.FromClause.InExpression, "Select"));
				
				var selector = new LambdaExpression();
				selector.Parameters.Add(new ParameterDeclarationExpression(null, "__rangeVariable"));
				selector.ExpressionBody = selectClause.Projection;
				selector.Parent = fakeInvocation;
				
				fakeInvocation.Arguments.Add(selector);
				
				return CreateResolveResult(ResolveType(fakeInvocation));
			} else if (groupClause != null) {
				// Fake a call to 'GroupBy'
				var fakeInvocation = new InvocationExpression(new MemberReferenceExpression(
					queryExpression.FromClause.InExpression, "GroupBy"));
				
				var keySelector = new LambdaExpression();
				keySelector.Parameters.Add(new ParameterDeclarationExpression(null, "__rangeVariable"));
				keySelector.ExpressionBody = groupClause.GroupBy;
				keySelector.Parent = fakeInvocation;
				
				var elementSelector = new LambdaExpression();
				elementSelector.Parameters.Add(new ParameterDeclarationExpression(null, "__rangeVariable"));
				elementSelector.ExpressionBody = groupClause.Projection;
				elementSelector.Parent = fakeInvocation;
				
				fakeInvocation.Arguments.Add(keySelector);
				fakeInvocation.Arguments.Add(elementSelector);
				
				return CreateResolveResult(ResolveType(fakeInvocation));
			} else {
				return null;
			}
		}
		public sealed override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data) {
			this.BeginVisit(lambdaExpression);
			object result = this.TrackedVisitLambdaExpression(lambdaExpression, data);
			this.EndVisit(lambdaExpression);
			return result;
		}
Exemplo n.º 25
0
		public override object VisitLambdaExpression(LambdaExpression lambdaExpression, object data)
		{
			ResolveResult result;
			if (!lambdaDictionary.TryGetValue (lambdaExpression, out result)) {
				lambdaDictionary[lambdaExpression] = result;
				result = resolver.ResolveLambda (this, lambdaExpression);
			}
			return result;
		}
		private static INode ModifyLambdaForNumerics(LambdaExpression lambdaExpression,
		                                        ParenthesizedExpression parenthesizedlambdaExpression)
		{
			var castExpression = lambdaExpression.ExpressionBody as CastExpression;
			if (castExpression != null)
			{
				return new CastExpression(new TypeReference("Func", new List<TypeReference>
				{
					new TypeReference("dynamic"),
					castExpression.CastTo
				}), parenthesizedlambdaExpression, CastType.Cast);
			}
			var expression = new LambdaExpression
			{
				ExpressionBody = new CastExpression(new TypeReference("decimal",isKeyword:true), new ParenthesizedExpression(lambdaExpression.ExpressionBody), CastType.Cast),
				Parameters = lambdaExpression.Parameters
			};
			return new CastExpression(new TypeReference("Func<dynamic, decimal>"),
			                          new ParenthesizedExpression(expression), CastType.Cast);

		}
Exemplo n.º 27
0
		public override object VisitQueryExpression(QueryExpression queryExpression, object data)
		{
			if (this.queryExpression != null) // prevent endloss loop: var n = from n select n; n.$ (doesn't make sense, but you can type this)
				return null;
			this.queryExpression = queryExpression;
			IReturnType type = null;
			QueryExpressionSelectClause selectClause = queryExpression.SelectOrGroupClause as QueryExpressionSelectClause;
			if (selectClause != null) {
				InvocationExpression selectInvocation = new InvocationExpression (new MemberReferenceExpression (queryExpression.FromClause.InExpression, "Select"));
				LambdaExpression selectLambdaExpr = new LambdaExpression ();
				selectLambdaExpr.Parent = selectInvocation;
				selectLambdaExpr.Parameters.Add (new ParameterDeclarationExpression (null, "par"));
				selectLambdaExpr.ExpressionBody = selectClause.Projection;
				TypeReference typeRef = new TypeReference ("System.Func");
				typeRef.GenericTypes.Add (TypeReference.Null);
				ResolveResult result = resolver.ResolveExpression (selectLambdaExpr, resolver.ResolvePosition, false);
				
				typeRef.GenericTypes.Add (result.ResolvedType.ConvertToTypeReference ());
				
				ObjectCreateExpression createExpression = new ObjectCreateExpression (typeRef, new List<Expression> (new Expression [] {
					null,
					selectLambdaExpr
				}));
				
				selectInvocation.Arguments.Add (createExpression);
				return CreateResult (ResolveType (selectInvocation));
			}
			
			QueryExpressionGroupClause groupClause = queryExpression.SelectOrGroupClause as QueryExpressionGroupClause;
			if (groupClause != null) {
				InvocationExpression groupInvocation = new InvocationExpression (new MemberReferenceExpression (queryExpression.FromClause.InExpression, "GroupBy"));
				
				LambdaExpression keyLambdaExpr = new LambdaExpression ();
				keyLambdaExpr.Parent = groupInvocation;
				keyLambdaExpr.Parameters.Add (new ParameterDeclarationExpression (null, "par"));
				keyLambdaExpr.ExpressionBody = groupClause.GroupBy;
				groupInvocation.Arguments.Add (keyLambdaExpr);
				
				LambdaExpression elementLambdaExpr = new LambdaExpression ();
				elementLambdaExpr.Parent = groupInvocation;
				elementLambdaExpr.Parameters.Add (new ParameterDeclarationExpression (null, "par"));
				elementLambdaExpr.ExpressionBody = groupClause.Projection;
				groupInvocation.Arguments.Add (elementLambdaExpr);
				return CreateResult (ResolveType (groupInvocation));
			}
			
			if (type != null) 
				return CreateResult (new DomReturnType("System.Collections.Generic.IEnumerable", false, new List<IReturnType> (new IReturnType[] { type })));
			return null;
		}
 public override object TrackedVisitLambdaExpression(LambdaExpression lambdaExpression, object data)
 {
     return null;
 }
Exemplo n.º 29
0
	void LambdaExpressionBody(
//#line  2137 "cs.ATG" 
LambdaExpression lambda) {

//#line  2138 "cs.ATG" 
		Expression expr; BlockStatement stmt; 
		if (la.kind == 16) {
			Block(
//#line  2141 "cs.ATG" 
out stmt);

//#line  2141 "cs.ATG" 
			lambda.StatementBody = stmt; 
		} else if (StartOf(6)) {
			Expr(
//#line  2142 "cs.ATG" 
out expr);

//#line  2142 "cs.ATG" 
			lambda.ExpressionBody = expr; 
		} else SynErr(212);

//#line  2144 "cs.ATG" 
		lambda.EndLocation = t.EndLocation; 

//#line  2145 "cs.ATG" 
		lambda.ExtendedEndLocation = la.Location; 
	}
Exemplo n.º 30
0
	void FunctionLambdaExpression(
//#line  2257 "VBNET.ATG" 
out LambdaExpression lambda) {

//#line  2259 "VBNET.ATG" 
		lambda = new LambdaExpression();
		TypeReference typeRef = null;
		Expression inner = null;
		Statement statement = null;
		lambda.StartLocation = la.Location;
		
		Expect(127);
		if (la.kind == 37) {
			lexer.NextToken();
			if (StartOf(6)) {
				FormalParameterList(
//#line  2266 "VBNET.ATG" 
lambda.Parameters);
			}
			Expect(38);
		}
		if (la.kind == 63) {
			lexer.NextToken();
			TypeName(
//#line  2267 "VBNET.ATG" 
out typeRef);

//#line  2267 "VBNET.ATG" 
			lambda.ReturnType = typeRef; 
		}
		if (StartOf(42)) {
			if (StartOf(24)) {
				Expr(
//#line  2270 "VBNET.ATG" 
out inner);

//#line  2272 "VBNET.ATG" 
				lambda.ExpressionBody = inner;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			} else {
				EmbeddedStatement(
//#line  2277 "VBNET.ATG" 
out statement);

//#line  2279 "VBNET.ATG" 
				lambda.StatementBody = statement;
				lambda.EndLocation = t.EndLocation;
				lambda.ExtendedEndLocation = la.Location;
				
			}
		} else if (la.kind == 1) {
			lexer.NextToken();
			Block(
//#line  2286 "VBNET.ATG" 
out statement);
			Expect(113);
			Expect(127);

//#line  2289 "VBNET.ATG" 
			lambda.StatementBody = statement;
			lambda.EndLocation = t.EndLocation;
			lambda.ExtendedEndLocation = la.Location;
			
		} else SynErr(297);
	}
Exemplo n.º 31
0
	void LambdaExpression(
#line  2118 "cs.ATG" 
out Expression outExpr) {

#line  2120 "cs.ATG" 
		LambdaExpression lambda = new LambdaExpression();
		lambda.StartLocation = la.Location;
		ParameterDeclarationExpression p;
		outExpr = lambda;
		
		Expect(20);
		if (StartOf(36)) {
			LambdaExpressionParameter(
#line  2128 "cs.ATG" 
out p);

#line  2128 "cs.ATG" 
			SafeAdd(lambda, lambda.Parameters, p); 
			while (la.kind == 14) {
				lexer.NextToken();
				LambdaExpressionParameter(
#line  2130 "cs.ATG" 
out p);

#line  2130 "cs.ATG" 
				SafeAdd(lambda, lambda.Parameters, p); 
			}
		}
		Expect(21);
		Expect(48);
		LambdaExpressionBody(
#line  2135 "cs.ATG" 
lambda);
	}