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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1287 if (to >= kNonBmpStart) return true; | 1287 if (to >= kNonBmpStart) return true; |
1288 // Check for lone surrogates. | 1288 // Check for lone surrogates. |
1289 if (from <= kTrailSurrogateEnd && to >= kLeadSurrogateStart) return true; | 1289 if (from <= kTrailSurrogateEnd && to >= kLeadSurrogateStart) return true; |
1290 } | 1290 } |
1291 return false; | 1291 return false; |
1292 } | 1292 } |
1293 | 1293 |
1294 | 1294 |
1295 bool RegExpBuilder::NeedsDesugaringForIgnoreCase(uc32 c) { | 1295 bool RegExpBuilder::NeedsDesugaringForIgnoreCase(uc32 c) { |
1296 #ifdef V8_I18N_SUPPORT | 1296 #ifdef V8_I18N_SUPPORT |
1297 if (unicode() && ignore_case()) { | 1297 if (unicode() && ignore_case() && c >= kNonBmpStart) { |
| 1298 // BMP characters are handled in the case-insensitive TextEmitPass. |
| 1299 // Surrogate code units do not have case equivalents. |
| 1300 // Non-BMP characters need to be desugared into two uc16 parts. |
1298 USet* set = uset_open(c, c); | 1301 USet* set = uset_open(c, c); |
1299 uset_closeOver(set, USET_CASE_INSENSITIVE); | 1302 uset_closeOver(set, USET_CASE_INSENSITIVE); |
1300 uset_removeAllStrings(set); | 1303 uset_removeAllStrings(set); |
1301 bool result = uset_size(set) > 1; | 1304 bool result = uset_size(set) > 1; |
1302 uset_close(set); | 1305 uset_close(set); |
1303 return result; | 1306 return result; |
1304 } | 1307 } |
1305 // In the case where ICU is not included, we act as if the unicode flag is | 1308 // In the case where ICU is not included, we act as if the unicode flag is |
1306 // not set, and do not desugar. | 1309 // not set, and do not desugar. |
1307 #endif // V8_I18N_SUPPORT | 1310 #endif // V8_I18N_SUPPORT |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 return false; | 1365 return false; |
1363 } | 1366 } |
1364 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1367 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
1365 zone()); | 1368 zone()); |
1366 LAST(ADD_TERM); | 1369 LAST(ADD_TERM); |
1367 return true; | 1370 return true; |
1368 } | 1371 } |
1369 | 1372 |
1370 } // namespace internal | 1373 } // namespace internal |
1371 } // namespace v8 | 1374 } // namespace v8 |
OLD | NEW |