| 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 14 matching lines...) Expand all Loading... |
| 25 */ | 25 */ |
| 26 | 26 |
| 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 FINAL : public Expression { | 37 class Number FINAL : public Expression { |
| 38 public: | 38 public: |
| 39 explicit Number(double); | 39 explicit Number(double); |
| 40 virtual void trace(Visitor*) OVERRIDE; | 40 virtual void trace(Visitor*) OVERRIDE; |
| 41 | 41 |
| 42 private: | 42 private: |
| 43 virtual Value evaluate() const OVERRIDE; | 43 virtual Value evaluate() const OVERRIDE; |
| 44 virtual Value::Type resultType() const OVERRIDE { return Value::Numb
erValue; } | 44 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
| 45 | 45 |
| 46 Value m_value; | 46 Value m_value; |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 class StringExpression FINAL : public Expression { | 49 class StringExpression FINAL : public Expression { |
| 50 public: | 50 public: |
| 51 explicit StringExpression(const String&); | 51 explicit StringExpression(const String&); |
| 52 virtual void trace(Visitor*) OVERRIDE; | 52 virtual void trace(Visitor*) OVERRIDE; |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 virtual Value evaluate() const OVERRIDE; | 55 virtual Value evaluate() const OVERRIDE; |
| 56 virtual Value::Type resultType() const OVERRIDE { return Value::Stri
ngValue; } | 56 virtual Value::Type resultType() const OVERRIDE { return Value::StringValue;
} |
| 57 | 57 |
| 58 Value m_value; | 58 Value m_value; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 class Negative FINAL : public Expression { | 61 class Negative FINAL : public Expression { |
| 62 private: | 62 private: |
| 63 virtual Value evaluate() const OVERRIDE; | 63 virtual Value evaluate() const OVERRIDE; |
| 64 virtual Value::Type resultType() const OVERRIDE { return Value::Numb
erValue; } | 64 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 class NumericOp FINAL : public Expression { | 67 class NumericOp FINAL : public Expression { |
| 68 public: | 68 public: |
| 69 enum Opcode { | 69 enum Opcode { |
| 70 OP_Add, OP_Sub, OP_Mul, OP_Div, OP_Mod | 70 OP_Add, OP_Sub, OP_Mul, OP_Div, OP_Mod |
| 71 }; | 71 }; |
| 72 NumericOp(Opcode, PassOwnPtrWillBeRawPtr<Expression> lhs, PassOwnPtr
WillBeRawPtr<Expression> rhs); | 72 NumericOp(Opcode, PassOwnPtrWillBeRawPtr<Expression> lhs, PassOwnPtrWillBeRa
wPtr<Expression> rhs); |
| 73 private: | |
| 74 virtual Value evaluate() const OVERRIDE; | |
| 75 virtual Value::Type resultType() const OVERRIDE { return Value::Numb
erValue; } | |
| 76 | 73 |
| 77 Opcode m_opcode; | 74 private: |
| 78 }; | 75 virtual Value evaluate() const OVERRIDE; |
| 76 virtual Value::Type resultType() const OVERRIDE { return Value::NumberValue;
} |
| 79 | 77 |
| 80 class EqTestOp FINAL : public Expression { | 78 Opcode m_opcode; |
| 81 public: | 79 }; |
| 82 enum Opcode { OP_EQ, OP_NE, OP_GT, OP_LT, OP_GE, OP_LE }; | |
| 83 EqTestOp(Opcode, PassOwnPtrWillBeRawPtr<Expression> lhs, PassOwnPtrW
illBeRawPtr<Expression> rhs); | |
| 84 virtual Value evaluate() const OVERRIDE; | |
| 85 private: | |
| 86 virtual Value::Type resultType() const OVERRIDE { return Value::Bool
eanValue; } | |
| 87 bool compare(const Value&, const Value&) const; | |
| 88 | 80 |
| 89 Opcode m_opcode; | 81 class EqTestOp FINAL : public Expression { |
| 90 }; | 82 public: |
| 83 enum Opcode { OpcodeEqual, OpcodeNotEqual, OpcodeGreaterThan, OpcodeLessThan
, OpcodeGreaterOrEqual, OpcodeLessOrEqual }; |
| 84 EqTestOp(Opcode, PassOwnPtrWillBeRawPtr<Expression> lhs, PassOwnPtrWillBeRaw
Ptr<Expression> rhs); |
| 85 virtual Value evaluate() const OVERRIDE; |
| 91 | 86 |
| 92 class LogicalOp FINAL : public Expression { | 87 private: |
| 93 public: | 88 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
| 94 enum Opcode { OP_And, OP_Or }; | 89 bool compare(const Value&, const Value&) const; |
| 95 LogicalOp(Opcode, PassOwnPtrWillBeRawPtr<Expression> lhs, PassOwnPtr
WillBeRawPtr<Expression> rhs); | |
| 96 private: | |
| 97 virtual Value::Type resultType() const OVERRIDE { return Value::Bool
eanValue; } | |
| 98 bool shortCircuitOn() const; | |
| 99 virtual Value evaluate() const OVERRIDE; | |
| 100 | 90 |
| 101 Opcode m_opcode; | 91 Opcode m_opcode; |
| 102 }; | 92 }; |
| 103 | 93 |
| 104 class Union FINAL : public Expression { | 94 class LogicalOp FINAL : public Expression { |
| 105 private: | 95 public: |
| 106 virtual Value evaluate() const OVERRIDE; | 96 enum Opcode { OP_And, OP_Or }; |
| 107 virtual Value::Type resultType() const OVERRIDE { return Value::Node
SetValue; } | 97 LogicalOp(Opcode, PassOwnPtrWillBeRawPtr<Expression> lhs, PassOwnPtrWillBeRa
wPtr<Expression> rhs); |
| 108 }; | |
| 109 | 98 |
| 110 class Predicate FINAL : public NoBaseWillBeGarbageCollected<Predicate> { | 99 private: |
| 111 WTF_MAKE_NONCOPYABLE(Predicate); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REM
OVED; | 100 virtual Value::Type resultType() const OVERRIDE { return Value::BooleanValue
; } |
| 112 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Predicate); | 101 bool shortCircuitOn() const; |
| 113 public: | 102 virtual Value evaluate() const OVERRIDE; |
| 114 explicit Predicate(PassOwnPtrWillBeRawPtr<Expression>); | |
| 115 void trace(Visitor*); | |
| 116 bool evaluate() const; | |
| 117 | 103 |
| 118 bool isContextPositionSensitive() const { return m_expr->isContextPo
sitionSensitive() || m_expr->resultType() == Value::NumberValue; } | 104 Opcode m_opcode; |
| 119 bool isContextSizeSensitive() const { return m_expr->isContextSizeSe
nsitive(); } | 105 }; |
| 120 | 106 |
| 121 private: | 107 class Union FINAL : public Expression { |
| 122 OwnPtrWillBeMember<Expression> m_expr; | 108 private: |
| 123 }; | 109 virtual Value evaluate() const OVERRIDE; |
| 110 virtual Value::Type resultType() const OVERRIDE { return Value::NodeSetValue
; } |
| 111 }; |
| 124 | 112 |
| 125 } | 113 class Predicate FINAL : public NoBaseWillBeGarbageCollected<Predicate> { |
| 114 WTF_MAKE_NONCOPYABLE(Predicate); WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 115 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(Predicate); |
| 116 public: |
| 117 explicit Predicate(PassOwnPtrWillBeRawPtr<Expression>); |
| 118 void trace(Visitor*); |
| 119 |
| 120 bool evaluate() const; |
| 121 bool isContextPositionSensitive() const { return m_expr->isContextPositionSe
nsitive() || m_expr->resultType() == Value::NumberValue; } |
| 122 bool isContextSizeSensitive() const { return m_expr->isContextSizeSensitive(
); } |
| 123 |
| 124 private: |
| 125 OwnPtrWillBeMember<Expression> m_expr; |
| 126 }; |
| 126 | 127 |
| 127 } | 128 } |
| 128 | 129 |
| 130 } |
| 129 #endif // XPathPredicate_h | 131 #endif // XPathPredicate_h |
| OLD | NEW |