| 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 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 | 702 |
| 703 Handle<String> pattern() const { return pattern_; } | 703 Handle<String> pattern() const { return pattern_; } |
| 704 Handle<String> flags() const { return flags_; } | 704 Handle<String> flags() const { return flags_; } |
| 705 | 705 |
| 706 private: | 706 private: |
| 707 Handle<String> pattern_; | 707 Handle<String> pattern_; |
| 708 Handle<String> flags_; | 708 Handle<String> flags_; |
| 709 }; | 709 }; |
| 710 | 710 |
| 711 // An array literal has a literals object that is used | 711 // An array literal has a literals object that is used |
| 712 // used for minimizing the work when contructing it at runtime. | 712 // for minimizing the work when constructing it at runtime. |
| 713 class ArrayLiteral: public Expression { | 713 class ArrayLiteral: public Expression { |
| 714 public: | 714 public: |
| 715 ArrayLiteral(Handle<FixedArray> literals, | 715 ArrayLiteral(Handle<FixedArray> literals, |
| 716 ZoneList<Expression*>* values) | 716 ZoneList<Expression*>* values) |
| 717 : literals_(literals), values_(values) { | 717 : literals_(literals), values_(values) { |
| 718 } | 718 } |
| 719 | 719 |
| 720 virtual void Accept(AstVisitor* v); | 720 virtual void Accept(AstVisitor* v); |
| 721 | 721 |
| 722 Handle<FixedArray> literals() const { return literals_; } | 722 Handle<FixedArray> literals() const { return literals_; } |
| (...skipping 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1293 virtual RegExpAssertion* AsAssertion(); | 1293 virtual RegExpAssertion* AsAssertion(); |
| 1294 virtual bool IsAssertion(); | 1294 virtual bool IsAssertion(); |
| 1295 virtual int min_match() { return 0; } | 1295 virtual int min_match() { return 0; } |
| 1296 virtual int max_match() { return 0; } | 1296 virtual int max_match() { return 0; } |
| 1297 Type type() { return type_; } | 1297 Type type() { return type_; } |
| 1298 private: | 1298 private: |
| 1299 Type type_; | 1299 Type type_; |
| 1300 }; | 1300 }; |
| 1301 | 1301 |
| 1302 | 1302 |
| 1303 class CharacterSet BASE_EMBEDDED { |
| 1304 public: |
| 1305 explicit CharacterSet(uc16 standard_set_type) |
| 1306 : ranges_(NULL), |
| 1307 standard_set_type_(standard_set_type) {} |
| 1308 explicit CharacterSet(ZoneList<CharacterRange>* ranges) |
| 1309 : ranges_(ranges), |
| 1310 standard_set_type_(0) {} |
| 1311 ZoneList<CharacterRange>* ranges(); |
| 1312 uc16 standard_set_type() { return standard_set_type_; } |
| 1313 void set_standard_set_type(uc16 special_set_type) { |
| 1314 standard_set_type_ = special_set_type; |
| 1315 } |
| 1316 bool is_standard() { return standard_set_type_ != 0; } |
| 1317 private: |
| 1318 ZoneList<CharacterRange>* ranges_; |
| 1319 // If non-zero, the value represents a standard set (e.g., all whitespace |
| 1320 // characters) without having to expand the ranges. |
| 1321 uc16 standard_set_type_; |
| 1322 }; |
| 1323 |
| 1324 |
| 1303 class RegExpCharacterClass: public RegExpTree { | 1325 class RegExpCharacterClass: public RegExpTree { |
| 1304 public: | 1326 public: |
| 1305 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) | 1327 RegExpCharacterClass(ZoneList<CharacterRange>* ranges, bool is_negated) |
| 1306 : ranges_(ranges), | 1328 : set_(ranges), |
| 1307 is_negated_(is_negated) { } | 1329 is_negated_(is_negated) { } |
| 1308 explicit RegExpCharacterClass(uc16 type) | 1330 explicit RegExpCharacterClass(uc16 type) |
| 1309 : ranges_(new ZoneList<CharacterRange>(2)), | 1331 : set_(type), |
| 1310 is_negated_(false) { | 1332 is_negated_(false) { } |
| 1311 CharacterRange::AddClassEscape(type, ranges_); | |
| 1312 } | |
| 1313 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1333 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1314 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1334 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1315 RegExpNode* on_success); | 1335 RegExpNode* on_success); |
| 1316 virtual RegExpCharacterClass* AsCharacterClass(); | 1336 virtual RegExpCharacterClass* AsCharacterClass(); |
| 1317 virtual bool IsCharacterClass(); | 1337 virtual bool IsCharacterClass(); |
| 1318 virtual bool IsTextElement() { return true; } | 1338 virtual bool IsTextElement() { return true; } |
| 1319 virtual int min_match() { return 1; } | 1339 virtual int min_match() { return 1; } |
| 1320 virtual int max_match() { return 1; } | 1340 virtual int max_match() { return 1; } |
| 1321 virtual void AppendToText(RegExpText* text); | 1341 virtual void AppendToText(RegExpText* text); |
| 1322 ZoneList<CharacterRange>* ranges() { return ranges_; } | 1342 CharacterSet character_set() { return set_; } |
| 1343 // TODO(lrn): Remove need for complex version if is_standard that |
| 1344 // recognizes a mangled standard set and just do { return set_.is_special(); } |
| 1345 bool is_standard(); |
| 1346 // Returns a value representing the standard character set if is_standard() |
| 1347 // returns true. |
| 1348 // Currently used values are: |
| 1349 // s : unicode whitespace |
| 1350 // S : unicode non-whitespace |
| 1351 // w : ASCII word character (digit, letter, underscore) |
| 1352 // W : non-ASCII word character |
| 1353 // d : ASCII digit |
| 1354 // D : non-ASCII digit |
| 1355 // . : non-unicode newline |
| 1356 // * : All characters |
| 1357 uc16 standard_type() { return set_.standard_set_type(); } |
| 1358 ZoneList<CharacterRange>* ranges() { return set_.ranges(); } |
| 1323 bool is_negated() { return is_negated_; } | 1359 bool is_negated() { return is_negated_; } |
| 1324 private: | 1360 private: |
| 1325 ZoneList<CharacterRange>* ranges_; | 1361 CharacterSet set_; |
| 1326 bool is_negated_; | 1362 bool is_negated_; |
| 1327 }; | 1363 }; |
| 1328 | 1364 |
| 1329 | 1365 |
| 1330 class RegExpAtom: public RegExpTree { | 1366 class RegExpAtom: public RegExpTree { |
| 1331 public: | 1367 public: |
| 1332 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } | 1368 explicit RegExpAtom(Vector<const uc16> data) : data_(data) { } |
| 1333 virtual void* Accept(RegExpVisitor* visitor, void* data); | 1369 virtual void* Accept(RegExpVisitor* visitor, void* data); |
| 1334 virtual RegExpNode* ToNode(RegExpCompiler* compiler, | 1370 virtual RegExpNode* ToNode(RegExpCompiler* compiler, |
| 1335 RegExpNode* on_success); | 1371 RegExpNode* on_success); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 #undef DEF_VISIT | 1584 #undef DEF_VISIT |
| 1549 | 1585 |
| 1550 private: | 1586 private: |
| 1551 bool stack_overflow_; | 1587 bool stack_overflow_; |
| 1552 }; | 1588 }; |
| 1553 | 1589 |
| 1554 | 1590 |
| 1555 } } // namespace v8::internal | 1591 } } // namespace v8::internal |
| 1556 | 1592 |
| 1557 #endif // V8_AST_H_ | 1593 #endif // V8_AST_H_ |
| OLD | NEW |