public ParametersBlock Block;
- public AnonymousMethodExpression (bool isAsync, Location loc)
+ public AnonymousMethodExpression (Location loc)
{
this.loc = loc;
this.compatibles = new Dictionary<TypeSpec, Expression> ();
target.Block = (ParametersBlock) clonectx.LookupBlock (Block);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
_target.target = target.Clone (clonectx);
_target.source = source.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class SimpleAssign : Assign
this.left = left;
}
+ public Binary.Operator Operator {
+ get {
+ return op;
+ }
+ }
+
protected override Expression DoResolve (ResolveContext ec)
{
right = right.Resolve (ec);
ctarget.right = ctarget.source = source.Clone (clonectx);
ctarget.target = target.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
}
this.loc = loc;
}
+ public Expression Expr {
+ get {
+ return expr;
+ }
+ }
+
protected override void CloneTo (CloneContext clonectx, Expression target)
{
var t = (Await) target;
{
stmt.EmitStatement (ec);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
class AwaitStatement : YieldStatement<AsyncInitializer>
public AttributeTargets Target;
readonly ATypeNameExpression expression;
- Arguments PosArguments;
- Arguments NamedArguments;
+ Arguments pos_args, named_args;
bool resolve_error;
bool arg_resolved;
{
this.expression = expr;
if (args != null) {
- PosArguments = args[0];
- NamedArguments = args[1];
+ pos_args = args[0];
+ named_args = args[1];
}
this.loc = loc;
ExplicitTarget = target;
}
}
+ public Arguments NamedArguments {
+ get {
+ return named_args;
+ }
+ }
+
+ public Arguments PositionalArguments {
+ get {
+ return pos_args;
+ }
+ }
+
+ public ATypeNameExpression TypeExpression {
+ get {
+ return expression;
+ }
+ }
+
void AddModuleCharSet (ResolveContext rc)
{
const string dll_import_char_set = "CharSet";
}
if (NamedArguments == null)
- NamedArguments = new Arguments (1);
+ named_args = new Arguments (1);
var value = Constant.CreateConstant (rc.Module.PredefinedTypes.CharSet.TypeSpec, rc.Module.DefaultCharSet, Location);
NamedArguments.Add (new NamedArgument (dll_import_char_set, loc, value));
public Attribute Clone ()
{
Attribute a = new Attribute (ExplicitTarget, expression, null, loc, nameEscaped);
- a.PosArguments = PosArguments;
- a.NamedArguments = NamedArguments;
+ a.pos_args = pos_args;
+ a.named_args = NamedArguments;
return a;
}
MethodSpec ctor;
// Try if the attribute is simple and has been resolved before
- if (PosArguments != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) {
+ if (pos_args != null || !context.Module.AttributeConstructorCache.TryGetValue (Type, out ctor)) {
rc = CreateResolveContext ();
ctor = ResolveConstructor (rc);
if (ctor == null) {
return null;
}
- if (PosArguments == null && ctor.Parameters.IsEmpty)
+ if (pos_args == null && ctor.Parameters.IsEmpty)
context.Module.AttributeConstructorCache.Add (Type, ctor);
}
MethodSpec ResolveConstructor (ResolveContext ec)
{
- if (PosArguments != null) {
+ if (pos_args != null) {
bool dynamic;
- PosArguments.Resolve (ec, out dynamic);
+ pos_args.Resolve (ec, out dynamic);
if (dynamic) {
Error_AttributeArgumentIsDynamic (ec.MemberContext, loc);
return null;
}
}
- return Expression.ConstructorLookup (ec, Type, ref PosArguments, loc);
+ return Expression.ConstructorLookup (ec, Type, ref pos_args, loc);
}
bool ResolveNamedArguments (ResolveContext ec)
if (resolve_error)
return DefaultUsageAttribute;
- AttributeUsageAttribute usage_attribute = new AttributeUsageAttribute ((AttributeTargets)((Constant) PosArguments [0].Expr).GetValue ());
+ AttributeUsageAttribute usage_attribute = new AttributeUsageAttribute ((AttributeTargets) ((Constant) pos_args[0].Expr).GetValue ());
var field = GetNamedValue ("AllowMultiple") as BoolConstant;
if (field != null)
// But because a lot of attribute class code must be rewritten will be better to wait...
Resolve ();
- if (resolve_error || PosArguments.Count != 1 || !(PosArguments [0].Expr is Constant))
+ if (resolve_error || pos_args.Count != 1 || !(pos_args[0].Expr is Constant))
return null;
- return ((Constant) PosArguments [0].Expr).GetValue () as string;
+ return ((Constant) pos_args[0].Expr).GetValue () as string;
}
/// <summary>
if (resolve_error)
return null;
- return ((Constant) PosArguments[0].Expr).GetValue () as string;
+ return ((Constant) pos_args[0].Expr).GetValue () as string;
}
/// <summary>
if (resolve_error)
return null;
- if (PosArguments == null)
+ if (pos_args == null)
return new ObsoleteAttribute ();
- string msg = ((Constant) PosArguments[0].Expr).GetValue () as string;
- if (PosArguments.Count == 1)
+ string msg = ((Constant) pos_args[0].Expr).GetValue () as string;
+ if (pos_args.Count == 1)
return new ObsoleteAttribute (msg);
- return new ObsoleteAttribute (msg, ((BoolConstant) PosArguments[1].Expr).Value);
+ return new ObsoleteAttribute (msg, ((BoolConstant) pos_args[1].Expr).Value);
}
/// <summary>
if (resolve_error)
return false;
- return ((BoolConstant) PosArguments[0].Expr).Value;
+ return ((BoolConstant) pos_args[0].Expr).Value;
}
public TypeSpec GetCoClassAttributeValue ()
System.Security.Permissions.SecurityAction GetSecurityActionValue ()
{
- return (SecurityAction) ((Constant) PosArguments[0].Expr).GetValue ();
+ return (SecurityAction) ((Constant) pos_args[0].Expr).GetValue ();
}
/// <summary>
public void ExtractSecurityPermissionSet (MethodSpec ctor, ref SecurityType permissions)
{
#if STATIC
- object[] values = new object [PosArguments.Count];
+ object[] values = new object[pos_args.Count];
for (int i = 0; i < values.Length; ++i)
- values [i] = ((Constant) PosArguments [i].Expr).GetValue ();
+ values[i] = ((Constant) pos_args[i].Expr).GetValue ();
PropertyInfo[] prop;
object[] prop_values;
public CharSet GetCharSetValue ()
{
- return (CharSet)System.Enum.Parse (typeof (CharSet), ((Constant) PosArguments [0].Expr).GetValue ().ToString ());
+ return (CharSet) System.Enum.Parse (typeof (CharSet), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
}
public bool HasField (string fieldName)
public bool IsInternalCall ()
{
MethodImplOptions options = 0;
- if (PosArguments.Count == 1) {
- options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
+ if (pos_args.Count == 1) {
+ options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
} else if (HasField ("Value")) {
var named = GetNamedValue ("Value");
options = (MethodImplOptions) System.Enum.Parse (typeof (MethodImplOptions), named.GetValue ().ToString ());
//
public bool IsExplicitLayoutKind ()
{
- if (PosArguments == null || PosArguments.Count != 1)
+ if (pos_args == null || pos_args.Count != 1)
return false;
- var value = (LayoutKind) System.Enum.Parse (typeof (LayoutKind), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
+ var value = (LayoutKind) System.Enum.Parse (typeof (LayoutKind), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
return value == LayoutKind.Explicit;
}
public Expression GetParameterDefaultValue ()
{
- if (PosArguments == null)
+ if (pos_args == null)
return null;
- return PosArguments[0].Expr;
+ return pos_args[0].Expr;
}
public override bool Equals (object obj)
}
byte[] cdata;
- if (PosArguments == null && named_values == null) {
+ if (pos_args == null && named_values == null) {
cdata = AttributeEncoder.Empty;
} else {
AttributeEncoder encoder = new AttributeEncoder ();
- if (PosArguments != null) {
+ if (pos_args != null) {
var param_types = ctor.Parameters.Types;
- for (int j = 0; j < PosArguments.Count; ++j) {
+ for (int j = 0; j < pos_args.Count; ++j) {
var pt = param_types[j];
- var arg_expr = PosArguments[j].Expr;
+ var arg_expr = pos_args[j].Expr;
if (j == 0) {
if ((Type == predefined.IndexerName || Type == predefined.Conditional) && arg_expr is Constant) {
string v = ((Constant) arg_expr).GetValue () as string;
"System.AttributeUsage");
}
} else if (Type == predefined.MarshalAs) {
- if (PosArguments.Count == 1) {
- var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) PosArguments[0].Expr).GetValue ().ToString ());
+ if (pos_args.Count == 1) {
+ var u_type = (UnmanagedType) System.Enum.Parse (typeof (UnmanagedType), ((Constant) pos_args[0].Expr).GetValue ().ToString ());
if (u_type == UnmanagedType.ByValArray && !(Owner is FieldBase)) {
Error_AttributeEmitError ("Specified unmanaged type is only valid on fields");
}
}
} else if (Type == predefined.DllImport) {
- if (PosArguments.Count == 1 && PosArguments[0].Expr is Constant) {
- var value = ((Constant) PosArguments[0].Expr).GetValue () as string;
+ if (pos_args.Count == 1 && pos_args[0].Expr is Constant) {
+ var value = ((Constant) pos_args[0].Expr).GetValue () as string;
if (string.IsNullOrEmpty (value))
Error_AttributeEmitError ("DllName cannot be empty");
}
// Here we are testing attribute arguments for array usage (error 3016)
if (Owner.IsClsComplianceRequired ()) {
- if (PosArguments != null)
- PosArguments.CheckArrayAsAttribute (context.Module.Compiler);
+ if (pos_args != null)
+ pos_args.CheckArrayAsAttribute (context.Module.Compiler);
if (NamedArguments == null)
return;
private Expression GetValue ()
{
- if (PosArguments == null || PosArguments.Count < 1)
+ if (pos_args == null || pos_args.Count < 1)
return null;
- return PosArguments [0].Expr;
+ return pos_args[0].Expr;
}
public string GetString ()
// from classes from the arraylist `type_bases'
//
protected TypeSpec base_type;
- protected FullNamedExpression base_type_expr; // TODO: It's temporary variable
+ FullNamedExpression base_type_expr; // TODO: It's temporary variable
protected TypeSpec[] iface_exprs;
protected List<FullNamedExpression> type_bases;
#region Properties
+ public List<FullNamedExpression> BaseTypeExpressions {
+ get {
+ return type_bases;
+ }
+ }
+
public override TypeSpec CurrentType {
get {
if (current_type == null) {
#endregion
- public abstract void Accept (StructuralVisitor visitor);
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
public bool AddMember (MemberCore symbol)
{
return field.Parent.GetSignatureForError () + "." + Name;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
}
--lexer.parsing_block;
var lt = (Tokenizer.LocatedToken) $1;
$$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4);
+ lbag.AddLocation ($$, GetLocation($2));
}
;
var lt = (Tokenizer.LocatedToken) $1;
$$ = new NamedArgument (lt.Value, lt.Location, (Expression) $4, arg_mod);
+ lbag.AddLocation ($$, GetLocation($2));
}
;
| explicit_interface THIS
{
lexer.parsing_generic_declaration = false;
- $$ = new MemberName ((MemberName) $1, TypeContainer.DefaultIndexerName, null, GetLocation ($1));
+ $$ = new MemberName ((MemberName) $1, TypeContainer.DefaultIndexerName, null, GetLocation ($2));
}
;
var lt2 = (Tokenizer.LocatedToken) $2;
$$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (TypeArguments) $3, lt1.Location);
+ lbag.AddLocation ($$, GetLocation ($2));
}
| primary_expression DOT GENERATE_COMPLETION {
$$ = new CompletionMemberAccess ((Expression) $1, null,GetLocation ($3));
var lt2 = (Tokenizer.LocatedToken) $2;
$$ = new QualifiedAliasMember (lt1.Value, lt2.Value, (int) $3, lt1.Location);
+ lbag.AddLocation ($$, GetLocation ($2));
}
| unbound_type_name DOT identifier_inside_body
{
expression_or_error // Have to close block when error occurs
{
Block b = end_block (lexer.Location);
+ b.IsCompilerGenerated = true;
b.AddStatement (new ContextualReturn ((Expression) $2));
$$ = b;
}
lambda_expression_body
{
$$ = end_anonymous ((ParametersBlock) $7);
- lbag.AddLocation ($$, GetLocation ($4), GetLocation ($5));
+ lbag.AddLocation ($$, GetLocation ($1), GetLocation ($4), GetLocation ($5));
}
| ASYNC OPEN_PARENS_LAMBDA
{
lambda_expression_body
{
$$ = end_anonymous ((ParametersBlock) $8);
- lbag.AddLocation ($$, GetLocation ($1), GetLocation ($5), GetLocation ($6));
+ lbag.AddLocation ($$, GetLocation ($1), GetLocation ($2), GetLocation ($5), GetLocation ($6));
}
;
{
var lt = (Tokenizer.LocatedToken) $2;
$$ = new Constraints (new SimpleMemberName (lt.Value, lt.Location), (List<FullNamedExpression>) $4, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($3));
}
;
{
var lt = (Tokenizer.LocatedToken) $1;
LabeledStatement labeled = new LabeledStatement (lt.Value, current_block, lt.Location);
-
+ lbag.AddLocation (labeled, GetLocation ($2));
current_block.AddLabel (labeled);
current_block.AddStatement (labeled);
}
ExpressionStatement s = $1 as ExpressionStatement;
if (s == null) {
Expression.Error_InvalidExpressionStatement (report, GetLocation ($1));
- $$ = new StatementExpression (EmptyExpressionStatement.Instance);
+ $$ = new StatementErrorExpression ($1 as Expression);
} else {
$$ = new StatementExpression (s);
}
For f = ((For) $0);
f.Statement = (Statement) $10;
- lbag.AddStatement (f, current_block.StartLocation, GetLocation ($2), GetLocation ($5), GetLocation ($9));
+ lbag.AddStatement (f, current_block.StartLocation, GetLocation ($2), GetLocation ($5), GetLocation ($8));
$$ = end_block (GetLocation ($2));
}
: GOTO identifier_inside_body SEMICOLON
{
var lt = (Tokenizer.LocatedToken) $2;
- $$ = new Goto (lt.Value, lt.Location);
- lbag.AddStatement ($$, GetLocation ($1), GetLocation ($3));
+ $$ = new Goto (lt.Value, GetLocation ($1));
+ lbag.AddStatement ($$, GetLocation ($2), GetLocation ($3));
}
| GOTO CASE constant_expression SEMICOLON
{
BY expression
{
$$ = new Linq.GroupBy ((Linq.QueryBlock)current_block, (Expression)$3, linq_clause_blocks.Pop (), (Expression)$6, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($5));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
var lt = (Tokenizer.LocatedToken) $2;
var sn = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.Let ((Linq.QueryBlock) current_block, sn, (Expression)$5, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($3));
current_block.SetEndLocation (lexer.Location);
current_block = current_block.Parent;
if ($12 == null) {
into = sn;
$$ = new Linq.Join (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9));
} else {
//
// Set equals right side parent to beginning of linq query, it is not accessible therefore cannot cause name collisions
into = new Linq.RangeVariable (lt.Value, lt.Location);
$$ = new Linq.GroupJoin (block, sn, (Expression)$5, outer_selector, (Linq.QueryBlock) current_block, into, GetLocation ($1));
+ lbag.AddLocation ($$, GetLocation ($3), GetLocation ($6), GetLocation ($9), GetLocation ($12));
}
current_block = block.Parent;
| expression ASCENDING
{
$$ = new Linq.OrderByAscending ((Linq.QueryBlock) current_block, (Expression)$1);
+ lbag.AddLocation ($$, GetLocation ($2));
}
| expression DESCENDING
{
$$ = new Linq.OrderByDescending ((Linq.QueryBlock) current_block, (Expression)$1);
+ lbag.AddLocation ($$, GetLocation ($2));
}
;
| expression ASCENDING
{
$$ = new Linq.ThenByAscending ((Linq.QueryBlock) current_block, (Expression)$1);
+ lbag.AddLocation ($$, GetLocation ($2));
}
| expression DESCENDING
{
$$ = new Linq.ThenByDescending ((Linq.QueryBlock) current_block, (Expression)$1);
+ lbag.AddLocation ($$, GetLocation ($2));
}
;
if (lang_version <= LanguageVersion.ISO_2)
FeatureIsNotAvailable (loc, "lambda expressions");
- current_anonymous_method = new LambdaExpression (isAsync, loc);
+ current_anonymous_method = new LambdaExpression (loc);
} else {
if (lang_version == LanguageVersion.ISO_1)
FeatureIsNotAvailable (loc, "anonymous methods");
- current_anonymous_method = new AnonymousMethodExpression (isAsync, loc);
+ current_anonymous_method = new AnonymousMethodExpression (loc);
}
async_block = isAsync;
}
}
- enum PreprocessorDirective
+ public enum PreprocessorDirective
{
Invalid = 0,
}
}
+ public bool IsDoubleColon {
+ get {
+ return is_double_colon;
+ }
+ }
+
public bool IsGeneric {
get {
if (TypeArguments != null)
cached_name = null;
}
+ public virtual void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
protected bool CheckAbstractAndExtern (bool has_block)
{
if (Parent.PartialContainer.Kind == MemberKind.Interface)
return parameters;
}
}
+
+ public FullNamedExpression TypExpression {
+ get {
+ return ReturnType;
+ }
+ }
+
#endregion
public override void Accept (StructuralVisitor visitor)
{
throw new NotImplementedException ("MakeExpression for " + GetType ());
}
+
+ public virtual object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
//if (ec.CurrentBlock == null || ec.CurrentBlock.CheckInvariantMeaningInBlock (Name, e, Location))
return e;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
Parent.MemberCache.AddMember (spec);
return true;
}
+
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
}
/// <summary>
{
return expr.DoResolveLValue (ec, right_side);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
target.Expr = Expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+
}
//
loc = l;
}
+ public Expression Expr {
+ get {
+ return expr;
+ }
+ }
+
public bool IsFixed {
get { return true; }
}
eclass = ExprClass.Variable;
return this;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
expr = e;
}
+ public Mode UnaryMutatorMode {
+ get {
+ return mode;
+ }
+ }
+
+ public Expression Expr {
+ get {
+ return expr;
+ }
+ }
+
public override bool ContainsEmitWithAwait ()
{
return expr.ContainsEmitWithAwait ();
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+
}
//
{
}
+ protected override string OperatorName {
+ get { return "is"; }
+ }
+
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
return this;
}
- protected override string OperatorName {
- get { return "is"; }
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
}
}
{
}
+ protected override string OperatorName {
+ get { return "as"; }
+ }
+
public override Expression CreateExpressionTree (ResolveContext ec)
{
Arguments args = Arguments.CreateForExpressionTree (ec, null,
return null;
}
- protected override string OperatorName {
- get { return "as"; }
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
}
}
target.target_type = target_type.Clone (clonectx);
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class ImplicitCast : ShimExpression
this.loc = loc;
}
+ public Expression Expr {
+ get {
+ return this.expr;
+ }
+ }
+
public override bool IsSideEffectFree {
get {
return true;
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
}
}
+ public Expression Left {
+ get {
+ return this.left;
+ }
+ }
+
+ public Expression Right {
+ get {
+ return this.right;
+ }
+ }
+
#endregion
/// <summary>
return CreateExpressionFactoryCall (ec, method_name, args);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+
}
//
return converted;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class BooleanExpressionFalse : Unary
}
}
- public Expression Expression {
+ public Expression Exp {
get {
return expr;
}
return SLE.Expression.Call (instance_expr, (MethodInfo) mi.GetMetaInfo (), Arguments.MakeExpression (args, ctx));
#endif
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
}
}
+ public Expression TypeExpression {
+ get {
+ return RequestedType;
+ }
+ }
+
#endregion
/// <summary>
return SLE.Expression.New ((ConstructorInfo) method.GetMetaInfo (), Arguments.MakeExpression (arguments, ctx));
#endif
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
get { return elements.Count; }
}
+ public List<Expression> Elements {
+ get {
+ return elements;
+ }
+ }
+
public Expression this [int index] {
get {
return elements [index];
{
throw new InternalErrorException ("Missing Resolve call");
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
{
}
+ public ComposedTypeSpecifier Rank {
+ get {
+ return this.rank;
+ }
+ }
+
+ public FullNamedExpression TypeExpression {
+ get {
+ return this.requested_base_type;
+ }
+ }
+
+ public ArrayInitializer Initializers {
+ get {
+ return this.initializers;
+ }
+ }
+
bool CheckIndices (ResolveContext ec, ArrayInitializer probe, int idx, bool specified_dims, int child_bounds)
{
if (initializers != null && bounds == null) {
if (initializers != null)
target.initializers = (ArrayInitializer) initializers.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
public override void VerifyAssigned (ResolveContext rc)
{
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
{
ec.Emit (OpCodes.Arglist);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
/// </summary>
public class Arglist : Expression
{
- Arguments Arguments;
+ Arguments arguments;
public Arglist (Location loc)
: this (null, loc)
public Arglist (Arguments args, Location l)
{
- Arguments = args;
+ arguments = args;
loc = l;
}
+ public Arguments Arguments {
+ get {
+ return arguments;
+ }
+ }
+
public MetaType[] ArgumentTypes {
get {
- if (Arguments == null)
+ if (arguments == null)
return MetaType.EmptyTypes;
- var retval = new MetaType[Arguments.Count];
- for (int i = 0; i < retval.Length; i++)
- retval[i] = Arguments[i].Expr.Type.GetMetaInfo ();
+ var retval = new MetaType[arguments.Count];
+ for (int i = 0; i < retval.Length; i++)
+ retval[i] = arguments[i].Expr.Type.GetMetaInfo ();
return retval;
}
{
eclass = ExprClass.Variable;
type = InternalType.Arglist;
- if (Arguments != null) {
+ if (arguments != null) {
bool dynamic; // Can be ignored as there is always only 1 overload
- Arguments.Resolve (ec, out dynamic);
+ arguments.Resolve (ec, out dynamic);
}
return this;
public override void Emit (EmitContext ec)
{
- if (Arguments != null)
- Arguments.Emit (ec);
+ if (arguments != null)
+ arguments.Emit (ec);
}
protected override void CloneTo (CloneContext clonectx, Expression t)
{
Arglist target = (Arglist) t;
- if (Arguments != null)
- target.Arguments = Arguments.Clone (clonectx);
+ if (arguments != null)
+ target.arguments = arguments.Clone (clonectx);
+ }
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
}
}
this.loc = loc;
}
+ public FullNamedExpression TypeExpression {
+ get {
+ return texpr;
+ }
+ }
+
public override bool ContainsEmitWithAwait ()
{
return false;
ec.Emit (OpCodes.Refanyval, type);
ec.EmitLoadFromPtr (type);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class RefTypeExpr : ShimExpression
if (m != null)
ec.Emit (OpCodes.Call, m);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class MakeRefExpr : ShimExpression
((IMemoryLocation) expr).AddressOf (ec, AddressOp.Load);
ec.Emit (OpCodes.Mkrefany, expr.Type);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
if (m != null)
ec.Emit (OpCodes.Call, m);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
sealed class TypeOfMethod : TypeOfMember<MethodSpec>
/// Implements the sizeof expression
/// </summary>
public class SizeOf : Expression {
- readonly Expression QueriedType;
+ readonly Expression texpr;
TypeSpec type_queried;
public SizeOf (Expression queried_type, Location l)
{
- this.QueriedType = queried_type;
+ this.texpr = queried_type;
loc = l;
}
}
}
+ public Expression TypeExpression {
+ get {
+ return texpr;
+ }
+ }
+
public override bool ContainsEmitWithAwait ()
{
return false;
protected override Expression DoResolve (ResolveContext ec)
{
- type_queried = QueriedType.ResolveAsType (ec);
+ type_queried = texpr.ResolveAsType (ec);
if (type_queried == null)
return null;
protected override void CloneTo (CloneContext clonectx, Expression t)
{
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
this.alias = alias;
}
+ public string Alias {
+ get {
+ return alias;
+ }
+ }
+
public override FullNamedExpression ResolveAsTypeOrNamespace (IMemberContext ec)
{
if (alias == GlobalAlias) {
{
// Nothing
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
target.Expr = Expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
target.Expr = Expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
if (Arguments != null)
target.Arguments = Arguments.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
base.ResolveBase (ec);
type = ec.CurrentType.BaseType;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
public override void EmitSideEffect (EmitContext ec)
{
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
sealed class EmptyAwaitExpression : EmptyExpression
{
// Do nothing
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class ErrorExpression : EmptyExpression
public override void Error_OperatorCannotBeApplied (ResolveContext rc, Location loc, string oper, TypeSpec t)
{
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class UserCast : Expression {
{
return left.GetSignatureForError () + spec.GetSignatureForError ();
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
class FixedBufferPtr : Expression
loc = l;
}
+ public Expression TypeExpression {
+ get {
+ return this.t;
+ }
+ }
+
+ public Expression CountExpression {
+ get {
+ return this.count;
+ }
+ }
+
public override bool ContainsEmitWithAwait ()
{
return false;
target.count = count.Clone (clonectx);
target.t = t.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
this.initializers = initializers;
}
+ public CollectionOrObjectInitializers Initializers {
+ get {
+ return initializers;
+ }
+ }
+
protected override void CloneTo (CloneContext clonectx, Expression t)
{
base.CloneTo (clonectx, t);
return instance;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class NewAnonymousType : New
this.parent = parent;
}
+ public List<AnonymousTypeParameter> Parameters {
+ get {
+ return this.parameters;
+ }
+ }
+
protected override void CloneTo (CloneContext clonectx, Expression target)
{
if (parameters == null)
RequestedType = new GenericTypeExpr (anonymous_type.Definition, new TypeArguments (t_args), loc);
return base.DoResolve (ec);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class AnonymousTypeParameter : ShimExpression
}
}
+ public List<FieldDeclarator> Declarators {
+ get {
+ return this.declarators;
+ }
+ }
+
public Expression Initializer {
get {
return initializer;
return false;
}
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public override bool Define ()
{
if (!base.Define ())
#region Properties
+ public List<FullNamedExpression> TypeExpressions {
+ get {
+ return constraints;
+ }
+ }
+
public Location Location {
get {
return loc;
}
}
+ public Constraints Constraints {
+ get {
+ return constraints;
+ }
+ }
+
public IAssemblyDefinition DeclaringAssembly {
get {
return Module.DeclaringAssembly;
}
}
+ public List<FullNamedExpression> TypeExpressions {
+ get {
+ return this.args;
+ }
+ }
+
public string GetSignatureForError()
{
StringBuilder sb = new StringBuilder ();
loc = l;
}
+ public Expression Expr {
+ get { return this.expr; }
+ }
+
protected override void CloneTo (CloneContext clonectx, Statement t)
{
var target = (YieldStatement<T>) t;
return true;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class YieldBreak : ExitStatement
{
iterator.EmitYieldBreak (ec, unwind_protect);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public abstract class StateMachine : AnonymousMethodStorey
// A list of Parameters (explicitly typed parameters)
// An ImplicitLambdaParameter
//
- public LambdaExpression (bool isAsync, Location loc)
- : base (isAsync, loc)
- {
- }
-
public LambdaExpression (Location loc)
- : this (false, loc)
+ : base (loc)
{
}
{
return "lambda expression";
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
class LambdaMethod : AnonymousMethodBody
this.identifier = identifier;
}
+ public RangeVariable Identifier {
+ get {
+ return identifier;
+ }
+ }
+
public FullNamedExpression IdentifierType { get; set; }
protected Invocation CreateCastExpression (Expression lSide)
}
}
+ public Expression SelectorExpression {
+ get {
+ return element_selector;
+ }
+ }
+
protected override void CreateArguments (ResolveContext ec, Parameter parameter, ref Arguments args)
{
base.CreateArguments (ec, parameter, ref args);
protected override string MethodName {
get { return "GroupBy"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Join : SelectMany
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);
protected override string MethodName {
get { return "Join"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class GroupJoin : Join
protected override string MethodName {
get { return "GroupJoin"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Let : ARangeVariableQueryClause
protected override string MethodName {
get { return "Select"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Select : AQueryClause
protected override string MethodName {
get { return "Select"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+
}
public class SelectMany : ARangeVariableQueryClause
protected override string MethodName {
get { return "SelectMany"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Where : AQueryClause
protected override string MethodName {
get { return "Where"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class OrderByAscending : AQueryClause
protected override string MethodName {
get { return "OrderBy"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class OrderByDescending : AQueryClause
protected override string MethodName {
get { return "OrderByDescending"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class ThenByAscending : OrderByAscending
protected override string MethodName {
get { return "ThenBy"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class ThenByDescending : OrderByDescending
protected override string MethodName {
get { return "ThenByDescending"; }
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class CharLiteral : CharConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class IntLiteral : IntConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class UIntLiteral : UIntConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class LongLiteral : LongConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class ULongLiteral : ULongConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class FloatLiteral : FloatConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class DoubleLiteral : DoubleConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class DecimalLiteral : DecimalConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class StringLiteral : StringConstant, ILiteralConstant
}
#if FULL_AST
- char[] ILiteralConstant.ParsedValue { get; set; }
+ public char[] ParsedValue { get; set; }
#endif
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
}
#endregion
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public static Method Create (DeclSpace parent, GenericMethod generic, FullNamedExpression returnType, Modifiers mod,
MemberName name, ParametersCompiled parameters, Attributes attrs, bool hasConstraints)
{
(Initializer.Arguments == null);
}
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.IsValidSecurityAttribute ()) {
ModFlags |= Modifiers.PROTECTED | Modifiers.OVERRIDE;
}
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.Conditional) {
Block = block;
}
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.Conditional) {
this.right = right;
this.loc = loc;
}
+
+ public Expression LeftExpression {
+ get {
+ return left;
+ }
+ }
+
+ public Expression Right {
+ get {
+ return right;
+ }
+ }
public override Expression CreateExpressionTree (ResolveContext ec)
{
target.left = left.Clone (clonectx);
target.right = right.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
class LiftedUnaryMutator : UnaryMutator
#region Properties
+ public Expression DefaultExpression {
+ get {
+ return default_expr;
+ }
+ }
+
public DefaultParameterValueExpression DefaultValue {
get {
return default_expr as DefaultParameterValueExpression;
}
}
+ public Modifier ParameterModifier {
+ get {
+ return modFlags;
+ }
+ }
+
public TypeSpec Type {
get {
return parameter_type;
//
// Default parameter value expression. We need this wrapper to handle
- // default parameter values of folded constants when for indexer parameters
+ // default parameter values of folded constants (e.g. indexer parameters).
// The expression is resolved only once but applied to two methods which
// both share reference to this expression and we ensure that resolving
// this expression always returns same instance
"Optional parameter expression of type `{0}' cannot be converted to parameter type `{1}'",
type.GetSignatureForError (), parameter_type.GetSignatureForError ());
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
}
{
}
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
+
void CreateAutomaticProperty ()
{
// Create backing field
{
}
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public override bool Define()
{
if (!base.Define ())
#region Properties
+ public List<FieldDeclarator> Declarators {
+ get {
+ return this.declarators;
+ }
+ }
+
bool HasBackingField {
get {
return !IsInterface && (ModFlags & Modifiers.ABSTRACT) == 0;
#endregion
+
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public void AddDeclarator (FieldDeclarator declarator)
{
if (declarators == null)
#endregion
+
+ public override void Accept (StructuralVisitor visitor)
+ {
+ visitor.Visit (this);
+ }
+
public override void ApplyAttributeBuilder (Attribute a, MethodSpec ctor, byte[] cdata, PredefinedAttributes pa)
{
if (a.Type == pa.IndexerName) {
ec.Report.Error (834, loc, "A lambda expression with statement body cannot be converted to an expresion tree");
return null;
}
+
+ public virtual object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public sealed class EmptyStatement : Statement
{
// nothing needed.
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class If : Statement {
loc = l;
}
+ public Expression Expr {
+ get {
+ return this.expr;
+ }
+ }
+
public override bool Resolve (BlockContext ec)
{
bool ok = true;
if (FalseStatement != null)
target.FalseStatement = FalseStatement.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Do : Statement {
target.EmbeddedStatement = EmbeddedStatement.Clone (clonectx);
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class While : Statement {
target.expr = expr.Clone (clonectx);
target.Statement = Statement.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class For : Statement
target.Iterator = Iterator.Clone (clonectx);
target.Statement = Statement.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class StatementExpression : Statement
loc = expr.Location;
}
+ public ExpressionStatement Expr {
+ get {
+ return this.expr;
+ }
+ }
+
protected override void CloneTo (CloneContext clonectx, Statement t)
{
StatementExpression target = (StatementExpression) t;
expr = expr.ResolveStatement (ec);
return expr != null;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class StatementErrorExpression : Statement
this.expr = expr;
}
- public Expression Expression {
+ public Expression Expr {
get {
return expr;
}
{
throw new NotImplementedException ();
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
foreach (Statement s in statements)
t.statements.Add (s.Clone (clonectx));
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
// A 'return' or a 'yield break'
/// </summary>
public class Return : ExitStatement
{
- protected Expression Expr;
+ Expression expr;
public Return (Expression expr, Location l)
{
- Expr = expr;
+ this.expr = expr;
loc = l;
}
#region Properties
- public Expression Expression {
+
+ public Expression Expr {
get {
- return Expr;
+ return expr;
+ }
+ protected set {
+ expr = value;
}
}
+
#endregion
protected override bool DoResolve (BlockContext ec)
{
- if (Expr == null) {
+ if (expr == null) {
if (ec.ReturnType.Kind == MemberKind.Void)
return true;
//
// Extra trick not to emit ret/leave inside awaiter body
//
- Expr = EmptyExpression.Null;
+ expr = EmptyExpression.Null;
return true;
}
}
return false;
}
- Expr = Expr.Resolve (ec);
+ expr = expr.Resolve (ec);
TypeSpec block_return_type = ec.ReturnType;
AnonymousExpression am = ec.CurrentAnonymousMethod;
var async_block = am as AsyncInitializer;
if (async_block != null) {
- if (Expr != null) {
+ if (expr != null) {
var storey = (AsyncTaskStorey) am.Storey;
var async_type = storey.ReturnType;
if (async_type == null && async_block.ReturnTypeInference != null) {
- async_block.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
+ async_block.ReturnTypeInference.AddCommonTypeBound (expr.Type);
return true;
}
}
} else {
var l = am as AnonymousMethodBody;
- if (l != null && l.ReturnTypeInference != null && Expr != null) {
- l.ReturnTypeInference.AddCommonTypeBound (Expr.Type);
+ if (l != null && l.ReturnTypeInference != null && expr != null) {
+ l.ReturnTypeInference.AddCommonTypeBound (expr.Type);
return true;
}
}
}
- if (Expr == null)
+ if (expr == null)
return false;
- if (Expr.Type != block_return_type) {
- Expr = Convert.ImplicitConversionRequired (ec, Expr, block_return_type, loc);
+ if (expr.Type != block_return_type) {
+ expr = Convert.ImplicitConversionRequired (ec, expr, block_return_type, loc);
- if (Expr == null) {
+ if (expr == null) {
if (am != null && block_return_type == ec.ReturnType) {
ec.Report.Error (1662, loc,
"Cannot convert `{0}' to delegate type `{1}' because some of the return types in the block are not implicitly convertible to the delegate return type",
protected override void DoEmit (EmitContext ec)
{
- if (Expr != null) {
- Expr.Emit (ec);
+ if (expr != null) {
+ expr.Emit (ec);
var async_body = ec.CurrentAnonymousMethod as AsyncInitializer;
if (async_body != null) {
{
Return target = (Return) t;
// It's null for simple return;
- if (Expr != null)
- target.Expr = Expr.Clone (clonectx);
+ if (expr != null)
+ target.expr = expr.Clone (clonectx);
+ }
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
}
}
Label l = label.LabelTarget (ec);
ec.Emit (unwind_protect ? OpCodes.Leave : OpCodes.Br, l);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class LabeledStatement : Statement {
{
referenced = true;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
{
ec.Emit (OpCodes.Br, ec.Switch.DefaultLabel);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
loc = l;
}
+ public Expression Expr {
+ get {
+ return this.expr;
+ }
+ }
+
public override bool Resolve (BlockContext ec)
{
if (ec.Switch == null){
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Throw : Statement {
loc = l;
}
+ public Expression Expr {
+ get {
+ return this.expr;
+ }
+ }
+
public override bool Resolve (BlockContext ec)
{
if (expr == null) {
if (expr != null)
target.expr = expr.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Break : Statement {
{
// nothing needed
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Continue : Statement {
{
// nothing needed.
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public interface ILocalVariable
t.AddDeclarator (new Declarator (d, d.Initializer == null ? null : d.Initializer.Clone (clonectx)));
}
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class BlockConstantDeclaration : BlockVariableDeclaration
li.ConstantValue = c;
return initializer;
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
int? resolving_init_idx;
- protected Block original;
+ Block original;
#if DEBUG
static int id;
get {
return original;
}
+ protected set {
+ original = value;
+ }
}
public bool IsCompilerGenerated {
set { flags |= Flags.Unsafe; }
}
+ public List<Statement> Statements {
+ get { return statements; }
+ }
+
#endregion
public Block CreateSwitchBlock (Location start)
foreach (Statement s in statements)
target.statements.Add (s.Clone (clonectx));
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class ExplicitBlock : Block
// Overwrite original for comparison purposes when linking cross references
// between anonymous methods
//
- original = source;
+ Original = source;
}
#region Properties
ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation);
pb.EndLocation = EndLocation;
pb.statements = statements;
- pb.original = this;
+ pb.Original = this;
var iterator = new Iterator (pb, method, host, iterator_type, is_enumerable);
am_storey = new IteratorStorey (iterator);
ParametersBlock pb = new ParametersBlock (this, ParametersCompiled.EmptyReadOnlyParameters, StartLocation);
pb.EndLocation = EndLocation;
pb.statements = statements;
- pb.original = this;
+ pb.Original = this;
var block_type = host.Module.Compiler.BuiltinTypes.Void;
var initializer = new AsyncInitializer (pb, host, block_type);
target.Sections.Add (ss.Clone (clonectx));
}
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
// A place where execution can restart in an iterator
this.expr = expr;
}
+ public Expression Expr {
+ get {
+ return this.expr;
+ }
+ }
+
public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);
target.expr = expr.Clone (clonectx);
target.stmt = Statement.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
+
}
public class Unchecked : Statement {
target.Block = clonectx.LookupBlock (Block);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Checked : Statement {
target.Block = clonectx.LookupBlock (Block);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Unsafe : Statement {
target.Block = clonectx.LookupBlock (Block);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
//
target.decl = (VariableDeclaration) decl.Clone (clonectx);
target.statement = statement.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Catch : Statement
this.fini = fini;
}
+ public Block Finallyblock {
+ get {
+ return fini;
+ }
+ }
+
public override bool Resolve (BlockContext ec)
{
bool ok = true;
if (fini != null)
target.fini = clonectx.LookupBlock (fini);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class TryCatch : ExceptionStatement
target.clauses.Add ((Catch) c.Clone (clonectx));
}
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
public class Using : TryFinallyBlock
declarators = null;
return stmt;
- }
+ }
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
VariableDeclaration decl;
#region Properties
- public Expression Expression {
+ public Expression Expr {
get {
return decl.Variable == null ? decl.Initializer : null;
}
target.decl = (VariableDeclaration) decl.Clone (clonectx);
target.stmt = stmt.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
/// <summary>
loc = l;
}
+ public Expression Expr {
+ get { return expr; }
+ }
+
public Statement Statement {
get { return statement; }
}
+ public Expression TypeExpression {
+ get { return type; }
+ }
+
+ public LocalVariable Variable {
+ get { return variable; }
+ }
+
+
public override bool Resolve (BlockContext ec)
{
expr = expr.Resolve (ec);
target.expr = expr.Clone (clonectx);
target.statement = statement.Clone (clonectx);
}
+
+ public override object Accept (StructuralVisitor visitor)
+ {
+ return visitor.Visit (this);
+ }
}
}
return System.Runtime.CompilerServices.RuntimeHelpers.GetHashCode (obj);
}
}
-
+#if !NET_4_0
public class Tuple<T1, T2> : IEquatable<Tuple<T1, T2>>
{
public Tuple (T1 item1, T2 item2)
return new Tuple<T1, T2, T3> (item1, item2, item3);
}
}
+#endif
static class ArrayComparer
{