aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/compiler
Commit message (Collapse)AuthorAgeFilesLines
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* extend grammar for better version parsing supportFabian Kosmale2019-07-041-5/+3
| | | | | | | | | | | | | | | | | | Be more strict in parsing version numbers This also makes it easier to access the version number in other places using the Visitor interface, like (soon) the linter and avoids reparsing the text twice. Potential disadvantages: previously allowed import statements will rejected at parse time, e.g. import QtQuick 0b10 Potential further advantage: Weird import statements like import QtQuick 0b10 will be rejected earlier Change-Id: Ifcd187b79a90952bc964c688afa4ea9b158e5109 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline the rest of qv4compileddata.cppUlf Hermann2019-06-264-181/+110
| | | | | | | | | This way we get a header-only representation usable for the QmlCommon module. Change-Id: Ia75e445ffbee0c3b2d473a2a3a6309b2f12e8eea Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline CompiledData::unlink() into the only callerUlf Hermann2019-06-242-12/+0
| | | | | | | | | | | | | The compiler never links anything and therefore it doesn't need to unlink, either. Change-Id: I9ccdc012f9333abc5f4b60174b794e490772e1fd Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Move unit checksum generation into qv4compilerUlf Hermann2019-06-245-24/+23
| | | | | | | | | | | | | Only the compiler ever has to do this, and we want the structure definition for the compiled data as a common header. Change-Id: Ie5c6d6c9dcd180dea79f54d0f7d10f3fc50fa20e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move saveToDisk into SaveableUnitPointerUlf Hermann2019-06-242-54/+47
| | | | | | | | | This way we can keep the flag mutilation closely local to the place where we write the data. Also, SaveableUnitPointer doesn't need a full CompilationUnit this way. Change-Id: I01872e4c406cb2ccbaa1fa35325cc063b1e8a7df Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Simplify errors and diagnosticsUlf Hermann2019-06-144-40/+22
| | | | | | | | | | | | | | | | We only need two classes to describe all possible diagnostics: * A low-level private POD DiagnosticMessage. This is easily copied and passed around internally. It doesn't need to adhere to a stable API and it doesn't carry any extra baggage. * The high-level public QQmlError with its stable interface. This can internally also use a DiagnosticMessage as storage. Change-Id: I52be88d9b5d9855a661b8032b01eedb43a0fb0b3 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move the header checking into ExecutableCompilationUnitUlf Hermann2019-06-143-61/+2
| | | | | | | | | We don't need to verify the header unless we want to execute the code. Change-Id: Ieac51c47faafcd7047228b4264aa7750ba3d8889 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Move AST -> CompiledData location transformation to scan functionsUlf Hermann2019-06-133-19/+18
| | | | | | | | | | That's the only place where we use it and this way we can remove the AST dependency from the compiled data. Change-Id: I530a0f18a08672acd7031a552885b819e6fe2b84 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.13' into devQt Forward Merge Bot2019-06-112-6/+18
|\ | | | | | | | | | | | | | | | | | | Conflicts: src/qml/jsruntime/qv4value_p.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmltypewrapper.cpp src/quick/items/qquicktableview.cpp Change-Id: I684f8e01a711580512848bf1253f39b39fcbf4c7
| * Merge remote-tracking branch 'origin/5.12' into 5.13Qt Forward Merge Bot2019-05-262-6/+18
| |\ | | | | | | | | | Change-Id: I208cd36d2b7add94f36e4d86cf0c790a1e4a7e86
| | * Don't add local for anonymous function's "name"Ulf Hermann2019-05-212-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead, populate their "name" property directly from the surrounding object pattern if applicable, without adding locals. This fixes some ecmascript tests where functions were assigned to the key "eval" in an object. The JS engine then rejected that because you shouldn't use eval in strict mode. That should be close enough to test for regressions. Fixes: QTBUG-75880 Change-Id: Iacc45a3f7b0eb90cddc6ecf6d2bada616d2cf355 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Remove unused includes and Q_DECLARE_METATYPEs re: QLinkedListMarc Mutz2019-06-061-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | They were all unused. Change-Id: I2b147b5a479f278c0607ef432faf1cb9e8e06236 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | Eliminate qmldevtools_buildUlf Hermann2019-05-3120-5371/+908
| | | | | | | | | | | | | | | | | | | | | | | | Move the relevant files into more fitting locations and build the devtools from only parser, compiler and qmldirparser. Change-Id: Ibf37a1187f36d02983f9f43c6622acb243785b7b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Split QV4::Value into a static and a dynamic partUlf Hermann2019-05-3110-40/+61
| | | | | | | | | | | | | | | | | | | | | | | | The static part can be used for compilation and won't resolve managed objects. This allows us to remove all the remaining V4_BOOTSTRAP. Change-Id: Id2f6feb64c48beb2a407697881aea8c0d791a532 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove V4_BOOTSTRAP condition around header verificationUlf Hermann2019-05-091-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's unclear why that was needed. Change-Id: I0b4d4ebe1992cd2252cfc3eb10baa7f1b3ae1a5a Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Move valueAsNumber into ExecutableCompilationUnitUlf Hermann2019-05-135-13/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reduces our dependence on QV4::Value in the devtools. Change-Id: I4b3f937bc08c16f7e2543fdc5cc34c0cfb121f8f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | Remove QUrl-related special casing in the compilerUlf Hermann2019-05-102-10/+1
| | | | | | | | | | | | | | | | | | | | | QUrl is being added to the bootstrap set. Change-Id: Ia96bbcf6e0ef808435ecddfa114fdcd213361bbf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>