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

Unified Diff: src/char-predicates.h

Issue 640193002: Allow identifier code points from supplementary multilingual planes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
« no previous file with comments | « BUILD.gn ('k') | src/char-predicates.cc » ('j') | src/scanner.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/char-predicates.h
diff --git a/src/char-predicates.h b/src/char-predicates.h
index bfe7fe18bf6f048ee85d57d1fb38134ea2b0035c..5ecb07de992a6f62b1ad605ee97ce7f81c04a624 100644
--- a/src/char-predicates.h
+++ b/src/char-predicates.h
@@ -22,13 +22,24 @@ inline bool IsBinaryDigit(uc32 c);
inline bool IsRegExpWord(uc32 c);
inline bool IsRegExpNewline(uc32 c);
+
+struct SupplementaryPlanes {
+ static bool IsIDStart(uc32 c);
+ static bool IsIDPart(uc32 c);
+};
+
+
// ES6 draft section 11.6
// This includes '_', '$' and '\', and ID_Start according to
// http://www.unicode.org/reports/tr31/, which consists of categories
// 'Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl', but excluding properties
// 'Pattern_Syntax' or 'Pattern_White_Space'.
+// For code points in the SMPs, we can resort to ICU (if available).
struct IdentifierStart {
- static inline bool Is(uc32 c) { return unibrow::ID_Start::Is(c); }
+ static inline bool Is(uc32 c) {
+ if (c > 0xFFFF) return SupplementaryPlanes::IsIDStart(c);
+ return unibrow::ID_Start::Is(c);
+ }
};
@@ -37,8 +48,10 @@ struct IdentifierStart {
// http://www.unicode.org/reports/tr31/, which consists of ID_Start,
// the categories 'Mn', 'Mc', 'Nd', 'Pc', but excluding properties
// 'Pattern_Syntax' or 'Pattern_White_Space'.
+// For code points in the SMPs, we can resort to ICU (if available).
struct IdentifierPart {
static inline bool Is(uc32 c) {
+ if (c > 0xFFFF) return SupplementaryPlanes::IsIDPart(c);
return unibrow::ID_Start::Is(c) || unibrow::ID_Continue::Is(c);
}
};
@@ -49,6 +62,7 @@ struct IdentifierPart {
// \u180e stops being one as of Unicode 6.3.0, but ES6 adheres to Unicode 5.1,
// so it is also included.
// Further included are \u0009, \u000b, \u0020, \u00a0, \u000c, and \ufeff.
+// There are no category 'Zs' code points in the SMPs.
struct WhiteSpace {
static inline bool Is(uc32 c) { return unibrow::WhiteSpace::Is(c); }
};
« no previous file with comments | « BUILD.gn ('k') | src/char-predicates.cc » ('j') | src/scanner.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698