aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmltypeloader.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Merge remote-tracking branch 'origin/5.3' into 5.4Simon Hausmann2014-08-261-3/+16
|\ | | | | | | | | | | Conflicts: src/qml/qml/qqmlobjectcreator_p.h Change-Id: I60858ddb46866a8fa1a8576bb05b412afeeb4e41
| * Fix crash with recursively loading cached compilation unitsSimon Hausmann2014-08-221-3/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When a cached compilation unit depends on an import that is implemented as a Qml C++ plugin and that plugin in turn loads an asynchronous component that is cached, we would get a crash in the typeloader and a failing assertion (ASSERT: "d->m_mainThreadWaiting == false" in file qml/ftw/qqmlthread.cpp, line 300) This is because we did not implement the asynchronous loading within the loader thread for cached compilation units. This is simply done using a posted event, using the same mechanism used for other async load methods. Change-Id: Iefce67ab634ce26122c348dcdfc8e66b00fec671 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Update license headers and add new licensesJani Heikkinen2014-08-251-19/+11
| | | | | | | | | | | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 & LICENSE.GPLv2 - Removed LICENSE.GPL Change-Id: I84a565e2e0caa3b76bf291a7d188a57a4b00e1b0 Reviewed-by: Jani Heikkinen <jani.heikkinen@digia.com>
* | CleanupSimon Hausmann2014-08-151-4/+3
| | | | | | | | | | | | | | | | | | Merge QV4::CompiledData::QmlUnit into QV4::CompiledData::Unit. For pure JS units it means a slight increase of memory usage by a few bytes, but overall it makes the code a lot simpler. Change-Id: Ib48927749720b056f004aac0fe22cb8ec729e3f6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Get rid of all uses of ObjectRefLars Knoll2014-07-221-1/+1
| | | | | | | | | | Change-Id: I705e2362dcda542f56826dadec6b0a6f15848788 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Avoid race condition in QQmlEngine on shutdown.Gunnar Sletta2014-07-041-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | The QQmlTypeLoader was deleted (and its thread shut down) when the QQmlEnginePrivate was destroyed. However, the QQmlTypeLoader runs a thread which would happiliy make calls on the engine and its managed data. Fix this by stopping the QQmlTypeLoader's thread right away in QQmlEngine. Task-number: QTBUG-39905 Change-Id: Ida8e95d083f79237c74b036fd3521133a9fa4ac7 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
* | Cleanup: Get rid of the url and file name members in QQmlCompiledDataSimon Hausmann2014-06-051-4/+2
|/ | | | | | | | This is part of the effor of moving members from QQmlCompiledData into QV4::CompilationUnit in order to eliminate the former in the long run. Change-Id: Icce7fe0ee9a49cb3a7677fd7020008fc55ecdcf6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Extend the QML bootstrap library by the IR buildersSimon Hausmann2014-04-231-6/+19
| | | | | | | | | | | | | This is among other things needed to fix the qml import scanner to detect dependencies from .js files correctly. The patch also fixes the use of Q_QML_EXPORT towards Q_QML_PRIVATE_EXPORT where appropriate and corrects the wrong include path for the double conversion code to actually be relative to the file it is included from. This worked by accident because of other include paths present in the build. Change-Id: I338583dad2f76300819af8ab0dae8e5724c84430 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Make it possible to supply compilation units from pluginsSimon Hausmann2014-03-291-36/+141
| | | | | | | | | This also cleans up the script and type initialization in the type loader, for example by getting rid of the m_irUnit member for scripts. Change-Id: I207afeb21c0bae9091d3c7b4cac2e80e9aae0ea3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Various cleanupsSimon Hausmann2014-03-281-16/+17
| | | | | | | | | | | | | * Encapsulate the string pooling for the V4 data generation into a StringGenerator class. * Move type reference collection into the IR::Document, where it belongs (as it writes into the typeReferences there) * const fixes * Remove unused methods and members * Store unit and qml unit sizes right in the generated data structure. That makes copying easier (like we do when generating the QML data based on the JS fields) Change-Id: I053146ab0b00cc90ac7f72f867415962d1be121b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup: Get rid of QQmlScript::TypeReferenceSimon Hausmann2014-03-191-9/+8
| | | | | Change-Id: I5f8b203ac71f0667947087bd2b1e7ce6d91d843d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* CleanupSimon Hausmann2014-03-191-97/+66
| | | | | | | | Get rid of QQmlScript::Import in favor of operating on QV4::CompiledData::Import structures throughout the type loader. Change-Id: I29de369373a3dc4fd8e7f30517b804edcce93e7a Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up script importsSimon Hausmann2014-03-191-19/+43
| | | | | | | | | | Move the .pragma and .import script extraction out of qqmlscript and into qqmlirbuilder, where it can populate a QQmlIR::Document. Changed the script part of the type loader to use that, which also allowed eliminating the m_source member and m_metaData. Change-Id: Icc64d219fff5666679a02e6afda73f7edfca132b Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean, part 3Simon Hausmann2014-03-191-32/+10
| | | | | | | | | | * Get rid of QQmlScript::Pragma * Allow retrieving the QML unit size after generation * Add flag equivalent of .pragma library to QV4::CompiledData * Remove unused method Change-Id: I2f95b83f919004013741bc539c82960cc878f3a4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup, part 2Simon Hausmann2014-03-181-51/+48
| | | | | | | | | | | * QQmlCodeGenerator -> QQmlIR::IRBuilder (it doesn't generate code, it generates the Object/Property/Signal/etc. IR of the .qml file, that's going to get transformed to QV4::CompiledData::*) * ParsedQML -> QQmlIR::Document Change-Id: I329e858487b66e1ae528d44316761f5dd34b79f4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Namespace cleanupSimon Hausmann2014-03-171-4/+4
| | | | | | | Move the QML IR types into the QmlIR namespace and clean them up. Change-Id: I2125449e5a519034e23670651efa620f405730b4 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix QQmlTypeData object leakLiang Jian2014-03-131-0/+5
| | | | | | | | 1) unref QQmlTypeData object stored in m_compositeSingletons 2) unref QQmlTypeData object in resolveQmlType() Change-Id: I5f2e3a542637f62509c4a2f2ed8a6ba080eacf1b Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove old compiler and VMESimon Hausmann2014-03-071-98/+15
| | | | | | | | | | | | This removes the bulk of the code. A few smaller cleanups remain, to be done in smaller changes as they move code around. Additionally the "optimize" option of qqmlbundle was removed. It called QQmlScript::Parser::preparseData, which however was not implemented and always returned an empty QByteArray. Therefore "optimize" would not do anything and the class is gone now :) Change-Id: I0c265e756704cb53c5250be1f69e4a3e1b6e64d5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix tst_qqmlengine::trimComponentCacheSimon Hausmann2014-03-021-0/+6
| | | | | | | Fix bug in QQmlCompiledData refcounting. Change-Id: I09528419c602d3173db2f13c516d2f0d79abd92e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] When resolving names of attached properties, don't report the ↵Simon Hausmann2014-03-021-2/+4
| | | | | | | | | error at import time Instead report it later with a more specific error message. This is consistent with the old compiler. Change-Id: Iba345b7ecc8a9ff474938f69118665eb0d965594 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Add dedicated QML profiler and adapterUlf Hermann2014-02-151-2/+2
| | | | | | | | The remaining "profiling" parts of the QML profiler service are engine specific and are best accessed through their own adapter. Change-Id: Idb763104bdd80e4dabdf132ec1a496b9bc9f6f46 Reviewed-by: Kai Koehne <kai.koehne@digia.com>
* [new compiler] Avoid uncreatable type errors for types that aren't createdSimon Hausmann2014-01-291-4/+6
| | | | | | | | | QtQuick.Keys for example is not creatable, but it's also never created but only used as attached properties. Therefore types used as attached properties create the needCreation = false flag in the referenced types. Change-Id: I6ca3a3ff677858bf3c55d3e08a0f0fc8ee9160fe Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* fix whitespaceOswald Buddenhagen2014-01-221-63/+63
| | | | | | | remove trailing spaces and expand tabs Change-Id: Ieacb9d096b612c45d1a64700044c114d1f7522bc Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-101-1/+1
| | | | | | | | Tie QQmlCompilePass and QQmlTypeCompiler together, so that we can eliminate the battery of parameters to the individual compiler phases. Change-Id: If2b6cf8416e6c2253c8f054048d1fd5ae12282b6 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] CleanupsSimon Hausmann2014-01-081-171/+4
| | | | | | | | Move the code that calls the main compilation passes into a separate QQmlTypeCompiler class, away from the QQmlTypeLoader. Change-Id: Ia2f33a074d7fe7d9a092ff94d1e6cfc961ad5bdb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Fix signal handlers for properties declared in the same objectSimon Hausmann2014-01-081-38/+41
| | | | | | | | | | | | We need to generate the property caches before we can try converting the signal handler expressions in the AST to function declarations, as that conversion requires looking up the signal signature / meta-data from the property cache. This in turn requires rewriting the property cache generator code to operate on the data structure we have before creating the QV4::CompiledData. Change-Id: I0d1c59d947f36171b4eb89f47a2e1ff1bc493c6f Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* [new compiler] Initial support for custom parsersSimon Hausmann2014-01-081-1/+2
| | | | | | | | Enough to support the Connections {} element. What's missing are pre-compiled bindings signal handlers. Change-Id: I3ad1413fa636434d899ae8fb380249aaf40363dc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Clean up handling of illegal names and enable in new compilerSimon Hausmann2014-01-061-2/+3
| | | | | | | | | | Access to the identifier hash may not be thread-safe from the loader thread, so use a QSet copy instead (which is cheap because we don't detach). This also enables the checking for illegal types again. Change-Id: I8c3ec1fd0fc01cce3269e206f479a90bdbbc89dd Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Merge remote-tracking branch 'origin/release' into stableFrederik Gladhorn2013-12-121-1/+1
|\ | | | | | | | | | | | | Conflicts: src/qml/qml/qqmlcompiler.cpp Change-Id: I802731139d47c5b733dd805f7bf432d67d7331e1
| * Revert "Revert ffaf39e9a7f11d4e2800b3b37160a2a952795614"Alan Alpert2013-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | This reverts commit 27052dcad9810869a9065da4c06e9f14379411d7. While the additional flexibility would be nice, I've been reminded that we already did commit to it back in July. Change-Id: Iaf990dda98ee46eb028b4737bdeeafd050d9513f Reviewed-by: Alan Alpert (Personal) <416365416c@gmail.com>
* | Fix broken Maroon game / regression in PropertyChanges {} elementSimon Hausmann2013-12-101-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Commit 0aadcf8077840068eb182269e9ed9c31ad12f45e that pre-compiles the expressions in PropertyChanges {} introduced a regression in where the evaluation context was incorrect and thus bindings would not be able to access the correct properties. For example PropertyChanges { target: someObject y: height / 2 } Here height should be looked up in the context of "someObject", not of the PropertyChanges element. This patch introduces an auto-test that verifies that the lookup context is correct and fixes the bug by disabling accelerated compile time property lookups for binding expressions that are requested from a custom parser. Change-Id: I5cb607d07211b453ddfc9928ccbf5f9ecec85575 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* | Remove unused memberLars Knoll2013-12-041-1/+1
| | | | | | | | | | Change-Id: I9926f1ab10ea04387f17794944dcc11f4a2a9054 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Encapsulate the current context and fix it's usageLars Knoll2013-12-041-1/+1
| | | | | | | | | | | | | | | | | | | | | | Encapsulate accesses to the current context, and rework the way we push and pop this context from the context stack. Largely a cleanup, but simplifies the code in the long term Change-Id: I409e378490d0ab027be6a4c01a4031b2ea35c51d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* | Improve type interference for QObject propertiesSimon Hausmann2013-11-251-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | Propagate QObject properties in member expressions across temporaries as part of the type interference SSA pass. This replaces the earlier attempt to resolving QObject properties in fieldMemberExpression() in the codegen, but it was incomplete and now things like the following are fully resolved: var tmp = blah.somePropertyThatReturnsAQQuickItem; <-- QQuickItem property return type propagated into tmp var width = tmp.width; <-- and picked up here again to resolve the index of width instead of by name With this patch Temp gets a helper structure with a function pointer, initialized to aid the resolution of properties in Qt meta objects. This structure is propagated into the temps until it reaches the next member expression that uses the temp. Similarly QObjectType is added as IR type, next to VarType. The resolution inside the SSA type interference pass also requires passing through the QQmlEngine from the upper caller levels, in order to resolve the property type to a potential QMetaObject property. Change-Id: I14c98fa455db57603da46613ce49c174d0944291 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Revert ffaf39e9a7f11d4e2800b3b37160a2a952795614Alan Alpert2013-11-131-1/+1
| | | | | | | | | Making it public right now seems a little premature, given all the work happening on the engine now (and for 5.3). We'll be in a better position to commit to it or not next release. Change-Id: Ib7b14afeb9205fb8a87ed16a6d38b1f468b2bbbb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Intercept qmldir files with the url interceptorAlan Alpert2013-11-111-7/+20
| | | | | | | | | | | There's another code path which loads qmldir files directly, and it did not use the interceptor when available. Note that this, like other interceptors, does not affect baseUrl and so any other qmldir file still must have paths relative from the initial URL. Change-Id: I620943c36d488d22fbaf1793514075d31ab76e3e Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix various compiler warnings in order to remove warn_off in the near futureErik Verbruggen2013-11-041-1/+1
| | | | | Change-Id: Ic0492fbe31a1e134674bc6c20381f735dd6d5b7a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Improve debugging of QML expressionsSimon Hausmann2013-11-011-1/+2
| | | | | | | | Add the name of the property to the generated IR function ("expression for x") to make it easier to debug. Change-Id: If35f42764774e6d7f40d3bf080e1fbdb12321ed5 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Speed up lookups of imported scriptsSimon Hausmann2013-10-311-2/+8
| | | | | | | | | | The QQmlContextData stores the JS objects of imported scripts in a QList<PersistentValue>. Instead of indexing into that list, this patch changes ctxt->importedScripts to be a JavaScript array, that in the IR we can index via subscript. Change-Id: Ie2c35fb5294a20a0b7084bb51d19671a27195fec Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Resolve member expressions of QObject membersSimon Hausmann2013-10-311-2/+3
| | | | | | | | | | | | ...when the base is a QObject property itself or an ID referenced object. This patch resolves for example the width property in a parent.width expression to be a per-index lookup at run-time. That requires the base ("parent") however to be a final property or come from an object where expected revision is known, i.e. a QML imported object (scope or context). Change-Id: Iaa1f57ace452da5e059c1d4e63b52b316e1a6b08 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Initial support for resolving meta-property access for the scope and context ↵Simon Hausmann2013-10-311-3/+3
| | | | | | | | | | | | | | | | | objects at QML compile time This avoids having to do a string lookup for ids and in the import cache at run-time, before we can do a string hash lookup in the property cache. Instead we resolve final properties in the context and scope object at compile time and look them up at run-time using their index instead. The dependencies to these properties are also tracked separately and recorded in the compiled data. This is merely the initial patch. There's a lot left to do, such as having specialized getter and setters for specific property types. Setters are missing altogether right now and will fall back to name lookup. Change-Id: If3cb4e7c9454ef4850a615f0935b311c9395b165 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Cleanup QML specific JS code generatorSimon Hausmann2013-10-291-2/+2
| | | | | | | | Move parameters global to the entire QML file to the constructor, pass component/context specific parameters to the generate function. Change-Id: I6c3ab41b3bab19b066bbe20f971c5cafaeb70b98 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Properly propagate parse errorsLars Knoll2013-10-291-5/+4
| | | | | | | | Replace all try/catch statements used when parsing with checks for engine->hasException. Change-Id: I4493cb600d5a3eb095c2003bb88bd031403e47c9 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Use finalUrl in QQmlTypeLoader::Blob::addPragma to fix a bug.Antti Piira2013-10-251-3/+3
| | | | | | | | | | There was a bug in addPragma where url() was being used instead of finalUrl(). This resulted in an error finding the type if selectors were used. This patch includes the fix and adds a unit test to cover the use case. Change-Id: I18b6c73e96af2e1464931de76f1f8fd804746d82 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* V4 debugger: retrieve formals and locals.Erik Verbruggen2013-10-241-1/+1
| | | | | Change-Id: I47507a4d7d1b429b9c43ed3a7822079efe577327 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Add support CompositeSingleton to the new V4 compiler.v5.2.0-beta1Antti Piira2013-10-211-1/+24
| | | | | | | | | | | | | | | | | Implements QQmlCodeGenerator::visit(AST::UiPragma *) to process any pragma statements in a QML file for the new V4 compiler approach. Only pragma Singleton is supported, others will generate errors. Also adds necessary hooks to treat types as Singletons. Basic functionality is working, but three of the QML Singleton unit tests fail. Some of them are dependent on other language capabilities that seem to have problems. In addition removes unnecessary toString() call in the equivalent visit(AST::UiPragma *) function of the old parser. Change-Id: Iec9fa887f953b80b7f9a11878d846637a8f519ef Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Remove internal method from public APILars Knoll2013-10-191-1/+1
| | | | | | | | QQmlError is public API and shouldn't expose an internal method. Change-Id: I7caf06af9340fefec5c96103395fe74acbf19497 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
* Compile binding expressions in the QQmlCompilerSimon Hausmann2013-10-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | This is done by re-using the JS code generator from the new compiler. A few bugs were fixed on the way: * The index into the compiledData->runtimeFunctions array is not the same as the function index when they are collected (from the AST), as for example binding expressions may create extra V4IR::Function objects that break the 1:1 mapping. Therefore the JS code gen will return a mapping from incoming function index to V4IR::Module::Function (and thus runtimeFunction) * Binding expressions in the old backend get usually unpacked from their ExpressionStatement node. The reference to that node is lost, and instead of trying to preserve it, we simply synthesize it again. This won't be necessary anymore with the new compiler in the future. * Commit 1c29d63d6045cf9d58cbc0f850de8fa50bf75d09 ensured to always look up locals by name, and so we have to do the same when initializing the closures of nested functions inside binding expressions (in qv4codegen.cpp) * Had to change the Qml debugger service auto-test, which does toString() on a function that is now compiled. Even if we implemented FunctionPrototype::toString() to do what v8 does by extracting the string from the file, it wouldn't help in this test, because it feeds the input from a string instead of a file. * In tst_parserstress we now end up compiling all JS code, which previously was only parsed. This triggers some bugs in the SSA handling. Those tests are skipped and tracked in QTBUG-34047 Change-Id: I44df51085510da0fd3d99eb5f1c7d4d17bcffdcf Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Change exception handling APISimon Hausmann2013-10-021-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch changes the exception handling API in the engine slightly, encapsulating any use of direct throw statements and catch blocks with concrete types. In the future we need to be able to change the way these are implemented, in order to ensure that the correct stack unwinding code is triggered for throw and re-throw. This patch separates the C++ exception object thrown from the V4 exception (that includes value, throwing context pointer) and stores the latter inside the engine. In order for that to compile, ExecutionEngine::StackTrace and StackFrame had to move into the QV4 namespace directly. In addition the syntax for catching exceptions changes from try { ... } catch (QV4::Exception &ex) { ex.accept(context); QV4::ScopedValue exceptionValue(scope, ex.value()); } to try { ... } catch (...) { QV4::ScopedValue exception(scope, context->catchException()); } Context::catchException() checks if there's a "current" exception in the engine, and if not assumes that we caught an unrelated exception and consequently re-throws. partiallyUnwind() is also gone and replaced with rethrowException(), in order to encapsulate the re-throw. Lastly, in the future nesting try/catch blocks isn't going to be possible due to limitations in the common C++ ABI with regards to foreign exceptions. Change-Id: Ic81c75b057a2147e3176d8e0b4d326c14278b47d Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Always call callCompleted in QQmlDataBlob::tryDoneAlbert Astals Cid2013-10-021-4/+2
| | | | | | | | | | | | | | | | | | | We need this since it could happen that in QQmlComponentPrivate::loadUrl we did QQmlTypeData *data = QQmlEnginePrivate::get(engine)->typeLoader.getType(url, loaderMode); and got a sync QQmlTypeData even if we asked for async, and thus the async loader was never notified when it finished and we were never loaded. Situation in which this can happen is: * ListView with an async Loader as delegate * Loader loads two items A and B, while A is a B * Item 0 of the ListView triggers an async loading of A that triggers the sync loading of B * Item 1 of the ListView triggers an async loading of B * Since B is already being loaded (though in sync), we just add ourselves to the people that want to be notified * sync loading of B is done and QQmlDataBlob::tryDone does not call the callbacks because it's sync * Item 1 is never finished loading Change-Id: I52a0979a1d3cfcfe73a71196bf24f491d6cf8e9a Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>