aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsapi/qjsprimitivevalue.cpp
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-06-27 16:26:43 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-07-05 19:50:19 +0200
commit46396070368568d44597a36b7c7646f139d92b23 (patch)
treedd94c75c1b9f5cc61bcc19d5ee4b2f61b18a614d /src/qml/jsapi/qjsprimitivevalue.cpp
parent5e4a1738b05f6f188eada38f1805018bdccc1c96 (diff)
QmlCompiler: Really fix writing into argument values
Arguments are now treated as registers "written" at the beginning of the first basic block. By modeling them this way, we can avoid all the complicated logic on whether to use a local or the arguments array when accessing any particular one of them. Furthermore, we can detect whether they are overwritten or not. If they are not overwritten, we can initialize them as a const reference into the arguments array. This way we save a copy. Treating the arguments as generic registers causes the basic blocks pass to aggressively adjust their types, pushing some conversions back into the QML engine. This is good. Unused arguments become void, for example, and don't have to be passed at all. However, we also need a special case for QJSPrimitiveValue arguments now. Pick-to: 6.4 Fixes: QTBUG-104462 Change-Id: I994bea0929bd508aa41db58dee4a7f12cd20f053 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qml/jsapi/qjsprimitivevalue.cpp')
-rw-r--r--src/qml/jsapi/qjsprimitivevalue.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/qml/jsapi/qjsprimitivevalue.cpp b/src/qml/jsapi/qjsprimitivevalue.cpp
index 7039d6387b..e094972c3a 100644
--- a/src/qml/jsapi/qjsprimitivevalue.cpp
+++ b/src/qml/jsapi/qjsprimitivevalue.cpp
@@ -131,6 +131,29 @@ QT_BEGIN_NAMESPACE
*/
/*!
+ \fn QJSPrimitiveValue::QJSPrimitiveValue(QMetaType type, const void *value)
+ \since 6.4
+
+ Creates a QJSPrimitiveValue of type \a type, and initializes with
+ \a value if \a type can be stored in QJSPrimtiveValue. \a value must not
+ be nullptr in that case. If \a type cannot be stored this results in a
+ QJSPrimitiveValue of type Undefined.
+
+ Note that you have to pass the address of the variable you want stored.
+
+ Usually, you never have to use this constructor, use the one taking QVariant
+ instead.
+ */
+
+/*!
+ \fn QJSPrimitiveValue::QJSPrimitiveValue(const QVariant &value)
+
+ Creates a QJSPrimitiveValue from the contents of \a value if those contents
+ can be stored in QJSPrimtiveValue. Otherwise this results in a
+ QJSPrimitiveValue of type Undefined.
+ */
+
+/*!
\fn bool QJSPrimitiveValue::toBoolean() const
Returns the value coerced a boolean by JavaScript rules.