Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(345)

Side by Side Diff: runtime/vm/regexp_ast.h

Issue 744853003: Integrate the Irregexp Regular Expression Engine. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix clang and win build Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/regexp_assembler.cc ('k') | runtime/vm/regexp_ast.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 VM_REGEXP_AST_H_ 5 #ifndef VM_REGEXP_AST_H_
6 #define VM_REGEXP_AST_H_ 6 #define VM_REGEXP_AST_H_
7 7
8 // SNIP 8 #include "platform/globals.h"
9 #include "platform/utils.h"
10 #include "vm/allocation.h"
11 #include "vm/regexp.h"
9 12
10 namespace dart { 13 namespace dart {
11 14
12 // SNIP
13
14 class RegExpAlternative; 15 class RegExpAlternative;
15 class RegExpAssertion; 16 class RegExpAssertion;
16 class RegExpAtom; 17 class RegExpAtom;
17 class RegExpBackReference; 18 class RegExpBackReference;
18 class RegExpCapture; 19 class RegExpCapture;
19 class RegExpCharacterClass; 20 class RegExpCharacterClass;
20 class RegExpCompiler; 21 class RegExpCompiler;
21 class RegExpDisjunction; 22 class RegExpDisjunction;
22 class RegExpEmpty; 23 class RegExpEmpty;
23 class RegExpLookahead; 24 class RegExpLookahead;
24 class RegExpQuantifier; 25 class RegExpQuantifier;
25 class RegExpText; 26 class RegExpText;
26 27
27 // SNIP
28 28
29 class RegExpVisitor BASE_EMBEDDED { 29 class RegExpVisitor : public ValueObject {
30 public: 30 public:
31 virtual ~RegExpVisitor() { } 31 virtual ~RegExpVisitor() { }
32 #define MAKE_CASE(Name) \ 32 #define MAKE_CASE(Name) \
33 virtual void* Visit##Name(RegExp##Name*, void* data) = 0; 33 virtual void* Visit##Name(RegExp##Name*, void* data) = 0;
34 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE) 34 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_CASE)
35 #undef MAKE_CASE 35 #undef MAKE_CASE
36 }; 36 };
37 37
38 38
39 class RegExpTree : public ZoneObject { 39 class RegExpTree : public ZoneAllocated {
40 public: 40 public:
41 static const int kInfinity = kMaxInt; 41 static const intptr_t kInfinity = kMaxInt32;
42 virtual ~RegExpTree() {} 42 virtual ~RegExpTree() {}
43 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0; 43 virtual void* Accept(RegExpVisitor* visitor, void* data) = 0;
44 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 44 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
45 RegExpNode* on_success) = 0; 45 RegExpNode* on_success) = 0;
46 virtual bool IsTextElement() { return false; } 46 virtual bool IsTextElement() const { return false; }
47 virtual bool IsAnchoredAtStart() { return false; } 47 virtual bool IsAnchoredAtStart() const { return false; }
48 virtual bool IsAnchoredAtEnd() { return false; } 48 virtual bool IsAnchoredAtEnd() const { return false; }
49 virtual int min_match() = 0; 49 virtual intptr_t min_match() const = 0;
50 virtual int max_match() = 0; 50 virtual intptr_t max_match() const = 0;
51 // Returns the interval of registers used for captures within this 51 // Returns the interval of registers used for captures within this
52 // expression. 52 // expression.
53 virtual Interval CaptureRegisters() { return Interval::Empty(); } 53 virtual Interval CaptureRegisters() const { return Interval::Empty(); }
54 virtual void AppendToText(RegExpText* text, Zone* zone); 54 virtual void AppendToText(RegExpText* text);
55 OStream& Print(OStream& os, Zone* zone); // NOLINT 55 void Print();
56 #define MAKE_ASTYPE(Name) \ 56 #define MAKE_ASTYPE(Name) \
57 virtual RegExp##Name* As##Name(); \ 57 virtual RegExp##Name* As##Name(); \
58 virtual bool Is##Name(); 58 virtual bool Is##Name() const;
59 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE) 59 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_ASTYPE)
60 #undef MAKE_ASTYPE 60 #undef MAKE_ASTYPE
61 }; 61 };
62 62
63 63
64 class RegExpDisjunction FINAL : public RegExpTree { 64 class RegExpDisjunction : public RegExpTree {
65 public: 65 public:
66 explicit RegExpDisjunction(ZoneList<RegExpTree*>* alternatives); 66 explicit RegExpDisjunction(ZoneGrowableArray<RegExpTree*>* alternatives);
67 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 67 virtual void* Accept(RegExpVisitor* visitor, void* data);
68 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 68 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
69 RegExpNode* on_success) OVERRIDE; 69 RegExpNode* on_success);
70 virtual RegExpDisjunction* AsDisjunction() OVERRIDE; 70 virtual RegExpDisjunction* AsDisjunction();
71 virtual Interval CaptureRegisters() OVERRIDE; 71 virtual Interval CaptureRegisters() const;
72 virtual bool IsDisjunction() OVERRIDE; 72 virtual bool IsDisjunction() const;
73 virtual bool IsAnchoredAtStart() OVERRIDE; 73 virtual bool IsAnchoredAtStart() const;
74 virtual bool IsAnchoredAtEnd() OVERRIDE; 74 virtual bool IsAnchoredAtEnd() const;
75 virtual int min_match() OVERRIDE { return min_match_; } 75 virtual intptr_t min_match() const { return min_match_; }
76 virtual int max_match() OVERRIDE { return max_match_; } 76 virtual intptr_t max_match() const { return max_match_; }
77 ZoneList<RegExpTree*>* alternatives() { return alternatives_; } 77 ZoneGrowableArray<RegExpTree*>* alternatives() const { return alternatives_; }
78 private: 78 private:
79 ZoneList<RegExpTree*>* alternatives_; 79 ZoneGrowableArray<RegExpTree*>* alternatives_;
80 int min_match_; 80 intptr_t min_match_;
81 int max_match_; 81 intptr_t max_match_;
82 }; 82 };
83 83
84 84
85 class RegExpAlternative FINAL : public RegExpTree { 85 class RegExpAlternative : public RegExpTree {
86 public: 86 public:
87 explicit RegExpAlternative(ZoneList<RegExpTree*>* nodes); 87 explicit RegExpAlternative(ZoneGrowableArray<RegExpTree*>* nodes);
88 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 88 virtual void* Accept(RegExpVisitor* visitor, void* data);
89 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 89 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
90 RegExpNode* on_success) OVERRIDE; 90 RegExpNode* on_success);
91 virtual RegExpAlternative* AsAlternative() OVERRIDE; 91 virtual RegExpAlternative* AsAlternative();
92 virtual Interval CaptureRegisters() OVERRIDE; 92 virtual Interval CaptureRegisters() const;
93 virtual bool IsAlternative() OVERRIDE; 93 virtual bool IsAlternative() const;
94 virtual bool IsAnchoredAtStart() OVERRIDE; 94 virtual bool IsAnchoredAtStart() const;
95 virtual bool IsAnchoredAtEnd() OVERRIDE; 95 virtual bool IsAnchoredAtEnd() const;
96 virtual int min_match() OVERRIDE { return min_match_; } 96 virtual intptr_t min_match() const { return min_match_; }
97 virtual int max_match() OVERRIDE { return max_match_; } 97 virtual intptr_t max_match() const { return max_match_; }
98 ZoneList<RegExpTree*>* nodes() { return nodes_; } 98 ZoneGrowableArray<RegExpTree*>* nodes() const { return nodes_; }
99 private: 99 private:
100 ZoneList<RegExpTree*>* nodes_; 100 ZoneGrowableArray<RegExpTree*>* nodes_;
101 int min_match_; 101 intptr_t min_match_;
102 int max_match_; 102 intptr_t max_match_;
103 }; 103 };
104 104
105 105
106 class RegExpAssertion FINAL : public RegExpTree { 106 class RegExpAssertion : public RegExpTree {
107 public: 107 public:
108 enum AssertionType { 108 enum AssertionType {
109 START_OF_LINE, 109 START_OF_LINE,
110 START_OF_INPUT, 110 START_OF_INPUT,
111 END_OF_LINE, 111 END_OF_LINE,
112 END_OF_INPUT, 112 END_OF_INPUT,
113 BOUNDARY, 113 BOUNDARY,
114 NON_BOUNDARY 114 NON_BOUNDARY
115 }; 115 };
116 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { } 116 explicit RegExpAssertion(AssertionType type) : assertion_type_(type) { }
117 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 117 virtual void* Accept(RegExpVisitor* visitor, void* data);
118 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 118 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
119 RegExpNode* on_success) OVERRIDE; 119 RegExpNode* on_success);
120 virtual RegExpAssertion* AsAssertion() OVERRIDE; 120 virtual RegExpAssertion* AsAssertion();
121 virtual bool IsAssertion() OVERRIDE; 121 virtual bool IsAssertion() const;
122 virtual bool IsAnchoredAtStart() OVERRIDE; 122 virtual bool IsAnchoredAtStart() const;
123 virtual bool IsAnchoredAtEnd() OVERRIDE; 123 virtual bool IsAnchoredAtEnd() const;
124 virtual int min_match() OVERRIDE { return 0; } 124 virtual intptr_t min_match() const { return 0; }
125 virtual int max_match() OVERRIDE { return 0; } 125 virtual intptr_t max_match() const { return 0; }
126 AssertionType assertion_type() { return assertion_type_; } 126 AssertionType assertion_type() const { return assertion_type_; }
127 private: 127 private:
128 AssertionType assertion_type_; 128 AssertionType assertion_type_;
129 }; 129 };
130 130
131 131
132 class CharacterSet FINAL BASE_EMBEDDED { 132 class CharacterSet : public ValueObject {
133 public: 133 public:
134 explicit CharacterSet(uc16 standard_set_type) 134 explicit CharacterSet(uint16_t standard_set_type)
135 : ranges_(NULL), 135 : ranges_(NULL),
136 standard_set_type_(standard_set_type) {} 136 standard_set_type_(standard_set_type) {}
137 explicit CharacterSet(ZoneList<CharacterRange>* ranges) 137 explicit CharacterSet(ZoneGrowableArray<CharacterRange>* ranges)
138 : ranges_(ranges), 138 : ranges_(ranges),
139 standard_set_type_(0) {} 139 standard_set_type_(0) {}
140 ZoneList<CharacterRange>* ranges(Zone* zone); 140 CharacterSet(const CharacterSet& that)
141 uc16 standard_set_type() { return standard_set_type_; } 141 : ValueObject(),
142 void set_standard_set_type(uc16 special_set_type) { 142 ranges_(that.ranges_),
143 standard_set_type_(that.standard_set_type_) {}
144 ZoneGrowableArray<CharacterRange>* ranges();
145 uint16_t standard_set_type() const { return standard_set_type_; }
146 void set_standard_set_type(uint16_t special_set_type) {
143 standard_set_type_ = special_set_type; 147 standard_set_type_ = special_set_type;
144 } 148 }
145 bool is_standard() { return standard_set_type_ != 0; } 149 bool is_standard() { return standard_set_type_ != 0; }
146 void Canonicalize(); 150 void Canonicalize();
147 private: 151 private:
148 ZoneList<CharacterRange>* ranges_; 152 ZoneGrowableArray<CharacterRange>* ranges_;
149 // If non-zero, the value represents a standard set (e.g., all whitespace 153 // If non-zero, the value represents a standard set (e.g., all whitespace
150 // characters) without having to expand the ranges. 154 // characters) without having to expand the ranges.
151 uc16 standard_set_type_; 155 uint16_t standard_set_type_;
152 }; 156 };
153 157
154 158
155 class RegExpCharacterClass FINAL : public RegExpTree { 159 class RegExpCharacterClass : public RegExpTree {
156 public: 160 public:
157 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) 161 RegExpCharacterClass(ZoneGrowableArray<CharacterRange>* ranges,
162 bool is_negated)
158 : set_(ranges), 163 : set_(ranges),
159 is_negated_(is_negated) { } 164 is_negated_(is_negated) { }
160 explicit RegExpCharacterClass(uc16 type) 165 explicit RegExpCharacterClass(uint16_t type)
161 : set_(type), 166 : set_(type),
162 is_negated_(false) { } 167 is_negated_(false) { }
163 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 168 virtual void* Accept(RegExpVisitor* visitor, void* data);
164 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 169 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
165 RegExpNode* on_success) OVERRIDE; 170 RegExpNode* on_success);
166 virtual RegExpCharacterClass* AsCharacterClass() OVERRIDE; 171 virtual RegExpCharacterClass* AsCharacterClass();
167 virtual bool IsCharacterClass() OVERRIDE; 172 virtual bool IsCharacterClass() const;
168 virtual bool IsTextElement() OVERRIDE { return true; } 173 virtual bool IsTextElement() const { return true; }
169 virtual int min_match() OVERRIDE { return 1; } 174 virtual intptr_t min_match() const { return 1; }
170 virtual int max_match() OVERRIDE { return 1; } 175 virtual intptr_t max_match() const { return 1; }
171 virtual void AppendToText(RegExpText* text, Zone* zone) OVERRIDE; 176 virtual void AppendToText(RegExpText* text);
172 CharacterSet character_set() { return set_; } 177 CharacterSet character_set() const { return set_; }
173 // TODO(lrn): Remove need for complex version if is_standard that 178 // TODO(lrn): Remove need for complex version if is_standard that
174 // recognizes a mangled standard set and just do { return set_.is_special(); } 179 // recognizes a mangled standard set and just do { return set_.is_special(); }
175 bool is_standard(Zone* zone); 180 bool is_standard();
176 // Returns a value representing the standard character set if is_standard() 181 // Returns a value representing the standard character set if is_standard()
177 // returns true. 182 // returns true.
178 // Currently used values are: 183 // Currently used values are:
179 // s : unicode whitespace 184 // s : unicode whitespace
180 // S : unicode non-whitespace 185 // S : unicode non-whitespace
181 // w : ASCII word character (digit, letter, underscore) 186 // w : ASCII word character (digit, letter, underscore)
182 // W : non-ASCII word character 187 // W : non-ASCII word character
183 // d : ASCII digit 188 // d : ASCII digit
184 // D : non-ASCII digit 189 // D : non-ASCII digit
185 // . : non-unicode non-newline 190 // . : non-unicode non-newline
186 // * : All characters 191 // * : All characters
187 uc16 standard_type() { return set_.standard_set_type(); } 192 uint16_t standard_type() const { return set_.standard_set_type(); }
188 ZoneList<CharacterRange>* ranges(Zone* zone) { return set_.ranges(zone); } 193 ZoneGrowableArray<CharacterRange>* ranges() {
189 bool is_negated() { return is_negated_; } 194 return set_.ranges();
195 }
196 bool is_negated() const { return is_negated_; }
190 197
191 private: 198 private:
192 CharacterSet set_; 199 CharacterSet set_;
193 bool is_negated_; 200 bool is_negated_;
194 }; 201 };
195 202
196 203
197 class RegExpAtom FINAL : public RegExpTree { 204 class RegExpAtom : public RegExpTree {
198 public: 205 public:
199 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } 206 explicit RegExpAtom(ZoneGrowableArray<uint16_t>* data) : data_(data) { }
200 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 207 virtual void* Accept(RegExpVisitor* visitor, void* data);
201 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 208 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
202 RegExpNode* on_success) OVERRIDE; 209 RegExpNode* on_success);
203 virtual RegExpAtom* AsAtom() OVERRIDE; 210 virtual RegExpAtom* AsAtom();
204 virtual bool IsAtom() OVERRIDE; 211 virtual bool IsAtom() const;
205 virtual bool IsTextElement() OVERRIDE { return true; } 212 virtual bool IsTextElement() const { return true; }
206 virtual int min_match() OVERRIDE { return data_.length(); } 213 virtual intptr_t min_match() const { return data_->length(); }
207 virtual int max_match() OVERRIDE { return data_.length(); } 214 virtual intptr_t max_match() const { return data_->length(); }
208 virtual void AppendToText(RegExpText* text, Zone* zone) OVERRIDE; 215 virtual void AppendToText(RegExpText* text);
209 Vector<const uc16> data() { return data_; } 216 ZoneGrowableArray<uint16_t>* data() const { return data_; }
210 int length() { return data_.length(); } 217 intptr_t length() const { return data_->length(); }
211 private: 218 private:
212 Vector<const uc16> data_; 219 ZoneGrowableArray<uint16_t>* data_;
213 }; 220 };
214 221
215 222
216 class RegExpText FINAL : public RegExpTree { 223 class RegExpText : public RegExpTree {
217 public: 224 public:
218 explicit RegExpText(Zone* zone) : elements_(2, zone), length_(0) {} 225 RegExpText() : elements_(2), length_(0) {}
219 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 226 virtual void* Accept(RegExpVisitor* visitor, void* data);
220 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 227 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
221 RegExpNode* on_success) OVERRIDE; 228 RegExpNode* on_success);
222 virtual RegExpText* AsText() OVERRIDE; 229 virtual RegExpText* AsText();
223 virtual bool IsText() OVERRIDE; 230 virtual bool IsText() const;
224 virtual bool IsTextElement() OVERRIDE { return true; } 231 virtual bool IsTextElement() const { return true; }
225 virtual int min_match() OVERRIDE { return length_; } 232 virtual intptr_t min_match() const { return length_; }
226 virtual int max_match() OVERRIDE { return length_; } 233 virtual intptr_t max_match() const { return length_; }
227 virtual void AppendToText(RegExpText* text, Zone* zone) OVERRIDE; 234 virtual void AppendToText(RegExpText* text);
228 void AddElement(TextElement elm, Zone* zone) { 235 void AddElement(TextElement elm) {
229 elements_.Add(elm, zone); 236 elements_.Add(elm);
230 length_ += elm.length(); 237 length_ += elm.length();
231 } 238 }
232 ZoneList<TextElement>* elements() { return &elements_; } 239 GrowableArray<TextElement>* elements() { return &elements_; }
233 private: 240 private:
234 ZoneList<TextElement> elements_; 241 GrowableArray<TextElement> elements_;
235 int length_; 242 intptr_t length_;
236 }; 243 };
237 244
238 245
239 class RegExpQuantifier FINAL : public RegExpTree { 246 class RegExpQuantifier : public RegExpTree {
240 public: 247 public:
241 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE }; 248 enum QuantifierType { GREEDY, NON_GREEDY, POSSESSIVE };
242 RegExpQuantifier(int min, int max, QuantifierType type, RegExpTree* body) 249 RegExpQuantifier(intptr_t min, intptr_t max,
250 QuantifierType type, RegExpTree* body)
243 : body_(body), 251 : body_(body),
244 min_(min), 252 min_(min),
245 max_(max), 253 max_(max),
246 min_match_(min * body->min_match()), 254 min_match_(min * body->min_match()),
247 quantifier_type_(type) { 255 quantifier_type_(type) {
248 if (max > 0 && body->max_match() > kInfinity / max) { 256 if (max > 0 && body->max_match() > kInfinity / max) {
249 max_match_ = kInfinity; 257 max_match_ = kInfinity;
250 } else { 258 } else {
251 max_match_ = max * body->max_match(); 259 max_match_ = max * body->max_match();
252 } 260 }
253 } 261 }
254 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 262 virtual void* Accept(RegExpVisitor* visitor, void* data);
255 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 263 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
256 RegExpNode* on_success) OVERRIDE; 264 RegExpNode* on_success);
257 static RegExpNode* ToNode(int min, 265 static RegExpNode* ToNode(intptr_t min,
258 int max, 266 intptr_t max,
259 bool is_greedy, 267 bool is_greedy,
260 RegExpTree* body, 268 RegExpTree* body,
261 RegExpCompiler* compiler, 269 RegExpCompiler* compiler,
262 RegExpNode* on_success, 270 RegExpNode* on_success,
263 bool not_at_start = false); 271 bool not_at_start = false);
264 virtual RegExpQuantifier* AsQuantifier() OVERRIDE; 272 virtual RegExpQuantifier* AsQuantifier();
265 virtual Interval CaptureRegisters() OVERRIDE; 273 virtual Interval CaptureRegisters() const;
266 virtual bool IsQuantifier() OVERRIDE; 274 virtual bool IsQuantifier() const;
267 virtual int min_match() OVERRIDE { return min_match_; } 275 virtual intptr_t min_match() const { return min_match_; }
268 virtual int max_match() OVERRIDE { return max_match_; } 276 virtual intptr_t max_match() const { return max_match_; }
269 int min() { return min_; } 277 intptr_t min() const { return min_; }
270 int max() { return max_; } 278 intptr_t max() const { return max_; }
271 bool is_possessive() { return quantifier_type_ == POSSESSIVE; } 279 bool is_possessive() const { return quantifier_type_ == POSSESSIVE; }
272 bool is_non_greedy() { return quantifier_type_ == NON_GREEDY; } 280 bool is_non_greedy() const { return quantifier_type_ == NON_GREEDY; }
273 bool is_greedy() { return quantifier_type_ == GREEDY; } 281 bool is_greedy() const { return quantifier_type_ == GREEDY; }
274 RegExpTree* body() { return body_; } 282 RegExpTree* body() const { return body_; }
275 283
276 private: 284 private:
277 RegExpTree* body_; 285 RegExpTree* body_;
278 int min_; 286 intptr_t min_;
279 int max_; 287 intptr_t max_;
280 int min_match_; 288 intptr_t min_match_;
281 int max_match_; 289 intptr_t max_match_;
282 QuantifierType quantifier_type_; 290 QuantifierType quantifier_type_;
283 }; 291 };
284 292
285 293
286 class RegExpCapture FINAL : public RegExpTree { 294 class RegExpCapture : public RegExpTree {
287 public: 295 public:
288 explicit RegExpCapture(RegExpTree* body, int index) 296 explicit RegExpCapture(RegExpTree* body, intptr_t index)
289 : body_(body), index_(index) { } 297 : body_(body), index_(index) { }
290 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 298 virtual void* Accept(RegExpVisitor* visitor, void* data);
291 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 299 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
292 RegExpNode* on_success) OVERRIDE; 300 RegExpNode* on_success);
293 static RegExpNode* ToNode(RegExpTree* body, 301 static RegExpNode* ToNode(RegExpTree* body,
294 int index, 302 intptr_t index,
295 RegExpCompiler* compiler, 303 RegExpCompiler* compiler,
296 RegExpNode* on_success); 304 RegExpNode* on_success);
297 virtual RegExpCapture* AsCapture() OVERRIDE; 305 virtual RegExpCapture* AsCapture();
298 virtual bool IsAnchoredAtStart() OVERRIDE; 306 virtual bool IsAnchoredAtStart() const;
299 virtual bool IsAnchoredAtEnd() OVERRIDE; 307 virtual bool IsAnchoredAtEnd() const;
300 virtual Interval CaptureRegisters() OVERRIDE; 308 virtual Interval CaptureRegisters() const;
301 virtual bool IsCapture() OVERRIDE; 309 virtual bool IsCapture() const;
302 virtual int min_match() OVERRIDE { return body_->min_match(); } 310 virtual intptr_t min_match() const { return body_->min_match(); }
303 virtual int max_match() OVERRIDE { return body_->max_match(); } 311 virtual intptr_t max_match() const { return body_->max_match(); }
304 RegExpTree* body() { return body_; } 312 RegExpTree* body() const { return body_; }
305 int index() { return index_; } 313 intptr_t index() const { return index_; }
306 static int StartRegister(int index) { return index * 2; } 314 static intptr_t StartRegister(intptr_t index) { return index * 2; }
307 static int EndRegister(int index) { return index * 2 + 1; } 315 static intptr_t EndRegister(intptr_t index) { return index * 2 + 1; }
308 316
309 private: 317 private:
310 RegExpTree* body_; 318 RegExpTree* body_;
311 int index_; 319 intptr_t index_;
312 }; 320 };
313 321
314 322
315 class RegExpLookahead FINAL : public RegExpTree { 323 class RegExpLookahead : public RegExpTree {
316 public: 324 public:
317 RegExpLookahead(RegExpTree* body, 325 RegExpLookahead(RegExpTree* body,
318 bool is_positive, 326 bool is_positive,
319 int capture_count, 327 intptr_t capture_count,
320 int capture_from) 328 intptr_t capture_from)
321 : body_(body), 329 : body_(body),
322 is_positive_(is_positive), 330 is_positive_(is_positive),
323 capture_count_(capture_count), 331 capture_count_(capture_count),
324 capture_from_(capture_from) { } 332 capture_from_(capture_from) { }
325 333
326 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 334 virtual void* Accept(RegExpVisitor* visitor, void* data);
327 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 335 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
328 RegExpNode* on_success) OVERRIDE; 336 RegExpNode* on_success);
329 virtual RegExpLookahead* AsLookahead() OVERRIDE; 337 virtual RegExpLookahead* AsLookahead();
330 virtual Interval CaptureRegisters() OVERRIDE; 338 virtual Interval CaptureRegisters() const;
331 virtual bool IsLookahead() OVERRIDE; 339 virtual bool IsLookahead() const;
332 virtual bool IsAnchoredAtStart() OVERRIDE; 340 virtual bool IsAnchoredAtStart() const;
333 virtual int min_match() OVERRIDE { return 0; } 341 virtual intptr_t min_match() const { return 0; }
334 virtual int max_match() OVERRIDE { return 0; } 342 virtual intptr_t max_match() const { return 0; }
335 RegExpTree* body() { return body_; } 343 RegExpTree* body() const { return body_; }
336 bool is_positive() { return is_positive_; } 344 bool is_positive() const { return is_positive_; }
337 int capture_count() { return capture_count_; } 345 intptr_t capture_count() const { return capture_count_; }
338 int capture_from() { return capture_from_; } 346 intptr_t capture_from() const { return capture_from_; }
339 347
340 private: 348 private:
341 RegExpTree* body_; 349 RegExpTree* body_;
342 bool is_positive_; 350 bool is_positive_;
343 int capture_count_; 351 intptr_t capture_count_;
344 int capture_from_; 352 intptr_t capture_from_;
345 }; 353 };
346 354
347 355
348 class RegExpBackReference FINAL : public RegExpTree { 356 class RegExpBackReference : public RegExpTree {
349 public: 357 public:
350 explicit RegExpBackReference(RegExpCapture* capture) 358 explicit RegExpBackReference(RegExpCapture* capture)
351 : capture_(capture) { } 359 : capture_(capture) { }
352 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 360 virtual void* Accept(RegExpVisitor* visitor, void* data);
353 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 361 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
354 RegExpNode* on_success) OVERRIDE; 362 RegExpNode* on_success);
355 virtual RegExpBackReference* AsBackReference() OVERRIDE; 363 virtual RegExpBackReference* AsBackReference();
356 virtual bool IsBackReference() OVERRIDE; 364 virtual bool IsBackReference() const;
357 virtual int min_match() OVERRIDE { return 0; } 365 virtual intptr_t min_match() const { return 0; }
358 virtual int max_match() OVERRIDE { return capture_->max_match(); } 366 virtual intptr_t max_match() const { return capture_->max_match(); }
359 int index() { return capture_->index(); } 367 intptr_t index() const { return capture_->index(); }
360 RegExpCapture* capture() { return capture_; } 368 RegExpCapture* capture() const { return capture_; }
361 private: 369 private:
362 RegExpCapture* capture_; 370 RegExpCapture* capture_;
363 }; 371 };
364 372
365 373
366 class RegExpEmpty FINAL : public RegExpTree { 374 class RegExpEmpty : public RegExpTree {
367 public: 375 public:
368 RegExpEmpty() { } 376 RegExpEmpty() { }
369 virtual void* Accept(RegExpVisitor* visitor, void* data) OVERRIDE; 377 virtual void* Accept(RegExpVisitor* visitor, void* data);
370 virtual RegExpNode* ToNode(RegExpCompiler* compiler, 378 virtual RegExpNode* ToNode(RegExpCompiler* compiler,
371 RegExpNode* on_success) OVERRIDE; 379 RegExpNode* on_success);
372 virtual RegExpEmpty* AsEmpty() OVERRIDE; 380 virtual RegExpEmpty* AsEmpty();
373 virtual bool IsEmpty() OVERRIDE; 381 virtual bool IsEmpty() const;
374 virtual int min_match() OVERRIDE { return 0; } 382 virtual intptr_t min_match() const { return 0; }
375 virtual int max_match() OVERRIDE { return 0; } 383 virtual intptr_t max_match() const { return 0; }
376 static RegExpEmpty* GetInstance() { 384 static RegExpEmpty* GetInstance() {
377 static RegExpEmpty* instance = ::new RegExpEmpty(); 385 static RegExpEmpty* instance = ::new RegExpEmpty();
378 return instance; 386 return instance;
379 } 387 }
380 }; 388 };
381 389
382 // SNIP
383
384 } // namespace dart 390 } // namespace dart
385 391
386 #endif // VM_REGEXP_AST_H_ 392 #endif // VM_REGEXP_AST_H_
OLDNEW
« no previous file with comments | « runtime/vm/regexp_assembler.cc ('k') | runtime/vm/regexp_ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698