| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> | 2 * Copyright 2005 Frerich Raabe <raabe@kde.org> |
| 3 * Copyright (C) 2006 Apple Computer, Inc. | 3 * Copyright (C) 2006 Apple Computer, Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #ifndef XPathPredicate_h | 27 #ifndef XPathPredicate_h |
| 28 #define XPathPredicate_h | 28 #define XPathPredicate_h |
| 29 | 29 |
| 30 #include "core/xml/XPathExpressionNode.h" | 30 #include "core/xml/XPathExpressionNode.h" |
| 31 #include "core/xml/XPathValue.h" | 31 #include "core/xml/XPathValue.h" |
| 32 | 32 |
| 33 namespace WebCore { | 33 namespace WebCore { |
| 34 | 34 |
| 35 namespace XPath { | 35 namespace XPath { |
| 36 | 36 |
| 37 class Number : public Expression { | 37 class Number FINAL : public Expression { |
| 38 public: | 38 public: |
| 39 explicit Number(double); | 39 explicit Number(double); |
| 40 private: | 40 private: |
| 41 virtual Value evaluate() const; | 41 virtual Value evaluate() const OVERRIDE; |
| 42 virtual Value::Type resultType() const { return Value::NumberValue;
} | 42 virtual Value::Type resultType() const OVERRIDE { return Value::Numb
erValue; } |
| 43 | 43 |
| 44 Value m_value; | 44 Value m_value; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 class StringExpression : public Expression { | 47 class StringExpression FINAL : public Expression { |
| 48 public: | 48 public: |
| 49 explicit StringExpression(const String&); | 49 explicit StringExpression(const String&); |
| 50 private: | 50 private: |
| 51 virtual Value evaluate() const; | 51 virtual Value evaluate() const OVERRIDE; |
| 52 virtual Value::Type resultType() const { return Value::StringValue;
} | 52 virtual Value::Type resultType() const OVERRIDE { return Value::Stri
ngValue; } |
| 53 | 53 |
| 54 Value m_value; | 54 Value m_value; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 class Negative : public Expression { | 57 class Negative FINAL : public Expression { |
| 58 private: | 58 private: |
| 59 virtual Value evaluate() const; | 59 virtual Value evaluate() const OVERRIDE; |
| 60 virtual Value::Type resultType() const { return Value::NumberValue;
} | 60 virtual Value::Type resultType() const OVERRIDE { return Value::Numb
erValue; } |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class NumericOp : public Expression { | 63 class NumericOp FINAL : public Expression { |
| 64 public: | 64 public: |
| 65 enum Opcode { | 65 enum Opcode { |
| 66 OP_Add, OP_Sub, OP_Mul, OP_Div, OP_Mod | 66 OP_Add, OP_Sub, OP_Mul, OP_Div, OP_Mod |
| 67 }; | 67 }; |
| 68 NumericOp(Opcode, PassOwnPtr<Expression> lhs, PassOwnPtr<Expression>
rhs); | 68 NumericOp(Opcode, PassOwnPtr<Expression> lhs, PassOwnPtr<Expression>
rhs); |
| 69 private: | 69 private: |
| 70 virtual Value evaluate() const; | 70 virtual Value evaluate() const OVERRIDE; |
| 71 virtual Value::Type resultType() const { return Value::NumberValue;
} | 71 virtual Value::Type resultType() const OVERRIDE { return Value::Numb
erValue; } |
| 72 | 72 |
| 73 Opcode m_opcode; | 73 Opcode m_opcode; |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 class EqTestOp : public Expression { | 76 class EqTestOp FINAL : public Expression { |
| 77 public: | 77 public: |
| 78 enum Opcode { OP_EQ, OP_NE, OP_GT, OP_LT, OP_GE, OP_LE }; | 78 enum Opcode { OP_EQ, OP_NE, OP_GT, OP_LT, OP_GE, OP_LE }; |
| 79 EqTestOp(Opcode, PassOwnPtr<Expression> lhs, PassOwnPtr<Expression>
rhs); | 79 EqTestOp(Opcode, PassOwnPtr<Expression> lhs, PassOwnPtr<Expression>
rhs); |
| 80 virtual Value evaluate() const; | 80 virtual Value evaluate() const OVERRIDE; |
| 81 private: | 81 private: |
| 82 virtual Value::Type resultType() const { return Value::BooleanValue;
} | 82 virtual Value::Type resultType() const OVERRIDE { return Value::Bool
eanValue; } |
| 83 bool compare(const Value&, const Value&) const; | 83 bool compare(const Value&, const Value&) const; |
| 84 | 84 |
| 85 Opcode m_opcode; | 85 Opcode m_opcode; |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class LogicalOp : public Expression { | 88 class LogicalOp FINAL : public Expression { |
| 89 public: | 89 public: |
| 90 enum Opcode { OP_And, OP_Or }; | 90 enum Opcode { OP_And, OP_Or }; |
| 91 LogicalOp(Opcode, PassOwnPtr<Expression> lhs, PassOwnPtr<Expression>
rhs); | 91 LogicalOp(Opcode, PassOwnPtr<Expression> lhs, PassOwnPtr<Expression>
rhs); |
| 92 private: | 92 private: |
| 93 virtual Value::Type resultType() const { return Value::BooleanValue;
} | 93 virtual Value::Type resultType() const OVERRIDE { return Value::Bool
eanValue; } |
| 94 bool shortCircuitOn() const; | 94 bool shortCircuitOn() const; |
| 95 virtual Value evaluate() const; | 95 virtual Value evaluate() const OVERRIDE; |
| 96 | 96 |
| 97 Opcode m_opcode; | 97 Opcode m_opcode; |
| 98 }; | 98 }; |
| 99 | 99 |
| 100 class Union : public Expression { | 100 class Union FINAL : public Expression { |
| 101 private: | 101 private: |
| 102 virtual Value evaluate() const; | 102 virtual Value evaluate() const OVERRIDE; |
| 103 virtual Value::Type resultType() const { return Value::NodeSetValue;
} | 103 virtual Value::Type resultType() const OVERRIDE { return Value::Node
SetValue; } |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 class Predicate { | 106 class Predicate { |
| 107 WTF_MAKE_NONCOPYABLE(Predicate); WTF_MAKE_FAST_ALLOCATED; | 107 WTF_MAKE_NONCOPYABLE(Predicate); WTF_MAKE_FAST_ALLOCATED; |
| 108 public: | 108 public: |
| 109 explicit Predicate(PassOwnPtr<Expression>); | 109 explicit Predicate(PassOwnPtr<Expression>); |
| 110 ~Predicate(); | 110 ~Predicate(); |
| 111 bool evaluate() const; | 111 bool evaluate() const; |
| 112 | 112 |
| 113 bool isContextPositionSensitive() const { return m_expr->isContextPo
sitionSensitive() || m_expr->resultType() == Value::NumberValue; } | 113 bool isContextPositionSensitive() const { return m_expr->isContextPo
sitionSensitive() || m_expr->resultType() == Value::NumberValue; } |
| 114 bool isContextSizeSensitive() const { return m_expr->isContextSizeSe
nsitive(); } | 114 bool isContextSizeSensitive() const { return m_expr->isContextSizeSe
nsitive(); } |
| 115 | 115 |
| 116 private: | 116 private: |
| 117 OwnPtr<Expression> m_expr; | 117 OwnPtr<Expression> m_expr; |
| 118 }; | 118 }; |
| 119 | 119 |
| 120 } | 120 } |
| 121 | 121 |
| 122 } | 122 } |
| 123 | 123 |
| 124 #endif // XPathPredicate_h | 124 #endif // XPathPredicate_h |
| OLD | NEW |