aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilerscanfunctions.cpp
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-31 15:35:20 +0200
committerLars Knoll <lars.knoll@qt.io>2017-09-02 07:12:22 +0000
commit020ad3d259f57c379fbcdd4e69c235dd1b0a3774 (patch)
tree170e5199a8b7327ca7f46eccf557e5803224c488 /src/qml/compiler/qv4compilerscanfunctions.cpp
parent74c8fe86755af485f8d0a47799d6d50f00070f05 (diff)
Get rid of the hack for named expressions
Instead simply use the pointer to the FunctionObject we have in the CallData now. Change-Id: I6d7ed8af22e89e0217bef427110611b661ac7965 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp')
-rw-r--r--src/qml/compiler/qv4compilerscanfunctions.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp
index 8c41d89bd4..6a9b064bd8 100644
--- a/src/qml/compiler/qv4compilerscanfunctions.cpp
+++ b/src/qml/compiler/qv4compilerscanfunctions.cpp
@@ -252,11 +252,11 @@ bool ScanFunctions::visit(FunctionExpression *ast)
return true;
}
-void ScanFunctions::enterFunction(FunctionExpression *ast, bool enterName, bool isExpression)
+void ScanFunctions::enterFunction(FunctionExpression *ast, bool enterName)
{
if (_context->isStrict && (ast->name == QLatin1String("eval") || ast->name == QLatin1String("arguments")))
_cg->throwSyntaxError(ast->identifierToken, QStringLiteral("Function name may not be eval or arguments in strict mode"));
- enterFunction(ast, ast->name.toString(), ast->formals, ast->body, enterName ? ast : 0, isExpression);
+ enterFunction(ast, ast->name.toString(), ast->formals, ast->body, enterName ? ast : 0);
}
void ScanFunctions::endVisit(FunctionExpression *)
@@ -285,7 +285,7 @@ bool ScanFunctions::visit(ObjectLiteral *ast)
bool ScanFunctions::visit(PropertyGetterSetter *ast)
{
TemporaryBoolAssignment allowFuncDecls(_allowFuncDecls, true);
- enterFunction(ast, QString(), ast->formals, ast->functionBody, /*FunctionExpression*/0, /*isExpression*/false);
+ enterFunction(ast, QString(), ast->formals, ast->functionBody, /*FunctionExpression*/0);
return true;
}
@@ -296,7 +296,7 @@ void ScanFunctions::endVisit(PropertyGetterSetter *)
bool ScanFunctions::visit(FunctionDeclaration *ast)
{
- enterFunction(ast, /*enterName*/ true, /*isExpression */false);
+ enterFunction(ast, /*enterName*/ true);
return true;
}
@@ -386,7 +386,7 @@ bool ScanFunctions::visit(Block *ast) {
return false;
}
-void ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParameterList *formals, FunctionBody *body, FunctionExpression *expr, bool isExpression)
+void ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParameterList *formals, FunctionBody *body, FunctionExpression *expr)
{
if (_context) {
_context->hasNestedFunctions = true;
@@ -400,7 +400,8 @@ void ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParamete
enterEnvironment(ast, FunctionCode);
checkForArguments(formals);
- _context->isNamedFunctionExpression = isExpression && !name.isEmpty();
+ if (!name.isEmpty())
+ _context->addLocalVar(name, Context::ThisFunctionName, QQmlJS::AST::VariableDeclaration::FunctionScope);
_context->formals = formals;
if (body && !_context->isStrict)