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
9bool QQmlJSAOTIRBuilder::visit(QQmlJS::AST::FunctionExpression *ast)
10{
11 registerFunctionExpr(ast, IsQmlFunction::No);
12 return true;
13}
14
15bool QQmlJSAOTIRBuilder::visit(QQmlJS::AST::FunctionDeclaration *ast)
16{
17 // QML functions are already collected when visiting the UiSourceElements, we want to collect
18 // the remaining JS functions
19 if (qmlFuncDecls.contains({ _object, ast }))
20 return true;
21
22 registerFunctionExpr(ast, IsQmlFunction::No);
23 return true;
24}
25
26bool QQmlJSAOTIRBuilder::visit(QQmlJS::AST::UiSourceElement *node)
27{
28 if (QQmlJS::AST::FunctionExpression *funDecl = node->sourceElement->asFunctionDefinition())
29 qmlFuncDecls.insert({ _object, funDecl });
30
31 IRBuilder::visit(node);
32 return true;
33}
34
35void QQmlJSAOTIRBuilder::registerFunctionExpr(QQmlJS::AST::FunctionExpression *fexp,
36 IsQmlFunction isQmlFunction)
37{
38 // Ugly hack to prevent double insertion of bindings from setBindingValue
39 for (auto *foe = _object->functionsAndExpressions->first; foe; foe = foe->next) {
40 if (foe->node->kind == QQmlJS::AST::Node::Kind_ExpressionStatement) {
41 if (fexp == static_cast<QQmlJS::AST::ExpressionStatement *>(foe->node)->expression)
42 return;
43 }
44 }
45
46 IRBuilder::registerFunctionExpr(fexp, isQmlFunction);
47}
48
49void QQmlJSAOTIRBuilder::setBindingValue(QV4::CompiledData::Binding *binding,
50 QQmlJS::AST::Statement *statement,
51 QQmlJS::AST::Node *parentNode)
52{
53 IRBuilder::setBindingValue(binding, statement, parentNode);
54 statement->accept(this);
55}
56
57QT_END_NAMESPACE
Combined button and popup list for selecting options.