| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/regexp/regexp-parser.h" | 5 #include "src/regexp/regexp-parser.h" |
| 6 | 6 |
| 7 #include "src/char-predicates-inl.h" | 7 #include "src/char-predicates-inl.h" |
| 8 #include "src/factory.h" | 8 #include "src/factory.h" |
| 9 #include "src/isolate.h" | 9 #include "src/isolate.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 alternative = new (zone()) RegExpAlternative(terms_.GetList(zone())); | 1466 alternative = new (zone()) RegExpAlternative(terms_.GetList(zone())); |
| 1467 } | 1467 } |
| 1468 alternatives_.Add(alternative, zone()); | 1468 alternatives_.Add(alternative, zone()); |
| 1469 terms_.Clear(); | 1469 terms_.Clear(); |
| 1470 LAST(ADD_NONE); | 1470 LAST(ADD_NONE); |
| 1471 } | 1471 } |
| 1472 | 1472 |
| 1473 | 1473 |
| 1474 bool RegExpBuilder::NeedsDesugaringForUnicode(RegExpCharacterClass* cc) { | 1474 bool RegExpBuilder::NeedsDesugaringForUnicode(RegExpCharacterClass* cc) { |
| 1475 if (!unicode()) return false; | 1475 if (!unicode()) return false; |
| 1476 switch (cc->standard_type()) { | 1476 // TODO(yangguo): we could be smarter than this. Case-insensitivity does not |
| 1477 case 's': // white space | 1477 // necessarily mean that we need to desugar. It's probably nicer to have a |
| 1478 case 'w': // ASCII word character | 1478 // separate pass to figure out unicode desugarings. |
| 1479 case 'd': // ASCII digit | 1479 if (ignore_case()) return true; |
| 1480 return false; // These characters do not need desugaring. | |
| 1481 default: | |
| 1482 break; | |
| 1483 } | |
| 1484 ZoneList<CharacterRange>* ranges = cc->ranges(zone()); | 1480 ZoneList<CharacterRange>* ranges = cc->ranges(zone()); |
| 1485 CharacterRange::Canonicalize(ranges); | 1481 CharacterRange::Canonicalize(ranges); |
| 1486 for (int i = ranges->length() - 1; i >= 0; i--) { | 1482 for (int i = ranges->length() - 1; i >= 0; i--) { |
| 1487 uc32 from = ranges->at(i).from(); | 1483 uc32 from = ranges->at(i).from(); |
| 1488 uc32 to = ranges->at(i).to(); | 1484 uc32 to = ranges->at(i).to(); |
| 1489 // Check for non-BMP characters. | 1485 // Check for non-BMP characters. |
| 1490 if (to >= kNonBmpStart) return true; | 1486 if (to >= kNonBmpStart) return true; |
| 1491 // Check for lone surrogates. | 1487 // Check for lone surrogates. |
| 1492 if (from <= kTrailSurrogateEnd && to >= kLeadSurrogateStart) return true; | 1488 if (from <= kTrailSurrogateEnd && to >= kLeadSurrogateStart) return true; |
| 1493 } | 1489 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 return false; | 1561 return false; |
| 1566 } | 1562 } |
| 1567 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1563 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
| 1568 zone()); | 1564 zone()); |
| 1569 LAST(ADD_TERM); | 1565 LAST(ADD_TERM); |
| 1570 return true; | 1566 return true; |
| 1571 } | 1567 } |
| 1572 | 1568 |
| 1573 } // namespace internal | 1569 } // namespace internal |
| 1574 } // namespace v8 | 1570 } // namespace v8 |
| OLD | NEW |