зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1459384 - Move the finishToken call into getStringOrTemplateToken. r=arai
--HG-- extra : rebase_source : c156be076a95518eb7ab45f8d1615e9c598ba4de
This commit is contained in:
Родитель
0c6a64819c
Коммит
114791d853
|
@ -1668,14 +1668,8 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getTokenInternal(TokenKind* const tt
|
||||||
|
|
||||||
// Check if in the middle of a template string. Have to get this out of
|
// Check if in the middle of a template string. Have to get this out of
|
||||||
// the way first.
|
// the way first.
|
||||||
if (MOZ_UNLIKELY(modifier == TemplateTail)) {
|
if (MOZ_UNLIKELY(modifier == TemplateTail))
|
||||||
Token* tp;
|
return getStringOrTemplateToken('`', modifier, ttp);
|
||||||
if (!getStringOrTemplateToken('`', &tp))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
finishToken(ttp, tp, modifier);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This loop runs more than once only when whitespace or comments are
|
// This loop runs more than once only when whitespace or comments are
|
||||||
// encountered.
|
// encountered.
|
||||||
|
@ -1817,14 +1811,8 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getTokenInternal(TokenKind* const tt
|
||||||
|
|
||||||
// Look for a string or a template string.
|
// Look for a string or a template string.
|
||||||
//
|
//
|
||||||
if (c1kind == String) {
|
if (c1kind == String)
|
||||||
Token* tp;
|
return getStringOrTemplateToken(static_cast<char>(c), modifier, ttp);
|
||||||
if (!getStringOrTemplateToken(static_cast<char>(c), &tp))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
finishToken(ttp, tp, modifier);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Skip over EOL chars, updating line state along the way.
|
// Skip over EOL chars, updating line state along the way.
|
||||||
//
|
//
|
||||||
|
@ -2282,7 +2270,9 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getTokenInternal(TokenKind* const tt
|
||||||
|
|
||||||
template<typename CharT, class AnyCharsAccess>
|
template<typename CharT, class AnyCharsAccess>
|
||||||
bool
|
bool
|
||||||
TokenStreamSpecific<CharT, AnyCharsAccess>::getStringOrTemplateToken(char untilChar, Token** tp)
|
TokenStreamSpecific<CharT, AnyCharsAccess>::getStringOrTemplateToken(char untilChar,
|
||||||
|
Modifier modifier,
|
||||||
|
TokenKind* out)
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(untilChar == '\'' || untilChar == '"' || untilChar == '`',
|
MOZ_ASSERT(untilChar == '\'' || untilChar == '"' || untilChar == '`',
|
||||||
"unexpected string/template literal delimiter");
|
"unexpected string/template literal delimiter");
|
||||||
|
@ -2293,7 +2283,7 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getStringOrTemplateToken(char untilC
|
||||||
bool templateHead = false;
|
bool templateHead = false;
|
||||||
|
|
||||||
TokenStart start(sourceUnits, -1);
|
TokenStart start(sourceUnits, -1);
|
||||||
*tp = newToken(start);
|
Token* token = newToken(start);
|
||||||
tokenbuf.clear();
|
tokenbuf.clear();
|
||||||
|
|
||||||
// Run the bad-token code for every path out of this function except the
|
// Run the bad-token code for every path out of this function except the
|
||||||
|
@ -2542,16 +2532,17 @@ TokenStreamSpecific<CharT, AnyCharsAccess>::getStringOrTemplateToken(char untilC
|
||||||
if (!parsingTemplate) {
|
if (!parsingTemplate) {
|
||||||
MOZ_ASSERT(!templateHead);
|
MOZ_ASSERT(!templateHead);
|
||||||
|
|
||||||
(*tp)->type = TokenKind::String;
|
token->type = TokenKind::String;
|
||||||
} else {
|
} else {
|
||||||
if (templateHead)
|
if (templateHead)
|
||||||
(*tp)->type = TokenKind::TemplateHead;
|
token->type = TokenKind::TemplateHead;
|
||||||
else
|
else
|
||||||
(*tp)->type = TokenKind::NoSubsTemplate;
|
token->type = TokenKind::NoSubsTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
noteBadToken.release();
|
noteBadToken.release();
|
||||||
(*tp)->setAtom(atom);
|
token->setAtom(atom);
|
||||||
|
finishToken(out, token, modifier);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1600,7 +1600,7 @@ class MOZ_STACK_CLASS TokenStreamSpecific
|
||||||
|
|
||||||
MOZ_MUST_USE bool getTokenInternal(TokenKind* const ttp, const Modifier modifier);
|
MOZ_MUST_USE bool getTokenInternal(TokenKind* const ttp, const Modifier modifier);
|
||||||
|
|
||||||
MOZ_MUST_USE bool getStringOrTemplateToken(char untilChar, Token** tp);
|
MOZ_MUST_USE bool getStringOrTemplateToken(char untilChar, Modifier modifier, TokenKind* out);
|
||||||
|
|
||||||
// Try to get the next character, normalizing '\r', '\r\n', and '\n' into
|
// Try to get the next character, normalizing '\r', '\r\n', and '\n' into
|
||||||
// '\n'. Also updates internal line-counter state. Return true on success
|
// '\n'. Also updates internal line-counter state. Return true on success
|
||||||
|
|
Загрузка…
Ссылка в новой задаче