OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 RegExp##Name* RegExp##Name::As##Name() { \ | 203 RegExp##Name* RegExp##Name::As##Name() { \ |
204 return this; \ | 204 return this; \ |
205 } \ | 205 } \ |
206 bool RegExp##Name::Is##Name() { return true; } | 206 bool RegExp##Name::Is##Name() { return true; } |
207 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE) | 207 FOR_EACH_REG_EXP_TREE_TYPE(MAKE_TYPE_CASE) |
208 #undef MAKE_TYPE_CASE | 208 #undef MAKE_TYPE_CASE |
209 | 209 |
210 RegExpEmpty RegExpEmpty::kInstance; | 210 RegExpEmpty RegExpEmpty::kInstance; |
211 | 211 |
212 | 212 |
| 213 static Interval ListCaptureRegisters(ZoneList<RegExpTree*>* children) { |
| 214 Interval result = Interval::Empty(); |
| 215 for (int i = 0; i < children->length(); i++) |
| 216 result = result.Union(children->at(i)->CaptureRegisters()); |
| 217 return result; |
| 218 } |
| 219 |
| 220 |
| 221 Interval RegExpAlternative::CaptureRegisters() { |
| 222 return ListCaptureRegisters(nodes()); |
| 223 } |
| 224 |
| 225 |
| 226 Interval RegExpDisjunction::CaptureRegisters() { |
| 227 return ListCaptureRegisters(alternatives()); |
| 228 } |
| 229 |
| 230 |
| 231 Interval RegExpLookahead::CaptureRegisters() { |
| 232 return body()->CaptureRegisters(); |
| 233 } |
| 234 |
| 235 |
| 236 Interval RegExpCapture::CaptureRegisters() { |
| 237 Interval self(StartRegister(index()), EndRegister(index())); |
| 238 return self.Union(body()->CaptureRegisters()); |
| 239 } |
| 240 |
| 241 |
| 242 Interval RegExpQuantifier::CaptureRegisters() { |
| 243 return body()->CaptureRegisters(); |
| 244 } |
| 245 |
| 246 |
213 // Convert regular expression trees to a simple sexp representation. | 247 // Convert regular expression trees to a simple sexp representation. |
214 // This representation should be different from the input grammar | 248 // This representation should be different from the input grammar |
215 // in as many cases as possible, to make it more difficult for incorrect | 249 // in as many cases as possible, to make it more difficult for incorrect |
216 // parses to look as correct ones which is likely if the input and | 250 // parses to look as correct ones which is likely if the input and |
217 // output formats are alike. | 251 // output formats are alike. |
218 class RegExpUnparser: public RegExpVisitor { | 252 class RegExpUnparser: public RegExpVisitor { |
219 public: | 253 public: |
220 RegExpUnparser(); | 254 RegExpUnparser(); |
221 void VisitCharacterRange(CharacterRange that); | 255 void VisitCharacterRange(CharacterRange that); |
222 SmartPointer<const char> ToString() { return stream_.ToCString(); } | 256 SmartPointer<const char> ToString() { return stream_.ToCString(); } |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 if (kInfinity - max_match_ < node_max_match) { | 439 if (kInfinity - max_match_ < node_max_match) { |
406 max_match_ = kInfinity; | 440 max_match_ = kInfinity; |
407 } else { | 441 } else { |
408 max_match_ += node->max_match(); | 442 max_match_ += node->max_match(); |
409 } | 443 } |
410 } | 444 } |
411 } | 445 } |
412 | 446 |
413 | 447 |
414 } } // namespace v8::internal | 448 } } // namespace v8::internal |
OLD | NEW |