Issue #2173 - Introduce FunctionNode::syntaxKind instead of JSOPs

This moves some "implementation details" to later in the emitter,
and also keeps syntax information available for later use.

Based-on: 1518391/{3+4}
This commit is contained in:
Martok 2023-04-02 19:39:14 +02:00 • committed by roytam1
commit 0132ae2101
6 changed files with 138 additions and 133 deletions

View file

@ -7044,7 +7044,8 @@ ParseFunction(ModuleValidator& m, FunctionNode** funNodeOut, unsigned* line)
if (!name)
return false;
FunctionNode* funNode = m.parser().handler.newFunctionStatement();
FunctionSyntaxKind syntaxKind = FunctionSyntaxKind::Statement;
FunctionNode* funNode = m.parser().handler.newFunction(syntaxKind);
if (!funNode)
return false;
@ -7058,14 +7059,14 @@ ParseFunction(ModuleValidator& m, FunctionNode** funNodeOut, unsigned* line)
SyncFunction, /* tryAnnexB = */ false);
if (!funbox)
return false;
funbox->initWithEnclosingParseContext(outerpc, frontend::Statement);
funbox->initWithEnclosingParseContext(outerpc, syntaxKind);
Directives newDirectives = directives;
ParseContext funpc(&m.parser(), funbox, &newDirectives);
if (!funpc.init())
return false;
if (!m.parser().functionFormalParametersAndBody(InAllowed, YieldIsName, funNode, Statement)) {
if (!m.parser().functionFormalParametersAndBody(InAllowed, YieldIsName, funNode, syntaxKind)) {
if (tokenStream.hadError() || directives == newDirectives)
return false;