+
+ public override void MutateHoistedGenericType (AnonymousMethodStorey storey)
+ {
+ type = storey.MutateType (type);
+ if (child_generic_parameter != null)
+ child_generic_parameter = storey.MutateGenericArgument (child_generic_parameter);
+
+ base.MutateHoistedGenericType (storey);
+ }
+ }
+
+ //
+ // Used when resolved expression has different representations for
+ // expression trees and emit phase
+ //
+ public class ReducedExpression : Expression
+ {
+ class ReducedConstantExpression : Constant
+ {
+ readonly Constant expr;
+ readonly Expression orig_expr;
+
+ public ReducedConstantExpression (Constant expr, Expression orig_expr)
+ : base (expr.Location)
+ {
+ this.expr = expr;
+ this.orig_expr = orig_expr;
+ eclass = expr.eclass;
+ type = expr.Type;
+ }
+
+ public override string AsString ()
+ {
+ return expr.AsString ();
+ }
+
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ return orig_expr.CreateExpressionTree (ec);
+ }
+
+ public override object GetValue ()
+ {
+ return expr.GetValue ();
+ }
+
+ public override Constant ConvertExplicitly (bool in_checked_context, Type target_type)
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override Expression DoResolve (EmitContext ec)
+ {
+ return this;
+ }
+
+ public override Constant Increment ()
+ {
+ throw new NotImplementedException ();
+ }
+
+ public override bool IsDefaultValue {
+ get {
+ return expr.IsDefaultValue;
+ }
+ }
+
+ public override bool IsNegative {
+ get {
+ return expr.IsNegative;
+ }
+ }
+
+ public override void Emit (EmitContext ec)
+ {
+ expr.Emit (ec);
+ }
+ }
+
+ readonly Expression expr, orig_expr;
+
+ private ReducedExpression (Expression expr, Expression orig_expr)
+ {
+ this.expr = expr;
+ this.orig_expr = orig_expr;
+ this.loc = orig_expr.Location;
+ }
+
+ public static Expression Create (Constant expr, Expression original_expr)
+ {
+ return new ReducedConstantExpression (expr, original_expr);
+ }
+
+ public static Expression Create (Expression expr, Expression original_expr)
+ {
+ Constant c = expr as Constant;
+ if (c != null)
+ return Create (c, original_expr);
+
+ return new ReducedExpression (expr, original_expr);
+ }
+
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ return orig_expr.CreateExpressionTree (ec);
+ }
+
+ public override Expression DoResolve (EmitContext ec)
+ {
+ eclass = expr.eclass;
+ type = expr.Type;
+ return this;
+ }
+
+ public override void Emit (EmitContext ec)
+ {
+ expr.Emit (ec);
+ }
+
+ public override void EmitBranchable (EmitContext ec, Label target, bool on_true)
+ {
+ expr.EmitBranchable (ec, target, on_true);
+ }
+ }
+
+ //
+ // Unresolved type name expressions
+ //
+ public abstract class ATypeNameExpression : FullNamedExpression
+ {
+ public readonly string Name;
+ protected TypeArguments targs;
+
+ protected ATypeNameExpression (string name, Location l)
+ {
+ Name = name;
+ loc = l;
+ }
+
+ protected ATypeNameExpression (string name, TypeArguments targs, Location l)
+ {
+ Name = name;
+ this.targs = targs;
+ loc = l;
+ }
+
+ public bool HasTypeArguments {
+ get {
+ return targs != null;
+ }
+ }
+
+ public override string GetSignatureForError ()
+ {
+ if (targs != null) {
+ return TypeManager.RemoveGenericArity (Name) + "<" +
+ targs.GetSignatureForError () + ">";
+ }
+
+ return Name;
+ }