Bind() public method

public Bind ( DynamicContext ctx, Type callingType ) : DynamicMetaObject
ctx DynamicContext
callingType System.Type
return System.Dynamic.DynamicMetaObject
		public override DynamicMetaObject FallbackSetIndex (DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
		{
			if (argumentInfo.Count != indexes.Length + 2) {
				if (errorSuggestion == null)
					throw new NotImplementedException ();

				return errorSuggestion;
			}

			var ctx = DynamicContext.Create ();
			var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);
			var args = ctx.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
			expr = new Compiler.ElementAccess (expr, args, Compiler.Location.Null);

			var source = ctx.CreateCompilerExpression (argumentInfo [indexes.Length + 1], value);

			// Same conversion as in SetMemberBinder
			if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0) {
				expr = new Compiler.RuntimeExplicitAssign (expr, source);
			} else {
				expr = new Compiler.SimpleAssign (expr, source);
			}
			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);
			binder.AddRestrictions (value);
			binder.AddRestrictions (indexes);

			return binder.Bind (ctx, callingContext);
		}
示例#2
0
        public override DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion)
        {
            var left  = CSharpBinder.CreateCompilerExpression(argumentInfo [0], target, true);
            var right = CSharpBinder.CreateCompilerExpression(argumentInfo [1], arg, true);

            bool is_compound;
            var  oper = GetOperator(out is_compound);

            Compiler.Expression expr;

            if (is_compound)
            {
                var target_expr = CSharpBinder.CreateCompilerExpression(argumentInfo[0], target, false);
                expr = new Compiler.CompoundAssign(oper, target_expr, right, left);
            }
            else
            {
                expr = new Compiler.Binary(oper, left, right);
                expr = new Compiler.Cast(new Compiler.TypeExpression(typeof(object), Compiler.Location.Null), expr);
            }

            if (is_checked)
            {
                expr = new Compiler.CheckedExpr(expr, Compiler.Location.Null);
            }

            var restrictions = CreateRestrictionsOnTarget(target).Merge(CreateRestrictionsOnTarget(arg));

            return(CSharpBinder.Bind(target, expr, restrictions, errorSuggestion));
        }
示例#3
0
        public override DynamicMetaObject FallbackConvert(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
        {
            var ctx  = DynamicContext.Create();
            var expr = ctx.CreateCompilerExpression(null, target);

            if (Explicit)
            {
                expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(Type), Compiler.Location.Null), expr, Compiler.Location.Null);
            }
            else
            {
                expr = new Compiler.ImplicitCast(expr, ctx.ImportType(Type), (flags & CSharpBinderFlags.ConvertArrayIndex) != 0);
            }

            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 FallbackGetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion)
        {
            if (argumentInfo.Count != indexes.Length + 1)
            {
                if (errorSuggestion == null)
                {
                    throw new NotImplementedException();
                }

                return(errorSuggestion);
            }

            var ctx  = DynamicContext.Create();
            var expr = ctx.CreateCompilerExpression(argumentInfo [0], target);
            var args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), indexes);

            expr = new Compiler.ElementAccess(expr, args, Compiler.Location.Null);
            expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);
            binder.AddRestrictions(indexes);

            return(binder.Bind(ctx, callingContext));
        }
示例#5
0
		public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
		{
			var ctx = DynamicContext.Create ();
			var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
			var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);

			// Field assignment
			expr = new Compiler.MemberAccess (expr, Name);

			// Compound assignment under dynamic context does not convert result
			// expression but when setting member type we need to do explicit
			// conversion to ensure type match between member type and dynamic
			// expression type
			if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0) {
				expr = new Compiler.RuntimeExplicitAssign (expr, source);
			} else {
				expr = new Compiler.SimpleAssign (expr, source);
			}

			expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (value);

			return binder.Bind (ctx, callingContext);
		}
示例#6
0
        public override DynamicMetaObject FallbackBinaryOperation(DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion)
        {
            var ctx   = DynamicContext.Create();
            var left  = ctx.CreateCompilerExpression(argumentInfo [0], target);
            var right = ctx.CreateCompilerExpression(argumentInfo [1], arg);

            bool is_compound;
            var  oper = GetOperator(out is_compound);

            Compiler.Expression expr;

            if (is_compound)
            {
                var target_expr = new Compiler.RuntimeValueExpression(target, ctx.ImportType(target.LimitType));
                expr = new Compiler.CompoundAssign(oper, target_expr, right, left);
            }
            else
            {
                expr = new Compiler.Binary(oper, left, right);
            }

            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);
            binder.AddRestrictions(arg);

            return(binder.Bind(ctx, context));
        }
示例#7
0
		public override DynamicMetaObject FallbackGetMember (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
		{
			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			expr = new Compiler.MemberAccess (expr, Name);
			expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);

			return binder.Bind (callingContext, target);
		}
        public override DynamicMetaObject FallbackInvokeMember(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
        {
            var ctx    = DynamicContext.Create();
            var c_args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), args);
            var t_args = typeArguments == null ?
                         null :
                         new Compiler.TypeArguments(typeArguments.Select(l => new Compiler.TypeExpression(ctx.ImportType(l), Compiler.Location.Null)).ToArray());

            var expr = ctx.CreateCompilerExpression(argumentInfo[0], target);

            //
            // Simple name invocation is actually member access invocation
            // to capture original this argument. This  brings problem when
            // simple name is resolved as a static invocation and member access
            // has to be reduced back to simple name without reporting an error
            //
            if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0)
            {
                var value = expr as Compiler.RuntimeValueExpression;
                if (value != null)
                {
                    value.IsSuggestionOnly = true;
                }
            }

            expr = new Compiler.MemberAccess(expr, Name, t_args, Compiler.Location.Null);
            expr = new Invocation(expr, c_args, this);

            if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
            {
                expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
            }
            else
            {
                expr = new Compiler.DynamicResultCast(ctx.ImportType(ReturnType), expr);
            }

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);
            binder.AddRestrictions(args);

            if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
            {
                binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;
            }

            return(binder.Bind(ctx, callingContext));
        }
示例#9
0
		public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
		{
			var ctx = DynamicContext.Create ();
			var context_type = ctx.ImportType (callingContext);
			var queried_type = ctx.ImportType (target.LimitType);
			var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, context_type), 0);

			var expr = Compiler.Expression.MemberLookup (rc, context_type, queried_type, name, 0, false, Compiler.Location.Null);

			var binder = new CSharpBinder (
				this, new Compiler.BoolConstant (expr is Compiler.EventExpr, Compiler.Location.Null), null);

			binder.AddRestrictions (target);
			return binder.Bind (ctx, callingContext);
		}
示例#10
0
		public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
		{
			var ctx = CSharpBinder.CreateDefaultCompilerContext ();
			CSharpBinder.InitializeCompiler (ctx);
			var context_type = TypeImporter.Import (callingContext);
			var rc = new Compiler.ResolveContext (new RuntimeBinderContext (ctx, context_type), 0);

			var expr = Compiler.Expression.MemberLookup (rc, context_type, context_type, name, 0, false, Compiler.Location.Null);

			var binder = new CSharpBinder (
				this, new Compiler.BoolConstant (expr is Compiler.EventExpr, Compiler.Location.Null), null);

			binder.AddRestrictions (target);
			return binder.Bind (callingContext, target);
		}
        public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
        {
            var ctx = DynamicContext.Create();

            var expr = ctx.CreateCompilerExpression(argumentInfo [0], target);

            expr = new Compiler.MemberAccess(expr, Name);
            expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);

            return(binder.Bind(ctx, callingContext));
        }
		public override DynamicMetaObject Bind (DynamicMetaObject target, DynamicMetaObject[] args)
		{
			var type = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			target_return_type = type.Type.GetMetaInfo ();

			var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);

			var binder = new CSharpBinder (
				this, new Compiler.New (type, c_args, Compiler.Location.Null), null);

			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			return binder.Bind (callingContext, target);
		}
示例#13
0
        public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
        {
            var ctx          = DynamicContext.Create();
            var context_type = ctx.ImportType(callingContext);
            var queried_type = ctx.ImportType(target.LimitType);
            var rc           = new Compiler.ResolveContext(new RuntimeBinderContext(ctx, context_type), 0);

            var expr = Compiler.Expression.MemberLookup(rc, context_type, queried_type,
                                                        name, 0, Compiler.Expression.MemberLookupRestrictions.ExactArity, Compiler.Location.Null);

            var binder = new CSharpBinder(
                this, new Compiler.BoolConstant(expr is Compiler.EventExpr, Compiler.Location.Null), null);

            binder.AddRestrictions(target);
            return(binder.Bind(ctx, callingContext));
        }
示例#14
0
		public override DynamicMetaObject FallbackSetMember (DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
		{
			var ctx = DynamicContext.Create ();
			var source = ctx.CreateCompilerExpression (argumentInfo [1], value);
			var expr = ctx.CreateCompilerExpression (argumentInfo [0], target);

			// Field assignment
			expr = new Compiler.MemberAccess (expr, Name);
			expr = new Compiler.SimpleAssign (expr, source);
			expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (value);

			return binder.Bind (ctx, callingContext);
		}
示例#15
0
		public override DynamicMetaObject FallbackInvoke (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			var c_args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), args);
			expr = new Compiler.Invocation (expr, c_args);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (TypeImporter.Import (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			return binder.Bind (callingContext, target);
		}
示例#16
0
		public override DynamicMetaObject FallbackConvert (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
		{
			var expr = CSharpBinder.CreateCompilerExpression (null, target);

			if (Explicit)
				expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (Type), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.ImplicitCast (expr, TypeImporter.Import (Type), (flags & CSharpBinderFlags.ConvertArrayIndex) != 0);

			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 (context);
		}
        public override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
        {
            var ctx = DynamicContext.Create();

            var type = ctx.CreateCompilerExpression(argumentInfo [0], target);

            target_return_type = type.Type.GetMetaInfo();

            var c_args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), args);

            var binder = new CSharpBinder(
                this, new Compiler.New(type, c_args, Compiler.Location.Null), null);

            binder.AddRestrictions(target);
            binder.AddRestrictions(args);

            return(binder.Bind(ctx, callingContext));
        }
示例#18
0
        public override DynamicMetaObject FallbackSetIndex(DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
        {
            if (argumentInfo.Count != indexes.Length + 2)
            {
                if (errorSuggestion == null)
                {
                    throw new NotImplementedException();
                }

                return(errorSuggestion);
            }

            var ctx  = DynamicContext.Create();
            var expr = ctx.CreateCompilerExpression(argumentInfo [0], target);
            var args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), indexes);

            expr = new Compiler.ElementAccess(expr, args, Compiler.Location.Null);

            var source = ctx.CreateCompilerExpression(argumentInfo [indexes.Length + 1], value);

            // Same conversion as in SetMemberBinder
            if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0)
            {
                expr = new Compiler.RuntimeExplicitAssign(expr, source);
            }
            else
            {
                expr = new Compiler.SimpleAssign(expr, source);
            }
            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);
            binder.AddRestrictions(value);
            binder.AddRestrictions(indexes);

            return(binder.Bind(ctx, callingContext));
        }
        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));
        }
示例#20
0
		public override DynamicMetaObject FallbackGetIndex (DynamicMetaObject target, DynamicMetaObject[] indexes, DynamicMetaObject errorSuggestion)
		{
			if (argumentInfo.Count != indexes.Length + 1) {
				if (errorSuggestion == null)
					throw new NotImplementedException ();

				return errorSuggestion;
			}

			var expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			var args = CSharpBinder.CreateCompilerArguments (argumentInfo.Skip (1), indexes);
			expr = new Compiler.ElementAccess (expr, args, Compiler.Location.Null);
			expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (indexes);

			return binder.Bind (callingContext, target);
		}
示例#21
0
        public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
        {
            var ctx    = DynamicContext.Create();
            var expr   = ctx.CreateCompilerExpression(argumentInfo [0], target);
            var c_args = ctx.CreateCompilerArguments(argumentInfo.Skip(1), args);

            expr = new Compiler.Invocation(expr, c_args);

            if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
            {
                expr = new Compiler.Cast(new Compiler.TypeExpression(ctx.ImportType(ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
            }
            else
            {
                expr = new Compiler.DynamicResultCast(ctx.ImportType(ReturnType), expr);
            }

            var binder = new CSharpBinder(this, expr, errorSuggestion);

            binder.AddRestrictions(target);
            binder.AddRestrictions(args);

            return(binder.Bind(ctx, callingContext));
        }
        public override DynamicMetaObject FallbackSetMember(DynamicMetaObject target, DynamicMetaObject value, DynamicMetaObject errorSuggestion)
        {
            var ctx    = DynamicContext.Create();
            var source = ctx.CreateCompilerExpression(argumentInfo [1], value);
            var expr   = ctx.CreateCompilerExpression(argumentInfo [0], target);

            // Field assignment
            expr = new Compiler.MemberAccess(expr, Name);

            // Compound assignment under dynamic context does not convert result
            // expression but when setting member type we need to do explicit
            // conversion to ensure type match between member type and dynamic
            // expression type
            if ((flags & CSharpBinderFlags.ValueFromCompoundAssignment) != 0)
            {
                expr = new Compiler.RuntimeExplicitAssign(expr, source);
            }
            else
            {
                expr = new Compiler.SimpleAssign(expr, source);
            }

            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);
            binder.AddRestrictions(value);

            return(binder.Bind(ctx, callingContext));
        }
示例#23
0
 public override DynamicMetaObject FallbackGetMember(DynamicMetaObject target, DynamicMetaObject errorSuggestion)
 {
     return(CSharpBinder.Bind(target, errorSuggestion));
 }
示例#24
0
		public override DynamicMetaObject FallbackInvokeMember (DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
		{
			var ctx = DynamicContext.Create ();
			var c_args = ctx.CreateCompilerArguments (argumentInfo.Skip (1), args);
			var t_args = typeArguments == null ?
				null :
				new Compiler.TypeArguments (typeArguments.Select (l => new Compiler.TypeExpression (ctx.ImportType (l), Compiler.Location.Null)).ToArray ());

			var expr = ctx.CreateCompilerExpression (argumentInfo[0], target);

			//
			// Simple name invocation is actually member access invocation
 			// to capture original this argument. This  brings problem when
			// simple name is resolved as a static invocation and member access
			// has to be reduced back to simple name without reporting an error
			//
			if ((flags & CSharpBinderFlags.InvokeSimpleName) != 0) {
				var value = expr as Compiler.RuntimeValueExpression;
				if (value != null)
					value.IsSuggestionOnly = true;
			}

			expr = new Compiler.MemberAccess (expr, Name, t_args, Compiler.Location.Null);
			expr = new Invocation (expr, c_args, this);

			if ((flags & CSharpBinderFlags.ResultDiscarded) == 0)
				expr = new Compiler.Cast (new Compiler.TypeExpression (ctx.ImportType (ReturnType), Compiler.Location.Null), expr, Compiler.Location.Null);
			else
				expr = new Compiler.DynamicResultCast (ctx.ImportType (ReturnType), expr);

			var binder = new CSharpBinder (this, expr, errorSuggestion);
			binder.AddRestrictions (target);
			binder.AddRestrictions (args);

			if ((flags & CSharpBinderFlags.InvokeSpecialName) != 0)
				binder.ResolveOptions |= Compiler.ResolveContext.Options.InvokeSpecialName;

			return binder.Bind (ctx, callingContext);
		}
示例#25
0
 public override DynamicMetaObject FallbackInvoke(DynamicMetaObject target, DynamicMetaObject[] args, DynamicMetaObject errorSuggestion)
 {
     return(CSharpBinder.Bind(target, errorSuggestion, args));
 }
		public override DynamicMetaObject FallbackBinaryOperation (DynamicMetaObject target, DynamicMetaObject arg, DynamicMetaObject errorSuggestion)
		{
			var left = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);
			var right = CSharpBinder.CreateCompilerExpression (argumentInfo [1], arg);
			
			bool is_compound;
			var oper = GetOperator (out is_compound);
			Compiler.Expression expr;

			if (is_compound) {
				var target_expr = CSharpBinder.CreateCompilerExpression (argumentInfo[0], target);
				expr = new Compiler.CompoundAssign (oper, target_expr, right, left, Compiler.Location.Null);
			} else {
				expr = new Compiler.Binary (oper, left, right, Compiler.Location.Null);
			}

			expr = new Compiler.Cast (new Compiler.TypeExpression (TypeImporter.Import (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);
			binder.AddRestrictions (arg);

			return binder.Bind (context);
		}
示例#27
0
		public override DynamicMetaObject FallbackUnaryOperation (DynamicMetaObject target, DynamicMetaObject errorSuggestion)
		{
			Compiler.Expression expr = CSharpBinder.CreateCompilerExpression (argumentInfo [0], target);

			if (Operation == ExpressionType.IsTrue) {
				expr = new Compiler.BooleanExpression (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 (TypeImporter.Import (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 (context);
		}