コード例 #1
0
        public static UnaryExpression Negate(Expression expression)
        {
            Contract.RequiresNotNull(expression, "expression");
            Contract.Requires(TypeUtils.IsArithmetic(expression.Type) && !TypeUtils.IsUnsigned(expression.Type), "expression", "Expression must be signed numeric type");

            return(new UnaryExpression(AstNodeType.Negate, expression, expression.Type));
        }
コード例 #2
0
ファイル: BinaryExpression.cs プロジェクト: tylike/IronScheme
        private static BinaryExpression MakeBinaryArithmeticExpression(AstNodeType nodeType, Expression left, Expression right)
        {
            Contract.RequiresNotNull(left, "left");
            Contract.RequiresNotNull(left, "right");
            if (left.Type != right.Type || !TypeUtils.IsArithmetic(left.Type))
            {
                throw new NotSupportedException(String.Format("{0} only supports identical arithmetic types, got {1} {2}", nodeType, left.Type.Name, right.Type.Name));
            }

            return(new BinaryExpression(nodeType, left, right));
        }