Inheritance: ICSharpCode.NRefactory.Ast.Expression
 public virtual bool VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object d)
 {
     if ((anonymousMethodExpression == null)) {
         return SetFailure();
     }
     if ((d == null)) {
         return SetFailure();
     }
     if ((anonymousMethodExpression.Parameters == null)) {
         return SetFailure();
     }
     if ((anonymousMethodExpression.Body == null)) {
         return SetFailure();
     }
     if(anonymousMethodExpression.GetType() != d.GetType()) {return SetFailure();}
     var data = (AnonymousMethodExpression)d;
     if (!IsMatch(anonymousMethodExpression, data)) {
         return SetFailure();
     }
     if (anonymousMethodExpression.Parameters.Count == data.Parameters.Count) {
     for (int i=0; i<anonymousMethodExpression.Parameters.Count;i++) {
         ParameterDeclarationExpression o = anonymousMethodExpression.Parameters[i];
         if(o == null){return SetFailure();}
         if((bool)o.AcceptVisitor(this, data.Parameters[i]) == false) return SetFailure();
     }			}			else { return SetFailure(); }
     return anonymousMethodExpression.Body.AcceptVisitor(this, data.Body);
 }
		public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
			Debug.Assert((anonymousMethodExpression != null));
			Debug.Assert((anonymousMethodExpression.Parameters != null));
			Debug.Assert((anonymousMethodExpression.Body != null));
			foreach (ParameterDeclarationExpression o in anonymousMethodExpression.Parameters) {
				Debug.Assert(o != null);
				o.AcceptVisitor(this, data);
			}
			return anonymousMethodExpression.Body.AcceptVisitor(this, data);
		}
		internal LambdaReturnType(AnonymousMethodExpression expression, NRefactoryResolver resolver)
			: base(resolver.CompilationUnit)
		{
			this.resolver = resolver;
			
			if (expression.HasParameterList) {
				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));
				}
			}
			expression.Body.AcceptVisitor(new ReturnStatementFinder(returnExpressions), null);
		}
 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;
 }
		public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
			Debug.Assert((anonymousMethodExpression != null));
			Debug.Assert((anonymousMethodExpression.Parameters != null));
			Debug.Assert((anonymousMethodExpression.Body != null));
			for (int i = 0; i < anonymousMethodExpression.Parameters.Count; i++) {
				ParameterDeclarationExpression o = anonymousMethodExpression.Parameters[i];
				Debug.Assert(o != null);
				nodeStack.Push(o);
				o.AcceptVisitor(this, data);
				o = (ParameterDeclarationExpression)nodeStack.Pop();
				if (o == null)
					anonymousMethodExpression.Parameters.RemoveAt(i--);
				else
					anonymousMethodExpression.Parameters[i] = o;
			}
			nodeStack.Push(anonymousMethodExpression.Body);
			anonymousMethodExpression.Body.AcceptVisitor(this, data);
			anonymousMethodExpression.Body = ((BlockStatement)(nodeStack.Pop()));
			return null;
		}
Beispiel #6
0
			public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
			{
				return null;
			}
		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			foreach (ParameterDeclarationExpression p in anonymousMethodExpression.Parameters) {
				AddVariable(p.TypeReference, p.ParameterName,
				            anonymousMethodExpression.StartLocation, anonymousMethodExpression.EndLocation,
				            false, false, null, null, false, anonymousMethodExpression.EndLocation);
			}
			return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
		}
Beispiel #8
0
	void AnonymousMethodExpr(
#line  2185 "cs.ATG" 
out Expression outExpr) {

#line  2187 "cs.ATG" 
		AnonymousMethodExpression expr = new AnonymousMethodExpression();
		expr.StartLocation = t.Location;
		BlockStatement stmt;
		List<ParameterDeclarationExpression> p = new List<ParameterDeclarationExpression>();
		outExpr = expr;
		
		if (la.kind == 20) {
			lexer.NextToken();
			if (StartOf(11)) {
				FormalParameterList(
#line  2196 "cs.ATG" 
p);

#line  2196 "cs.ATG" 
				expr.Parameters = p; 
			}
			Expect(21);

#line  2198 "cs.ATG" 
			expr.HasParameterList = true; 
		}
		Block(
#line  2200 "cs.ATG" 
out stmt);

#line  2200 "cs.ATG" 
		expr.Body = stmt; 

#line  2201 "cs.ATG" 
		expr.EndLocation = t.Location; 
	}
Beispiel #9
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;
		}
		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			return CreateResolveResult(new LambdaReturnType(anonymousMethodExpression, resolver));
		}
Beispiel #11
0
		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			AnonymousMethodReturnType amrt = new AnonymousMethodReturnType(resolver.CompilationUnit);
			foreach (ParameterDeclarationExpression param in anonymousMethodExpression.Parameters) {
				amrt.MethodParameters.Add(NRefactoryASTConvertVisitor.CreateParameter(param, resolver.CallingMember as IMethod, resolver.CallingClass, resolver.CompilationUnit));
			}
			return amrt;
		}
		public virtual object TrackedVisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
			return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
		}
Beispiel #13
0
 public override object VisitAnonymousMethodExpression (AnonymousMethodExpression node, object data)
 {
     EmitLambda (node.Parameters, node.Body, node, null);
     return null;
 }
		public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
			throw new global::System.NotImplementedException("AnonymousMethodExpression");
		}
 public object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
 {
     throw new NotImplementedException ();
 }
 private bool IsMatch(AnonymousMethodExpression ame, AnonymousMethodExpression r_ame)
 {
     return true;
 }
		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			MethodDeclaration method = new MethodDeclaration(GetAnonymousMethodName(), Modifiers.Private, new TypeReference("System.Void"), anonymousMethodExpression.Parameters, null);
			method.Body = anonymousMethodExpression.Body;
			currentType.Children.Add(method);
			ReplaceCurrentNode(new AddressOfExpression(new IdentifierExpression(method.Name)));
			return null;
		}
		public override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			return base.VisitAnonymousMethodExpression(anonymousMethodExpression, data);
		}
		public sealed override object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
			this.BeginVisit(anonymousMethodExpression);
			object result = this.TrackedVisitAnonymousMethodExpression(anonymousMethodExpression, data);
			this.EndVisit(anonymousMethodExpression);
			return result;
		}
Beispiel #20
0
 public virtual object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data) {
     throw CreateException(anonymousMethodExpression);
 }
 public override object TrackedVisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
 {
     Console.WriteLine("VisitAnonymousMethodExpression");
     return null;
 }
		public object VisitAnonymousMethodExpression(AnonymousMethodExpression anonymousMethodExpression, object data)
		{
			B.BlockExpression cbe = new B.BlockExpression(GetLexicalInfo(anonymousMethodExpression));
			cbe.EndSourceLocation = GetLocation(anonymousMethodExpression.EndLocation);
			cbe.Body = ConvertBlock(anonymousMethodExpression.Body);
			ConvertParameters(anonymousMethodExpression.Parameters, cbe.Parameters);
			return cbe;
		}