Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2742)

Unified Diff: src/char-predicates.cc

Issue 2331303002: Use ICU for ID_START and ID_CONTINUE for Unicode 9 data (Closed)
Patch Set: undo the speculative fix to see if it's really necessary Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/char-predicates.cc
diff --git a/src/char-predicates.cc b/src/char-predicates.cc
index dc9865b5584ff91f77269e4919842f07adf8e3b7..875d63a1b5b2e1fe9cf919c6c679668c59012736 100644
--- a/src/char-predicates.cc
+++ b/src/char-predicates.cc
@@ -2,41 +2,37 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#ifdef V8_INTL_SUPPORT
#include "src/char-predicates.h"
-#ifdef V8_INTL_SUPPORT
#include "unicode/uchar.h"
#include "unicode/urename.h"
-#endif // V8_INTL_SUPPORT
namespace v8 {
namespace internal {
-bool SupplementaryPlanes::IsIDStart(uc32 c) {
- DCHECK(c > 0xFFFF);
-#ifdef V8_INTL_SUPPORT
- // This only works for code points in the SMPs, since ICU does not exclude
- // code points with properties 'Pattern_Syntax' or 'Pattern_White_Space'.
- // Code points in the SMP do not have those properties.
- return u_isIDStart(c);
-#else
- // This is incorrect, but if we don't have ICU, use this as fallback.
- return false;
-#endif // V8_INTL_SUPPORT
+bool IdentifierStart::Is(uc32 c) {
+ // cannot use u_isIDStart because it does not work for
+ // Other_ID_Start characters.
+ return u_hasBinaryProperty(c, UCHAR_ID_START) ||
+ (c < 0x60 && (c == 0x24 || c == 0x5C || c == 0x5F));
}
+bool IdentifierPart::Is(uc32 c) {
+ // Can't use u_isIDPart because it does not work for
+ // Other_ID_Continue characters.
+ return u_hasBinaryProperty(c, UCHAR_ID_CONTINUE) ||
+ (c < 0x60 && (c == 0x24 || c == 0x5C || c == 0x5F)) || c == 0x200C ||
+ c == 0x200D;
+}
-bool SupplementaryPlanes::IsIDPart(uc32 c) {
- DCHECK(c > 0xFFFF);
-#ifdef V8_INTL_SUPPORT
- // This only works for code points in the SMPs, since ICU does not exclude
- // code points with properties 'Pattern_Syntax' or 'Pattern_White_Space'.
- // Code points in the SMP do not have those properties.
- return u_isIDPart(c);
-#else
- // This is incorrect, but if we don't have ICU, use this as fallback.
- return false;
-#endif // V8_INTL_SUPPORT
+// Ecma 262 7.0 11.2 White Space
+// gC=Zs, U+0009, U+000B, U+000C, U+FEFF
+bool WhiteSpace::Is(uc32 c) {
+ return (u_charType(c) == U_SPACE_SEPARATOR) ||
+ (c < 0x0D && (c == 0x09 || c == 0x0B || c == 0x0C)) || c == 0xFEFF;
}
+
} // namespace internal
} // namespace v8
+#endif // V8_INTL_SUPPORT
« src/char-predicates.h ('K') | « src/char-predicates.h ('k') | src/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698