aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/parser
Commit message (Collapse)AuthorAgeFilesLines
* qtdeclarative: finish fixing compilation with explicit QChar(int)David Faure2020-11-071-1/+1
| | | | | Change-Id: Idb26e2df6d4fe8940db57066a30fa8c243f6d2c9 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Fix QtQml after QMetaType/QVariant changes in Qt CoreLars Knoll2020-08-281-0/+1
| | | | | Change-Id: I2a983cf8188e88d80d3b7726208d821427eb8f3c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Adapt to qtbase changesFabian Kosmale2020-08-231-0/+1
| | | | | | | | | | | The internal QVariant constructor taking a QMetaTypeId has been removed. Thus, construct QMetaTypes where necessary from the id, or avoid a QMetaType -> ID -> QMetaType roundtrip where we already have a metatype. Also fix a few missing includse that were previously transitively included. Change-Id: I56ce92281d616108a4ff80fe5052b919d1282357 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Use qstrntod instead of qstrtodhjk2020-08-101-4/+2
| | | | | | | Potentially saves a few cycles by avoiding a strlen call. Change-Id: I3c1e4ddf3fb0a52e9f44edea11616a8969604091 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix compilation with newer qtbaseFabian Kosmale2020-08-061-4/+2
| | | | | | | | | | qstrtod is no longer exported, but instead an inline function. This replaces the existing forward declarations with an include of the required private header. Change-Id: I50bd32557c55dddcb197f163609fd7d5a1b2301b Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Support required list propertiesFabian Kosmale2020-07-281-0/+35
| | | | | | | | The corresponding rules were missing so far. Fixes: QTBUG-85716 Change-Id: Ic97546ea2e574f694a96d974ee355ac84f8650b5 Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* Port QtDeclarative from QStringRef to QStringViewKarsten Heimrich2020-06-166-108/+107
| | | | | | | | 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>
* Fix lexer line number if code contains continuation stringsChristian Stenger2020-06-121-1/+4
| | | | | | | | | | | Follow-up lines of continuations strings that directly end with an unescaped line feed still broke the line numbers of code following the string. Fix by explicitly handling the first character inside a string differently. Amends 126ee5c901a9675a9ab61d4c6f2961c95b8bceac. Change-Id: Ia945546d35db844114064ae34d6189704ceefe3b Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
* QtQml: Use unicode character literalsUlf Hermann2020-06-031-166/+165
| | | | | | | This avoids the warnings on conversion to QChar. Change-Id: Ib774f24592d6f09a531c60bb6fa6e5bdbec88120 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Fix 'as' binary operation using invalid typesMaximilian Goldstein2020-05-205-2/+44
| | | | | | | Fixes: QTBUG-81392 Change-Id: Ic83091c547a7854b7fa86b44d93c575bd7426bae Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix line number for follow-up lines in stringsChristian Stenger2020-05-011-1/+3
| | | | | | | | If a string ends with a line terminator follow-up lines had a wrong line number. Change-Id: I98a8f69cbc876e07b3fe83490d517bf7771c59b5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix lexer handling of escape sequences in stringChristian Stenger2020-05-011-0/+1
| | | | | | | | | The lexer handled escape sequences inside string literals wrongly which could led to follow-up problems like wrong offsets or even lines of tokens. Change-Id: Ief14dda77f9079931a7d19ea549017a1d59c2d0b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove QT_CREATOR special casesUlf Hermann2020-04-011-20/+8
| | | | | | | | Always parse typeinfo entries from qmldir files, and export QQmlJS the Qt way. Change-Id: I3a87a8d0a9ed1014628df6eb906bde5ea23e5d9f Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Also support partly specified versions in JS .importsUlf Hermann2020-03-181-20/+17
| | | | | | 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-172-1/+6
| | | | | | | | | | 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-098-120/+30
|\ | | | | | | | | | | | | | | | | | | | | | | | | 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
| * Remove duplicate add of qqmljsengine_p.h to HEADERS in parser.priFawzi Mohamed2020-03-031-2/+1
| | | | | | | | | | Change-Id: I6848575df79be5f84e55e1e9ae9282216424afeb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Get rid of extra spaceFawzi Mohamed2020-03-031-1/+1
| | | | | | | | | | | | Change-Id: I11e5c9e95974e89f2fd1571ca4b97a0f2ac3309a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
| * Restore offset/length in QQmlJS::DiagnosticMessageSimon Hausmann2020-03-027-118/+29
| | | | | | | | | | | | | | | | | | | | | | | | 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 devQt Forward Merge Bot2020-02-176-478/+925
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/imports/qtqml/plugin.cpp src/qml/qml/qqml.h src/qml/qml/qqmlmetatype.cpp src/qml/qml/qqmlmetatype_p.h src/qml/qml/qqmltypeloader.cpp src/qml/types/qqmlbind.cpp src/quick/items/qquickitemsmodule.cpp tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp Change-Id: I52548938a582cb6510271ed4bc3a9aa0c3c11df6
| * Add UiAnnotation for annotation objectsFawzi Mohamed2020-02-125-8/+49
| | | | | | | | | | | | | | | | | | | | This is a partial patch that is fuilly fixed with the following one (big restructure) because it needs extra visit methods, and that leads to conflicts, but I think it gets lost if merged with the next one. Change-Id: I54331a47a5c7faaf78a97e580825d1feec5adf92 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Introduce BaseVisitorFawzi Mohamed2020-02-125-467/+801
| | | | | | | | | | | | | | | | | | | | Base Visitor is an abstract visitor that has all visit methods abstract, subclassing this one gets an error if some visit method is not implemented (dumper and reformatter for example will gain from this. Change-Id: I3f8cfeb6fc0ef917acf725bbe1c293d761304287 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Put Ui visitors togetherFawzi Mohamed2020-02-121-3/+2
| | | | | | | | | | | | | | | | | | | | UiRequired is not with all Ui Vistors and introduced with a // Ui comment. Move it there for consistency. Change-Id: I51315ad380fd50998e7efe095c873d14a5ae7a97 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * Remove unused AST::ModuleItemFawzi Mohamed2020-02-122-4/+0
| | | | | | | | | | | | | | | | | | ModuleItem is unused we should either remove it or make it a used abstract superclass like UiObjectMember. Here we remove it. Change-Id: Icfcebd450e09ebe324a99728613eea0348b980ac Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * Make UiObjectDefinition uniformFawzi Mohamed2020-02-121-4/+5
| | | | | | | | | | | | | | | | attributes are always at the end of AST objects, move them there also for UiObjectDefinition. Change-Id: I7630b1c40627913c3e7e46e752acf1d80203ce63 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| * Mark non visited AST partsFawzi Mohamed2020-02-121-0/+13
| | | | | | | | | | | | | | Add a commented out accept call for the non visited fields in accept0 Change-Id: Icb1ab0c77440f4c3eae5404bff2cf71086f96a2f Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Add annotations to ASTFawzi Mohamed2020-02-125-5/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Annotations are added to UiObjectMember. This makes it easy to find the annotations of any UiObjectMember through the annotations attribute. The clean AST approach would add an UiAnnotatedObjectMember that contains both the annotation list and an UiObjectMember, but that makes finding the annotation more difficult. The annotations are not visited by default, if one wants to dump them before the current object the simplest way is to use the preVisit and use .uiObjectMemberCast(). Depending on how we use annotation we could change the current approach. Task-number: QTBUG-81714 Change-Id: I543a2cfe5157bcc86de6de9faebde9aea22974eb Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Guard against invalid version specifiers in import statementsUlf Hermann2020-02-121-1/+16
| | | | | | | | | | | | | | | | | | Check that the version parsed is in the valid range for QTypeRevision and produce a compile error if not. Task-number: QTBUG-71278 Change-Id: I9a957a10f4254387f9868a8f3f1e231440bc2cd2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* | Merge remote-tracking branch 'origin/5.15' into devSimon Hausmann2020-02-036-7/+127
|\| | | | | | | | | | | | | | | 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-315-2/+48
| | | | | | | | | | | | | | | | 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>
| * add annotations to QMLFawzi Mohamed2020-01-312-5/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A QML Annotation is a Qml Object declaration prepended with @. The name of the annotation is restricted to a dot separated list of non keyword identifiers. Annotations can be put before an Object definition, or any object member declaration: bindings, property declarations, function declarations. This patch, aside parsing the annotations does absolutely nothing, the list of annotations is discarded and never touches the AST. [ChangeLog][QML] Add Qml Annotations Task-number: QTBUG-81714 Change-Id: I4d79559a0d1fb23acaf482d0ef8f7d106dbf099d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Use QTypeRevision for all versions and revisionsUlf Hermann2020-02-031-3/+6
|/ | | | | | | | | | | | | | 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>
* Required properties: Allow required default propertiesFabian Kosmale2020-01-291-0/+25
| | | | | | | | | This was already possible from C++, this change adds the required changes to the grammar to allow declaring required default properties in QML. Change-Id: I76cb4d70e573bf161676da8295ab257fe95ed4ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Long live QML inline componentsFabian Kosmale2020-01-236-24/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | [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-053-5/+49
| | | | | | | | | | 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-272-0/+15
| | | | | | | | | | 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>
* QML: Consider the semicolon as part of expression statementsUlf Hermann2019-11-182-5/+21
| | | | | | | | | | | | | | | | | | | | | | When asked for lastSourceLocation() we should always return the semicolon token. In order for that to work, the semicolon token needs to be valid in all cases. In the case of object literals as expressions for properties we neither accepted nor synthesized a semicolon as delimiter. Add an optional semicolon that we can then also use as end of the expression statement. Furthermore, this triggered a silent rule conflict for ImportSpecifier, which for some reason did not arise before: IdentifierReference could resolve to both ImpordBinding and IdentifierName, causing ambiguity in the grammar, and ultimately caused parse failues when parsing an import statement. This is now resolved by explicitly telling the parser to prefer shifting. Initial-patch-by: Ulf Hermann <ulf.hermann@qt.io> Change-Id: Iaec29c452b577312248a17cb48f005f4fc0bd8c4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Remove QQmlJS::AST::UiImport::versionTokenUlf Hermann2019-10-102-9/+1
| | | | | | | | It was incorrectly parsed in case of "as Foo", and it was mostly unused. Change-Id: Ie833a8eb247108cb7bcd6ca3e6f3e5df614461cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* V4: Provide an environment variable to disable runtime stack size checksUlf Hermann2019-09-172-1/+13
| | | | | | | | | | | | | | | | | | | | | | With QV4_CRASH_ON_STACKOVERFLOW set you can use up all the stack provided by the operating system to parse and execute JavaScript. Once the stack space is exhausted the program crashes like it would in case of a C++ stack overflow. We cannot reliably determine either the maximum stack size or the amount of stack space currently in use at runtime. Therefore, the guards we usually put in place are necessarily conservative. [ChangeLog][QtQml] There is now an option to disable the (necessarily) conservative stack size checks when parsing and executing JavaScript. If the environment variable QV4_CRASH_ON_STACKOVERFLOW is set, JavaScript stack overflows crash the program the same way C++ stack overflows do. On the flip side, more stack space is made available that way. Task-number: QTBUG-74087 Change-Id: I5e9d9ec6c0c9c6258c31d9e2d04a5c1819fbf400 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Introduce required properties to QMLFabian Kosmale2019-09-093-2/+32
| | | | | | | | | | | | | | | | | | | [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>
* qqmljs.g: deduplicate rulesFabian Kosmale2019-09-061-76/+32
| | | | | Change-Id: I9b6a9f95b838bbbf015c7619ae3a8828836e4178 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-09-052-42/+50
|\ | | | | | | Change-Id: Icc46cb06ac1dbe7097d11bc0db5813eb39fbf758
| * Allow semicolon after property declarationFabian Kosmale2019-09-031-7/+12
| | | | | | | | | | | | | | | | | | | | | | | | Most of the rules already had Semicolon at the end, however it was missing for UiScriptStatement, list properties and UiObjectInitializer. This change fixes the regression from 5.11.3 to 5.12.0, and keeps the behavior consistent. Fixes: QTBUG-77954 Change-Id: I45ef35fab399e3f971444b96d4a9ec6a99e29e09 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
| * Visit lists iteratively when parsing QMLUlf Hermann2019-09-021-35/+38
| | | | | | | | | | | | | | Change-Id: I243d12b75a07ac04560b444c326bff77d0dc642c Fixes: QTBUG-74087 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | qqmljs.g: reduce number of conflictsFabian Kosmale2019-09-032-62/+91
| | | | | | | | | | | | | | | | | | | | | | | | First, let the lexer create a T_FUNCTION_STAR token for "function *", which makes the job of the parser significantly easier. Then, by using GeneratorDeclaration instead of GeneratorExpression, we can avoid the conflicts between UiObjectMember and PrimaryExpression Change-Id: Ib08918e3977ed1a80cdea0948da80bf37886f7de Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | Visit lists iteratively when determining source locations in QMLFabian Kosmale2019-09-031-17/+44
| | | | | | | | | | Change-Id: I35d44de09f9d4133eb82490a1edb57eb374ff2f1 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* | qqmljs.g: reduce number of conflictsFabian Kosmale2019-08-291-0/+1
|/ | | | | | | | | | | | | Use right associativity to tell the parser to shift directly when encountering an else statement. This is the wanted behavior, as the "else" should be associated with the last "if" statement. This removes one more shift/reduce conflict in the grammar. See also https://stackoverflow.com/a/12734499 (qlalr behaves like Bison/Yacc here). Change-Id: Id29f00b5a2862fdb3399e4c8a183eda2ed328ba4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Support top level generator functionsFabian Kosmale2019-07-232-2/+10
| | | | | | | | | | | | | 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>
* QML Grammar: deduplicate semicolon rulesFabian Kosmale2019-07-151-52/+29
| | | | | | | | | | There were quite a few rules which were essentially the same, only differing in whether they matched T_SEMICOLON or T_AUTOMATIC_SEMICOLON By introducing a new rule, we can match both at the same time Change-Id: I46391e310e44ffa8bea03304a9c0726ffc872211 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Split compiler and runtime more clearlyUlf Hermann2019-07-111-1/+0
| | | | | | | | 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>