AST.LogicalNot.GetExpr C# (CSharp) Method

GetExpr() public method

public GetExpr ( ABT env ) : ABT.Expr
env ABT
return ABT.Expr
        public override ABT.Expr GetExpr(ABT.Env env) {
            var expr = this.Expr.GetExpr(env);

            if (!expr.Type.IsArith) {
                throw new InvalidOperationException("Expected arithmetic Type.");
            }

            if (expr.Type.IsIntegral) {
                expr = ABT.TypeCast.IntegralPromotion(expr).Item1;
            }

            if (expr.IsConstExpr) {
                Boolean isZero;
                switch (expr.Type.Kind) {
                    case ABT.ExprTypeKind.LONG:
                        isZero = ((ABT.ConstLong)expr).Value == 0;
                        break;
                    case ABT.ExprTypeKind.ULONG:
                        isZero = ((ABT.ConstULong)expr).Value == 0;
                        break;
                    case ABT.ExprTypeKind.FLOAT:
                        isZero = ((ABT.ConstFloat)expr).Value == 0;
                        break;
                    case ABT.ExprTypeKind.DOUBLE:
                        isZero = ((ABT.ConstDouble)expr).Value == 0;
                        break;
                    default:
                        throw new InvalidOperationException();
                }
                return new ABT.ConstLong(Convert.ToInt32(isZero), env);
            }

            return new ABT.LogicalNot(expr);
        }
    }