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 22 matching lines...) Expand all Loading... |
33 namespace blink { | 33 namespace blink { |
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 DECLARE_VIRTUAL_TRACE(); | 40 DECLARE_VIRTUAL_TRACE(); |
41 | 41 |
42 private: | 42 private: |
43 virtual Value evaluate(EvaluationContext&) const override; | 43 Value evaluate(EvaluationContext&) const override; |
44 virtual Value::Type resultType() const override { return Value::NumberValue;
} | 44 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 DECLARE_VIRTUAL_TRACE(); | 52 DECLARE_VIRTUAL_TRACE(); |
53 | 53 |
54 private: | 54 private: |
55 virtual Value evaluate(EvaluationContext&) const override; | 55 Value evaluate(EvaluationContext&) const override; |
56 virtual Value::Type resultType() const override { return Value::StringValue;
} | 56 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(EvaluationContext&) const override; | 63 Value evaluate(EvaluationContext&) const override; |
64 virtual Value::Type resultType() const override { return Value::NumberValue;
} | 64 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, Expression* lhs, Expression* rhs); | 72 NumericOp(Opcode, Expression* lhs, Expression* rhs); |
73 | 73 |
74 private: | 74 private: |
75 virtual Value evaluate(EvaluationContext&) const override; | 75 Value evaluate(EvaluationContext&) const override; |
76 virtual Value::Type resultType() const override { return Value::NumberValue;
} | 76 Value::Type resultType() const override { return Value::NumberValue; } |
77 | 77 |
78 Opcode m_opcode; | 78 Opcode m_opcode; |
79 }; | 79 }; |
80 | 80 |
81 class EqTestOp final : public Expression { | 81 class EqTestOp final : public Expression { |
82 public: | 82 public: |
83 enum Opcode { OpcodeEqual, OpcodeNotEqual, OpcodeGreaterThan, OpcodeLessThan
, OpcodeGreaterOrEqual, OpcodeLessOrEqual }; | 83 enum Opcode { OpcodeEqual, OpcodeNotEqual, OpcodeGreaterThan, OpcodeLessThan
, OpcodeGreaterOrEqual, OpcodeLessOrEqual }; |
84 EqTestOp(Opcode, Expression* lhs, Expression* rhs); | 84 EqTestOp(Opcode, Expression* lhs, Expression* rhs); |
85 virtual Value evaluate(EvaluationContext&) const override; | 85 Value evaluate(EvaluationContext&) const override; |
86 | 86 |
87 private: | 87 private: |
88 virtual Value::Type resultType() const override { return Value::BooleanValue
; } | 88 Value::Type resultType() const override { return Value::BooleanValue; } |
89 bool compare(EvaluationContext&, const Value&, const Value&) const; | 89 bool compare(EvaluationContext&, const Value&, const Value&) const; |
90 | 90 |
91 Opcode m_opcode; | 91 Opcode m_opcode; |
92 }; | 92 }; |
93 | 93 |
94 class LogicalOp final : public Expression { | 94 class LogicalOp final : public Expression { |
95 public: | 95 public: |
96 enum Opcode { OP_And, OP_Or }; | 96 enum Opcode { OP_And, OP_Or }; |
97 LogicalOp(Opcode, Expression* lhs, Expression* rhs); | 97 LogicalOp(Opcode, Expression* lhs, Expression* rhs); |
98 | 98 |
99 private: | 99 private: |
100 virtual Value::Type resultType() const override { return Value::BooleanValue
; } | 100 Value::Type resultType() const override { return Value::BooleanValue; } |
101 bool shortCircuitOn() const; | 101 bool shortCircuitOn() const; |
102 virtual Value evaluate(EvaluationContext&) const override; | 102 Value evaluate(EvaluationContext&) const override; |
103 | 103 |
104 Opcode m_opcode; | 104 Opcode m_opcode; |
105 }; | 105 }; |
106 | 106 |
107 class Union final : public Expression { | 107 class Union final : public Expression { |
108 private: | 108 private: |
109 virtual Value evaluate(EvaluationContext&) const override; | 109 Value evaluate(EvaluationContext&) const override; |
110 virtual Value::Type resultType() const override { return Value::NodeSetValue
; } | 110 Value::Type resultType() const override { return Value::NodeSetValue; } |
111 }; | 111 }; |
112 | 112 |
113 class Predicate final : public GarbageCollected<Predicate> { | 113 class Predicate final : public GarbageCollected<Predicate> { |
114 WTF_MAKE_NONCOPYABLE(Predicate); | 114 WTF_MAKE_NONCOPYABLE(Predicate); |
115 public: | 115 public: |
116 explicit Predicate(Expression*); | 116 explicit Predicate(Expression*); |
117 DECLARE_TRACE(); | 117 DECLARE_TRACE(); |
118 | 118 |
119 bool evaluate(EvaluationContext&) const; | 119 bool evaluate(EvaluationContext&) const; |
120 bool isContextPositionSensitive() const { return m_expr->isContextPositionSe
nsitive() || m_expr->resultType() == Value::NumberValue; } | 120 bool isContextPositionSensitive() const { return m_expr->isContextPositionSe
nsitive() || m_expr->resultType() == Value::NumberValue; } |
121 bool isContextSizeSensitive() const { return m_expr->isContextSizeSensitive(
); } | 121 bool isContextSizeSensitive() const { return m_expr->isContextSizeSensitive(
); } |
122 | 122 |
123 private: | 123 private: |
124 Member<Expression> m_expr; | 124 Member<Expression> m_expr; |
125 }; | 125 }; |
126 | 126 |
127 } // namespace XPath | 127 } // namespace XPath |
128 | 128 |
129 } // namespace blink | 129 } // namespace blink |
130 | 130 |
131 #endif // XPathPredicate_h | 131 #endif // XPathPredicate_h |
OLD | NEW |