Пример #1
0
        static ConstantValue CreateConstant(AST.Literal expr)
        {
            if (expr is AST.IntLiteral)
            {
                return(ConstantValue.Create(((AST.IntLiteral)expr).Value));
            }
            if (expr is AST.LongIntLiteral)
            {
                return(ConstantValue.Create(((AST.LongIntLiteral)expr).Value));
            }
            if (expr is AST.StringLiteral)
            {
                return(ConstantValue.Create(((AST.StringLiteral)expr).Value));
            }
            if (expr is AST.DoubleLiteral)
            {
                return(ConstantValue.Create(((AST.DoubleLiteral)expr).Value));
            }
            if (expr is AST.BoolLiteral)
            {
                return(ConstantValue.Create(((AST.BoolLiteral)expr).Value));
            }
            if (expr is AST.NullLiteral)
            {
                return(ConstantValue.Create(null));
            }
            //if (expr is BinaryStringLiteral) return ConstantValue.Create(((BinaryStringLiteral)expr).Value);

            return(null);
        }
Пример #2
0
        static BoundExpression BindLiteral(AST.Literal expr)
        {
            if (expr is AST.IntLiteral)
            {
                return(new BoundLiteral(((AST.IntLiteral)expr).Value));
            }
            if (expr is AST.LongIntLiteral)
            {
                return(new BoundLiteral(((AST.LongIntLiteral)expr).Value));
            }
            if (expr is AST.StringLiteral)
            {
                return(new BoundLiteral(((AST.StringLiteral)expr).Value));
            }
            if (expr is AST.DoubleLiteral)
            {
                return(new BoundLiteral(((AST.DoubleLiteral)expr).Value));
            }
            if (expr is AST.BoolLiteral)
            {
                return(new BoundLiteral(((AST.BoolLiteral)expr).Value));
            }
            if (expr is AST.NullLiteral)
            {
                return(new BoundLiteral(null));
            }
            if (expr is AST.BinaryStringLiteral)
            {
                return(new BoundLiteral(((AST.BinaryStringLiteral)expr).Value));
            }

            throw new NotImplementedException();
        }