diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-16 08:53:39 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2021-08-19 21:44:36 +0200 |
commit | 30e6bb35e48207a994dd4e49ca999d45266a04f5 (patch) | |
tree | fd5964c97b360a4a6775f314c938eef2e93dde7a /src/qmlcompiler/qqmljsregistercontent.cpp | |
parent | db58b8518e157b765bf2e01e6382a9eed4751f27 (diff) |
qmlcompiler: Add a content variant for module prefixes
The code generator needs to see the modulePrefix as a separate step in
order to generate sensible code. The savedPrefix we had before was not
exposed to the code generator. As an added benefit we can also check
that we don't refer to singletons as properties of objects this way.
Task-number: QTBUG-95822
Change-Id: Ia8992dba340bf0552e7647f0d66b441f1ac1b8c8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsregistercontent.cpp')
-rw-r--r-- | src/qmlcompiler/qqmljsregistercontent.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/qmlcompiler/qqmljsregistercontent.cpp b/src/qmlcompiler/qqmljsregistercontent.cpp index 99c49279f8..aef0453eac 100644 --- a/src/qmlcompiler/qqmljsregistercontent.cpp +++ b/src/qmlcompiler/qqmljsregistercontent.cpp @@ -64,6 +64,9 @@ QString QQmlJSRegisterContent::descriptiveName() const else return result + scope() + e.first.name() + u"::"_qs + e.second; } + case ImportNamespace: { + return u"import namespace %1"_qs.arg(std::get<uint>(m_content)); + } } Q_UNREACHABLE(); return result + u"wat?"_qs; @@ -140,6 +143,16 @@ QQmlJSRegisterContent QQmlJSRegisterContent::create(const QQmlJSScope::ConstPtr return result; } +QQmlJSRegisterContent QQmlJSRegisterContent::create(const QQmlJSScope::ConstPtr &storedType, + uint importNamespaceStringId, + QQmlJSRegisterContent::ContentVariant variant, + const QQmlJSScope::ConstPtr &scope) +{ + QQmlJSRegisterContent result(storedType, scope, variant); + result.m_content = importNamespaceStringId; + return result; +} + bool operator==(const QQmlJSRegisterContent &a, const QQmlJSRegisterContent &b) { return a.m_storedType == b.m_storedType && a.m_variant == b.m_variant && a.m_scope == b.m_scope |