aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler/qv4compilercontext.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/compiler/qv4compilercontext.cpp')
-rw-r--r--src/qml/compiler/qv4compilercontext.cpp59
1 files changed, 12 insertions, 47 deletions
diff --git a/src/qml/compiler/qv4compilercontext.cpp b/src/qml/compiler/qv4compilercontext.cpp
index bce46f59be..499c804b79 100644
--- a/src/qml/compiler/qv4compilercontext.cpp
+++ b/src/qml/compiler/qv4compilercontext.cpp
@@ -1,45 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtQml module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#include "qv4codegen_p.h"
#include "qv4compilercontext_p.h"
-#include "qv4compilercontrolflow_p.h"
#include "qv4bytecodegenerator_p.h"
+#include <QtQml/private/qv4calldata_p.h>
QT_USE_NAMESPACE
using namespace QV4;
@@ -146,7 +111,7 @@ Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::So
result.scope = scope;
result.index = m.index;
result.isConst = (m.scope == VariableScope::Const);
- result.requiresTDZCheck = m.requiresTDZCheck(accessLocation, c != this);
+ result.requiresTDZCheck = m.requiresTDZCheck(accessLocation, c != this) || c->isCaseBlock();
if (c->isStrict && (name == QLatin1String("arguments") || name == QLatin1String("eval")))
result.isArgOrEval = true;
result.declarationLocation = m.declarationLocation;
@@ -183,7 +148,7 @@ Context::ResolvedName Context::resolveName(const QString &name, const QQmlJS::So
return result;
if (c->contextType == ContextType::ESModule) {
- for (int i = 0; i < c->importEntries.count(); ++i) {
+ for (int i = 0; i < c->importEntries.size(); ++i) {
if (c->importEntries.at(i).localName == name) {
result.index = i;
result.type = ResolvedName::Import;
@@ -216,7 +181,7 @@ void Context::emitBlockHeader(Codegen *codegen)
if (requiresExecutionContext) {
if (blockIndex < 0) {
codegen->module()->blocks.append(this);
- blockIndex = codegen->module()->blocks.count() - 1;
+ blockIndex = codegen->module()->blocks.size() - 1;
}
if (contextType == ContextType::Global) {
@@ -308,7 +273,7 @@ void Context::emitBlockHeader(Codegen *codegen)
codegen->referenceForName(QStringLiteral("arguments"), false).storeConsumeAccumulator();
}
- for (const Context::Member &member : qAsConst(members)) {
+ for (const Context::Member &member : std::as_const(members)) {
if (member.function) {
const int function = codegen->defineFunction(member.function->name.toString(), member.function, member.function->formals, member.function->body);
codegen->loadClosure(function);
@@ -396,8 +361,8 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
break;
}
- sizeOfLocalTemporalDeadZone = localsInTDZ.count();
- for (auto &member: qAsConst(localsInTDZ)) {
+ sizeOfLocalTemporalDeadZone = localsInTDZ.size();
+ for (auto &member: std::as_const(localsInTDZ)) {
member->index = locals.size();
locals.append(member.key());
}
@@ -411,9 +376,9 @@ void Context::setupFunctionIndices(Moth::BytecodeGenerator *bytecodeGenerator)
}
}
- sizeOfRegisterTemporalDeadZone = registersInTDZ.count();
+ sizeOfRegisterTemporalDeadZone = registersInTDZ.size();
firstTemporalDeadZoneRegister = bytecodeGenerator->currentRegister();
- for (auto &member: qAsConst(registersInTDZ))
+ for (auto &member: std::as_const(registersInTDZ))
member->index = bytecodeGenerator->newRegister();
nRegisters = bytecodeGenerator->currentRegister() - registerOffset;