1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QQMLJSFUNCTIONINITIALIAZER_P_H
5#define QQMLJSFUNCTIONINITIALIAZER_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16
17#include <private/qqmljscompilepass_p.h>
18
19QT_BEGIN_NAMESPACE
20
21class Q_QMLCOMPILER_EXPORT QQmlJSFunctionInitializer
22{
23 Q_DISABLE_COPY_MOVE(QQmlJSFunctionInitializer)
24public:
25 QQmlJSFunctionInitializer(
26 const QQmlJSTypeResolver *typeResolver,
27 const QV4::CompiledData::Location &objectLocation,
28 const QV4::CompiledData::Location &scopeLocation,
29 QQmlJSLogger *logger)
30 : m_typeResolver(typeResolver)
31 , m_logger(logger)
32 , m_scopeType(typeResolver->scopeForLocation(location: scopeLocation))
33 , m_objectType(typeResolver->scopeForLocation(location: objectLocation))
34 {}
35
36 QQmlJSCompilePass::Function run(
37 const QV4::Compiler::Context *context, const QString &propertyName,
38 QQmlJS::AST::Node *astNode, const QmlIR::Binding &irBinding);
39 QQmlJSCompilePass::Function run(
40 const QV4::Compiler::Context *context, const QString &functionName,
41 QQmlJS::AST::Node *astNode);
42
43private:
44 void populateSignature(
45 const QV4::Compiler::Context *context, QQmlJS::AST::FunctionExpression *ast,
46 QQmlJSCompilePass::Function *function);
47
48 const QQmlJSTypeResolver *m_typeResolver = nullptr;
49 QQmlJSLogger *m_logger = nullptr;
50 const QQmlJSScope::ConstPtr m_scopeType;
51 const QQmlJSScope::ConstPtr m_objectType;
52};
53
54QT_END_NAMESPACE
55
56#endif // QQMLJSFUNCTIONINITIALIZER_P_H
57

source code of qtdeclarative/src/qmlcompiler/qqmljsfunctioninitializer_p.h