public ParenthesizedExpression (Expression expr)
{
this.Expr = expr;
+ this.loc = expr.Location;
+ }
+
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
}
public override Expression DoResolve (EmitContext ec)
throw new Exception ("Should not happen");
}
- public override Location Location
- {
- get {
- return Expr.Location;
- }
- }
-
protected override void CloneTo (CloneContext clonectx, Expression t)
{
ParenthesizedExpression target = (ParenthesizedExpression) t;
/// Implementation of the `is' operator.
/// </summary>
public class Is : Probe {
+ Nullable.Unwrap expr_unwrap;
+
public Is (Expression expr, Expression probe_type, Location l)
: base (expr, probe_type, l)
{
public override void Emit (EmitContext ec)
{
ILGenerator ig = ec.ig;
+ if (expr_unwrap != null) {
+ expr_unwrap.EmitCheck (ec);
+ return;
+ }
expr.Emit (ec);
ig.Emit (OpCodes.Isinst, probe_type_expr.Type);
public override void EmitBranchable (EmitContext ec, Label target, bool on_true)
{
ILGenerator ig = ec.ig;
-
- expr.Emit (ec);
- ig.Emit (OpCodes.Isinst, probe_type_expr.Type);
+ if (expr_unwrap != null) {
+ expr_unwrap.EmitCheck (ec);
+ } else {
+ expr.Emit (ec);
+ ig.Emit (OpCodes.Isinst, probe_type_expr.Type);
+ }
ig.Emit (on_true ? OpCodes.Brtrue : OpCodes.Brfalse, target);
}
//
// D and T are the same value types but D can be null
//
- if (d_is_nullable && !t_is_nullable)
- return Nullable.HasValue.Create (expr, ec);
+ if (d_is_nullable && !t_is_nullable) {
+ expr_unwrap = Nullable.Unwrap.Create (expr, ec);
+ return this;
+ }
//
// The result is true if D and T are the same value types
get { return expr; }
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
+ }
+
public override Expression DoResolve (EmitContext ec)
{
expr = expr.Resolve (ec);
MethodInfo method;
ArrayList args = new ArrayList (2);
-
- args = new ArrayList (2);
args.Add (new Argument (left, Argument.AType.Expression));
args.Add (new Argument (right, Argument.AType.Expression));
method = TypeManager.delegate_remove_delegate_delegate;
}
- return new BinaryDelegate (l, method, args);
+ MethodGroupExpr mg = new MethodGroupExpr (new MemberInfo [] { method }, TypeManager.delegate_type, loc);
+ mg = mg.OverloadResolve (ec, ref args, false, loc);
+
+ return new ClassCast (new UserOperatorCall (mg, args, CreateExpressionTree, loc), l);
}
//
return CreateExpressionFactoryCall (method_name, args);
}
}
-
- //
- // Object created by Binary when the binary operator uses an method instead of being
- // a binary operation that maps to a CIL binary operation.
- //
- public class BinaryMethod : Expression {
- public MethodBase method;
- public ArrayList Arguments;
-
- public BinaryMethod (Type t, MethodBase m, ArrayList args)
- {
- method = m;
- Arguments = args;
- type = t;
- eclass = ExprClass.Value;
- }
-
- public override Expression DoResolve (EmitContext ec)
- {
- return this;
- }
-
- public override void Emit (EmitContext ec)
- {
- ILGenerator ig = ec.ig;
-
- Invocation.EmitArguments (ec, Arguments, false, null);
-
- if (method is MethodInfo)
- ig.Emit (OpCodes.Call, (MethodInfo) method);
- else
- ig.Emit (OpCodes.Call, (ConstructorInfo) method);
- }
- }
//
// Represents the operation a + b [+ c [+ d [+ ...]]], where a is a string
}
}
- //
- // Object created with +/= on delegates
- //
- public class BinaryDelegate : Expression {
- MethodInfo method;
- ArrayList args;
-
- public BinaryDelegate (Type t, MethodInfo mi, ArrayList args)
- {
- method = mi;
- this.args = args;
- type = t;
- eclass = ExprClass.Value;
- }
-
- public override Expression DoResolve (EmitContext ec)
- {
- return this;
- }
-
- public override void Emit (EmitContext ec)
- {
- ILGenerator ig = ec.ig;
-
- Invocation.EmitArguments (ec, args, false, null);
-
- ig.Emit (OpCodes.Call, (MethodInfo) method);
- ig.Emit (OpCodes.Castclass, type);
- }
-
- public Expression Right {
- get {
- Argument arg = (Argument) args [1];
- return arg.Expr;
- }
- }
-
- public bool IsAddition {
- get {
- return method == TypeManager.delegate_combine_delegate_delegate;
- }
- }
- }
-
//
// User-defined conditional logical operator
//
this.loc = expr.Location;
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
+ }
+
public override Expression DoResolve (EmitContext ec)
{
//
this.loc = loc;
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
+ }
+
public override Expression DoResolve (EmitContext ec)
{
if (TypeManager.fieldinfo_get_field_from_handle == null) {
throw new NotImplementedException (at.ToString ());
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ ArrayList args = new ArrayList (arguments.Count + 2);
+ args.Add (new Argument (instance_expr.CreateExpressionTree (ec)));
+ args.Add (new Argument (new TypeOfMethodInfo (get, loc)));
+ foreach (Argument a in arguments)
+ args.Add (new Argument (a.Expr.CreateExpressionTree (ec)));
+
+ return CreateExpressionFactoryCall ("Call", args);
+ }
+
protected virtual bool CommonResolve (EmitContext ec)
{
indexer_type = instance_expr.Type;
eclass = ExprClass.Value;
loc = Location.Null;
}
+
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
+ }
public override Expression DoResolve (EmitContext ec)
{
loc = Location.Null;
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ return null;
+ }
+
public override void EmitStatement (EmitContext ec)
{
// Do nothing
return type;
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
+ }
+
public override Expression DoResolve (EmitContext ec)
{
AnonymousTypeClass anonymous_type;
Constructor = type.GetConstructor (new Type[] { UnderlyingType });
}
}
-
- public class HasValue : Expression
- {
- Expression expr;
- NullableInfo info;
-
- private HasValue (Expression expr)
- {
- this.expr = expr;
- }
-
- public static Expression Create (Expression expr, EmitContext ec)
- {
- return new HasValue (expr).Resolve (ec);
- }
-
- public override void Emit (EmitContext ec)
- {
- IMemoryLocation memory_loc = expr as IMemoryLocation;
- if (memory_loc == null) {
- LocalTemporary temp = new LocalTemporary (expr.Type);
- expr.Emit (ec);
- temp.Store (ec);
- memory_loc = temp;
- }
- memory_loc.AddressOf (ec, AddressOp.LoadStore);
- ec.ig.EmitCall (OpCodes.Call, info.HasValue, null);
- }
-
- public override Expression DoResolve (EmitContext ec)
- {
- this.info = new NullableInfo (expr.Type);
-
- type = TypeManager.bool_type;
- eclass = expr.eclass;
- return this;
- }
- }
public class Unwrap : Expression, IMemoryLocation, IAssignMethod
{
eclass = ExprClass.Value;
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ throw new NotSupportedException ("ET");
+ }
+
public override Expression DoResolve (EmitContext ec)
{
return this;
eclass = ExprClass.Value;
}
+ public override Expression CreateExpressionTree (EmitContext ec)
+ {
+ return new SimpleAssign (this, this).CreateExpressionTree (ec);
+ }
+
public override Expression DoResolve (EmitContext ec)
{
expr = expr.Resolve (ec);