diff options
author | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-18 14:55:49 +0100 |
---|---|---|
committer | janekptacijarabaci <janekptacijarabaci@seznam.cz> | 2018-03-18 14:55:49 +0100 |
commit | 427e7346629c76a1676a3f92320c3d2575d01b85 (patch) | |
tree | 661743558731b0b2ca20b50528354d2441f0d684 /js/src/vm/Unicode.h | |
parent | a24511ca8e19afe4d19008ba903e1edab0af3223 (diff) | |
download | UXP-427e7346629c76a1676a3f92320c3d2575d01b85.tar UXP-427e7346629c76a1676a3f92320c3d2575d01b85.tar.gz UXP-427e7346629c76a1676a3f92320c3d2575d01b85.tar.lz UXP-427e7346629c76a1676a3f92320c3d2575d01b85.tar.xz UXP-427e7346629c76a1676a3f92320c3d2575d01b85.zip |
Correctly tokenize valid JS names when using Unicode mathematical alphanumeric symbols as variable name
Issue https://github.com/MoonchildProductions/Pale-Moon/issues/1647
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) { |