OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_REGEXP_AST_H_ | 5 #ifndef RUNTIME_VM_REGEXP_AST_H_ |
6 #define RUNTIME_VM_REGEXP_AST_H_ | 6 #define RUNTIME_VM_REGEXP_AST_H_ |
7 | 7 |
8 #include "platform/globals.h" | 8 #include "platform/globals.h" |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
11 #include "vm/regexp.h" | 11 #include "vm/regexp.h" |
12 | 12 |
13 namespace dart { | 13 namespace dart { |
14 | 14 |
15 class RegExpAlternative; | 15 class RegExpAlternative; |
16 class RegExpAssertion; | 16 class RegExpAssertion; |
17 class RegExpAtom; | 17 class RegExpAtom; |
18 class RegExpBackReference; | 18 class RegExpBackReference; |
19 class RegExpCapture; | 19 class RegExpCapture; |
20 class RegExpCharacterClass; | 20 class RegExpCharacterClass; |
21 class RegExpCompiler; | 21 class RegExpCompiler; |
22 class RegExpDisjunction; | 22 class RegExpDisjunction; |
23 class RegExpEmpty; | 23 class RegExpEmpty; |
24 class RegExpLookahead; | 24 class RegExpLookahead; |
25 class RegExpQuantifier; | 25 class RegExpQuantifier; |
26 class RegExpText; | 26 class RegExpText; |
27 | 27 |
28 | |
29 class RegExpVisitor : public ValueObject { | 28 class RegExpVisitor : public ValueObject { |
30 public: | 29 public: |
31 virtual ~RegExpVisitor() {} | 30 virtual ~RegExpVisitor() {} |
32 #define MAKE_CASE(Name) \ | 31 #define MAKE_CASE(Name) \ |
33 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; | 32 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; |
34 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) | 33 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) |
35 #undef MAKE_CASE | 34 #undef MAKE_CASE |
36 }; | 35 }; |
37 | 36 |
38 | |
39 class RegExpTree : public ZoneAllocated { | 37 class RegExpTree : public ZoneAllocated { |
40 public: | 38 public: |
41 static const intptr_t kInfinity = kMaxInt32; | 39 static const intptr_t kInfinity = kMaxInt32; |
42 virtual ~RegExpTree() {} | 40 virtual ~RegExpTree() {} |
43 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; | 41 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; |
44 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 42 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
45 RegExpNode* on_success) = 0; | 43 RegExpNode* on_success) = 0; |
46 virtual bool IsTextElement() const { return false; } | 44 virtual bool IsTextElement() const { return false; } |
47 virtual bool IsAnchoredAtStart() const { return false; } | 45 virtual bool IsAnchoredAtStart() const { return false; } |
48 virtual bool IsAnchoredAtEnd() const { return false; } | 46 virtual bool IsAnchoredAtEnd() const { return false; } |
49 virtual intptr_t min_match() const = 0; | 47 virtual intptr_t min_match() const = 0; |
50 virtual intptr_t max_match() const = 0; | 48 virtual intptr_t max_match() const = 0; |
51 // Returns the interval of registers used for captures within this | 49 // Returns the interval of registers used for captures within this |
52 // expression. | 50 // expression. |
53 virtual Interval CaptureRegisters() const { return Interval::Empty(); } | 51 virtual Interval CaptureRegisters() const { return Interval::Empty(); } |
54 virtual void AppendToText(RegExpText* text); | 52 virtual void AppendToText(RegExpText* text); |
55 void Print(); | 53 void Print(); |
56 #define MAKE_ASTYPE(Name) \ | 54 #define MAKE_ASTYPE(Name) \ |
57 virtual RegExp##Name* As##Name(); \ | 55 virtual RegExp##Name* As##Name(); \ |
58 virtual bool Is##Name() const; | 56 virtual bool Is##Name() const; |
59 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) | 57 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) |
60 #undef MAKE_ASTYPE | 58 #undef MAKE_ASTYPE |
61 }; | 59 }; |
62 | 60 |
63 | |
64 class RegExpDisjunction : public RegExpTree { | 61 class RegExpDisjunction : public RegExpTree { |
65 public: | 62 public: |
66 explicit RegExpDisjunction(ZoneGrowableArray<RegExpTree*>* alternatives); | 63 explicit RegExpDisjunction(ZoneGrowableArray<RegExpTree*>* alternatives); |
67 virtual void* Accept(RegExpVisitor* visitor, void* data); | 64 virtual void* Accept(RegExpVisitor* visitor, void* data); |
68 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 65 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
69 virtual RegExpDisjunction* AsDisjunction(); | 66 virtual RegExpDisjunction* AsDisjunction(); |
70 virtual Interval CaptureRegisters() const; | 67 virtual Interval CaptureRegisters() const; |
71 virtual bool IsDisjunction() const; | 68 virtual bool IsDisjunction() const; |
72 virtual bool IsAnchoredAtStart() const; | 69 virtual bool IsAnchoredAtStart() const; |
73 virtual bool IsAnchoredAtEnd() const; | 70 virtual bool IsAnchoredAtEnd() const; |
74 virtual intptr_t min_match() const { return min_match_; } | 71 virtual intptr_t min_match() const { return min_match_; } |
75 virtual intptr_t max_match() const { return max_match_; } | 72 virtual intptr_t max_match() const { return max_match_; } |
76 ZoneGrowableArray<RegExpTree*>* alternatives() const { return alternatives_; } | 73 ZoneGrowableArray<RegExpTree*>* alternatives() const { return alternatives_; } |
77 | 74 |
78 private: | 75 private: |
79 ZoneGrowableArray<RegExpTree*>* alternatives_; | 76 ZoneGrowableArray<RegExpTree*>* alternatives_; |
80 intptr_t min_match_; | 77 intptr_t min_match_; |
81 intptr_t max_match_; | 78 intptr_t max_match_; |
82 }; | 79 }; |
83 | 80 |
84 | |
85 class RegExpAlternative : public RegExpTree { | 81 class RegExpAlternative : public RegExpTree { |
86 public: | 82 public: |
87 explicit RegExpAlternative(ZoneGrowableArray<RegExpTree*>* nodes); | 83 explicit RegExpAlternative(ZoneGrowableArray<RegExpTree*>* nodes); |
88 virtual void* Accept(RegExpVisitor* visitor, void* data); | 84 virtual void* Accept(RegExpVisitor* visitor, void* data); |
89 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 85 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
90 virtual RegExpAlternative* AsAlternative(); | 86 virtual RegExpAlternative* AsAlternative(); |
91 virtual Interval CaptureRegisters() const; | 87 virtual Interval CaptureRegisters() const; |
92 virtual bool IsAlternative() const; | 88 virtual bool IsAlternative() const; |
93 virtual bool IsAnchoredAtStart() const; | 89 virtual bool IsAnchoredAtStart() const; |
94 virtual bool IsAnchoredAtEnd() const; | 90 virtual bool IsAnchoredAtEnd() const; |
95 virtual intptr_t min_match() const { return min_match_; } | 91 virtual intptr_t min_match() const { return min_match_; } |
96 virtual intptr_t max_match() const { return max_match_; } | 92 virtual intptr_t max_match() const { return max_match_; } |
97 ZoneGrowableArray<RegExpTree*>* nodes() const { return nodes_; } | 93 ZoneGrowableArray<RegExpTree*>* nodes() const { return nodes_; } |
98 | 94 |
99 private: | 95 private: |
100 ZoneGrowableArray<RegExpTree*>* nodes_; | 96 ZoneGrowableArray<RegExpTree*>* nodes_; |
101 intptr_t min_match_; | 97 intptr_t min_match_; |
102 intptr_t max_match_; | 98 intptr_t max_match_; |
103 }; | 99 }; |
104 | 100 |
105 | |
106 class RegExpAssertion : public RegExpTree { | 101 class RegExpAssertion : public RegExpTree { |
107 public: | 102 public: |
108 enum AssertionType { | 103 enum AssertionType { |
109 START_OF_LINE, | 104 START_OF_LINE, |
110 START_OF_INPUT, | 105 START_OF_INPUT, |
111 END_OF_LINE, | 106 END_OF_LINE, |
112 END_OF_INPUT, | 107 END_OF_INPUT, |
113 BOUNDARY, | 108 BOUNDARY, |
114 NON_BOUNDARY | 109 NON_BOUNDARY |
115 }; | 110 }; |
116 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) {} | 111 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) {} |
117 virtual void* Accept(RegExpVisitor* visitor, void* data); | 112 virtual void* Accept(RegExpVisitor* visitor, void* data); |
118 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 113 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
119 virtual RegExpAssertion* AsAssertion(); | 114 virtual RegExpAssertion* AsAssertion(); |
120 virtual bool IsAssertion() const; | 115 virtual bool IsAssertion() const; |
121 virtual bool IsAnchoredAtStart() const; | 116 virtual bool IsAnchoredAtStart() const; |
122 virtual bool IsAnchoredAtEnd() const; | 117 virtual bool IsAnchoredAtEnd() const; |
123 virtual intptr_t min_match() const { return 0; } | 118 virtual intptr_t min_match() const { return 0; } |
124 virtual intptr_t max_match() const { return 0; } | 119 virtual intptr_t max_match() const { return 0; } |
125 AssertionType assertion_type() const { return assertion_type_; } | 120 AssertionType assertion_type() const { return assertion_type_; } |
126 | 121 |
127 private: | 122 private: |
128 AssertionType assertion_type_; | 123 AssertionType assertion_type_; |
129 }; | 124 }; |
130 | 125 |
131 | |
132 class CharacterSet : public ValueObject { | 126 class CharacterSet : public ValueObject { |
133 public: | 127 public: |
134 explicit CharacterSet(uint16_t standard_set_type) | 128 explicit CharacterSet(uint16_t standard_set_type) |
135 : ranges_(NULL), standard_set_type_(standard_set_type) {} | 129 : ranges_(NULL), standard_set_type_(standard_set_type) {} |
136 explicit CharacterSet(ZoneGrowableArray<CharacterRange>* ranges) | 130 explicit CharacterSet(ZoneGrowableArray<CharacterRange>* ranges) |
137 : ranges_(ranges), standard_set_type_(0) {} | 131 : ranges_(ranges), standard_set_type_(0) {} |
138 CharacterSet(const CharacterSet& that) | 132 CharacterSet(const CharacterSet& that) |
139 : ValueObject(), | 133 : ValueObject(), |
140 ranges_(that.ranges_), | 134 ranges_(that.ranges_), |
141 standard_set_type_(that.standard_set_type_) {} | 135 standard_set_type_(that.standard_set_type_) {} |
142 ZoneGrowableArray<CharacterRange>* ranges(); | 136 ZoneGrowableArray<CharacterRange>* ranges(); |
143 uint16_t standard_set_type() const { return standard_set_type_; } | 137 uint16_t standard_set_type() const { return standard_set_type_; } |
144 void set_standard_set_type(uint16_t special_set_type) { | 138 void set_standard_set_type(uint16_t special_set_type) { |
145 standard_set_type_ = special_set_type; | 139 standard_set_type_ = special_set_type; |
146 } | 140 } |
147 bool is_standard() { return standard_set_type_ != 0; } | 141 bool is_standard() { return standard_set_type_ != 0; } |
148 void Canonicalize(); | 142 void Canonicalize(); |
149 | 143 |
150 private: | 144 private: |
151 ZoneGrowableArray<CharacterRange>* ranges_; | 145 ZoneGrowableArray<CharacterRange>* ranges_; |
152 // If non-zero, the value represents a standard set (e.g., all whitespace | 146 // If non-zero, the value represents a standard set (e.g., all whitespace |
153 // characters) without having to expand the ranges. | 147 // characters) without having to expand the ranges. |
154 uint16_t standard_set_type_; | 148 uint16_t standard_set_type_; |
155 }; | 149 }; |
156 | 150 |
157 | |
158 class RegExpCharacterClass : public RegExpTree { | 151 class RegExpCharacterClass : public RegExpTree { |
159 public: | 152 public: |
160 RegExpCharacterClass(ZoneGrowableArray<CharacterRange>* ranges, | 153 RegExpCharacterClass(ZoneGrowableArray<CharacterRange>* ranges, |
161 bool is_negated) | 154 bool is_negated) |
162 : set_(ranges), is_negated_(is_negated) {} | 155 : set_(ranges), is_negated_(is_negated) {} |
163 explicit RegExpCharacterClass(uint16_t type) | 156 explicit RegExpCharacterClass(uint16_t type) |
164 : set_(type), is_negated_(false) {} | 157 : set_(type), is_negated_(false) {} |
165 virtual void* Accept(RegExpVisitor* visitor, void* data); | 158 virtual void* Accept(RegExpVisitor* visitor, void* data); |
166 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 159 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
167 virtual RegExpCharacterClass* AsCharacterClass(); | 160 virtual RegExpCharacterClass* AsCharacterClass(); |
(...skipping 19 matching lines...) Expand all Loading... |
187 // * : All characters | 180 // * : All characters |
188 uint16_t standard_type() const { return set_.standard_set_type(); } | 181 uint16_t standard_type() const { return set_.standard_set_type(); } |
189 ZoneGrowableArray<CharacterRange>* ranges() { return set_.ranges(); } | 182 ZoneGrowableArray<CharacterRange>* ranges() { return set_.ranges(); } |
190 bool is_negated() const { return is_negated_; } | 183 bool is_negated() const { return is_negated_; } |
191 | 184 |
192 private: | 185 private: |
193 CharacterSet set_; | 186 CharacterSet set_; |
194 bool is_negated_; | 187 bool is_negated_; |
195 }; | 188 }; |
196 | 189 |
197 | |
198 class RegExpAtom : public RegExpTree { | 190 class RegExpAtom : public RegExpTree { |
199 public: | 191 public: |
200 explicit RegExpAtom(ZoneGrowableArray<uint16_t>* data) : data_(data) {} | 192 explicit RegExpAtom(ZoneGrowableArray<uint16_t>* data) : data_(data) {} |
201 virtual void* Accept(RegExpVisitor* visitor, void* data); | 193 virtual void* Accept(RegExpVisitor* visitor, void* data); |
202 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 194 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
203 virtual RegExpAtom* AsAtom(); | 195 virtual RegExpAtom* AsAtom(); |
204 virtual bool IsAtom() const; | 196 virtual bool IsAtom() const; |
205 virtual bool IsTextElement() const { return true; } | 197 virtual bool IsTextElement() const { return true; } |
206 virtual intptr_t min_match() const { return data_->length(); } | 198 virtual intptr_t min_match() const { return data_->length(); } |
207 virtual intptr_t max_match() const { return data_->length(); } | 199 virtual intptr_t max_match() const { return data_->length(); } |
208 virtual void AppendToText(RegExpText* text); | 200 virtual void AppendToText(RegExpText* text); |
209 ZoneGrowableArray<uint16_t>* data() const { return data_; } | 201 ZoneGrowableArray<uint16_t>* data() const { return data_; } |
210 intptr_t length() const { return data_->length(); } | 202 intptr_t length() const { return data_->length(); } |
211 | 203 |
212 private: | 204 private: |
213 ZoneGrowableArray<uint16_t>* data_; | 205 ZoneGrowableArray<uint16_t>* data_; |
214 }; | 206 }; |
215 | 207 |
216 | |
217 class RegExpText : public RegExpTree { | 208 class RegExpText : public RegExpTree { |
218 public: | 209 public: |
219 RegExpText() : elements_(2), length_(0) {} | 210 RegExpText() : elements_(2), length_(0) {} |
220 virtual void* Accept(RegExpVisitor* visitor, void* data); | 211 virtual void* Accept(RegExpVisitor* visitor, void* data); |
221 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 212 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
222 virtual RegExpText* AsText(); | 213 virtual RegExpText* AsText(); |
223 virtual bool IsText() const; | 214 virtual bool IsText() const; |
224 virtual bool IsTextElement() const { return true; } | 215 virtual bool IsTextElement() const { return true; } |
225 virtual intptr_t min_match() const { return length_; } | 216 virtual intptr_t min_match() const { return length_; } |
226 virtual intptr_t max_match() const { return length_; } | 217 virtual intptr_t max_match() const { return length_; } |
227 virtual void AppendToText(RegExpText* text); | 218 virtual void AppendToText(RegExpText* text); |
228 void AddElement(TextElement elm) { | 219 void AddElement(TextElement elm) { |
229 elements_.Add(elm); | 220 elements_.Add(elm); |
230 length_ += elm.length(); | 221 length_ += elm.length(); |
231 } | 222 } |
232 GrowableArray<TextElement>* elements() { return &elements_; } | 223 GrowableArray<TextElement>* elements() { return &elements_; } |
233 | 224 |
234 private: | 225 private: |
235 GrowableArray<TextElement> elements_; | 226 GrowableArray<TextElement> elements_; |
236 intptr_t length_; | 227 intptr_t length_; |
237 }; | 228 }; |
238 | 229 |
239 | |
240 class RegExpQuantifier : public RegExpTree { | 230 class RegExpQuantifier : public RegExpTree { |
241 public: | 231 public: |
242 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; | 232 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; |
243 RegExpQuantifier(intptr_t min, | 233 RegExpQuantifier(intptr_t min, |
244 intptr_t max, | 234 intptr_t max, |
245 QuantifierType type, | 235 QuantifierType type, |
246 RegExpTree* body) | 236 RegExpTree* body) |
247 : body_(body), | 237 : body_(body), |
248 min_(min), | 238 min_(min), |
249 max_(max), | 239 max_(max), |
(...skipping 28 matching lines...) Expand all Loading... |
278 | 268 |
279 private: | 269 private: |
280 RegExpTree* body_; | 270 RegExpTree* body_; |
281 intptr_t min_; | 271 intptr_t min_; |
282 intptr_t max_; | 272 intptr_t max_; |
283 intptr_t min_match_; | 273 intptr_t min_match_; |
284 intptr_t max_match_; | 274 intptr_t max_match_; |
285 QuantifierType quantifier_type_; | 275 QuantifierType quantifier_type_; |
286 }; | 276 }; |
287 | 277 |
288 | |
289 class RegExpCapture : public RegExpTree { | 278 class RegExpCapture : public RegExpTree { |
290 public: | 279 public: |
291 explicit RegExpCapture(RegExpTree* body, intptr_t index) | 280 explicit RegExpCapture(RegExpTree* body, intptr_t index) |
292 : body_(body), index_(index) {} | 281 : body_(body), index_(index) {} |
293 virtual void* Accept(RegExpVisitor* visitor, void* data); | 282 virtual void* Accept(RegExpVisitor* visitor, void* data); |
294 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 283 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
295 static RegExpNode* ToNode(RegExpTree* body, | 284 static RegExpNode* ToNode(RegExpTree* body, |
296 intptr_t index, | 285 intptr_t index, |
297 RegExpCompiler* compiler, | 286 RegExpCompiler* compiler, |
298 RegExpNode* on_success); | 287 RegExpNode* on_success); |
299 virtual RegExpCapture* AsCapture(); | 288 virtual RegExpCapture* AsCapture(); |
300 virtual bool IsAnchoredAtStart() const; | 289 virtual bool IsAnchoredAtStart() const; |
301 virtual bool IsAnchoredAtEnd() const; | 290 virtual bool IsAnchoredAtEnd() const; |
302 virtual Interval CaptureRegisters() const; | 291 virtual Interval CaptureRegisters() const; |
303 virtual bool IsCapture() const; | 292 virtual bool IsCapture() const; |
304 virtual intptr_t min_match() const { return body_->min_match(); } | 293 virtual intptr_t min_match() const { return body_->min_match(); } |
305 virtual intptr_t max_match() const { return body_->max_match(); } | 294 virtual intptr_t max_match() const { return body_->max_match(); } |
306 RegExpTree* body() const { return body_; } | 295 RegExpTree* body() const { return body_; } |
307 intptr_t index() const { return index_; } | 296 intptr_t index() const { return index_; } |
308 static intptr_t StartRegister(intptr_t index) { return index * 2; } | 297 static intptr_t StartRegister(intptr_t index) { return index * 2; } |
309 static intptr_t EndRegister(intptr_t index) { return index * 2 + 1; } | 298 static intptr_t EndRegister(intptr_t index) { return index * 2 + 1; } |
310 | 299 |
311 private: | 300 private: |
312 RegExpTree* body_; | 301 RegExpTree* body_; |
313 intptr_t index_; | 302 intptr_t index_; |
314 }; | 303 }; |
315 | 304 |
316 | |
317 class RegExpLookahead : public RegExpTree { | 305 class RegExpLookahead : public RegExpTree { |
318 public: | 306 public: |
319 RegExpLookahead(RegExpTree* body, | 307 RegExpLookahead(RegExpTree* body, |
320 bool is_positive, | 308 bool is_positive, |
321 intptr_t capture_count, | 309 intptr_t capture_count, |
322 intptr_t capture_from) | 310 intptr_t capture_from) |
323 : body_(body), | 311 : body_(body), |
324 is_positive_(is_positive), | 312 is_positive_(is_positive), |
325 capture_count_(capture_count), | 313 capture_count_(capture_count), |
326 capture_from_(capture_from) {} | 314 capture_from_(capture_from) {} |
(...skipping 11 matching lines...) Expand all Loading... |
338 intptr_t capture_count() const { return capture_count_; } | 326 intptr_t capture_count() const { return capture_count_; } |
339 intptr_t capture_from() const { return capture_from_; } | 327 intptr_t capture_from() const { return capture_from_; } |
340 | 328 |
341 private: | 329 private: |
342 RegExpTree* body_; | 330 RegExpTree* body_; |
343 bool is_positive_; | 331 bool is_positive_; |
344 intptr_t capture_count_; | 332 intptr_t capture_count_; |
345 intptr_t capture_from_; | 333 intptr_t capture_from_; |
346 }; | 334 }; |
347 | 335 |
348 | |
349 class RegExpBackReference : public RegExpTree { | 336 class RegExpBackReference : public RegExpTree { |
350 public: | 337 public: |
351 explicit RegExpBackReference(RegExpCapture* capture) : capture_(capture) {} | 338 explicit RegExpBackReference(RegExpCapture* capture) : capture_(capture) {} |
352 virtual void* Accept(RegExpVisitor* visitor, void* data); | 339 virtual void* Accept(RegExpVisitor* visitor, void* data); |
353 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 340 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
354 virtual RegExpBackReference* AsBackReference(); | 341 virtual RegExpBackReference* AsBackReference(); |
355 virtual bool IsBackReference() const; | 342 virtual bool IsBackReference() const; |
356 virtual intptr_t min_match() const { return 0; } | 343 virtual intptr_t min_match() const { return 0; } |
357 virtual intptr_t max_match() const { return capture_->max_match(); } | 344 virtual intptr_t max_match() const { return capture_->max_match(); } |
358 intptr_t index() const { return capture_->index(); } | 345 intptr_t index() const { return capture_->index(); } |
359 RegExpCapture* capture() const { return capture_; } | 346 RegExpCapture* capture() const { return capture_; } |
360 | 347 |
361 private: | 348 private: |
362 RegExpCapture* capture_; | 349 RegExpCapture* capture_; |
363 }; | 350 }; |
364 | 351 |
365 | |
366 class RegExpEmpty : public RegExpTree { | 352 class RegExpEmpty : public RegExpTree { |
367 public: | 353 public: |
368 RegExpEmpty() {} | 354 RegExpEmpty() {} |
369 virtual void* Accept(RegExpVisitor* visitor, void* data); | 355 virtual void* Accept(RegExpVisitor* visitor, void* data); |
370 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); | 356 virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); |
371 virtual RegExpEmpty* AsEmpty(); | 357 virtual RegExpEmpty* AsEmpty(); |
372 virtual bool IsEmpty() const; | 358 virtual bool IsEmpty() const; |
373 virtual intptr_t min_match() const { return 0; } | 359 virtual intptr_t min_match() const { return 0; } |
374 virtual intptr_t max_match() const { return 0; } | 360 virtual intptr_t max_match() const { return 0; } |
375 static RegExpEmpty* GetInstance() { | 361 static RegExpEmpty* GetInstance() { |
376 static RegExpEmpty* instance = ::new RegExpEmpty(); | 362 static RegExpEmpty* instance = ::new RegExpEmpty(); |
377 return instance; | 363 return instance; |
378 } | 364 } |
379 }; | 365 }; |
380 | 366 |
381 } // namespace dart | 367 } // namespace dart |
382 | 368 |
383 #endif // RUNTIME_VM_REGEXP_AST_H_ | 369 #endif // RUNTIME_VM_REGEXP_AST_H_ |
OLD | NEW |