Bug 1497792 - Make arguments objects for more functions in BinAST. (r=arai)

--HG--
extra : rebase_source : 774ac7ef9c638786baa62364bdbeb86504158b35
This commit is contained in:
Eric Faust 2018-10-15 17:17:58 -04:00
parent 6f88a7757b
commit ae0de9dc24

View File

@ -340,16 +340,27 @@ BinASTParser<Tok>::buildFunction(const size_t start, const BinKind kind, ParseNo
// as they don't yet apply to us.
HandlePropertyName arguments = cx_->names().arguments;
if (hasUsedName(arguments) || parseContext_->functionBox()->bindingsAccessedDynamically()) {
funbox->usesArguments = true;
ParseContext::Scope& funScope = parseContext_->functionScope();
ParseContext::Scope::AddDeclaredNamePtr p = funScope.lookupDeclaredNameForAdd(arguments);
if (!p) {
BINJS_TRY(funScope.addDeclaredName(parseContext_, p, arguments, DeclarationKind::Var,
DeclaredNameInfo::npos));
funbox->declaredArguments = true;
funbox->usesArguments = true;
} else if (p->value()->kind() != DeclarationKind::Var) {
// Lexicals, formal parameters, and body level functions shadow.
funbox->usesArguments = false;
}
if (funbox->usesArguments) {
funbox->setArgumentsHasLocalBinding();
funbox->setDefinitelyNeedsArgsObj();
if (parseContext_->sc()->bindingsAccessedDynamically() ||
parseContext_->sc()->hasDebuggerStatement())
{
funbox->setDefinitelyNeedsArgsObj();
}
}
}