From e07a03365ad07cd4294f487b15a57f31bd0a3d40 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 22 Mar 2018 16:04:03 +0100 Subject: Rename Array/ObjectLiteral to Array/ObjectPattern in the AST To get a consistent representation in the AST, we need to unify the AST that is generated by theObjectLiterals, ObjectBindingPattern and ObjectAssignmentPattern rules in the grammar. Like this we can avoid having to reparse part of the source code, and instead replace this with consistency checks once we know which of the three grammars are supposed to apply. Change-Id: Ib90f521f9595db6bcad446e40de9b912bab3da7c Reviewed-by: Simon Hausmann --- src/qml/compiler/qv4compilerscanfunctions.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/qml/compiler/qv4compilerscanfunctions.cpp') diff --git a/src/qml/compiler/qv4compilerscanfunctions.cpp b/src/qml/compiler/qv4compilerscanfunctions.cpp index 57f9105484..b2a5e7ca79 100644 --- a/src/qml/compiler/qv4compilerscanfunctions.cpp +++ b/src/qml/compiler/qv4compilerscanfunctions.cpp @@ -175,7 +175,7 @@ bool ScanFunctions::visit(NewMemberExpression *ast) return true; } -bool ScanFunctions::visit(ArrayLiteral *ast) +bool ScanFunctions::visit(ArrayPattern *ast) { int index = 0; for (ElementList *it = ast->elements; it; it = it->next) { @@ -268,7 +268,7 @@ void ScanFunctions::endVisit(FunctionExpression *) leaveEnvironment(); } -bool ScanFunctions::visit(ObjectLiteral *ast) +bool ScanFunctions::visit(ObjectPattern *ast) { int argc = 0; for (PropertyDefinitionList *it = ast->properties; it; it = it->next) { @@ -400,11 +400,11 @@ bool ScanFunctions::enterFunction(Node *ast, const QString &name, FormalParamete outerContext->hasNestedFunctions = true; // The identifier of a function expression cannot be referenced from the enclosing environment. if (enterName) { - if (!outerContext->addLocalVar(name, Context::FunctionDefinition, AST::VariableScope::Var, expr)) { + if (!outerContext->addLocalVar(name, Context::FunctionDefinition, VariableDeclaration::FunctionScope, expr)) { _cg->throwSyntaxError(ast->firstSourceLocation(), QStringLiteral("Identifier %1 has already been declared").arg(name)); return false; } - outerContext->addLocalVar(name, Context::FunctionDefinition, AST::VariableScope::Var, expr); + outerContext->addLocalVar(name, Context::FunctionDefinition, VariableDeclaration::FunctionScope, expr); } if (name == QLatin1String("arguments")) outerContext->usesArgumentsObject = Context::ArgumentsObjectNotUsed; -- cgit v1.2.3