Example #1
0
        public static BoundUnaryExpression Not(SyntaxNode syntax, BoundExpression condition)
        {
            Debug.Assert(condition.Type == TypeSymbol.Bool);

            var op = BoundUnaryOperator.Bind(SyntaxKind.BangToken, TypeSymbol.Bool);

            Debug.Assert(op != null);
            return(new BoundUnaryExpression(syntax, op, condition));
        }
Example #2
0
 public static BoundConstant?Fold(BoundUnaryOperator op, BoundExpression operand)
 {
     if (operand.ConstantValue?.Value != null)
     {
         return(op.Kind switch
         {
             BoundUnaryOperatorKind.Identity => new BoundConstant(operand.ConstantValue.Value switch
             {
                 char i => i,
                 sbyte i => i,
                 short i => i,
                 int i => i,
                 long i => i,
                 byte i => i,
                 ushort i => i,
                 uint i => i,
                 ulong i => i,
                 float i => i,
                 double i => i,
                 decimal i => i,
                 _ => throw new Exception("Unexpected type")
             }),