#ifndef XPathPredicate_h
#define XPathPredicate_h
#include "XPathExpressionNode.h"
namespace WebCore {
namespace XPath {
class Number final : public Expression {
public:
explicit Number(double);
private:
Value evaluate() const override;
Value::Type resultType() const override { return Value::NumberValue; }
Value m_value;
};
class StringExpression final : public Expression {
public:
explicit StringExpression(String&&);
private:
Value evaluate() const override;
Value::Type resultType() const override { return Value::StringValue; }
Value m_value;
};
class Negative final : public Expression {
public:
explicit Negative(std::unique_ptr<Expression>);
private:
Value evaluate() const override;
Value::Type resultType() const override { return Value::NumberValue; }
};
class NumericOp final : public Expression {
public:
enum Opcode { OP_Add, OP_Sub, OP_Mul, OP_Div, OP_Mod };
NumericOp(Opcode, std::unique_ptr<Expression> lhs, std::unique_ptr<Expression> rhs);
private:
Value evaluate() const override;
Value::Type resultType() const override { return Value::NumberValue; }
Opcode m_opcode;
};
class EqTestOp final : public Expression {
public:
enum Opcode { OP_EQ, OP_NE, OP_GT, OP_LT, OP_GE, OP_LE };
EqTestOp(Opcode, std::unique_ptr<Expression> lhs, std::unique_ptr<Expression> rhs);
Value evaluate() const override;
private:
Value::Type resultType() const override { return Value::BooleanValue; }
bool compare(const Value&, const Value&) const;
Opcode m_opcode;
};
class LogicalOp final : public Expression {
public:
enum Opcode { OP_And, OP_Or };
LogicalOp(Opcode, std::unique_ptr<Expression> lhs, std::unique_ptr<Expression> rhs);
private:
Value::Type resultType() const override { return Value::BooleanValue; }
bool shortCircuitOn() const;
Value evaluate() const override;
Opcode m_opcode;
};
class Union final : public Expression {
public:
Union(std::unique_ptr<Expression>, std::unique_ptr<Expression>);
private:
Value evaluate() const override;
Value::Type resultType() const override { return Value::NodeSetValue; }
};
bool evaluatePredicate(const Expression&);
bool predicateIsContextPositionSensitive(const Expression&);
}
}
#endif // XPathPredicate_h