aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
Commit message (Collapse)AuthorAgeFilesLines
* QmlIR: Make sure that all objects receive a locationUlf Hermann2020-10-222-13/+35
| | | | | | | For grouped properties, this is the location of binding now. Change-Id: I7148ba92150e3569d47c382ef78794bfa3b75fce Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix ubsan errorAllan Sandfeld Jensen2020-09-231-5/+9
| | | | | | | | memcpy can't officially copy from nullptr, not even 0 bytes. Pick-to: 5.15 Change-Id: Ie6ede9a861cb2ae7ab35a50db5aa6c82cea6ad76 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Unify "variant" and "var" properties in QMLFabian Kosmale2020-08-241-1/+1
| | | | | | | | | | | | | | | | | | | | variant and var properties differ in two important ways: - variant properties trigger "magic" string conversions: variant v1: "red" // contains a QColor var v2: "red" // contains a string - variant properties behave differently for value types: they create copies, instead of references. However, as variant properties were marked as obsolete and this behavior was effetively undocumented, it should be safe to give "variant" "var semantics". With this change, we can also avoid doing magic conversions when storing data in QVariant properties of QObjects/QGadgets Change-Id: I549b1beb98e6af9639c1ee81f316bda513d5ff65 Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port QtDeclarative from QStringRef to QStringViewKarsten Heimrich2020-06-166-35/+35
| | | | | | | | Task-number: QTBUG-84319 Change-Id: I2dcfb8a2db98282c7a1acdad1e6f4f949f26df15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
* Prettify QV4_SHOW_BYTECODE output for JS classesUlf Hermann2020-05-261-11/+12
| | | | | | | | | | | Drop all the double spaces, force a line break after each class, and avoid converting empty strings to utf8. Coverity-Id: 190711 Pick-to: 5.15 Pick-to: 5.12 Change-Id: I789291e257aeac97c2a931bfc604f453c39906eb Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qv4compilercontext: avoid potential null deferenceFabian Kosmale2020-05-191-1/+4
| | | | | | | Coverity-Id: 274162 Pick-to: 5.15 Change-Id: I58e23d600e9778f5149258fac58657c1a165e0c0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Merge "Merge remote-tracking branch 'origin/5.15' into dev"Qt Forward Merge Bot2020-03-182-0/+7
|\
| * Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-182-0/+7
| |\ | | | | | | | | | | | | | | | | | | Conflicts: tools/qmllint/findunqualified.cpp Change-Id: I2593b5cc0db1d14e0c944aec4b88a80f46f5b0c1
| | * Inline components: Abort if two IC's with same name existFabian Kosmale2020-03-162-0/+7
| | | | | | | | | | | | | | | Change-Id: Ic52fa388711a76d729ae28678932f4a150da9583 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | | Also support partly specified versions in JS .importsUlf Hermann2020-03-181-1/+1
|/ / | | | | | | | | | | Task-number: QTBUG-71278 Change-Id: Ie3167d44780a192b5010052eea5192eee8c21c32 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Allow partial and absent version specifiers in import statementsUlf Hermann2020-03-171-5/+1
| | | | | | | | | | | | | | | | | | | | An import statement without version specifier imports the latest version available, one with only a major version imports the latest minor version from that major version. Task-number: QTBUG-71278 Change-Id: I43907ae4e1052be533039d545de5391c41d38307 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-03-0910-71/+68
|\| | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/qml/compiler/qqmlirbuilder_p.h src/qml/qml/qqmlpropertycachecreator_p.h src/qmltyperegistrar/qmltypesclassdescription.cpp src/qmltyperegistrar/qmltypesclassdescription.h src/qmltyperegistrar/qmltypescreator.cpp src/quick/items/qquicktext_p.h src/quick/util/qquickvaluetypes_p.h Change-Id: Ic209741592e7b85820bf3845722023a190ebc1c5
| * Restore offset/length in QQmlJS::DiagnosticMessageSimon Hausmann2020-03-0210-71/+68
| | | | | | | | | | | | | | | | | | | | | | | | This is needed in a few places outside of declarative, so this change restores the loc member in DiagnosticMessage and moves QQmlJS::AST::SourceLocation into common's QQmlJS namespace/directory. QQmlError is unaffected and retains only line/column. Amends d4d197d06279f9257647628f7e1ccc9ec763a6bb Change-Id: Ifb9d344228e3c6e9e26fc4fe112686f9336ea2b2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devSimon Hausmann2020-02-032-1/+71
|\| | | | | | | | | | | | | | | Conflicts: src/qml/common/qv4compileddata_p.h tests/auto/qml/qmlmin/tst_qmlmin.cpp Change-Id: Ieabc9e0729630de6a8644024d11b765f35199f29
| * Required properties: Allow retroactive require specificationFabian Kosmale2020-01-312-1/+71
| | | | | | | | | | | | | | | | It is now possible to mark a property of a parent class as required in the child by writing required <propertyName> Change-Id: I9e9d58c7b5c00577b056e905b39744b2fa359ea0 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-032-25/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | In many places we carry major and minor versions or revisions that are loosely coupled to minor versions. As the Qt minor version resets now, we need to handle these things more systematically. In particular, we need to add a "major" part to revisions. QTypeRevision can express the current major/minor pairs more efficiently and can also be used to add a major version to revisions. This change does not change the semantics, yet, but only replaces the types. Change-Id: Ie58ba8114d7e4c6427f0f28716deee71995c0d24 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2020-01-252-3/+72
|\| | | | | | | Change-Id: Icb61522fb41a35303bb3d201b344a0407f67f9a0
| * Long live QML inline componentsFabian Kosmale2020-01-232-3/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] It is now possible to declare new QML components in a QML file via the component keyword. They can be used just as if they were declared in another file, with the only difference that the type name needs to be prefixed with the name of the containing type outside of the file were the inline component has been declared. Notably, inline components are not closures: In the following example, the output would be 42 // MyItem.qml Item { property int i: 33 component IC: Item { Component.onCompleted: console.log(i) } } // user.qml Item { property int i: 42 MyItem.IC {} } Fixes: QTBUG-79382 Change-Id: I6a5ffc43f093a76323f435cfee9bab217781b8f5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Make QtQml work with the latest changes in qtbaseLars Knoll2020-01-141-10/+4
| | | | | | | | | | | | | | | | | | | | | | | | Adjust the code to work with the new QString and QVector data structures that have inlined size and data pointers. Fix a large bunch of compiler warnings from QFlags. Update dependencies for qtbase and qtsvg Change-Id: Iba237aed90c140b822e0cf501b9fb7156ec27c2d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-121-1/+37
|\| | | | | | | | | | | | | Conflicts: src/qml/types/qqmlbind.cpp Change-Id: Ib992d1a7ac6c1a96d39819be6f23955dc31b44b2
| * qml/parser: Implement nullish coalescingMaximilian Goldstein2019-12-051-0/+34
| | | | | | | | | | | | | | | | | | | | Implements the '??' operator as specified in https://github.com/tc39/proposal-nullish-coalescing. Also adds a few tests. Task-number: QTBUG-77926 Change-Id: I3993450c192d11bf1ade0662d945c1553b4c6976 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * Add (and ignore for now) type assertions to QMLUlf Hermann2019-11-271-1/+3
| | | | | | | | | | | | | | | | | | | | You can write "(something as Foo)" to give hints to any tools that you expect something to be a Foo at this place. This is not a conversion and ignored at runtime for now. Eventually the compiler will verify that the type assertions are plausible and error out if they aren't. Change-Id: I21c8705bb387f7ab2cbc153293dbf477663afe87 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Replace usage of Q_ALIGNOF with alignofVolker Hilsheimer2019-10-211-1/+1
|/ | | | | | | | | | Q_ALIGNOF is no longer needed as alignof is part of the C++11 standard, and will be removed from Qt 6. Task-number: QTBUG-76414 Change-Id: I2fdb84de7fa7342c5d032b7679be7ba6bbaf3b40 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlIRBuilder: Turn Iterator into a iteratorFabian Kosmale2019-10-182-4/+22
| | | | | | | | | | | The iterator class was missing the required typedefs which are expected of iterators to support standard algorithms. Also demonstrate that we can now use standard algorithms on the containers by using find_if. Change-Id: Ia03dee4cb89731f407393c340606c3d94f3edb9d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-082-2/+2
|\ | | | | | | Change-Id: Ib381f350ada365747ce20b989bfdc368d75f2219
| * Small performance improvements suggested by clang-tidyAlbert Astals Cid2019-10-072-2/+2
| | | | | | | | | | | | | | | | | | mostly add const &, a few std::move and in particular case, remove const so the std::move being done over the variable actually has effect Change-Id: Id611cd31bc012f219d7a17d4626b1c2a5fbddd66 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Introduce required properties to QMLFabian Kosmale2019-09-091-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtQml] "required" is now a (contextual) keyword in QML, and users can mark properties with it to specify that those properties must be set when the component gets instantiated. This can be done either declaratively via standard property bindings from QML, or imperatively by using the functions to set initial properties (QQmlCompoent::setInitalProperties and related functions in C++, Qt.createObject, Loader.setSource,... in QML/JS). Logic has been added to QQmlComponent::create and the various QQmlIncubator classes to verify that the required properties were set. If properties marked as required are not set, a warning will be printed at runtime, and the component will not be created. Change-Id: I8e38227fc8f173b053b689c1597dc7fd40e835e7 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | Tighten verification of signal namesUlf Hermann2019-09-091-3/+9
|/ | | | | | | | You can have signal names beginning with "_" and numbers, but the first letter (if any) has to be lowercase. Change-Id: I001b6c1c0fe4eaef1f5498cb201947fa93208f8d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support top level generator functionsFabian Kosmale2019-07-232-4/+4
| | | | | | | | | | | | | Extends grammar to support generator functions in QML components and adjusts codegen accordingly The corresponding test case must be blacklisted in tst_qmlmin, as qmlmin cannot handle yield statements Fixes: QTBUG-77096 Change-Id: I47d45dd56289cdf073b41932a585259d3052de04 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split compiler and runtime more clearlyUlf Hermann2019-07-1116-2165/+43
| | | | | | | | Provide different export macros and different top level headers for each, don't include runtime headers from compiler sources. Change-Id: I7dc3f8c95839a00a871ba045ec65af87123154be Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move BindingPropertyData into ExecutableCompilationUnitUlf Hermann2019-07-111-4/+0
| | | | | | | | It is only used in the runtime. Change-Id: I93bc91a97f7a6967cdf49f2eb5c32b47217d905f Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Disentangle includes and namespacesUlf Hermann2019-07-117-196/+208
| | | | | | | | Avoid using namespace in headers and include only the headers we actually need. Change-Id: I526a0f874dc09b07693fd87070665be396d3b637 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split qqmltypeloader{_p.h|.cpp} into a several filesUlf Hermann2019-07-111-1/+0
| | | | | | | No one can read this mess. Change-Id: Icec4f2afc466435c1ae5e4e80fa2c1b5baf7d087 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge JSCodeGen and QQmlJSCodeGeneratorUlf Hermann2019-07-102-24/+70
| | | | | Change-Id: I2219cba0dd3782cb2e0b09b8f3c4d5472e6e5d7e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Allow generating debug instructions even if !qml_debugUlf Hermann2019-07-101-4/+0
| | | | | | | | | | qml_debug is about the runtime debug support. Even if it's not running in debug mode itself, the compiler should still be able to generate debug instructions to be interpreted later by a potentially debugging runtime. Change-Id: Ided5ff8ef9ce820de204e8a967ddeddad3fea5d5 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add support for C++ accessible typed parameters and return types in qml ↵Simon Hausmann2019-07-096-54/+79
| | | | | | | | | | | | functions These can be declared using the new typescript-like syntax and using type names that are also used for signal parameters and property types. This merely affects their signature on the C++ side and allows the corresponding invocation. Change-Id: Icaed4ee0dc7aa71330f99d96e073a2a63d409bbe Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Collect type information for function parametersSimon Hausmann2019-07-094-8/+12
| | | | | | Change-Id: Ia9ba819ce77eee7e582cf90aacf5baa4813d9fca Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix internal boundNames() API to expose optional typesSimon Hausmann2019-07-091-13/+13
| | | | | | | This allows extracting the type information for variable declarations. Change-Id: I1241df3b27ae292b83392d5caaa1587caafa46a3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Add basic type annotation support for QML functions to the grammarSimon Hausmann2019-07-093-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | Inspired by TypeScript syntax, allow optional type annotations in the style of ": <name of type>" in for the parameters of functions and their return type. These annotations are not used at the moment, so by default we produce an error message when encountering them in the AST. In addition their usage is limited to functions declared in the QML scope. All other uses attempt to produce readable syntax errors. So for example this is okay: Item { function blah(param: string) string { ... } } And this is not okay: // some file.js function blah(param: string) : string { ... } Change-Id: I12d20b4e2ce92e01108132975a06cfd13ba4a254 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* remove QmlIR::Document::removeScriptPragmasUlf Hermann2019-07-092-55/+0
| | | | | | | | | We don't need to blank the script pragmas as the parser will ignore them anyway. Change-Id: Id93e9ba0a6aacb38692cb294fb140d8ef99a2d23 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix standalone buildSimon Hausmann2019-07-091-0/+2
| | | | | | | | | The header file uses std::function and should include the corresponding header file and not rely on the includee to do that. Change-Id: Ic7a87aea4fcf49d17b0e5ef6c1aaf35424b66f01 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Centralize property & signal parameter type handling at compilation timeSimon Hausmann2019-07-083-84/+96
| | | | | | | | Collect all that code in the Parameter class, which allows for future re-use for function parameters and return types. Change-Id: Ib9dfec9313dc3938634f9ce3a2e5a3a59a7135d9 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Move the memory pool into the common codeUlf Hermann2019-07-081-0/+1
| | | | | | | We need it in both, the compiler and the runtime. Change-Id: Iffacb9d150bf9eef6ef477bfd427dbac9bf49359 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move qQmlCompileError to QQmlPropertyCacheCreatorUlf Hermann2019-07-081-10/+0
| | | | | | | | It's only used in the runtime. Change-Id: Iac1d9f5eabeae7fb8c1816be61d2f35711815dc9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Minor internal API cleanupSimon Hausmann2019-07-052-30/+32
| | | | | | | | Move Property::Type out into a standalone BuiltinType enum class, as it's also used in the signal parameters (and more in the future). Change-Id: I1125c954f6e45c7a1ce6fe2aae77c5f0e68455f5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Reduce the size of Property fields in type compilation dataSimon Hausmann2019-07-052-23/+33
| | | | | | | | We can shave off 4 bytes of each property declaration by sharing the bits for the custom type name index or the builtin type enum. Change-Id: I77071cbef66c5a83b3e7e281dba3a435d3c68b39 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Internal API cleanupSimon Hausmann2019-07-052-10/+4
| | | | | | | | | Fold the only member of Property::Flags into a straight boolean (bit) member. This makes the code easier to read. Change-Id: Ib621952cf5b28ce8de6293bff4ca9ebb1290fb36 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Reduce the size of signal parameters in qml cache dataSimon Hausmann2019-07-052-7/+12
| | | | | | | | We can reduce the distinction between a built-in type or a custom type down to a single bit. Change-Id: Ibe15d35357aa8c3948809f981221df29a40c400b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove unused field memberSimon Hausmann2019-07-052-4/+1
| | | | | | | | | The location member of signal parameters is not used at the moment, so let's remove it. Change-Id: Ia33bbe3bb79c382a78d61945c285b773b3492b55 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Simplify codegen error handlingUlf Hermann2019-07-043-154/+156
| | | | | | | | | | There can only ever be one error, either a syntax error or a reference error. We record the error type as we want to get rid of the virtual throw<X>Error methods in favor of an explicit compilation result. Change-Id: Ie228490aad8efb7885083f6485f931299567f54c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>