зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1351107 - Use unicode::{LINE,PARA}_SEPARATOR instead of hand-rolling them for TokenStream code. r=arai
--HG-- extra : rebase_source : 928d87700a93fe6ccaa5eac45de9c304f2b0f03f
This commit is contained in:
Родитель
c69ddc19ad
Коммит
d1bac2da78
|
@ -500,7 +500,7 @@ TokenStream::getChar(int32_t* cp)
|
|||
break;
|
||||
}
|
||||
|
||||
if (MOZ_UNLIKELY(c == LINE_SEPARATOR || c == PARA_SEPARATOR))
|
||||
if (MOZ_UNLIKELY(c == unicode::LINE_SEPARATOR || c == unicode::PARA_SEPARATOR))
|
||||
break;
|
||||
|
||||
*cp = c;
|
||||
|
@ -1328,7 +1328,7 @@ TokenStream::getTokenInternal(TokenKind* ttp, Modifier modifier)
|
|||
// early allows subsequent checking to be faster.
|
||||
if (MOZ_UNLIKELY(c >= 128)) {
|
||||
if (unicode::IsSpaceOrBOM2(c)) {
|
||||
if (c == LINE_SEPARATOR || c == PARA_SEPARATOR) {
|
||||
if (c == unicode::LINE_SEPARATOR || c == unicode::PARA_SEPARATOR) {
|
||||
if (!updateLineInfoForEOL())
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "vm/ErrorReporting.h"
|
||||
#include "vm/RegExpObject.h"
|
||||
#include "vm/String.h"
|
||||
#include "vm/Unicode.h"
|
||||
|
||||
struct KeywordInfo;
|
||||
|
||||
|
@ -268,12 +269,6 @@ class TokenStreamBase
|
|||
protected:
|
||||
TokenStreamBase(JSContext* cx, const ReadOnlyCompileOptions& options, StrictModeGetter* smg);
|
||||
|
||||
// Unicode separators that are treated as line terminators, in addition to \n, \r.
|
||||
enum {
|
||||
LINE_SEPARATOR = 0x2028,
|
||||
PARA_SEPARATOR = 0x2029
|
||||
};
|
||||
|
||||
static const size_t ntokens = 4; // 1 current + 2 lookahead, rounded
|
||||
// to power of 2 to avoid divmod by 3
|
||||
static const unsigned maxLookahead = 2;
|
||||
|
@ -1011,7 +1006,10 @@ class MOZ_STACK_CLASS TokenStream final : public TokenStreamBase
|
|||
#endif
|
||||
|
||||
static bool isRawEOLChar(int32_t c) {
|
||||
return c == '\n' || c == '\r' || c == LINE_SEPARATOR || c == PARA_SEPARATOR;
|
||||
return c == '\n' ||
|
||||
c == '\r' ||
|
||||
c == unicode::LINE_SEPARATOR ||
|
||||
c == unicode::PARA_SEPARATOR;
|
||||
}
|
||||
|
||||
// Returns the offset of the next EOL, but stops once 'max' characters
|
||||
|
|
|
@ -63,16 +63,18 @@ namespace CharFlag {
|
|||
const uint8_t UNICODE_ID_CONTINUE = UNICODE_ID_START + UNICODE_ID_CONTINUE_ONLY;
|
||||
}
|
||||
|
||||
const char16_t NO_BREAK_SPACE = 0x00A0;
|
||||
const char16_t MICRO_SIGN = 0x00B5;
|
||||
const char16_t LATIN_SMALL_LETTER_SHARP_S = 0x00DF;
|
||||
const char16_t LATIN_SMALL_LETTER_Y_WITH_DIAERESIS = 0x00FF;
|
||||
const char16_t LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE = 0x0130;
|
||||
const char16_t COMBINING_DOT_ABOVE = 0x0307;
|
||||
const char16_t GREEK_CAPITAL_LETTER_SIGMA = 0x03A3;
|
||||
const char16_t GREEK_SMALL_LETTER_FINAL_SIGMA = 0x03C2;
|
||||
const char16_t GREEK_SMALL_LETTER_SIGMA = 0x03C3;
|
||||
const char16_t BYTE_ORDER_MARK2 = 0xFFFE;
|
||||
constexpr char16_t NO_BREAK_SPACE = 0x00A0;
|
||||
constexpr char16_t MICRO_SIGN = 0x00B5;
|
||||
constexpr char16_t LATIN_SMALL_LETTER_SHARP_S = 0x00DF;
|
||||
constexpr char16_t LATIN_SMALL_LETTER_Y_WITH_DIAERESIS = 0x00FF;
|
||||
constexpr char16_t LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE = 0x0130;
|
||||
constexpr char16_t LINE_SEPARATOR = 0x2028;
|
||||
constexpr char16_t PARA_SEPARATOR = 0x2029;
|
||||
constexpr char16_t COMBINING_DOT_ABOVE = 0x0307;
|
||||
constexpr char16_t GREEK_CAPITAL_LETTER_SIGMA = 0x03A3;
|
||||
constexpr char16_t GREEK_SMALL_LETTER_FINAL_SIGMA = 0x03C2;
|
||||
constexpr char16_t GREEK_SMALL_LETTER_SIGMA = 0x03C3;
|
||||
constexpr char16_t BYTE_ORDER_MARK2 = 0xFFFE;
|
||||
|
||||
const char16_t LeadSurrogateMin = 0xD800;
|
||||
const char16_t LeadSurrogateMax = 0xDBFF;
|
||||
|
|
Загрузка…
Ссылка в новой задаче