зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550616 - Make FunctionBox::setEnd take the actual uint32_t end, not TokenStreamAnyChars&, and add ParserBase::setFunctionEndFromCurrentToken that calls it passing the correct value, to eliminate another SharedContext.h dependency on... r=tcampbell
...TokenStream.h. r=tcampbell Depends on D30574 Differential Revision: https://phabricator.services.mozilla.com/D30575 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
04812304af
Коммит
8c3bcd64f2
|
@ -2912,6 +2912,10 @@ FunctionNode* Parser<FullParseHandler, Unit>::standaloneLazyFunction(
|
|||
return funNode;
|
||||
}
|
||||
|
||||
void ParserBase::setFunctionEndFromCurrentToken(FunctionBox* funbox) const {
|
||||
funbox->setEnd(anyChars.currentToken().pos.end);
|
||||
}
|
||||
|
||||
template <class ParseHandler, typename Unit>
|
||||
bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
|
@ -3052,7 +3056,7 @@ bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
|||
return false;
|
||||
}
|
||||
|
||||
funbox->setEnd(anyChars);
|
||||
setFunctionEndFromCurrentToken(funbox);
|
||||
} else {
|
||||
MOZ_ASSERT(kind == FunctionSyntaxKind::Arrow);
|
||||
|
||||
|
@ -3060,7 +3064,7 @@ bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
|||
return false;
|
||||
}
|
||||
|
||||
funbox->setEnd(anyChars);
|
||||
setFunctionEndFromCurrentToken(funbox);
|
||||
|
||||
if (kind == FunctionSyntaxKind::Statement) {
|
||||
if (!matchOrInsertSemicolon()) {
|
||||
|
@ -7161,7 +7165,7 @@ GeneralParser<ParseHandler, Unit>::synthesizeConstructor(
|
|||
}
|
||||
funbox->initWithEnclosingParseContext(pc_, functionSyntaxKind);
|
||||
handler_.setFunctionBox(funNode, funbox);
|
||||
funbox->setEnd(anyChars);
|
||||
setFunctionEndFromCurrentToken(funbox);
|
||||
|
||||
// Push a SourceParseContext on to the stack.
|
||||
SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
|
||||
|
@ -7352,7 +7356,7 @@ GeneralParser<ParseHandler, Unit>::fieldInitializerOpt(
|
|||
|
||||
// Update the end position of the parse node.
|
||||
handler_.setEndPosition(funNode, wholeInitializerPos.end);
|
||||
funbox->setEnd(anyChars);
|
||||
setFunctionEndFromCurrentToken(funbox);
|
||||
|
||||
// Create a ListNode for the parameters + body (there are no parameters).
|
||||
ListNodeType argsbody =
|
||||
|
|
|
@ -457,6 +457,8 @@ class MOZ_STACK_CLASS ParserBase : public ParserSharedBase,
|
|||
JSAtom* prefixAccessorName(PropertyType propType, HandleAtom propAtom);
|
||||
|
||||
MOZ_MUST_USE bool setSourceMapInfo();
|
||||
|
||||
void setFunctionEndFromCurrentToken(FunctionBox* funbox) const;
|
||||
};
|
||||
|
||||
enum FunctionCallBehavior {
|
||||
|
@ -824,6 +826,7 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
|||
using Base::prefixAccessorName;
|
||||
using Base::processExport;
|
||||
using Base::processExportFrom;
|
||||
using Base::setFunctionEndFromCurrentToken;
|
||||
|
||||
private:
|
||||
inline FinalParser* asFinalParser();
|
||||
|
|
|
@ -555,13 +555,11 @@ class FunctionBox : public ObjectBox, public SharedContext {
|
|||
startColumn = column;
|
||||
}
|
||||
|
||||
void setEnd(const TokenStreamAnyChars& anyChars) {
|
||||
void setEnd(uint32_t end) {
|
||||
// For all functions except class constructors, the buffer and
|
||||
// toString ending positions are the same. Class constructors override
|
||||
// the toString ending position with the end of the class definition.
|
||||
uint32_t offset = anyChars.currentToken().pos.end;
|
||||
bufEnd = offset;
|
||||
toStringEnd = offset;
|
||||
bufEnd = toStringEnd = end;
|
||||
}
|
||||
|
||||
void trace(JSTracer* trc) override;
|
||||
|
|
Загрузка…
Ссылка в новой задаче