mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-10 02:08:38 +09:00
Issue #2173 - Separate CodeNode into FunctionNode and ModuleNode
ModuleNode only has a body and FunctionNode has many more attributes, and will get more in the following commit. Based-on: 1518391/2
This commit is contained in:
parent
f21340f1a8
commit
0dac791851
16 changed files with 247 additions and 195 deletions
|
|
@ -1279,7 +1279,7 @@ ModuleBuilder::processExport(frontend::ParseNode* exportNode)
|
|||
}
|
||||
|
||||
case PNK_FUNCTION: {
|
||||
RootedFunction func(cx_, kid->as<CodeNode>().funbox()->function());
|
||||
RootedFunction func(cx_, kid->as<FunctionNode>().funbox()->function());
|
||||
MOZ_ASSERT(!func->isArrow());
|
||||
RootedAtom localName(cx_, func->explicitName());
|
||||
RootedAtom exportName(cx_, isDefault ? cx_->names().default_ : localName.get());
|
||||
|
|
|
|||
|
|
@ -1867,7 +1867,7 @@ class ASTSerializer
|
|||
bool arrayPattern(ListNode* array, MutableHandleValue dst);
|
||||
bool objectPattern(ListNode* obj, MutableHandleValue dst);
|
||||
|
||||
bool function(CodeNode* funNode, ASTType type, MutableHandleValue dst);
|
||||
bool function(FunctionNode* funNode, ASTType type, MutableHandleValue dst);
|
||||
bool functionArgsAndBody(ParseNode* pn, NodeVector& args, NodeVector& defaults,
|
||||
bool isAsync, bool isExpression,
|
||||
MutableHandleValue body, MutableHandleValue rest);
|
||||
|
|
@ -2095,7 +2095,7 @@ ASTSerializer::declaration(ParseNode* pn, MutableHandleValue dst)
|
|||
|
||||
switch (pn->getKind()) {
|
||||
case PNK_FUNCTION:
|
||||
return function(&pn->as<CodeNode>(), AST_FUNC_DECL, dst);
|
||||
return function(&pn->as<FunctionNode>(), AST_FUNC_DECL, dst);
|
||||
|
||||
case PNK_VAR:
|
||||
return variableDeclaration(&pn->as<ListNode>(), false, dst);
|
||||
|
|
@ -2239,7 +2239,7 @@ ASTSerializer::exportDeclaration(ParseNode* exportNode, MutableHandleValue dst)
|
|||
}
|
||||
|
||||
case PNK_FUNCTION:
|
||||
if (!function(&kid->as<CodeNode>(), AST_FUNC_DECL, &decl))
|
||||
if (!function(&kid->as<FunctionNode>(), AST_FUNC_DECL, &decl))
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
|
@ -2937,7 +2937,7 @@ ASTSerializer::expression(ParseNode* pn, MutableHandleValue dst)
|
|||
switch (pn->getKind()) {
|
||||
case PNK_FUNCTION:
|
||||
{
|
||||
CodeNode* funNode = &pn->as<CodeNode>();
|
||||
FunctionNode* funNode = &pn->as<FunctionNode>();
|
||||
ASTType type = funNode->funbox()->function()->isArrow() ? AST_ARROW_EXPR : AST_FUNC_EXPR;
|
||||
return function(funNode, type, dst);
|
||||
}
|
||||
|
|
@ -3081,7 +3081,7 @@ ASTSerializer::expression(ParseNode* pn, MutableHandleValue dst)
|
|||
ParseNode* callee = pn->as<BinaryNode>().left();
|
||||
MOZ_ASSERT(callee->isKind(PNK_FUNCTION));
|
||||
|
||||
ListNode* paramsBody = callee->as<CodeNode>().body();
|
||||
ListNode* paramsBody = callee->as<FunctionNode>().body();
|
||||
MOZ_ASSERT(paramsBody->isKind(PNK_PARAMSBODY));
|
||||
|
||||
ListNode* body = ¶msBody->last()->as<ListNode>();
|
||||
|
|
@ -3441,9 +3441,8 @@ ASTSerializer::property(ParseNode* pn, MutableHandleValue dst)
|
|||
ParseNode* valNode = node->right();
|
||||
|
||||
bool isShorthand = node->isKind(PNK_SHORTHAND);
|
||||
bool isMethod =
|
||||
valNode->isKind(PNK_FUNCTION) &&
|
||||
valNode->as<CodeNode>().funbox()->function()->kind() == JSFunction::Method;
|
||||
bool isMethod = valNode->is<FunctionNode>() &&
|
||||
valNode->as<FunctionNode>().funbox()->function()->kind() == JSFunction::Method;
|
||||
RootedValue key(cx), val(cx);
|
||||
return propertyName(keyNode, &key) &&
|
||||
expression(valNode, &val) &&
|
||||
|
|
@ -3614,7 +3613,7 @@ ASTSerializer::identifier(NameNode* id, MutableHandleValue dst)
|
|||
}
|
||||
|
||||
bool
|
||||
ASTSerializer::function(CodeNode* funNode, ASTType type, MutableHandleValue dst)
|
||||
ASTSerializer::function(FunctionNode* funNode, ASTType type, MutableHandleValue dst)
|
||||
{
|
||||
FunctionBox* funbox = funNode->funbox();
|
||||
RootedFunction func(cx, funbox->function());
|
||||
|
|
@ -3938,8 +3937,7 @@ reflect_parse(JSContext* cx, uint32_t argc, Value* vp)
|
|||
if (!pn)
|
||||
return false;
|
||||
|
||||
MOZ_ASSERT(pn->getKind() == PNK_MODULE);
|
||||
pn = pn->as<CodeNode>().body();
|
||||
pn = pn->as<ModuleNode>().body();
|
||||
}
|
||||
|
||||
RootedValue val(cx);
|
||||
|
|
|
|||
|
|
@ -413,7 +413,7 @@ BytecodeCompiler::compileModule()
|
|||
Maybe<BytecodeEmitter> emitter;
|
||||
if (!emplaceEmitter(emitter, &modulesc))
|
||||
return nullptr;
|
||||
if (!emitter->emitScript(pn->as<CodeNode>().body()))
|
||||
if (!emitter->emitScript(pn->as<ModuleNode>().body()))
|
||||
return nullptr;
|
||||
|
||||
if (!NameFunctions(cx, pn))
|
||||
|
|
@ -457,7 +457,7 @@ BytecodeCompiler::compileStandaloneFunction(MutableHandleFunction fun,
|
|||
// function should have been parsed, we backup and reparse with the new set
|
||||
// of directives.
|
||||
|
||||
ParseNode* fn;
|
||||
FunctionNode* fn;
|
||||
do {
|
||||
Directives newDirectives = directives;
|
||||
fn = parser->standaloneFunction(fun, enclosingScope, parameterListEnd, generatorKind,
|
||||
|
|
@ -466,7 +466,7 @@ BytecodeCompiler::compileStandaloneFunction(MutableHandleFunction fun,
|
|||
return false;
|
||||
} while (!fn);
|
||||
|
||||
FunctionBox* funbox = fn->as<CodeNode>().funbox();
|
||||
FunctionBox* funbox = fn->funbox();
|
||||
if (funbox->function()->isInterpreted()) {
|
||||
MOZ_ASSERT(fun == funbox->function());
|
||||
|
||||
|
|
@ -476,7 +476,7 @@ BytecodeCompiler::compileStandaloneFunction(MutableHandleFunction fun,
|
|||
Maybe<BytecodeEmitter> emitter;
|
||||
if (!emplaceEmitter(emitter, funbox))
|
||||
return false;
|
||||
if (!emitter->emitFunctionScript(&fn->as<CodeNode>()))
|
||||
if (!emitter->emitFunctionScript(fn))
|
||||
return false;
|
||||
} else {
|
||||
fun.set(funbox->function());
|
||||
|
|
@ -674,12 +674,12 @@ frontend::CompileLazyFunction(JSContext* cx, Handle<LazyScript*> lazy, const cha
|
|||
if (lazy->hasBeenCloned())
|
||||
script->setHasBeenCloned();
|
||||
|
||||
BytecodeEmitter bce(/* parent = */ nullptr, &parser, pn->as<CodeNode>().funbox(), script, lazy,
|
||||
BytecodeEmitter bce(/* parent = */ nullptr, &parser, pn->as<FunctionNode>().funbox(), script, lazy,
|
||||
pn->pn_pos, BytecodeEmitter::LazyFunction);
|
||||
if (!bce.init())
|
||||
return false;
|
||||
|
||||
if (!bce.emitFunctionScript(&pn->as<CodeNode>()))
|
||||
if (!bce.emitFunctionScript(&pn->as<FunctionNode>()))
|
||||
return false;
|
||||
|
||||
if (!NameFunctions(cx, pn))
|
||||
|
|
|
|||
|
|
@ -1415,7 +1415,7 @@ BytecodeEmitter::checkSideEffects(ParseNode* pn, bool* answer)
|
|||
return true;
|
||||
|
||||
case PNK_FUNCTION:
|
||||
MOZ_ASSERT(pn->is<CodeNode>());
|
||||
MOZ_ASSERT(pn->is<FunctionNode>());
|
||||
/*
|
||||
* A named function, contrary to ES3, is no longer effectful, because
|
||||
* we bind its name lexically (using JSOP_CALLEE) instead of creating
|
||||
|
|
@ -2385,9 +2385,8 @@ BytecodeEmitter::emitScript(ParseNode* body)
|
|||
}
|
||||
|
||||
bool
|
||||
BytecodeEmitter::emitFunctionScript(CodeNode* funNode)
|
||||
BytecodeEmitter::emitFunctionScript(FunctionNode* funNode)
|
||||
{
|
||||
MOZ_ASSERT(funNode->isKind(PNK_FUNCTION));
|
||||
ParseNode* body = funNode->body();
|
||||
FunctionBox* funbox = sc->asFunctionBox();
|
||||
|
||||
|
|
@ -2967,10 +2966,10 @@ bool
|
|||
BytecodeEmitter::setOrEmitSetFunName(ParseNode* maybeFun, HandleAtom name,
|
||||
FunctionPrefixKind prefixKind)
|
||||
{
|
||||
if (maybeFun->isKind(PNK_FUNCTION)) {
|
||||
if (maybeFun->is<FunctionNode>()) {
|
||||
// Function doesn't have 'name' property at this point.
|
||||
// Set function's name at compile time.
|
||||
RootedFunction fun(cx, maybeFun->as<CodeNode>().funbox()->function());
|
||||
RootedFunction fun(cx, maybeFun->as<FunctionNode>().funbox()->function());
|
||||
|
||||
// Single node can be emitted multiple times if it appears in
|
||||
// array destructuring default. If function already has a name,
|
||||
|
|
@ -4355,7 +4354,7 @@ BytecodeEmitter::emitHoistedFunctionsInList(ListNode* stmtList)
|
|||
maybeFun = maybeFun->as<LabeledStatement>().statement();
|
||||
}
|
||||
|
||||
if (maybeFun->isKind(PNK_FUNCTION) && maybeFun->as<CodeNode>().functionIsHoisted()) {
|
||||
if (maybeFun->is<FunctionNode>() && maybeFun->as<FunctionNode>().functionIsHoisted()) {
|
||||
if (!emitTree(maybeFun))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -5609,7 +5608,7 @@ BytecodeEmitter::emitComprehensionFor(ForNode* forNode)
|
|||
}
|
||||
|
||||
MOZ_NEVER_INLINE bool
|
||||
BytecodeEmitter::emitFunction(CodeNode* funNode, bool needsProto)
|
||||
BytecodeEmitter::emitFunction(FunctionNode* funNode, bool needsProto)
|
||||
{
|
||||
FunctionBox* funbox = funNode->funbox();
|
||||
RootedFunction fun(cx, funbox->function());
|
||||
|
|
@ -7808,10 +7807,9 @@ BytecodeEmitter::emitPropertyList(ListNode* obj, MutableHandlePlainObject objp,
|
|||
if (op == JSOP_INITPROP_GETTER || op == JSOP_INITPROP_SETTER)
|
||||
objp.set(nullptr);
|
||||
|
||||
if (propVal->isKind(PNK_FUNCTION) &&
|
||||
propVal->as<CodeNode>().funbox()->needsHomeObject())
|
||||
{
|
||||
FunctionBox* funbox = propVal->as<CodeNode>().funbox();
|
||||
if (propVal->is<FunctionNode>() &&
|
||||
propVal->as<FunctionNode>().funbox()->needsHomeObject()) {
|
||||
FunctionBox* funbox = propVal->as<FunctionNode>().funbox();
|
||||
MOZ_ASSERT(funbox->function()->allowSuperProperty());
|
||||
bool isAsync = funbox->isAsync();
|
||||
if (isAsync) {
|
||||
|
|
@ -8507,7 +8505,7 @@ BytecodeEmitter::emitClass(ClassNode* classNode)
|
|||
ParseNode* heritageExpression = classNode->heritage();
|
||||
ListNode* classMethods = classNode->methodList();
|
||||
|
||||
CodeNode* constructor = nullptr;
|
||||
FunctionNode* constructor = nullptr;
|
||||
for (ParseNode* mn : classMethods->contents()) {
|
||||
ClassMethod& method = mn->as<ClassMethod>();
|
||||
ParseNode& methodName = method.name();
|
||||
|
|
@ -8641,7 +8639,7 @@ BytecodeEmitter::emitTree(ParseNode* pn, ValueUsage valueUsage /* = ValueUsage::
|
|||
|
||||
switch (pn->getKind()) {
|
||||
case PNK_FUNCTION:
|
||||
if (!emitFunction(&pn->as<CodeNode>()))
|
||||
if (!emitFunction(&pn->as<FunctionNode>()))
|
||||
return false;
|
||||
break;
|
||||
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
|
|||
MOZ_MUST_USE bool emitScript(ParseNode* body);
|
||||
|
||||
// Emit function code for the tree rooted at body.
|
||||
MOZ_MUST_USE bool emitFunctionScript(CodeNode* funNode);
|
||||
MOZ_MUST_USE bool emitFunctionScript(FunctionNode* funNode);
|
||||
|
||||
// If op is JOF_TYPESET (see the type barriers comment in TypeInference.h),
|
||||
// reserve a type set to store its result.
|
||||
|
|
@ -508,7 +508,7 @@ struct MOZ_STACK_CLASS BytecodeEmitter
|
|||
MOZ_MUST_USE bool emitObjectPairOp(ObjectBox* objbox1, ObjectBox* objbox2, JSOp op);
|
||||
MOZ_MUST_USE bool emitRegExp(uint32_t index);
|
||||
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitFunction(CodeNode* funNode, bool needsProto = false);
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitFunction(FunctionNode* funNode, bool needsProto = false);
|
||||
MOZ_NEVER_INLINE MOZ_MUST_USE bool emitObject(ListNode* objNode);
|
||||
|
||||
MOZ_MUST_USE bool replaceNewInitWithNewObject(JSObject* obj, ptrdiff_t offset);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ ContainsHoistedDeclaration(ExclusiveContext* cx, ParseNode* node, bool* result)
|
|||
// that we preserve an unreachable function declaration node against
|
||||
// dead-code removal.
|
||||
case PNK_FUNCTION:
|
||||
MOZ_ASSERT(node->is<CodeNode>());
|
||||
*result = false;
|
||||
return true;
|
||||
|
||||
|
|
@ -289,7 +288,7 @@ ContainsHoistedDeclaration(ExclusiveContext* cx, ParseNode* node, bool* result)
|
|||
LexicalScopeNode* scope = &node->as<LexicalScopeNode>();
|
||||
ParseNode* expr = scope->scopeBody();
|
||||
|
||||
if (expr->isKind(PNK_FOR) || expr->isKind(PNK_FUNCTION))
|
||||
if (expr->isKind(PNK_FOR) || expr->is<FunctionNode>())
|
||||
return ContainsHoistedDeclaration(cx, expr, result);
|
||||
|
||||
MOZ_ASSERT(expr->isKind(PNK_STATEMENTLIST));
|
||||
|
|
@ -588,7 +587,7 @@ FoldTypeOfExpr(ExclusiveContext* cx, UnaryNode* node, Parser<FullParseHandler>&
|
|||
result = cx->names().object;
|
||||
else if (expr->isKind(PNK_TRUE) || expr->isKind(PNK_FALSE))
|
||||
result = cx->names().boolean;
|
||||
else if (expr->isKind(PNK_FUNCTION))
|
||||
else if (expr->is<FunctionNode>())
|
||||
result = cx->names().function;
|
||||
|
||||
if (result) {
|
||||
|
|
@ -1018,11 +1017,9 @@ FoldIf(ExclusiveContext* cx, ParseNode** nodePtr, Parser<FullParseHandler>& pars
|
|||
}
|
||||
|
||||
static bool
|
||||
FoldFunction(ExclusiveContext* cx, CodeNode* node, Parser<FullParseHandler>& parser,
|
||||
FoldFunction(ExclusiveContext* cx, FunctionNode* node, Parser<FullParseHandler>& parser,
|
||||
bool inGenexpLambda)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_FUNCTION));
|
||||
|
||||
// Don't constant-fold inside "use asm" code, as this could create a parse
|
||||
// tree that doesn't type-check as asm.js.
|
||||
if (node->funbox()->useAsmOrInsideUseAsm())
|
||||
|
|
@ -1080,9 +1077,8 @@ ComputeBinary(ParseNodeKind kind, double left, double right)
|
|||
}
|
||||
|
||||
static bool
|
||||
FoldModule(ExclusiveContext* cx, CodeNode* node, Parser<FullParseHandler>& parser)
|
||||
FoldModule(ExclusiveContext* cx, ModuleNode* node, Parser<FullParseHandler>& parser)
|
||||
{
|
||||
MOZ_ASSERT(node->isKind(PNK_MODULE));
|
||||
MOZ_ASSERT(node->body());
|
||||
return Fold(cx, node->unsafeBodyReference(), parser, false);
|
||||
}
|
||||
|
|
@ -1775,10 +1771,10 @@ Fold(ExclusiveContext* cx, ParseNode** pnp, Parser<FullParseHandler>& parser, bo
|
|||
return FoldLogical(cx, pnp, parser, inGenexpLambda);
|
||||
|
||||
case PNK_FUNCTION:
|
||||
return FoldFunction(cx, &pn->as<CodeNode>(), parser, inGenexpLambda);
|
||||
return FoldFunction(cx, &pn->as<FunctionNode>(), parser, inGenexpLambda);
|
||||
|
||||
case PNK_MODULE:
|
||||
return FoldModule(cx, &pn->as<CodeNode>(), parser);
|
||||
return FoldModule(cx, &pn->as<ModuleNode>(), parser);
|
||||
|
||||
case PNK_SUB:
|
||||
case PNK_STAR:
|
||||
|
|
|
|||
|
|
@ -439,7 +439,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node key, CodeNodeType funNode,
|
||||
MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node key, FunctionNodeType funNode,
|
||||
JSOp op)
|
||||
{
|
||||
MOZ_ASSERT(key->isKind(PNK_NUMBER) ||
|
||||
|
|
@ -455,7 +455,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
return true;
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool addClassMethodDefinition(ListNodeType methodList, Node key, CodeNodeType funNode,
|
||||
MOZ_MUST_USE bool addClassMethodDefinition(ListNodeType methodList, Node key, FunctionNodeType funNode,
|
||||
JSOp op, bool isStatic)
|
||||
{
|
||||
MOZ_ASSERT(methodList->isKind(PNK_CLASSMETHODLIST));
|
||||
|
|
@ -505,7 +505,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
MOZ_MUST_USE bool isFunctionStmt(Node stmt) {
|
||||
while (stmt->isKind(PNK_LABEL))
|
||||
stmt = stmt->as<LabeledStatement>().statement();
|
||||
return stmt->isKind(PNK_FUNCTION);
|
||||
return stmt->is<FunctionNode>();
|
||||
}
|
||||
|
||||
void addStatementToList(ListNodeType list, Node stmt) {
|
||||
|
|
@ -713,7 +713,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
inline MOZ_MUST_USE bool addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lexicalScope,
|
||||
Node catchBinding, Node catchGuard, Node catchBody);
|
||||
|
||||
inline MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(CodeNodeType funNode,
|
||||
inline MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(FunctionNodeType funNode,
|
||||
Node defaultValue);
|
||||
inline void setLastFunctionFormalParameterDestructuring(Node funcpn, Node pn);
|
||||
|
||||
|
|
@ -722,19 +722,19 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
pn->setDirectRHSAnonFunction(true);
|
||||
}
|
||||
|
||||
CodeNodeType newFunctionStatement() {
|
||||
return new_<CodeNode>(PNK_FUNCTION, JSOP_NOP, pos());
|
||||
FunctionNodeType newFunctionStatement() {
|
||||
return new_<FunctionNode>(JSOP_NOP, pos());
|
||||
}
|
||||
|
||||
CodeNodeType newFunctionExpression() {
|
||||
return new_<CodeNode>(PNK_FUNCTION, JSOP_LAMBDA, pos());
|
||||
FunctionNodeType newFunctionExpression() {
|
||||
return new_<FunctionNode>(JSOP_LAMBDA, pos());
|
||||
}
|
||||
|
||||
CodeNodeType newArrowFunction() {
|
||||
return new_<CodeNode>(PNK_FUNCTION, JSOP_LAMBDA_ARROW, pos());
|
||||
FunctionNodeType newArrowFunction() {
|
||||
return new_<FunctionNode>(JSOP_LAMBDA_ARROW, pos());
|
||||
}
|
||||
|
||||
bool setComprehensionLambdaBody(CodeNodeType funNode, ListNodeType body) {
|
||||
bool setComprehensionLambdaBody(FunctionNodeType funNode, ListNodeType body) {
|
||||
MOZ_ASSERT(body->isKind(PNK_STATEMENTLIST));
|
||||
ListNode* paramsBody = newList(PNK_PARAMSBODY, body);
|
||||
if (!paramsBody)
|
||||
|
|
@ -742,25 +742,24 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
setFunctionFormalParametersAndBody(funNode, paramsBody);
|
||||
return true;
|
||||
}
|
||||
void setFunctionFormalParametersAndBody(CodeNodeType funNode, ListNodeType paramsBody) {
|
||||
void setFunctionFormalParametersAndBody(FunctionNodeType funNode, ListNodeType paramsBody) {
|
||||
MOZ_ASSERT_IF(paramsBody, paramsBody->isKind(PNK_PARAMSBODY));
|
||||
funNode->setBody(paramsBody);
|
||||
}
|
||||
void setFunctionBox(CodeNodeType funNode, FunctionBox* funbox) {
|
||||
MOZ_ASSERT(funNode->isKind(PNK_FUNCTION));
|
||||
void setFunctionBox(FunctionNodeType funNode, FunctionBox* funbox) {
|
||||
funNode->setFunbox(funbox);
|
||||
funbox->functionNode = funNode;
|
||||
}
|
||||
void addFunctionFormalParameter(CodeNodeType funNode, Node argpn) {
|
||||
void addFunctionFormalParameter(FunctionNodeType funNode, Node argpn) {
|
||||
addList(/* list = */ funNode->body(), /* child = */ argpn);
|
||||
}
|
||||
void setFunctionBody(CodeNodeType funNode, LexicalScopeNodeType body) {
|
||||
void setFunctionBody(FunctionNodeType funNode, LexicalScopeNodeType body) {
|
||||
MOZ_ASSERT(funNode->body()->isKind(PNK_PARAMSBODY));
|
||||
addList(/* list = */ funNode->body(), /* child = */ body);
|
||||
}
|
||||
|
||||
CodeNodeType newModule() {
|
||||
return new_<CodeNode>(PNK_MODULE, JSOP_NOP, pos());
|
||||
ModuleNodeType newModule() {
|
||||
return new_<ModuleNode>(pos());
|
||||
}
|
||||
|
||||
BinaryNodeType newNewExpression(uint32_t begin, Node ctor, Node args) {
|
||||
|
|
@ -1009,7 +1008,7 @@ FullParseHandler::addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lex
|
|||
}
|
||||
|
||||
inline bool
|
||||
FullParseHandler::setLastFunctionFormalParameterDefault(CodeNodeType funNode, Node defaultValue)
|
||||
FullParseHandler::setLastFunctionFormalParameterDefault(FunctionNodeType funNode, Node defaultValue)
|
||||
{
|
||||
MOZ_ASSERT(funNode->isKind(PNK_FUNCTION));
|
||||
ListNode* body = funNode->body();
|
||||
|
|
|
|||
|
|
@ -190,9 +190,8 @@ class NameResolver
|
|||
* listed, then it is skipped. Otherwise an intelligent name is guessed to
|
||||
* assign to the function's displayAtom field.
|
||||
*/
|
||||
bool resolveFun(CodeNode* funNode, HandleAtom prefix, MutableHandleAtom retAtom) {
|
||||
bool resolveFun(FunctionNode* funNode, HandleAtom prefix, MutableHandleAtom retAtom) {
|
||||
MOZ_ASSERT(funNode != nullptr);
|
||||
MOZ_ASSERT(funNode->isKind(PNK_FUNCTION));
|
||||
RootedFunction fun(cx, funNode->funbox()->function());
|
||||
|
||||
StringBuffer buf(cx);
|
||||
|
|
@ -359,10 +358,9 @@ class NameResolver
|
|||
if (cur == nullptr)
|
||||
return true;
|
||||
|
||||
MOZ_ASSERT((cur->isKind(PNK_FUNCTION) || cur->isKind(PNK_MODULE)) == cur->is<CodeNode>());
|
||||
if (cur->isKind(PNK_FUNCTION)) {
|
||||
if (cur->is<FunctionNode>()) {
|
||||
RootedAtom prefix2(cx);
|
||||
if (!resolveFun(&cur->as<CodeNode>(), prefix, &prefix2))
|
||||
if (!resolveFun(&cur->as<FunctionNode>(), prefix, &prefix2))
|
||||
return false;
|
||||
|
||||
/*
|
||||
|
|
@ -866,8 +864,14 @@ class NameResolver
|
|||
break;
|
||||
|
||||
case PNK_FUNCTION:
|
||||
if (ParseNode* body = cur->as<FunctionNode>().body()) {
|
||||
if (!resolve(body, prefix))
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case PNK_MODULE:
|
||||
if (ParseNode* body = cur->as<CodeNode>().body()) {
|
||||
if (ParseNode* body = cur->as<ModuleNode>().body()) {
|
||||
if (!resolve(body, prefix))
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,8 @@ namespace frontend {
|
|||
inline PropertyName*
|
||||
ParseNode::name() const
|
||||
{
|
||||
MOZ_ASSERT(isKind(PNK_FUNCTION) || isKind(PNK_NAME));
|
||||
JSAtom* atom = isKind(PNK_FUNCTION)
|
||||
? as<CodeNode>().funbox()->function()->explicitName()
|
||||
JSAtom* atom = is<FunctionNode>()
|
||||
? as<FunctionNode>().funbox()->function()->explicitName()
|
||||
: as<NameNode>().atom();
|
||||
return atom->asPropertyName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class NodeStack {
|
|||
enum class PushResult { Recyclable, CleanUpLater };
|
||||
|
||||
static PushResult
|
||||
PushCodeNodeChildren(CodeNode* node, NodeStack* stack)
|
||||
PushFunctionNodeChildren(FunctionNode* node, NodeStack* stack)
|
||||
{
|
||||
/*
|
||||
* Function nodes are linked into the function box tree, and may appear
|
||||
|
|
@ -121,6 +121,15 @@ PushCodeNodeChildren(CodeNode* node, NodeStack* stack)
|
|||
return PushResult::CleanUpLater;
|
||||
}
|
||||
|
||||
static PushResult
|
||||
PushModuleNodeChildren(ModuleNode* node, NodeStack* stack)
|
||||
{
|
||||
stack->push(node->body());
|
||||
node->setBody(nullptr);
|
||||
|
||||
return PushResult::CleanUpLater;
|
||||
}
|
||||
|
||||
static PushResult
|
||||
PushNameNodeChildren(NameNode* node, NodeStack* stack)
|
||||
{
|
||||
|
|
@ -506,8 +515,9 @@ PushNodeChildren(ParseNode* pn, NodeStack* stack)
|
|||
return PushScopeNodeChildren(&pn->as<LexicalScopeNode>(), stack);
|
||||
|
||||
case PNK_FUNCTION:
|
||||
return PushFunctionNodeChildren(&pn->as<FunctionNode>(), stack);
|
||||
case PNK_MODULE:
|
||||
return PushCodeNodeChildren(&pn->as<CodeNode>(), stack);
|
||||
return PushModuleNodeChildren(&pn->as<ModuleNode>(), stack);
|
||||
|
||||
case PNK_LIMIT: // invalid sentinel value
|
||||
MOZ_CRASH("invalid node kind");
|
||||
|
|
@ -677,9 +687,11 @@ ParseNode::dump(int indent)
|
|||
case PN_TERNARY:
|
||||
as<TernaryNode>().dump(indent);
|
||||
return;
|
||||
case PN_CODE:
|
||||
as<CodeNode>().dump(indent);
|
||||
case PN_FUNCTION:
|
||||
as<FunctionNode>().dump(indent);
|
||||
return;
|
||||
case PN_MODULE:
|
||||
as<ModuleNode>().dump(indent);
|
||||
case PN_LIST:
|
||||
as<ListNode>().dump(indent);
|
||||
return;
|
||||
|
|
@ -802,7 +814,17 @@ TernaryNode::dump(int indent)
|
|||
}
|
||||
|
||||
void
|
||||
CodeNode::dump(int indent)
|
||||
FunctionNode::dump(int indent)
|
||||
{
|
||||
const char* name = parseNodeNames[getKind()];
|
||||
fprintf(stderr, "(%s ", name);
|
||||
indent += strlen(name) + 2;
|
||||
DumpParseTree(body(), indent);
|
||||
fprintf(stderr, ")");
|
||||
}
|
||||
|
||||
void
|
||||
ModuleNode::dump(int indent)
|
||||
{
|
||||
const char* name = parseNodeNames[getKind()];
|
||||
fprintf(stderr, "(%s ", name);
|
||||
|
|
@ -979,8 +1001,8 @@ js::frontend::IsAnonymousFunctionDefinition(ParseNode* pn)
|
|||
// 14.1.12 (FunctionExpression).
|
||||
// 14.4.8 (GeneratorExpression).
|
||||
// 14.6.8 (AsyncFunctionExpression)
|
||||
if (pn->isKind(PNK_FUNCTION) &&
|
||||
!pn->as<CodeNode>().funbox()->function()->explicitName())
|
||||
if (pn->is<FunctionNode>() &&
|
||||
!pn->as<FunctionNode>().funbox()->function()->explicitName())
|
||||
return true;
|
||||
|
||||
// 14.5.8 (ClassExpression)
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ IsTypeofKind(ParseNodeKind kind)
|
|||
|
||||
/*
|
||||
* <Definitions>
|
||||
* PNK_FUNCTION (CodeNode)
|
||||
* PNK_FUNCTION (FunctionNode)
|
||||
* funbox: ptr to js::FunctionBox holding function object containing arg and
|
||||
* var properties. We create the function object at parse (not emit)
|
||||
* time to specialize arg and var bytecodes early.
|
||||
|
|
@ -259,9 +259,8 @@ IsTypeofKind(ParseNodeKind kind)
|
|||
* PNK_CLASSMETHOD (ClassMethod)
|
||||
* name: propertyName
|
||||
* method: methodDefinition
|
||||
* PNK_MODULE (CodeNode)
|
||||
* funbox: ?
|
||||
* body: ?
|
||||
* PNK_MODULE (ModuleNode)
|
||||
* body: statement list of the module
|
||||
*
|
||||
* <Statements>
|
||||
* PNK_STATEMENTLIST (ListNode)
|
||||
|
|
@ -546,7 +545,8 @@ enum ParseNodeArity
|
|||
PN_UNARY, /* one kid, plus a couple of scalars */
|
||||
PN_BINARY, /* two kids, plus a couple of scalars */
|
||||
PN_TERNARY, /* three kids */
|
||||
PN_CODE, /* module or function definition node */
|
||||
PN_FUNCTION, /* function definition node */
|
||||
PN_MODULE, /* module node */
|
||||
PN_LIST, /* generic singly linked list */
|
||||
PN_NAME, /* name, label, string */
|
||||
PN_NUMBER, /* numeric literal */
|
||||
|
|
@ -568,7 +568,8 @@ enum ParseNodeArity
|
|||
macro(OptionalPropertyByValue, OptionalPropertyByValueType, asOptionalPropertyByValue) \
|
||||
macro(SwitchStatement, SwitchStatementType, asSwitchStatement) \
|
||||
\
|
||||
macro(CodeNode, CodeNodeType, asCode) \
|
||||
macro(FunctionNode, FunctionNodeType, asFunction) \
|
||||
macro(ModuleNode, ModuleNodeType, asModule) \
|
||||
\
|
||||
macro(LexicalScopeNode, LexicalScopeNodeType, asLexicalScope) \
|
||||
\
|
||||
|
|
@ -734,10 +735,15 @@ class ParseNode
|
|||
} regexp;
|
||||
struct {
|
||||
private:
|
||||
friend class CodeNode;
|
||||
FunctionBox* funbox; /* function object */
|
||||
ParseNode* body; /* module or function body */
|
||||
} code;
|
||||
friend class FunctionNode;
|
||||
FunctionBox* funbox;
|
||||
ParseNode* body;
|
||||
} function;
|
||||
struct {
|
||||
private:
|
||||
friend class ModuleNode;
|
||||
ParseNode* body;
|
||||
} module;
|
||||
struct {
|
||||
private:
|
||||
friend class LexicalScopeNode;
|
||||
|
|
@ -1418,24 +1424,22 @@ ParseNode::isForLoopDeclaration() const
|
|||
return false;
|
||||
}
|
||||
|
||||
class CodeNode : public ParseNode
|
||||
class FunctionNode : public ParseNode
|
||||
{
|
||||
public:
|
||||
CodeNode(ParseNodeKind kind, JSOp op, const TokenPos& pos)
|
||||
: ParseNode(kind, op, PN_CODE, pos)
|
||||
FunctionNode(JSOp op, const TokenPos& pos)
|
||||
: ParseNode(PNK_FUNCTION, op, PN_FUNCTION, pos)
|
||||
{
|
||||
MOZ_ASSERT(kind == PNK_FUNCTION || kind == PNK_MODULE);
|
||||
MOZ_ASSERT_IF(kind == PNK_MODULE, op == JSOP_NOP);
|
||||
MOZ_ASSERT(op == JSOP_NOP || // statement, module
|
||||
op == JSOP_LAMBDA_ARROW || // arrow function
|
||||
op == JSOP_LAMBDA); // expression, method, comprehension, accessor, &c.
|
||||
MOZ_ASSERT(!pn_u.code.body);
|
||||
MOZ_ASSERT(!pn_u.code.funbox);
|
||||
MOZ_ASSERT(!pn_u.function.body);
|
||||
MOZ_ASSERT(!pn_u.function.funbox);
|
||||
}
|
||||
|
||||
static bool test(const ParseNode& node) {
|
||||
bool match = node.isKind(PNK_FUNCTION) || node.isKind(PNK_MODULE);
|
||||
MOZ_ASSERT_IF(match, node.isArity(PN_CODE));
|
||||
bool match = node.isKind(PNK_FUNCTION);
|
||||
MOZ_ASSERT_IF(match, node.isArity(PN_FUNCTION));
|
||||
return match;
|
||||
}
|
||||
|
||||
|
|
@ -1444,28 +1448,27 @@ class CodeNode : public ParseNode
|
|||
#endif
|
||||
|
||||
FunctionBox* funbox() const {
|
||||
return pn_u.code.funbox;
|
||||
return pn_u.function.funbox;
|
||||
}
|
||||
|
||||
ListNode* body() const {
|
||||
return pn_u.code.body ? &pn_u.code.body->as<ListNode>() : nullptr;
|
||||
return pn_u.function.body ? &pn_u.function.body->as<ListNode>() : nullptr;
|
||||
}
|
||||
|
||||
void setFunbox(FunctionBox* funbox) {
|
||||
pn_u.code.funbox = funbox;
|
||||
pn_u.function.funbox = funbox;
|
||||
}
|
||||
|
||||
void setBody(ListNode* body) {
|
||||
pn_u.code.body = body;
|
||||
pn_u.function.body = body;
|
||||
}
|
||||
|
||||
// Methods used by FoldConstants.cpp.
|
||||
ParseNode** unsafeBodyReference() {
|
||||
return &pn_u.code.body;
|
||||
return &pn_u.function.body;
|
||||
}
|
||||
|
||||
bool functionIsHoisted() const {
|
||||
MOZ_ASSERT(isKind(PNK_FUNCTION));
|
||||
MOZ_ASSERT(isOp(JSOP_LAMBDA) || // lambda
|
||||
isOp(JSOP_LAMBDA_ARROW) || // arrow function
|
||||
isOp(JSOP_NOP)); // body-level function stmt in global code
|
||||
|
|
@ -1473,6 +1476,39 @@ class CodeNode : public ParseNode
|
|||
}
|
||||
};
|
||||
|
||||
class ModuleNode : public ParseNode
|
||||
{
|
||||
public:
|
||||
ModuleNode(const TokenPos& pos)
|
||||
: ParseNode(PNK_MODULE, JSOP_NOP, PN_MODULE, pos)
|
||||
{
|
||||
MOZ_ASSERT(!pn_u.module.body);
|
||||
}
|
||||
|
||||
static bool test(const ParseNode& node) {
|
||||
bool match = node.isKind(PNK_MODULE);
|
||||
MOZ_ASSERT_IF(match, node.isArity(PN_MODULE));
|
||||
return match;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
void dump(int indent);
|
||||
#endif
|
||||
|
||||
ListNode* body() const {
|
||||
return &pn_u.module.body->as<ListNode>();
|
||||
}
|
||||
|
||||
void setBody(ListNode* body) {
|
||||
pn_u.module.body = body;
|
||||
}
|
||||
|
||||
// Methods used by FoldConstants.cpp.
|
||||
ParseNode** unsafeBodyReference() {
|
||||
return &pn_u.module.body;
|
||||
}
|
||||
};
|
||||
|
||||
class NumericLiteral : public ParseNode
|
||||
{
|
||||
public:
|
||||
|
|
@ -2012,8 +2048,8 @@ class ClassMethod : public BinaryNode
|
|||
ParseNode& name() const {
|
||||
return *left();
|
||||
}
|
||||
CodeNode& method() const {
|
||||
return right()->as<CodeNode>();
|
||||
FunctionNode& method() const {
|
||||
return right()->as<FunctionNode>();
|
||||
}
|
||||
bool isStatic() const {
|
||||
return pn_u.binary.isStatic;
|
||||
|
|
@ -2254,7 +2290,7 @@ static inline ParseNode*
|
|||
FunctionFormalParametersList(ParseNode* fn, unsigned* numFormals)
|
||||
{
|
||||
MOZ_ASSERT(fn->isKind(PNK_FUNCTION));
|
||||
ListNode* argsBody = fn->as<CodeNode>().body();
|
||||
ListNode* argsBody = fn->as<FunctionNode>().body();
|
||||
MOZ_ASSERT(argsBody->isKind(PNK_PARAMSBODY));
|
||||
*numFormals = argsBody->count();
|
||||
if (*numFormals > 0 &&
|
||||
|
|
|
|||
|
|
@ -907,7 +907,7 @@ Parser<ParseHandler>::newObjectBox(JSObject* obj)
|
|||
|
||||
template <typename ParseHandler>
|
||||
FunctionBox*
|
||||
Parser<ParseHandler>::newFunctionBox(CodeNodeType funNode, JSFunction* fun, uint32_t toStringStart,
|
||||
Parser<ParseHandler>::newFunctionBox(FunctionNodeType funNode, JSFunction* fun, uint32_t toStringStart,
|
||||
Directives inheritedDirectives,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
bool tryAnnexB)
|
||||
|
|
@ -1124,7 +1124,7 @@ Parser<ParseHandler>::reportRedeclaration(HandlePropertyName name, DeclarationKi
|
|||
// forbid duplicates.)
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::notePositionalFormalParameter(CodeNodeType funNode, HandlePropertyName name,
|
||||
Parser<ParseHandler>::notePositionalFormalParameter(FunctionNodeType funNode, HandlePropertyName name,
|
||||
uint32_t beginPos,
|
||||
bool disallowDuplicateParams,
|
||||
bool* duplicatedParam)
|
||||
|
|
@ -1169,7 +1169,7 @@ Parser<ParseHandler>::notePositionalFormalParameter(CodeNodeType funNode, Handle
|
|||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::noteDestructuredPositionalFormalParameter(CodeNodeType funNode, Node destruct)
|
||||
Parser<ParseHandler>::noteDestructuredPositionalFormalParameter(FunctionNodeType funNode, Node destruct)
|
||||
{
|
||||
// Append an empty name to the positional formals vector to keep track of
|
||||
// argument slots when making FunctionScope::Data.
|
||||
|
|
@ -2220,7 +2220,7 @@ Parser<FullParseHandler>::globalBody(GlobalSharedContext* globalsc)
|
|||
}
|
||||
|
||||
template <>
|
||||
CodeNode*
|
||||
ModuleNode*
|
||||
Parser<FullParseHandler>::moduleBody(ModuleSharedContext* modulesc)
|
||||
{
|
||||
MOZ_ASSERT(checkOptionsCalled);
|
||||
|
|
@ -2233,7 +2233,7 @@ Parser<FullParseHandler>::moduleBody(ModuleSharedContext* modulesc)
|
|||
if (!varScope.init(pc))
|
||||
return nullptr;
|
||||
|
||||
CodeNodeType moduleNode = handler.newModule();
|
||||
ModuleNodeType moduleNode = handler.newModule();
|
||||
if (!moduleNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -2294,7 +2294,7 @@ Parser<FullParseHandler>::moduleBody(ModuleSharedContext* modulesc)
|
|||
}
|
||||
|
||||
template <>
|
||||
SyntaxParseHandler::CodeNodeType
|
||||
SyntaxParseHandler::ModuleNodeType
|
||||
Parser<SyntaxParseHandler>::moduleBody(ModuleSharedContext* modulesc)
|
||||
{
|
||||
MOZ_ALWAYS_FALSE(abortIfSyntaxParser());
|
||||
|
|
@ -2510,7 +2510,7 @@ GetYieldHandling(GeneratorKind generatorKind)
|
|||
}
|
||||
|
||||
template <>
|
||||
CodeNode*
|
||||
FunctionNode*
|
||||
Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
|
||||
HandleScope enclosingScope,
|
||||
Maybe<uint32_t> parameterListEnd,
|
||||
|
|
@ -2547,7 +2547,7 @@ Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
|
|||
tokenStream.ungetToken();
|
||||
}
|
||||
|
||||
CodeNodeType funNode = handler.newFunctionStatement();
|
||||
FunctionNodeType funNode = handler.newFunctionStatement();
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -2585,7 +2585,7 @@ Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
|
|||
ParseNode* node = funNode;
|
||||
if (!FoldConstants(context, &node, this))
|
||||
return null();
|
||||
funNode = &node->as<CodeNode>();
|
||||
funNode = &node->as<FunctionNode>();
|
||||
|
||||
return funNode;
|
||||
}
|
||||
|
|
@ -2960,7 +2960,7 @@ Parser<ParseHandler>::prefixAccessorName(PropertyType propType, HandleAtom propA
|
|||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyntaxKind kind,
|
||||
CodeNodeType funNode)
|
||||
FunctionNodeType funNode)
|
||||
{
|
||||
FunctionBox* funbox = pc->functionBox();
|
||||
|
||||
|
|
@ -3221,7 +3221,7 @@ Parser<ParseHandler>::functionArguments(YieldHandling yieldHandling, FunctionSyn
|
|||
|
||||
template <>
|
||||
bool
|
||||
Parser<FullParseHandler>::skipLazyInnerFunction(CodeNode* funNode, uint32_t toStringStart,
|
||||
Parser<FullParseHandler>::skipLazyInnerFunction(FunctionNode* funNode, uint32_t toStringStart,
|
||||
FunctionSyntaxKind kind, bool tryAnnexB)
|
||||
{
|
||||
// When a lazily-parsed function is called, we only fully parse (and emit)
|
||||
|
|
@ -3268,7 +3268,7 @@ Parser<FullParseHandler>::skipLazyInnerFunction(CodeNode* funNode, uint32_t toSt
|
|||
|
||||
template <>
|
||||
bool
|
||||
Parser<SyntaxParseHandler>::skipLazyInnerFunction(CodeNodeType funNode, uint32_t toStringStart,
|
||||
Parser<SyntaxParseHandler>::skipLazyInnerFunction(FunctionNodeType funNode, uint32_t toStringStart,
|
||||
FunctionSyntaxKind kind, bool tryAnnexB)
|
||||
{
|
||||
MOZ_CRASH("Cannot skip lazy inner functions when syntax parsing");
|
||||
|
|
@ -3344,8 +3344,8 @@ Parser<ParseHandler>::templateLiteral(YieldHandling yieldHandling)
|
|||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
typename ParseHandler::CodeNodeType
|
||||
Parser<ParseHandler>::functionDefinition(uint32_t toStringStart, CodeNodeType funNode, InHandling inHandling,
|
||||
typename ParseHandler::FunctionNodeType
|
||||
Parser<ParseHandler>::functionDefinition(uint32_t toStringStart, FunctionNodeType funNode, InHandling inHandling,
|
||||
YieldHandling yieldHandling,
|
||||
HandleAtom funName, FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
|
|
@ -3419,7 +3419,7 @@ Parser<ParseHandler>::functionDefinition(uint32_t toStringStart, CodeNodeType fu
|
|||
|
||||
template <>
|
||||
bool
|
||||
Parser<FullParseHandler>::trySyntaxParseInnerFunction(CodeNode* funNode, HandleFunction fun,
|
||||
Parser<FullParseHandler>::trySyntaxParseInnerFunction(FunctionNode* funNode, HandleFunction fun,
|
||||
uint32_t toStringStart,
|
||||
InHandling inHandling,
|
||||
YieldHandling yieldHandling,
|
||||
|
|
@ -3494,7 +3494,7 @@ Parser<FullParseHandler>::trySyntaxParseInnerFunction(CodeNode* funNode, HandleF
|
|||
|
||||
template <>
|
||||
bool
|
||||
Parser<SyntaxParseHandler>::trySyntaxParseInnerFunction(CodeNodeType funNode, HandleFunction fun,
|
||||
Parser<SyntaxParseHandler>::trySyntaxParseInnerFunction(FunctionNodeType funNode, HandleFunction fun,
|
||||
uint32_t toStringStart,
|
||||
InHandling inHandling,
|
||||
YieldHandling yieldHandling,
|
||||
|
|
@ -3512,7 +3512,7 @@ Parser<SyntaxParseHandler>::trySyntaxParseInnerFunction(CodeNodeType funNode, Ha
|
|||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::innerFunction(CodeNodeType funNode, ParseContext* outerpc, FunctionBox* funbox,
|
||||
Parser<ParseHandler>::innerFunction(FunctionNodeType funNode, ParseContext* outerpc, FunctionBox* funbox,
|
||||
uint32_t toStringStart,
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
FunctionSyntaxKind kind, Directives inheritedDirectives,
|
||||
|
|
@ -3536,7 +3536,7 @@ Parser<ParseHandler>::innerFunction(CodeNodeType funNode, ParseContext* outerpc,
|
|||
|
||||
template <typename ParseHandler>
|
||||
bool
|
||||
Parser<ParseHandler>::innerFunction(CodeNodeType funNode, ParseContext* outerpc, HandleFunction fun,
|
||||
Parser<ParseHandler>::innerFunction(FunctionNodeType funNode, ParseContext* outerpc, HandleFunction fun,
|
||||
uint32_t toStringStart,
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
FunctionSyntaxKind kind,
|
||||
|
|
@ -3579,14 +3579,14 @@ Parser<ParseHandler>::appendToCallSiteObj(CallSiteNodeType callSiteObj)
|
|||
}
|
||||
|
||||
template <>
|
||||
CodeNode*
|
||||
FunctionNode*
|
||||
Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, bool strict,
|
||||
GeneratorKind generatorKind,
|
||||
FunctionAsyncKind asyncKind)
|
||||
{
|
||||
MOZ_ASSERT(checkOptionsCalled);
|
||||
|
||||
CodeNodeType funNode = handler.newFunctionStatement();
|
||||
FunctionNodeType funNode = handler.newFunctionStatement();
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -3633,7 +3633,7 @@ Parser<FullParseHandler>::standaloneLazyFunction(HandleFunction fun, bool strict
|
|||
ParseNode* node = funNode;
|
||||
if (!FoldConstants(context, &node, this))
|
||||
return null();
|
||||
funNode = &node->as<CodeNode>();
|
||||
funNode = &node->as<FunctionNode>();
|
||||
|
||||
return funNode;
|
||||
}
|
||||
|
|
@ -3642,7 +3642,7 @@ template <typename ParseHandler>
|
|||
bool
|
||||
Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
||||
YieldHandling yieldHandling,
|
||||
CodeNodeType funNode, FunctionSyntaxKind kind,
|
||||
FunctionNodeType funNode, FunctionSyntaxKind kind,
|
||||
Maybe<uint32_t> parameterListEnd /* = Nothing() */,
|
||||
bool isStandaloneFunction /* = false */)
|
||||
{
|
||||
|
|
@ -3788,7 +3788,7 @@ Parser<ParseHandler>::functionFormalParametersAndBody(InHandling inHandling,
|
|||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
typename ParseHandler::CodeNodeType
|
||||
typename ParseHandler::FunctionNodeType
|
||||
Parser<ParseHandler>::functionStmt(uint32_t toStringStart, YieldHandling yieldHandling,
|
||||
DefaultHandling defaultHandling, FunctionAsyncKind asyncKind)
|
||||
{
|
||||
|
|
@ -3864,7 +3864,7 @@ Parser<ParseHandler>::functionStmt(uint32_t toStringStart, YieldHandling yieldHa
|
|||
return null();
|
||||
}
|
||||
|
||||
CodeNodeType funNode = handler.newFunctionStatement();
|
||||
FunctionNodeType funNode = handler.newFunctionStatement();
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -3874,7 +3874,7 @@ Parser<ParseHandler>::functionStmt(uint32_t toStringStart, YieldHandling yieldHa
|
|||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
typename ParseHandler::CodeNodeType
|
||||
typename ParseHandler::FunctionNodeType
|
||||
Parser<ParseHandler>::functionExpr(uint32_t toStringStart, InvokedPrediction invoked,
|
||||
FunctionAsyncKind asyncKind)
|
||||
{
|
||||
|
|
@ -3903,7 +3903,7 @@ Parser<ParseHandler>::functionExpr(uint32_t toStringStart, InvokedPrediction inv
|
|||
tokenStream.ungetToken();
|
||||
}
|
||||
|
||||
CodeNodeType funNode = handler.newFunctionExpression();
|
||||
FunctionNodeType funNode = handler.newFunctionExpression();
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -5369,14 +5369,14 @@ Parser<SyntaxParseHandler>::checkExportedNameForClause(NameNodeType nameNode)
|
|||
|
||||
template<>
|
||||
bool
|
||||
Parser<FullParseHandler>::checkExportedNameForFunction(CodeNodeType funNode)
|
||||
Parser<FullParseHandler>::checkExportedNameForFunction(FunctionNodeType funNode)
|
||||
{
|
||||
return checkExportedName(funNode->funbox()->function()->explicitName());
|
||||
}
|
||||
|
||||
template<>
|
||||
bool
|
||||
Parser<SyntaxParseHandler>::checkExportedNameForFunction(CodeNodeType funNode)
|
||||
Parser<SyntaxParseHandler>::checkExportedNameForFunction(FunctionNodeType funNode)
|
||||
{
|
||||
MOZ_ALWAYS_FALSE(abortIfSyntaxParser());
|
||||
return false;
|
||||
|
|
@ -5650,7 +5650,7 @@ Parser<ParseHandler>::exportFunctionDeclaration(uint32_t begin)
|
|||
if (!kid)
|
||||
return null();
|
||||
|
||||
if (!checkExportedNameForFunction(handler.asCode(kid)))
|
||||
if (!checkExportedNameForFunction(handler.asFunction(kid)))
|
||||
return null();
|
||||
|
||||
UnaryNodeType node = handler.newExportDeclaration(kid, TokenPos(begin, pos().end));
|
||||
|
|
@ -7398,8 +7398,8 @@ Parser<ParseHandler>::classDefinition(YieldHandling yieldHandling,
|
|||
// Calling toString on constructors need to return the source text for
|
||||
// the entire class. The end offset is unknown at this point in
|
||||
// parsing and will be amended when class parsing finishes below.
|
||||
CodeNodeType funNode = methodDefinition(isConstructor ? classStartOffset : nameOffset,
|
||||
propType, funName);
|
||||
FunctionNodeType funNode = methodDefinition(isConstructor ? classStartOffset : nameOffset,
|
||||
propType, funName);
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -8395,7 +8395,7 @@ Parser<ParseHandler>::assignExpr(InHandling inHandling, YieldHandling yieldHandl
|
|||
}
|
||||
}
|
||||
|
||||
CodeNodeType funNode = handler.newArrowFunction();
|
||||
FunctionNodeType funNode = handler.newArrowFunction();
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -8792,7 +8792,7 @@ template <typename ParseHandler>
|
|||
typename ParseHandler::Node
|
||||
Parser<ParseHandler>::generatorComprehensionLambda(unsigned begin)
|
||||
{
|
||||
CodeNodeType genfn = handler.newFunctionExpression();
|
||||
FunctionNodeType genfn = handler.newFunctionExpression();
|
||||
if (!genfn)
|
||||
return null();
|
||||
|
||||
|
|
@ -10277,7 +10277,7 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
|||
}
|
||||
}
|
||||
|
||||
CodeNodeType funNode = methodDefinition(namePos.begin, propType, funName);
|
||||
FunctionNodeType funNode = methodDefinition(namePos.begin, propType, funName);
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
@ -10312,7 +10312,7 @@ Parser<ParseHandler>::objectLiteral(YieldHandling yieldHandling, PossibleError*
|
|||
}
|
||||
|
||||
template <typename ParseHandler>
|
||||
typename ParseHandler::CodeNodeType
|
||||
typename ParseHandler::FunctionNodeType
|
||||
Parser<ParseHandler>::methodDefinition(uint32_t toStringStart, PropertyType propType,
|
||||
HandleAtom funName)
|
||||
{
|
||||
|
|
@ -10365,7 +10365,7 @@ Parser<ParseHandler>::methodDefinition(uint32_t toStringStart, PropertyType prop
|
|||
|
||||
YieldHandling yieldHandling = GetYieldHandling(generatorKind);
|
||||
|
||||
CodeNodeType funNode = handler.newFunctionExpression();
|
||||
FunctionNodeType funNode = handler.newFunctionExpression();
|
||||
if (!funNode)
|
||||
return null();
|
||||
|
||||
|
|
|
|||
|
|
@ -1085,7 +1085,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
* cx->tempLifoAlloc.
|
||||
*/
|
||||
ObjectBox* newObjectBox(JSObject* obj);
|
||||
FunctionBox* newFunctionBox(CodeNodeType funNode, JSFunction* fun, uint32_t toStringStart,
|
||||
FunctionBox* newFunctionBox(FunctionNodeType funNode, JSFunction* fun, uint32_t toStringStart,
|
||||
Directives directives,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
bool tryAnnexB);
|
||||
|
|
@ -1138,23 +1138,23 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
ListNodeType globalBody(GlobalSharedContext* globalsc);
|
||||
|
||||
// Parse a module.
|
||||
CodeNodeType moduleBody(ModuleSharedContext* modulesc);
|
||||
ModuleNodeType moduleBody(ModuleSharedContext* modulesc);
|
||||
|
||||
// Parse a function, used for the Function, GeneratorFunction, and
|
||||
// AsyncFunction constructors.
|
||||
CodeNodeType standaloneFunction(HandleFunction fun, HandleScope enclosingScope,
|
||||
mozilla::Maybe<uint32_t> parameterListEnd,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
Directives inheritedDirectives, Directives* newDirectives);
|
||||
FunctionNodeType standaloneFunction(HandleFunction fun, HandleScope enclosingScope,
|
||||
mozilla::Maybe<uint32_t> parameterListEnd,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
Directives inheritedDirectives, Directives* newDirectives);
|
||||
|
||||
// Parse a function, given only its arguments and body. Used for lazily
|
||||
// parsed functions.
|
||||
CodeNodeType standaloneLazyFunction(HandleFunction fun, bool strict,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind);
|
||||
FunctionNodeType standaloneLazyFunction(HandleFunction fun, bool strict,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind);
|
||||
|
||||
// Parse an inner function given an enclosing ParseContext and a
|
||||
// FunctionBox for the inner function.
|
||||
bool innerFunction(CodeNodeType funNode, ParseContext* outerpc, FunctionBox* funbox, uint32_t toStringStart,
|
||||
bool innerFunction(FunctionNodeType funNode, ParseContext* outerpc, FunctionBox* funbox, uint32_t toStringStart,
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
FunctionSyntaxKind kind,
|
||||
Directives inheritedDirectives, Directives* newDirectives);
|
||||
|
|
@ -1162,7 +1162,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
// Parse a function's formal parameters and its body assuming its function
|
||||
// ParseContext is already on the stack.
|
||||
bool functionFormalParametersAndBody(InHandling inHandling, YieldHandling yieldHandling,
|
||||
CodeNodeType funNode, FunctionSyntaxKind kind,
|
||||
FunctionNodeType funNode, FunctionSyntaxKind kind,
|
||||
mozilla::Maybe<uint32_t> parameterListEnd = mozilla::Nothing(),
|
||||
bool isStandaloneFunction = false);
|
||||
|
||||
|
|
@ -1188,11 +1188,11 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
* Some parsers have two versions: an always-inlined version (with an 'i'
|
||||
* suffix) and a never-inlined version (with an 'n' suffix).
|
||||
*/
|
||||
CodeNodeType functionStmt(uint32_t toStringStart,
|
||||
YieldHandling yieldHandling, DefaultHandling defaultHandling,
|
||||
FunctionAsyncKind asyncKind = SyncFunction);
|
||||
CodeNodeType functionExpr(uint32_t toStringStart, InvokedPrediction invoked = PredictUninvoked,
|
||||
FunctionAsyncKind asyncKind = SyncFunction);
|
||||
FunctionNodeType functionStmt(uint32_t toStringStart,
|
||||
YieldHandling yieldHandling, DefaultHandling defaultHandling,
|
||||
FunctionAsyncKind asyncKind = SyncFunction);
|
||||
FunctionNodeType functionExpr(uint32_t toStringStart, InvokedPrediction invoked = PredictUninvoked,
|
||||
FunctionAsyncKind asyncKind = SyncFunction);
|
||||
|
||||
ListNodeType statementList(YieldHandling yieldHandling);
|
||||
|
||||
|
|
@ -1346,19 +1346,19 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
bool tryNewTarget(BinaryNodeType* newTarget);
|
||||
bool checkAndMarkSuperScope();
|
||||
|
||||
CodeNodeType methodDefinition(uint32_t toStringStart, PropertyType propType, HandleAtom funName);
|
||||
FunctionNodeType methodDefinition(uint32_t toStringStart, PropertyType propType, HandleAtom funName);
|
||||
|
||||
/*
|
||||
* Additional JS parsers.
|
||||
*/
|
||||
bool functionArguments(YieldHandling yieldHandling, FunctionSyntaxKind kind,
|
||||
CodeNodeType funNode);
|
||||
FunctionNodeType funNode);
|
||||
|
||||
CodeNodeType functionDefinition(uint32_t toStringStart, CodeNodeType funNode,
|
||||
InHandling inHandling, YieldHandling yieldHandling, HandleAtom name,
|
||||
FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
bool tryAnnexB = false);
|
||||
FunctionNodeType functionDefinition(uint32_t toStringStart, FunctionNodeType funNode,
|
||||
InHandling inHandling, YieldHandling yieldHandling, HandleAtom name,
|
||||
FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
bool tryAnnexB = false);
|
||||
|
||||
// Parse a function body. Pass StatementListBody if the body is a list of
|
||||
// statements; pass ExpressionBody if the body is a single expression.
|
||||
|
|
@ -1394,7 +1394,7 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
bool checkExportedNamesForDeclarationList(ListNodeType node);
|
||||
|
||||
bool checkExportedNameForClause(NameNodeType funNode);
|
||||
bool checkExportedNameForFunction(CodeNodeType funNode);
|
||||
bool checkExportedNameForFunction(FunctionNodeType funNode);
|
||||
bool checkExportedNameForClass(ClassNodeType classNode);
|
||||
|
||||
enum ClassContext { ClassStatement, ClassExpression };
|
||||
|
|
@ -1449,14 +1449,14 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
NameNodeType newDotGeneratorName();
|
||||
bool declareDotGeneratorName();
|
||||
|
||||
bool skipLazyInnerFunction(CodeNodeType funNode, uint32_t toStringStart, FunctionSyntaxKind kind,
|
||||
bool skipLazyInnerFunction(FunctionNodeType funNode, uint32_t toStringStart, FunctionSyntaxKind kind,
|
||||
bool tryAnnexB);
|
||||
bool innerFunction(CodeNodeType funNode, ParseContext* outerpc, HandleFunction fun, uint32_t toStringStart,
|
||||
bool innerFunction(FunctionNodeType funNode, ParseContext* outerpc, HandleFunction fun, uint32_t toStringStart,
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind, bool tryAnnexB,
|
||||
Directives inheritedDirectives, Directives* newDirectives);
|
||||
bool trySyntaxParseInnerFunction(CodeNodeType funNode, HandleFunction fun, uint32_t toStringStart,
|
||||
bool trySyntaxParseInnerFunction(FunctionNodeType funNode, HandleFunction fun, uint32_t toStringStart,
|
||||
InHandling inHandling, YieldHandling yieldHandling,
|
||||
FunctionSyntaxKind kind,
|
||||
GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
|
||||
|
|
@ -1489,9 +1489,9 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_TYPE)
|
|||
|
||||
void reportRedeclaration(HandlePropertyName name, DeclarationKind prevKind, TokenPos pos,
|
||||
uint32_t prevPos);
|
||||
bool notePositionalFormalParameter(CodeNodeType funNode, HandlePropertyName name, uint32_t beginPos,
|
||||
bool notePositionalFormalParameter(FunctionNodeType funNode, HandlePropertyName name, uint32_t beginPos,
|
||||
bool disallowDuplicateParams, bool* duplicatedParam);
|
||||
bool noteDestructuredPositionalFormalParameter(CodeNodeType funNode, Node destruct);
|
||||
bool noteDestructuredPositionalFormalParameter(FunctionNodeType funNode, Node destruct);
|
||||
mozilla::Maybe<DeclarationKind> isVarRedeclaredInEval(HandlePropertyName name,
|
||||
DeclarationKind kind);
|
||||
bool tryDeclareVar(HandlePropertyName name, DeclarationKind kind, uint32_t beginPos,
|
||||
|
|
|
|||
|
|
@ -395,7 +395,7 @@ class FunctionBox : public ObjectBox, public SharedContext
|
|||
void initWithEnclosingScope(Scope* enclosingScope);
|
||||
|
||||
public:
|
||||
CodeNode* functionNode; /* back pointer used by asm.js for error messages */
|
||||
FunctionNode* functionNode; /* back pointer used by asm.js for error messages */
|
||||
uint32_t bufStart;
|
||||
uint32_t bufEnd;
|
||||
uint32_t startLine;
|
||||
|
|
|
|||
|
|
@ -330,8 +330,8 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
MOZ_MUST_USE bool addPropertyDefinition(ListNodeType literal, Node name, Node expr) { return true; }
|
||||
MOZ_MUST_USE bool addShorthand(ListNodeType literal, NameNodeType name, NameNodeType expr) { return true; }
|
||||
MOZ_MUST_USE bool addSpreadProperty(ListNodeType literal, uint32_t begin, Node inner) { return true; }
|
||||
MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node name, CodeNodeType funNode, JSOp op) { return true; }
|
||||
MOZ_MUST_USE bool addClassMethodDefinition(ListNodeType literal, Node name, CodeNodeType funNode, JSOp op, bool isStatic) { return true; }
|
||||
MOZ_MUST_USE bool addObjectMethodDefinition(ListNodeType literal, Node name, FunctionNodeType funNode, JSOp op) { return true; }
|
||||
MOZ_MUST_USE bool addClassMethodDefinition(ListNodeType literal, Node name, FunctionNodeType funNode, JSOp op, bool isStatic) { return true; }
|
||||
UnaryNodeType newYieldExpression(uint32_t begin, Node value) { return NodeGeneric; }
|
||||
UnaryNodeType newYieldStarExpression(uint32_t begin, Node value) { return NodeGeneric; }
|
||||
UnaryNodeType newAwaitExpression(uint32_t begin, Node value) { return NodeGeneric; }
|
||||
|
|
@ -407,19 +407,19 @@ FOR_EACH_PARSENODE_SUBCLASS(DECLARE_AS)
|
|||
MOZ_MUST_USE bool addCatchBlock(ListNodeType catchList, LexicalScopeNodeType lexicalScope,
|
||||
Node catchBinding, Node catchGuard, Node catchBody) { return true; }
|
||||
|
||||
MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(CodeNodeType funNode, Node pn) { return true; }
|
||||
MOZ_MUST_USE bool setLastFunctionFormalParameterDefault(FunctionNodeType funNode, Node pn) { return true; }
|
||||
|
||||
void checkAndSetIsDirectRHSAnonFunction(Node pn) {}
|
||||
|
||||
CodeNodeType newFunctionStatement() { return NodeFunctionDefinition; }
|
||||
CodeNodeType newFunctionExpression() { return NodeFunctionDefinition; }
|
||||
CodeNodeType newArrowFunction() { return NodeFunctionDefinition; }
|
||||
FunctionNodeType newFunctionStatement() { return NodeFunctionDefinition; }
|
||||
FunctionNodeType newFunctionExpression() { return NodeFunctionDefinition; }
|
||||
FunctionNodeType newArrowFunction() { return NodeFunctionDefinition; }
|
||||
|
||||
bool setComprehensionLambdaBody(CodeNodeType funNode, ListNodeType body) { return true; }
|
||||
void setFunctionFormalParametersAndBody(CodeNodeType funNode, ListNodeType paramsBody) {}
|
||||
void setFunctionBody(CodeNodeType funNode, LexicalScopeNodeType body) {}
|
||||
void setFunctionBox(CodeNodeType funNode, FunctionBox* funbox) {}
|
||||
void addFunctionFormalParameter(CodeNodeType funNode, Node argpn) {}
|
||||
bool setComprehensionLambdaBody(FunctionNodeType funNode, ListNodeType body) { return true; }
|
||||
void setFunctionFormalParametersAndBody(FunctionNodeType funNode, ListNodeType paramsBody) {}
|
||||
void setFunctionBody(FunctionNodeType funNode, LexicalScopeNodeType body) {}
|
||||
void setFunctionBox(FunctionNodeType funNode, FunctionBox* funbox) {}
|
||||
void addFunctionFormalParameter(FunctionNodeType funNode, Node argpn) {}
|
||||
|
||||
ForNodeType newForStatement(uint32_t begin, TernaryNodeType forHead, Node body, unsigned iflags) {
|
||||
return NodeGeneric;
|
||||
|
|
|
|||
|
|
@ -650,14 +650,14 @@ ElemIndex(ParseNode* pn)
|
|||
}
|
||||
|
||||
static inline JSFunction*
|
||||
FunctionObject(CodeNode* funNode)
|
||||
FunctionObject(FunctionNode* funNode)
|
||||
{
|
||||
MOZ_ASSERT(funNode->isKind(PNK_FUNCTION));
|
||||
return funNode->funbox()->function();
|
||||
}
|
||||
|
||||
static inline PropertyName*
|
||||
FunctionName(CodeNode* funNode)
|
||||
FunctionName(FunctionNode* funNode)
|
||||
{
|
||||
if (JSAtom* name = FunctionObject(funNode)->explicitName())
|
||||
return name->asPropertyName();
|
||||
|
|
@ -665,7 +665,7 @@ FunctionName(CodeNode* funNode)
|
|||
}
|
||||
|
||||
static inline ParseNode*
|
||||
FunctionStatementList(CodeNode* funNode)
|
||||
FunctionStatementList(FunctionNode* funNode)
|
||||
{
|
||||
MOZ_ASSERT(funNode->body()->isKind(PNK_PARAMSBODY));
|
||||
LexicalScopeNode* last = &funNode->body()->as<ListNode>().last()->as<LexicalScopeNode>();
|
||||
|
|
@ -1615,7 +1615,7 @@ class MOZ_STACK_CLASS ModuleValidator
|
|||
|
||||
ExclusiveContext* cx_;
|
||||
AsmJSParser& parser_;
|
||||
CodeNode* moduleFunctionNode_;
|
||||
FunctionNode* moduleFunctionNode_;
|
||||
PropertyName* moduleFunctionName_;
|
||||
PropertyName* globalArgumentName_;
|
||||
PropertyName* importArgumentName_;
|
||||
|
|
@ -1694,7 +1694,7 @@ class MOZ_STACK_CLASS ModuleValidator
|
|||
}
|
||||
|
||||
public:
|
||||
ModuleValidator(ExclusiveContext* cx, AsmJSParser& parser, CodeNode* moduleFunctionNode)
|
||||
ModuleValidator(ExclusiveContext* cx, AsmJSParser& parser, FunctionNode* moduleFunctionNode)
|
||||
: cx_(cx),
|
||||
parser_(parser),
|
||||
moduleFunctionNode_(moduleFunctionNode),
|
||||
|
|
@ -3226,7 +3226,7 @@ CheckModuleLevelName(ModuleValidator& m, ParseNode* usepn, PropertyName* name)
|
|||
}
|
||||
|
||||
static bool
|
||||
CheckFunctionHead(ModuleValidator& m, CodeNode* funNode)
|
||||
CheckFunctionHead(ModuleValidator& m, FunctionNode* funNode)
|
||||
{
|
||||
FunctionBox* funbox = funNode->funbox();
|
||||
MOZ_ASSERT(!funbox->isExprBody());
|
||||
|
|
@ -3266,7 +3266,7 @@ CheckModuleArgument(ModuleValidator& m, ParseNode* arg, PropertyName** name)
|
|||
}
|
||||
|
||||
static bool
|
||||
CheckModuleArguments(ModuleValidator& m, CodeNode* funNode)
|
||||
CheckModuleArguments(ModuleValidator& m, FunctionNode* funNode)
|
||||
{
|
||||
unsigned numFormals;
|
||||
ParseNode* arg1 = FunctionFormalParametersList(funNode, &numFormals);
|
||||
|
|
@ -7026,7 +7026,7 @@ CheckStatement(FunctionValidator& f, ParseNode* stmt)
|
|||
}
|
||||
|
||||
static bool
|
||||
ParseFunction(ModuleValidator& m, CodeNode** funNodeOut, unsigned* line)
|
||||
ParseFunction(ModuleValidator& m, FunctionNode** funNodeOut, unsigned* line)
|
||||
{
|
||||
TokenStream& tokenStream = m.tokenStream();
|
||||
|
||||
|
|
@ -7044,7 +7044,7 @@ ParseFunction(ModuleValidator& m, CodeNode** funNodeOut, unsigned* line)
|
|||
if (!name)
|
||||
return false;
|
||||
|
||||
CodeNode* funNode = m.parser().handler.newFunctionStatement();
|
||||
FunctionNode* funNode = m.parser().handler.newFunctionStatement();
|
||||
if (!funNode)
|
||||
return false;
|
||||
|
||||
|
|
@ -7086,7 +7086,7 @@ CheckFunction(ModuleValidator& m)
|
|||
// the backing LifoAlloc after parsing/compiling each function.
|
||||
AsmJSParser::Mark mark = m.parser().mark();
|
||||
|
||||
CodeNode* funNode = nullptr;
|
||||
FunctionNode* funNode = nullptr;
|
||||
unsigned line = 0;
|
||||
if (!ParseFunction(m, &funNode, &line))
|
||||
return false;
|
||||
|
|
@ -7336,7 +7336,7 @@ CheckModule(ExclusiveContext* cx, AsmJSParser& parser, ParseNode* stmtList, unsi
|
|||
{
|
||||
int64_t before = PRMJ_Now();
|
||||
|
||||
CodeNode* moduleFunctionNode = parser.pc->functionBox()->functionNode;
|
||||
FunctionNode* moduleFunctionNode = parser.pc->functionBox()->functionNode;
|
||||
|
||||
ModuleValidator m(cx, parser, moduleFunctionNode);
|
||||
if (!m.init())
|
||||
|
|
@ -8292,7 +8292,7 @@ class ModuleCharsForStore : ModuleChars
|
|||
isFunCtor_ = parser.pc->isStandaloneFunctionBody();
|
||||
if (isFunCtor_) {
|
||||
unsigned numArgs;
|
||||
CodeNode* functionNode = parser.pc->functionBox()->functionNode;
|
||||
FunctionNode* functionNode = parser.pc->functionBox()->functionNode;
|
||||
ParseNode* arg = FunctionFormalParametersList(functionNode, &numArgs);
|
||||
for (unsigned i = 0; i < numArgs; i++, arg = arg->pn_next) {
|
||||
UniqueChars name = StringToNewUTF8CharsZ(nullptr, *arg->name());
|
||||
|
|
@ -8373,7 +8373,7 @@ class ModuleCharsForLookup : ModuleChars
|
|||
if (parseBegin + chars_.length() != parseLimit)
|
||||
return false;
|
||||
unsigned numArgs;
|
||||
CodeNode* functionNode = parser.pc->functionBox()->functionNode;
|
||||
FunctionNode* functionNode = parser.pc->functionBox()->functionNode;
|
||||
ParseNode* arg = FunctionFormalParametersList(functionNode, &numArgs);
|
||||
if (funCtorArgs_.length() != numArgs)
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue