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 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 if (to >= kNonBmpStart) return true; | 1246 if (to >= kNonBmpStart) return true; |
1247 // Check for lone surrogates. | 1247 // Check for lone surrogates. |
1248 if (from <= kTrailSurrogateEnd && to >= kLeadSurrogateStart) return true; | 1248 if (from <= kTrailSurrogateEnd && to >= kLeadSurrogateStart) return true; |
1249 } | 1249 } |
1250 return false; | 1250 return false; |
1251 } | 1251 } |
1252 | 1252 |
1253 | 1253 |
1254 bool RegExpBuilder::NeedsDesugaringForIgnoreCase(uc32 c) { | 1254 bool RegExpBuilder::NeedsDesugaringForIgnoreCase(uc32 c) { |
1255 #ifdef V8_I18N_SUPPORT | 1255 #ifdef V8_I18N_SUPPORT |
1256 if (unicode() && ignore_case()) { | 1256 if (unicode() && ignore_case() && c >= kNonBmpStart) { |
| 1257 // BMP characters are handled in the case-insensitive TextEmitPass. |
| 1258 // Surrogate code units do not have case equivalents. |
| 1259 // Non-BMP characters need to be desugared into two uc16 parts. |
1257 USet* set = uset_open(c, c); | 1260 USet* set = uset_open(c, c); |
1258 uset_closeOver(set, USET_CASE_INSENSITIVE); | 1261 uset_closeOver(set, USET_CASE_INSENSITIVE); |
1259 uset_removeAllStrings(set); | 1262 uset_removeAllStrings(set); |
1260 bool result = uset_size(set) > 1; | 1263 bool result = uset_size(set) > 1; |
1261 uset_close(set); | 1264 uset_close(set); |
1262 return result; | 1265 return result; |
1263 } | 1266 } |
1264 // In the case where ICU is not included, we act as if the unicode flag is | 1267 // In the case where ICU is not included, we act as if the unicode flag is |
1265 // not set, and do not desugar. | 1268 // not set, and do not desugar. |
1266 #endif // V8_I18N_SUPPORT | 1269 #endif // V8_I18N_SUPPORT |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 UNREACHABLE(); | 1322 UNREACHABLE(); |
1320 return; | 1323 return; |
1321 } | 1324 } |
1322 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), | 1325 terms_.Add(new (zone()) RegExpQuantifier(min, max, quantifier_type, atom), |
1323 zone()); | 1326 zone()); |
1324 LAST(ADD_TERM); | 1327 LAST(ADD_TERM); |
1325 } | 1328 } |
1326 | 1329 |
1327 } // namespace internal | 1330 } // namespace internal |
1328 } // namespace v8 | 1331 } // namespace v8 |
OLD | NEW |