public override object Visit(InvocationExpression invocationExpression, object data)
 {
     if (invocationExpression.TargetObject is FieldReferenceExpression) {
         FieldReferenceExpression field = (FieldReferenceExpression)invocationExpression.TargetObject;
         IReturnType type = field.TargetObject.AcceptVisitor(this, data) as IReturnType;
         ArrayList methods = resolver.SearchMethod(type, field.FieldName);
         resolver.ShowStatic = false;
         if (methods.Count <= 0) {
             return null;
         }
         // TODO: Find the right method
         return ((IMethod)methods[0]).ReturnType;
     } else if (invocationExpression.TargetObject is IdentifierExpression) {
         string id = ((IdentifierExpression)invocationExpression.TargetObject).Identifier;
         if (resolver.CallingClass == null) {
             return null;
         }
         IReturnType type = new ReturnType(resolver.CallingClass.FullyQualifiedName);
         ArrayList methods = resolver.SearchMethod(type, id);
         resolver.ShowStatic = false;
         if (methods.Count <= 0) {
             return null;
         }
         // TODO: Find the right method
         return ((IMethod)methods[0]).ReturnType;
     }
     // invocationExpression is delegate call
     IReturnType t = invocationExpression.AcceptChildren(this, data) as IReturnType;
     if (t == null) {
         return null;
     }
     IClass c = resolver.SearchType(t.FullyQualifiedName, resolver.CompilationUnit);
     if (c.ClassType == ClassType.Delegate) {
         ArrayList methods = resolver.SearchMethod(t, "invoke");
         if (methods.Count <= 0) {
             return null;
         }
         return ((IMethod)methods[0]).ReturnType;
     }
     return null;
 }
 public override object Visit(InvocationExpression invocationExpression, object data)
 {
     Expression     target     = invocationExpression.TargetObject;
     CodeExpression targetExpr;
     string         methodName = null;
     if (target == null) {
         targetExpr = new CodeThisReferenceExpression();
     } else if (target is FieldReferenceExpression) {
         FieldReferenceExpression fRef = (FieldReferenceExpression)target;
         targetExpr = (CodeExpression)fRef.TargetObject.AcceptVisitor(this, data);
         if (fRef.TargetObject is FieldReferenceExpression) {
             FieldReferenceExpression fRef2 = (FieldReferenceExpression)fRef.TargetObject;
             if (fRef2.FieldName != null && Char.IsUpper(fRef2.FieldName[0])) {
                 // an exception is thrown if it doesn't end in an indentifier exception
                 // for example for : this.MyObject.MyMethod() leads to an exception, which
                 // is correct in this case ... I know this is really HACKY :)
                 try {
                     targetExpr = ConvertToIdentifier(fRef2);
                 } catch (Exception) {}
             }
         }
         methodName = fRef.FieldName;
     } else {
         targetExpr = (CodeExpression)target.AcceptVisitor(this, data);
     }
     return new CodeMethodInvokeExpression(targetExpr, methodName, GetExpressionList(invocationExpression.Parameters));
 }
        public override object Visit(InvocationExpression invocationExpression, object data)
        {
            DebugOutput(invocationExpression);
            string backString;

            if (invocationExpression.TargetObject is ObjectCreateExpression) {
                backString = String.Concat("(",
                                     invocationExpression.TargetObject.AcceptVisitor(this, data),
                                     ")",
                                     GetParameters(invocationExpression.Parameters));
            } else {
                backString = String.Concat(invocationExpression.TargetObject.AcceptVisitor(this, data),
                                     GetParameters(invocationExpression.Parameters));
            }
            //todo: invocationExpression, indexer ... etc.
            Expression expr = invocationExpression.TargetObject;
            while (expr is FieldReferenceExpression) {
                expr = ((FieldReferenceExpression)expr).TargetObject;
            }

            if (data is StatementExpression && expr is ObjectCreateExpression) {
                return String.Concat("call ", backString);
            }
            return backString;
        }
 public override object Visit(InvocationExpression invocationExpression, object data)
 {
     Console.WriteLine(invocationExpression.ToString());
     return invocationExpression.AcceptChildren(this, data);
 }
 public virtual object Visit(InvocationExpression invocationExpression, object data)
 {
     object result = data;
     if (invocationExpression.TargetObject != null) {
         result = invocationExpression.TargetObject.AcceptVisitor(this, data);
     }
     if (invocationExpression.Parameters != null) {
         foreach (INode n in invocationExpression.Parameters) {
             n.AcceptVisitor(this, data);
         }
     }
     return result;
 }
	void PrimaryExpr(
#line  1824 "cs.ATG" 
out Expression pexpr) {

#line  1826 "cs.ATG" 
		TypeReference type = null;
		bool isArrayCreation = false;
		Expression expr;
		pexpr = null;
		
		switch (la.kind) {
		case 112: {
			lexer.NextToken();

#line  1833 "cs.ATG" 
			pexpr = new PrimitiveExpression(true, "true");  
			break;
		}
		case 71: {
			lexer.NextToken();

#line  1834 "cs.ATG" 
			pexpr = new PrimitiveExpression(false, "false"); 
			break;
		}
		case 89: {
			lexer.NextToken();

#line  1835 "cs.ATG" 
			pexpr = new PrimitiveExpression(null, "null");  
			break;
		}
		case 2: {
			lexer.NextToken();

#line  1836 "cs.ATG" 
			pexpr = new PrimitiveExpression(t.literalValue, t.val);  
			break;
		}
		case 1: {
			lexer.NextToken();

#line  1838 "cs.ATG" 
			pexpr = new IdentifierExpression(t.val); 
			break;
		}
		case 18: {
			lexer.NextToken();
			Expr(
#line  1840 "cs.ATG" 
out expr);
			Expect(19);

#line  1840 "cs.ATG" 
			pexpr = new ParenthesizedExpression(expr); 
			break;
		}
		case 51: case 53: case 56: case 61: case 65: case 74: case 81: case 86: case 90: case 101: case 103: case 107: case 115: case 116: case 119: {
			switch (la.kind) {
			case 51: {
				lexer.NextToken();
				break;
			}
			case 53: {
				lexer.NextToken();
				break;
			}
			case 56: {
				lexer.NextToken();
				break;
			}
			case 61: {
				lexer.NextToken();
				break;
			}
			case 65: {
				lexer.NextToken();
				break;
			}
			case 74: {
				lexer.NextToken();
				break;
			}
			case 81: {
				lexer.NextToken();
				break;
			}
			case 86: {
				lexer.NextToken();
				break;
			}
			case 90: {
				lexer.NextToken();
				break;
			}
			case 101: {
				lexer.NextToken();
				break;
			}
			case 103: {
				lexer.NextToken();
				break;
			}
			case 107: {
				lexer.NextToken();
				break;
			}
			case 115: {
				lexer.NextToken();
				break;
			}
			case 116: {
				lexer.NextToken();
				break;
			}
			case 119: {
				lexer.NextToken();
				break;
			}
			}

#line  1846 "cs.ATG" 
			string val = t.val; t.val = ""; 
			Expect(13);
			Expect(1);

#line  1846 "cs.ATG" 
			pexpr = new FieldReferenceExpression(new TypeReferenceExpression(val), t.val); 
			break;
		}
		case 110: {
			lexer.NextToken();

#line  1848 "cs.ATG" 
			pexpr = new ThisReferenceExpression(); 
			break;
		}
		case 50: {
			lexer.NextToken();

#line  1850 "cs.ATG" 
			Expression retExpr = new BaseReferenceExpression(); 
			if (la.kind == 13) {
				lexer.NextToken();
				Expect(1);

#line  1852 "cs.ATG" 
				retExpr = new FieldReferenceExpression(retExpr, t.val); 
			} else if (la.kind == 16) {
				lexer.NextToken();
				Expr(
#line  1853 "cs.ATG" 
out expr);

#line  1853 "cs.ATG" 
				ArrayList indices = new ArrayList(); indices.Add(expr); 
				while (la.kind == 12) {
					lexer.NextToken();
					Expr(
#line  1854 "cs.ATG" 
out expr);

#line  1854 "cs.ATG" 
					indices.Add(expr); 
				}
				Expect(17);

#line  1855 "cs.ATG" 
				retExpr = new IndexerExpression(retExpr, indices); 
			} else SynErr(179);

#line  1856 "cs.ATG" 
			pexpr = retExpr; 
			break;
		}
		case 88: {
			lexer.NextToken();
			NonArrayType(
#line  1857 "cs.ATG" 
out type);

#line  1857 "cs.ATG" 
			ArrayList parameters = new ArrayList(); 
			if (la.kind == 18) {
				lexer.NextToken();

#line  1862 "cs.ATG" 
				ObjectCreateExpression oce = new ObjectCreateExpression(type, parameters); 
				if (StartOf(21)) {
					Argument(
#line  1862 "cs.ATG" 
out expr);

#line  1862 "cs.ATG" 
					parameters.Add(expr); 
					while (la.kind == 12) {
						lexer.NextToken();
						Argument(
#line  1863 "cs.ATG" 
out expr);

#line  1863 "cs.ATG" 
						parameters.Add(expr); 
					}
				}
				Expect(19);

#line  1863 "cs.ATG" 
				pexpr = oce; 
			} else if (la.kind == 16) {

#line  1865 "cs.ATG" 
				isArrayCreation = true; ArrayCreateExpression ace = new ArrayCreateExpression(type); pexpr = ace; 
				lexer.NextToken();

#line  1866 "cs.ATG" 
				int dims = 0; ArrayList rank = new ArrayList(); ArrayList parameterExpression = new ArrayList(); 
				if (StartOf(4)) {
					Expr(
#line  1868 "cs.ATG" 
out expr);

#line  1868 "cs.ATG" 
					parameterExpression.Add(expr); 
					while (la.kind == 12) {
						lexer.NextToken();
						Expr(
#line  1868 "cs.ATG" 
out expr);

#line  1868 "cs.ATG" 
						parameterExpression.Add(expr); 
					}
					Expect(17);

#line  1868 "cs.ATG" 
					parameters.Add(new ArrayCreationParameter(parameterExpression)); ace.Parameters = parameters; 
					while (
#line  1869 "cs.ATG" 
IsDims()) {
						Expect(16);

#line  1869 "cs.ATG" 
						dims =0;
						while (la.kind == 12) {
							lexer.NextToken();

#line  1869 "cs.ATG" 
							dims++;
						}

#line  1869 "cs.ATG" 
						rank.Add(dims); parameters.Add(new ArrayCreationParameter(dims)); 
						Expect(17);
					}

#line  1870 "cs.ATG" 
					if (rank.Count > 0) { ace.Rank = (int[])rank.ToArray(typeof (int)); } 
					if (la.kind == 14) {
						ArrayInitializer(
#line  1871 "cs.ATG" 
out expr);

#line  1871 "cs.ATG" 
						ace.ArrayInitializer = (ArrayInitializerExpression)expr; 
					}
				} else if (la.kind == 12 || la.kind == 17) {
					while (la.kind == 12) {
						lexer.NextToken();

#line  1873 "cs.ATG" 
						dims++;
					}

#line  1873 "cs.ATG" 
					parameters.Add(new ArrayCreationParameter(dims)); 
					Expect(17);
					while (
#line  1873 "cs.ATG" 
IsDims()) {
						Expect(16);

#line  1873 "cs.ATG" 
						dims =0;
						while (la.kind == 12) {
							lexer.NextToken();

#line  1873 "cs.ATG" 
							dims++;
						}

#line  1873 "cs.ATG" 
						parameters.Add(new ArrayCreationParameter(dims)); 
						Expect(17);
					}
					ArrayInitializer(
#line  1873 "cs.ATG" 
out expr);

#line  1873 "cs.ATG" 
					ace.ArrayInitializer = (ArrayInitializerExpression)expr; ace.Parameters = parameters; 
				} else SynErr(180);
			} else SynErr(181);
			break;
		}
		case 114: {
			lexer.NextToken();
			Expect(18);
			if (
#line  1879 "cs.ATG" 
NotVoidPointer()) {
				Expect(122);

#line  1879 "cs.ATG" 
				type = new TypeReference("void"); 
			} else if (StartOf(8)) {
				Type(
#line  1880 "cs.ATG" 
out type);
			} else SynErr(182);
			Expect(19);

#line  1881 "cs.ATG" 
			pexpr = new TypeOfExpression(type); 
			break;
		}
		case 104: {
			lexer.NextToken();
			Expect(18);
			Type(
#line  1882 "cs.ATG" 
out type);
			Expect(19);

#line  1882 "cs.ATG" 
			pexpr = new SizeOfExpression(type); 
			break;
		}
		case 57: {
			lexer.NextToken();
			Expect(18);
			Expr(
#line  1883 "cs.ATG" 
out expr);
			Expect(19);

#line  1883 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
			break;
		}
		case 117: {
			lexer.NextToken();
			Expect(18);
			Expr(
#line  1884 "cs.ATG" 
out expr);
			Expect(19);

#line  1884 "cs.ATG" 
			pexpr = new CheckedExpression(expr); 
			break;
		}
		default: SynErr(183); break;
		}
		while (StartOf(27)) {
			if (la.kind == 29 || la.kind == 30) {
				if (la.kind == 29) {
					lexer.NextToken();

#line  1888 "cs.ATG" 
					pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostIncrement); 
				} else if (la.kind == 30) {
					lexer.NextToken();

#line  1889 "cs.ATG" 
					pexpr = new UnaryOperatorExpression(pexpr, UnaryOperatorType.PostDecrement); 
				} else SynErr(184);
			} else if (la.kind == 47) {
				lexer.NextToken();
				Expect(1);

#line  1892 "cs.ATG" 
				pexpr = new PointerReferenceExpression(pexpr, t.val); 
			} else if (la.kind == 13) {
				lexer.NextToken();
				Expect(1);

#line  1893 "cs.ATG" 
				pexpr = new FieldReferenceExpression(pexpr, t.val);
			} else if (la.kind == 18) {
				lexer.NextToken();

#line  1895 "cs.ATG" 
				ArrayList parameters = new ArrayList(); 
				if (StartOf(21)) {
					Argument(
#line  1896 "cs.ATG" 
out expr);

#line  1896 "cs.ATG" 
					parameters.Add(expr); 
					while (la.kind == 12) {
						lexer.NextToken();
						Argument(
#line  1897 "cs.ATG" 
out expr);

#line  1897 "cs.ATG" 
						parameters.Add(expr); 
					}
				}
				Expect(19);

#line  1898 "cs.ATG" 
				pexpr = new InvocationExpression(pexpr, parameters); 
			} else {

#line  1900 "cs.ATG" 
				if (isArrayCreation) Error("element access not allow on array creation");
				ArrayList indices = new ArrayList();
				
				lexer.NextToken();
				Expr(
#line  1903 "cs.ATG" 
out expr);

#line  1903 "cs.ATG" 
				indices.Add(expr); 
				while (la.kind == 12) {
					lexer.NextToken();
					Expr(
#line  1904 "cs.ATG" 
out expr);

#line  1904 "cs.ATG" 
					indices.Add(expr); 
				}
				Expect(17);

#line  1905 "cs.ATG" 
				pexpr = new IndexerExpression(pexpr, indices); 
			}
		}
	}
 public override object Visit(InvocationExpression invocationExpression, object data)
 {
     invocationExpression.TargetObject.AcceptVisitor(this, data);
     outputFormatter.Space ();
     outputFormatter.PrintToken(Tokens.OpenParenthesis);
     AppendCommaSeparatedList(invocationExpression.Parameters);
     outputFormatter.PrintToken(Tokens.CloseParenthesis);
     return null;
 }