Bug 1351107 - Use unicode::{LINE,PARA}_SEPARATOR instead of hand-rolling them for TokenStream code. r=arai

This commit is contained in:
Jeff Walden 2017-05-01 19:40:51 -07:00
Родитель a053255a13
Коммит b87d68dcc0
3 изменённых файлов: 19 добавлений и 19 удалений

Просмотреть файл

@ -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 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 LINE_SEPARATOR = 0x2028;
constexpr char16_t PARA_SEPARATOR = 0x2029;
constexpr char16_t BYTE_ORDER_MARK2 = 0xFFFE;
const char16_t LeadSurrogateMin = 0xD800;
const char16_t LeadSurrogateMax = 0xDBFF;