public override DynamicMetaObject FallbackUnaryOperation (DynamicMetaObject target, DynamicMetaObject errorSuggestion) { var ctx = DynamicContext.Create (); var expr = ctx.CreateCompilerExpression (argumentInfo [0], target); if (Operation == ExpressionType.IsTrue) { expr = new Compiler.BooleanExpression (expr); } else if (Operation == ExpressionType.IsFalse) { expr = new Compiler.BooleanExpressionFalse (expr); } else { if (Operation == ExpressionType.Increment) expr = new Compiler.UnaryMutator (Compiler.UnaryMutator.Mode.PreIncrement, expr, Compiler.Location.Null); else if (Operation == ExpressionType.Decrement) expr = new Compiler.UnaryMutator (Compiler.UnaryMutator.Mode.PreDecrement, expr, Compiler.Location.Null); else expr = new Compiler.Unary (GetOperator (), expr, Compiler.Location.Null); expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null); if ((flags & CSharpBinderFlags.CheckedContext) != 0) expr = new Compiler.CheckedExpr (expr, Compiler.Location.Null); } var binder = new CSharpBinder (this, expr, errorSuggestion); binder.AddRestrictions (target); return binder.Bind (ctx, context); }
public override DynamicMetaObject FallbackUnaryOperation(DynamicMetaObject target, DynamicMetaObject errorSuggestion) { var ctx = DynamicContext.Create(); var expr = ctx.CreateCompilerExpression(argumentInfo [0], target); if (Operation == ExpressionType.IsTrue) { expr = new Compiler.BooleanExpression(expr); } else if (Operation == ExpressionType.IsFalse) { expr = new Compiler.BooleanExpressionFalse(expr); } else { if (Operation == ExpressionType.Increment) { expr = new Compiler.UnaryMutator(Compiler.UnaryMutator.Mode.PreIncrement, expr, Compiler.Location.Null); } else if (Operation == ExpressionType.Decrement) { expr = new Compiler.UnaryMutator(Compiler.UnaryMutator.Mode.PreDecrement, expr, Compiler.Location.Null); } else { expr = new Compiler.Unary(GetOperator(), expr, Compiler.Location.Null); } expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null); if ((flags & CSharpBinderFlags.CheckedContext) != 0) { expr = new Compiler.CheckedExpr(expr, Compiler.Location.Null); } } var binder = new CSharpBinder(this, expr, errorSuggestion); binder.AddRestrictions(target); return(binder.Bind(ctx, context)); }