зеркало из 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;
|
return funNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ParserBase::setFunctionEndFromCurrentToken(FunctionBox* funbox) const {
|
||||||
|
funbox->setEnd(anyChars.currentToken().pos.end);
|
||||||
|
}
|
||||||
|
|
||||||
template <class ParseHandler, typename Unit>
|
template <class ParseHandler, typename Unit>
|
||||||
bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
||||||
InHandling inHandling, YieldHandling yieldHandling,
|
InHandling inHandling, YieldHandling yieldHandling,
|
||||||
|
@ -3052,7 +3056,7 @@ bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
funbox->setEnd(anyChars);
|
setFunctionEndFromCurrentToken(funbox);
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(kind == FunctionSyntaxKind::Arrow);
|
MOZ_ASSERT(kind == FunctionSyntaxKind::Arrow);
|
||||||
|
|
||||||
|
@ -3060,7 +3064,7 @@ bool GeneralParser<ParseHandler, Unit>::functionFormalParametersAndBody(
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
funbox->setEnd(anyChars);
|
setFunctionEndFromCurrentToken(funbox);
|
||||||
|
|
||||||
if (kind == FunctionSyntaxKind::Statement) {
|
if (kind == FunctionSyntaxKind::Statement) {
|
||||||
if (!matchOrInsertSemicolon()) {
|
if (!matchOrInsertSemicolon()) {
|
||||||
|
@ -7161,7 +7165,7 @@ GeneralParser<ParseHandler, Unit>::synthesizeConstructor(
|
||||||
}
|
}
|
||||||
funbox->initWithEnclosingParseContext(pc_, functionSyntaxKind);
|
funbox->initWithEnclosingParseContext(pc_, functionSyntaxKind);
|
||||||
handler_.setFunctionBox(funNode, funbox);
|
handler_.setFunctionBox(funNode, funbox);
|
||||||
funbox->setEnd(anyChars);
|
setFunctionEndFromCurrentToken(funbox);
|
||||||
|
|
||||||
// Push a SourceParseContext on to the stack.
|
// Push a SourceParseContext on to the stack.
|
||||||
SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
|
SourceParseContext funpc(this, funbox, /* newDirectives = */ nullptr);
|
||||||
|
@ -7352,7 +7356,7 @@ GeneralParser<ParseHandler, Unit>::fieldInitializerOpt(
|
||||||
|
|
||||||
// Update the end position of the parse node.
|
// Update the end position of the parse node.
|
||||||
handler_.setEndPosition(funNode, wholeInitializerPos.end);
|
handler_.setEndPosition(funNode, wholeInitializerPos.end);
|
||||||
funbox->setEnd(anyChars);
|
setFunctionEndFromCurrentToken(funbox);
|
||||||
|
|
||||||
// Create a ListNode for the parameters + body (there are no parameters).
|
// Create a ListNode for the parameters + body (there are no parameters).
|
||||||
ListNodeType argsbody =
|
ListNodeType argsbody =
|
||||||
|
|
|
@ -457,6 +457,8 @@ class MOZ_STACK_CLASS ParserBase : public ParserSharedBase,
|
||||||
JSAtom* prefixAccessorName(PropertyType propType, HandleAtom propAtom);
|
JSAtom* prefixAccessorName(PropertyType propType, HandleAtom propAtom);
|
||||||
|
|
||||||
MOZ_MUST_USE bool setSourceMapInfo();
|
MOZ_MUST_USE bool setSourceMapInfo();
|
||||||
|
|
||||||
|
void setFunctionEndFromCurrentToken(FunctionBox* funbox) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FunctionCallBehavior {
|
enum FunctionCallBehavior {
|
||||||
|
@ -824,6 +826,7 @@ class MOZ_STACK_CLASS GeneralParser : public PerHandlerParser<ParseHandler> {
|
||||||
using Base::prefixAccessorName;
|
using Base::prefixAccessorName;
|
||||||
using Base::processExport;
|
using Base::processExport;
|
||||||
using Base::processExportFrom;
|
using Base::processExportFrom;
|
||||||
|
using Base::setFunctionEndFromCurrentToken;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline FinalParser* asFinalParser();
|
inline FinalParser* asFinalParser();
|
||||||
|
|
|
@ -555,13 +555,11 @@ class FunctionBox : public ObjectBox, public SharedContext {
|
||||||
startColumn = column;
|
startColumn = column;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEnd(const TokenStreamAnyChars& anyChars) {
|
void setEnd(uint32_t end) {
|
||||||
// For all functions except class constructors, the buffer and
|
// For all functions except class constructors, the buffer and
|
||||||
// toString ending positions are the same. Class constructors override
|
// toString ending positions are the same. Class constructors override
|
||||||
// the toString ending position with the end of the class definition.
|
// the toString ending position with the end of the class definition.
|
||||||
uint32_t offset = anyChars.currentToken().pos.end;
|
bufEnd = toStringEnd = end;
|
||||||
bufEnd = offset;
|
|
||||||
toStringEnd = offset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void trace(JSTracer* trc) override;
|
void trace(JSTracer* trc) override;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче