HasSet() public method

public HasSet ( Options options ) : bool
options Options
return bool
Beispiel #1
0
        public override System.Linq.Expressions.Expression MakeExpression(BuilderContext ctx)
        {
            var tassign = target as IDynamicAssign;

            if (tassign == null)
            {
                throw new InternalErrorException(target.GetType() + " does not support dynamic assignment");
            }

            var target_object = tassign.MakeAssignExpression(ctx, source);

            //
            // Some hacking is needed as DLR does not support void type and requires
            // always have object convertible return type to support caching and chaining
            //
            // We do this by introducing an explicit block which returns RHS value when
            // available or null
            //
            if (target_object.NodeType == System.Linq.Expressions.ExpressionType.Block)
            {
                return(target_object);
            }

            System.Linq.Expressions.UnaryExpression source_object;
            if (ctx.HasSet(BuilderContext.Options.CheckedScope))
            {
                source_object = System.Linq.Expressions.Expression.ConvertChecked(source.MakeExpression(ctx), target_object.Type);
            }
            else
            {
                source_object = System.Linq.Expressions.Expression.Convert(source.MakeExpression(ctx), target_object.Type);
            }

            return(System.Linq.Expressions.Expression.Assign(target_object, source_object));
        }
Beispiel #2
0
		public override System.Linq.Expressions.Expression MakeExpression (BuilderContext ctx)
		{
			var tassign = target as IDynamicAssign;
			if (tassign == null)
				throw new InternalErrorException (target.GetType () + " does not support dynamic assignment");

			var target_object = tassign.MakeAssignExpression (ctx, source);

			//
			// Some hacking is needed as DLR does not support void type and requires
			// always have object convertible return type to support caching and chaining
			//
			// We do this by introducing an explicit block which returns RHS value when
			// available or null
			//
			if (target_object.NodeType == System.Linq.Expressions.ExpressionType.Block)
				return target_object;

			System.Linq.Expressions.UnaryExpression source_object;
			if (ctx.HasSet (BuilderContext.Options.CheckedScope)) {
				source_object = System.Linq.Expressions.Expression.ConvertChecked (source.MakeExpression (ctx), target_object.Type);
			} else {
				source_object = System.Linq.Expressions.Expression.Convert (source.MakeExpression (ctx), target_object.Type);
			}

			return System.Linq.Expressions.Expression.Assign (target_object, source_object);
		}
Beispiel #3
0
 public override SLE.Expression MakeExpression(BuilderContext ctx)
 {
     return ctx.HasSet (BuilderContext.Options.CheckedScope) ?
         SLE.Expression.ConvertChecked (child.MakeExpression (ctx), type.GetMetaInfo ()) :
         SLE.Expression.Convert (child.MakeExpression (ctx), type.GetMetaInfo ());
 }
		public override SLE.Expression MakeExpression (BuilderContext ctx)
		{
			var le = left.MakeExpression (ctx);
			var re = right.MakeExpression (ctx);
			bool is_checked = ctx.HasSet (BuilderContext.Options.CheckedScope);

			switch (oper) {
			case Operator.Addition:
				return is_checked ? SLE.Expression.AddChecked (le, re) : SLE.Expression.Add (le, re);
			case Operator.BitwiseAnd:
				return SLE.Expression.And (le, re);
			case Operator.BitwiseOr:
				return SLE.Expression.Or (le, re);
			case Operator.Division:
				return SLE.Expression.Divide (le, re);
			case Operator.Equality:
				return SLE.Expression.Equal (le, re);
			case Operator.ExclusiveOr:
				return SLE.Expression.ExclusiveOr (le, re);
			case Operator.GreaterThan:
				return SLE.Expression.GreaterThan (le, re);
			case Operator.GreaterThanOrEqual:
				return SLE.Expression.GreaterThanOrEqual (le, re);
			case Operator.Inequality:
				return SLE.Expression.NotEqual (le, re);
			case Operator.LeftShift:
				return SLE.Expression.LeftShift (le, re);
			case Operator.LessThan:
				return SLE.Expression.LessThan (le, re);
			case Operator.LessThanOrEqual:
				return SLE.Expression.LessThanOrEqual (le, re);
			case Operator.LogicalAnd:
				return SLE.Expression.AndAlso (le, re);
			case Operator.LogicalOr:
				return SLE.Expression.OrElse (le, re);
			case Operator.Modulus:
				return SLE.Expression.Modulo (le, re);
			case Operator.Multiply:
				return is_checked ? SLE.Expression.MultiplyChecked (le, re) : SLE.Expression.Multiply (le, re);
			case Operator.RightShift:
				return SLE.Expression.RightShift (le, re);
			case Operator.Subtraction:
				return is_checked ? SLE.Expression.SubtractChecked (le, re) : SLE.Expression.Subtract (le, re);
			default:
				throw new NotImplementedException (oper.ToString ());
			}
		}