Inheritance: Expression, IDynamicAssign, IMemoryLocation
コード例 #1
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));
        }
コード例 #2
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);
		}