diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-03-18 17:57:11 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-03-18 17:58:37 +0100 |
commit | b2331d76221b67bffb5cb5a2344c8b150a305dc7 (patch) | |
tree | 5d9cae4cdfc502b568f436fd66d77e0b16476395 /js/src/vm/Unicode.h | |
parent | 122938a4398ae8db07060dca3561ff46f93b5925 (diff) | |
parent | 427e7346629c76a1676a3f92320c3d2575d01b85 (diff) | |
download | UXP-b2331d76221b67bffb5cb5a2344c8b150a305dc7.tar UXP-b2331d76221b67bffb5cb5a2344c8b150a305dc7.tar.gz UXP-b2331d76221b67bffb5cb5a2344c8b150a305dc7.tar.lz UXP-b2331d76221b67bffb5cb5a2344c8b150a305dc7.tar.xz UXP-b2331d76221b67bffb5cb5a2344c8b150a305dc7.zip |
Correctly tokenize valid JS names when using code points outside of BMP range.
This resolves #72.
Merged remote-tracking branch 'janek/js_variable_unicode_1'
Diffstat (limited to 'js/src/vm/Unicode.h')
-rw-r--r-- | js/src/vm/Unicode.h | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/js/src/vm/Unicode.h b/js/src/vm/Unicode.h index 8b538d06d..bdac848fb 100644 --- a/js/src/vm/Unicode.h +++ b/js/src/vm/Unicode.h @@ -143,11 +143,15 @@ IsIdentifierStart(char16_t ch) return CharInfo(ch).isUnicodeIDStart(); } +bool +IsIdentifierStartNonBMP(uint32_t codePoint); + inline bool IsIdentifierStart(uint32_t codePoint) { - // TODO: Supplemental code points not yet supported (bug 1197230). - return codePoint <= UTF16Max && IsIdentifierStart(char16_t(codePoint)); + if (MOZ_UNLIKELY(codePoint > UTF16Max)) + return IsIdentifierStartNonBMP(codePoint); + return IsIdentifierStart(char16_t(codePoint)); } inline bool @@ -170,11 +174,16 @@ IsIdentifierPart(char16_t ch) return CharInfo(ch).isUnicodeIDContinue(); } + +bool +IsIdentifierPartNonBMP(uint32_t codePoint); + inline bool IsIdentifierPart(uint32_t codePoint) { - // TODO: Supplemental code points not yet supported (bug 1197230). - return codePoint <= UTF16Max && IsIdentifierPart(char16_t(codePoint)); + if (MOZ_UNLIKELY(codePoint > UTF16Max)) + return IsIdentifierPartNonBMP(codePoint); + return IsIdentifierPart(char16_t(codePoint)); } inline bool @@ -183,6 +192,17 @@ IsUnicodeIDStart(char16_t ch) return CharInfo(ch).isUnicodeIDStart(); } +bool +IsUnicodeIDStartNonBMP(uint32_t codePoint); + +inline bool +IsUnicodeIDStart(uint32_t codePoint) +{ + if (MOZ_UNLIKELY(codePoint > UTF16Max)) + return IsIdentifierStartNonBMP(codePoint); + return IsUnicodeIDStart(char16_t(codePoint)); +} + inline bool IsSpace(char16_t ch) { |