зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1478170 - Move TokenStreamChars::getCodePoint to a generalized TokenStreamSpecific::getCodePoint that works for any CharT. r=arai
--HG-- extra : rebase_source : 678d69901e73e6732a625ebfdf33cf42953d93b2
This commit is contained in:
Родитель
28450f03f2
Коммит
705b8e96ed
|
@ -789,44 +789,6 @@ TokenStreamChars<Utf8Unit, AnyCharsAccess>::getNonAsciiCodePointDontNormalize(Ut
|
|||
return true;
|
||||
}
|
||||
|
||||
template<class AnyCharsAccess>
|
||||
bool
|
||||
TokenStreamChars<char16_t, AnyCharsAccess>::getCodePoint(int32_t* cp)
|
||||
{
|
||||
TokenStreamAnyChars& anyChars = anyCharsAccess();
|
||||
|
||||
if (MOZ_UNLIKELY(this->sourceUnits.atEnd())) {
|
||||
anyChars.flags.isEOF = true;
|
||||
*cp = EOF;
|
||||
return true;
|
||||
}
|
||||
|
||||
int32_t c = this->sourceUnits.getCodeUnit();
|
||||
|
||||
do {
|
||||
// Normalize the char16_t if it was a newline.
|
||||
if (MOZ_UNLIKELY(c == '\n'))
|
||||
break;
|
||||
|
||||
if (MOZ_UNLIKELY(c == '\r')) {
|
||||
matchLineTerminator('\n');
|
||||
break;
|
||||
}
|
||||
|
||||
if (MOZ_UNLIKELY(c == unicode::LINE_SEPARATOR || c == unicode::PARA_SEPARATOR))
|
||||
break;
|
||||
|
||||
*cp = c;
|
||||
return true;
|
||||
} while (false);
|
||||
|
||||
if (!updateLineInfoForEOL())
|
||||
return false;
|
||||
|
||||
*cp = '\n';
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class AnyCharsAccess>
|
||||
bool
|
||||
TokenStreamChars<char16_t, AnyCharsAccess>::getNonAsciiCodePoint(int32_t lead, int32_t* codePoint)
|
||||
|
@ -881,6 +843,24 @@ TokenStreamChars<char16_t, AnyCharsAccess>::getNonAsciiCodePoint(int32_t lead, i
|
|||
return true;
|
||||
}
|
||||
|
||||
template<typename CharT, class AnyCharsAccess>
|
||||
bool
|
||||
TokenStreamSpecific<CharT, AnyCharsAccess>::getCodePoint(int32_t* cp)
|
||||
{
|
||||
int32_t unit = getCodeUnit();
|
||||
if (unit == EOF) {
|
||||
MOZ_ASSERT(anyCharsAccess().flags.isEOF,
|
||||
"flags.isEOF should have been set by getCodeUnit()");
|
||||
*cp = EOF;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (isAsciiCodePoint(unit))
|
||||
return getFullAsciiCodePoint(unit, cp);
|
||||
|
||||
return getNonAsciiCodePoint(unit, cp);
|
||||
}
|
||||
|
||||
template<class AnyCharsAccess>
|
||||
bool
|
||||
TokenStreamChars<Utf8Unit, AnyCharsAccess>::getNonAsciiCodePoint(int32_t unit, int32_t* codePoint)
|
||||
|
|
|
@ -2033,14 +2033,6 @@ class TokenStreamChars<char16_t, AnyCharsAccess>
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the next code point, converting LineTerminatorSequences to '\n' and
|
||||
* updating internal line-counter state if needed. Return true on success
|
||||
* and store the code point in |*c|. Return false and leave |*c| undefined
|
||||
* on failure.
|
||||
*/
|
||||
MOZ_MUST_USE bool getCodePoint(int32_t* cp);
|
||||
|
||||
/**
|
||||
* Given a just-consumed non-ASCII code unit |lead| (which may also be a
|
||||
* full code point, for UTF-16), consume a full code point or
|
||||
|
@ -2276,7 +2268,6 @@ class MOZ_STACK_CLASS TokenStreamSpecific
|
|||
using TokenStreamCharsShared::copyCharBufferTo;
|
||||
using TokenStreamCharsShared::drainCharBufferIntoAtom;
|
||||
using CharsBase::fillCharBufferFromSourceNormalizingAsciiLineBreaks;
|
||||
using SpecializedChars::getCodePoint;
|
||||
using GeneralCharsBase::getCodeUnit;
|
||||
using GeneralCharsBase::getFullAsciiCodePoint;
|
||||
using SpecializedChars::getNonAsciiCodePoint;
|
||||
|
@ -2303,6 +2294,14 @@ class MOZ_STACK_CLASS TokenStreamSpecific
|
|||
TokenStreamSpecific(JSContext* cx, const ReadOnlyCompileOptions& options,
|
||||
const CharT* base, size_t length);
|
||||
|
||||
/**
|
||||
* Get the next code point, converting LineTerminatorSequences to '\n' and
|
||||
* updating internal line-counter state if needed. Return true on success
|
||||
* and store the code point in |*cp|. Return false and leave |*cp|
|
||||
* undefined on failure.
|
||||
*/
|
||||
MOZ_MUST_USE bool getCodePoint(int32_t* cp);
|
||||
|
||||
// If there is an invalid escape in a template, report it and return false,
|
||||
// otherwise return true.
|
||||
bool checkForInvalidTemplateEscapeError() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче