Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmljsaotirbuilder.cpp
Go to the documentation of this file.
1// Copyright (C) 2025 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3// Qt-Security score:significant
4
6
8
9QQmlJSAOTIRBuilder::QQmlJSAOTIRBuilder(QmlIR::IRBuilder::FailureMode failureMode)
10 : QmlIR::IRBuilder(failureMode)
11{
12}
13
14bool QQmlJSAOTIRBuilder::visit(QQmlJS::AST::FunctionExpression *ast)
15{
16 registerFunctionExpr(ast, IsQmlFunction::No);
17 return true;
18}
19
20bool QQmlJSAOTIRBuilder::visit(QQmlJS::AST::FunctionDeclaration *ast)
21{
22 // QML functions are already collected when visiting the UiSourceElements, we want to collect
23 // the remaining JS functions
24 if (qmlFuncDecls.contains({ _object, ast }))
25 return true;
26
27 registerFunctionExpr(ast, IsQmlFunction::No);
28 return true;
29}
30
31bool QQmlJSAOTIRBuilder::visit(QQmlJS::AST::UiSourceElement *node)
32{
33 if (QQmlJS::AST::FunctionExpression *funDecl = node->sourceElement->asFunctionDefinition())
34 qmlFuncDecls.insert({ _object, funDecl });
35
36 IRBuilder::visit(node);
37 return true;
38}
39
40void QQmlJSAOTIRBuilder::registerFunctionExpr(QQmlJS::AST::FunctionExpression *fexp,
41 IsQmlFunction isQmlFunction)
42{
43 // Ugly hack to prevent double insertion of bindings from setBindingValue
44 for (auto *foe = _object->functionsAndExpressions->first; foe; foe = foe->next) {
45 if (foe->node->kind == QQmlJS::AST::Node::Kind_ExpressionStatement) {
46 if (fexp == static_cast<QQmlJS::AST::ExpressionStatement *>(foe->node)->expression)
47 return;
48 }
49 }
50
51 if (!_object->declarationsOverride)
52 IRBuilder::registerFunctionExpr(fexp, isQmlFunction);
53}
54
55void QQmlJSAOTIRBuilder::setBindingValue(QV4::CompiledData::Binding *binding,
56 QQmlJS::AST::Statement *statement,
57 QQmlJS::AST::Node *parentNode)
58{
59 IRBuilder::setBindingValue(binding, statement, parentNode);
60 statement->accept(this);
61}
62
63QT_END_NAMESPACE
Combined button and popup list for selecting options.