1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under MIT X11 license (for details please see \doc\license.txt)
5
using System.Collections.Generic;
7
namespace ICSharpCode.NRefactory.VB.Ast
9
public abstract class Expression : AstNode
12
public new static readonly Expression Null = new NullExpression ();
14
sealed class NullExpression : Expression
16
public override bool IsNull {
22
public override S AcceptVisitor<T, S> (IAstVisitor<T, S> visitor, T data)
27
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
29
return other == null || other.IsNull;
34
#region Builder methods
36
/// Builds an member reference expression using this expression as target.
38
public MemberAccessExpression Member(string memberName)
40
return new MemberAccessExpression { Target = this, MemberName = memberName };
44
/// Builds an invocation expression using this expression as target.
46
public InvocationExpression Invoke(string methodName, IEnumerable<Expression> arguments)
48
return Invoke(methodName, null, arguments);
52
/// Builds an invocation expression using this expression as target.
54
public InvocationExpression Invoke(string methodName, params Expression[] arguments)
56
return Invoke(methodName, null, arguments);
60
/// Builds an invocation expression using this expression as target.
62
public InvocationExpression Invoke(string methodName, IEnumerable<AstType> typeArguments, IEnumerable<Expression> arguments)
64
InvocationExpression ie = new InvocationExpression();
65
MemberAccessExpression mre = new MemberAccessExpression();
67
mre.MemberName = methodName;
68
mre.TypeArguments.AddRange(typeArguments);
70
ie.Arguments.AddRange(arguments);
75
/// Builds an invocation expression using this expression as target.
77
public InvocationExpression Invoke(IEnumerable<Expression> arguments)
79
InvocationExpression ie = new InvocationExpression();
81
ie.Arguments.AddRange(arguments);
86
/// Builds an invocation expression using this expression as target.
88
public InvocationExpression Invoke(params Expression[] arguments)
90
InvocationExpression ie = new InvocationExpression();
92
ie.Arguments.AddRange(arguments);
96
public CastExpression CastTo(AstType type)
98
return new CastExpression { CastType = CastType.CType, Type = type, Expression = this };
101
public CastExpression CastTo(Type type)
103
return new CastExpression { CastType = CastType.CType, Type = AstType.Create(type), Expression = this };