Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmltypecompiler.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5
6#include <private/qqmlobjectcreator_p.h>
7#include <private/qqmlcustomparser_p.h>
8#include <private/qqmlvmemetaobject_p.h>
9#include <private/qqmlcomponent_p.h>
10#include <private/qqmlpropertyresolver_p.h>
11#include <private/qqmlcomponentandaliasresolver_p.h>
12#include <private/qqmlsignalnames_p.h>
13
14#define COMPILE_EXCEPTION(token, desc)
15 {
16 recordError((token)->location, desc);
17 return false;
18 }
19
21
22DEFINE_BOOL_CONFIG_OPTION(
23 disableInternalDeferredProperties, QML_DISABLE_INTERNAL_DEFERRED_PROPERTIES);
24
25Q_LOGGING_CATEGORY(lcQmlTypeCompiler, "qt.qml.typecompiler");
26
27QQmlTypeCompiler::QQmlTypeCompiler(
28 QQmlTypeLoader *typeLoader, QQmlTypeData *typeData, QmlIR::Document *parsedQML,
29 QV4::CompiledData::ResolvedTypeReferenceMap *resolvedTypeCache,
30 const QV4::CompiledData::DependentTypesHasher &dependencyHasher)
31 : resolvedTypes(resolvedTypeCache)
32 , loader(typeLoader)
33 , dependencyHasher(dependencyHasher)
34 , document(parsedQML)
35 , typeData(typeData)
36{
37}
38
40{
41 // Build property caches and VME meta object data
42
43 for (auto it = resolvedTypes->constBegin(), end = resolvedTypes->constEnd();
44 it != end; ++it) {
45 QQmlCustomParser *customParser = (*it)->type().customParser();
46 if (customParser)
47 customParsers.insert(it.key(), customParser);
48 }
49
50 QQmlPendingGroupPropertyBindings pendingGroupPropertyBindings;
51
52
53 {
54 QQmlPropertyCacheCreator<QQmlTypeCompiler> propertyCacheBuilder(
55 &m_propertyCaches, &pendingGroupPropertyBindings,
56 loader, this, imports(), typeData->typeClassName());
57 QQmlError cycleError = propertyCacheBuilder.verifyNoICCycle();
58 if (cycleError.isValid()) {
59 recordError(cycleError);
60 return nullptr;
61 }
62 QQmlPropertyCacheCreatorBase::IncrementalResult result;
63 do {
64 result = propertyCacheBuilder.buildMetaObjectsIncrementally();
65 const QQmlError &error = result.error;
66 if (error.isValid()) {
67 recordError(error);
68 return nullptr;
69 } else {
70 // Resolve component boundaries and aliases
71
72 QQmlComponentAndAliasResolver resolver(this, &m_propertyCaches);
73 if (QQmlError error = resolver.resolve(result.processedRoot); error.isValid()) {
74 recordError(error);
75 return nullptr;
76 }
77 pendingGroupPropertyBindings.resolveMissingPropertyCaches(&m_propertyCaches);
78 pendingGroupPropertyBindings.clear(); // anything that can be processed is now processed
79 }
80 } while (result.canResume);
81 }
82
83 {
86 }
87
88 {
89 SignalHandlerResolver converter(this);
91 return nullptr;
92 }
93
94 {
95 QQmlEnumTypeResolver enumResolver(this);
96 if (!enumResolver.resolveEnumBindings())
97 return nullptr;
98 }
99
100 {
103 }
104
105 {
106 QQmlAliasAnnotator annotator(this);
108 }
109
110 {
111 QQmlDeferredAndCustomParserBindingScanner deferredAndCustomParserBindingScanner(this);
112 if (!deferredAndCustomParserBindingScanner.scanObject())
113 return nullptr;
114 }
115
116 if (!document->javaScriptCompilationUnit || !document->javaScriptCompilationUnit->unitData()) {
117 // Compile JS binding expressions and signal handlers if necessary
118 {
119 // We can compile script strings ahead of time, but they must be compiled
120 // without type optimizations as their scope is always entirely dynamic.
122 sss.scan();
123 }
124
125 Q_ASSERT(document->jsModule.fileName == typeData->urlString());
126 Q_ASSERT(document->jsModule.finalUrl == typeData->finalUrlString());
127 QmlIR::JSCodeGen v4CodeGenerator(document);
128 for (QmlIR::Object *object : std::as_const(document->objects)) {
129 if (!v4CodeGenerator.generateRuntimeFunctions(object)) {
130 Q_ASSERT(v4CodeGenerator.hasError());
131 recordError(v4CodeGenerator.error());
132 return nullptr;
133 }
134 }
135 document->javaScriptCompilationUnit = v4CodeGenerator.generateCompilationUnit(/*generated unit data*/false);
136 }
137
138 // Generate QML compiled type data structures
139
140 QmlIR::QmlUnitGenerator qmlGenerator;
141 qmlGenerator.generate(*document, dependencyHasher);
142
143 if (!errors.isEmpty())
144 return nullptr;
145
146 return std::move(document->javaScriptCompilationUnit);
147}
148
149void QQmlTypeCompiler::recordError(const QV4::CompiledData::Location &location, const QString &description)
150{
151 QQmlError error;
152 error.setLine(qmlConvertSourceCoordinate<quint32, int>(location.line()));
153 error.setColumn(qmlConvertSourceCoordinate<quint32, int>(location.column()));
154 error.setDescription(description);
155 error.setUrl(url());
156 errors << error;
157}
158
159void QQmlTypeCompiler::recordError(const QQmlJS::DiagnosticMessage &message)
160{
161 QQmlError error;
162 error.setDescription(message.message);
163 error.setLine(qmlConvertSourceCoordinate<quint32, int>(message.loc.startLine));
164 error.setColumn(qmlConvertSourceCoordinate<quint32, int>(message.loc.startColumn));
165 error.setUrl(url());
166 errors << error;
167}
168
169void QQmlTypeCompiler::recordError(const QQmlError &e)
170{
171 QQmlError error = e;
172 error.setUrl(url());
173 errors << error;
174}
175
177{
178 return document->stringAt(idx);
179}
180
181int QQmlTypeCompiler::registerString(const QString &str)
182{
183 return document->jsGenerator.registerString(str);
184}
185
186int QQmlTypeCompiler::registerConstant(QV4::ReturnedValue v)
187{
188 return document->jsGenerator.registerConstant(v);
189}
190
192{
193 return document->javaScriptCompilationUnit->unitData();
194}
195
196const QQmlImports *QQmlTypeCompiler::imports() const
197{
198 return typeData->imports();
199}
200
202{
203 return &document->objects;
204}
205
207{
208 return &m_propertyCaches;
209}
210
212{
213 return &m_propertyCaches;
214}
215
217{
218 return document->jsParserEngine.pool();
219}
220
222{
223 return document->jsParserEngine.newStringRef(string);
224}
225
227{
228 return &document->jsGenerator.stringTable;
229}
230
231QString QQmlTypeCompiler::bindingAsString(const QmlIR::Object *object, int scriptIndex) const
232{
233 return object->bindingAsString(document, scriptIndex);
234}
235
236void QQmlTypeCompiler::addImport(const QString &module, const QString &qualifier, QTypeRevision version)
237{
238 const quint32 moduleIdx = registerString(module);
239 const quint32 qualifierIdx = registerString(qualifier);
240
241 for (int i = 0, count = document->imports.size(); i < count; ++i) {
242 const QV4::CompiledData::Import *existingImport = document->imports.at(i);
243 if (existingImport->type == QV4::CompiledData::Import::ImportLibrary
244 && existingImport->uriIndex == moduleIdx
245 && existingImport->qualifierIndex == qualifierIdx)
246 return;
247 }
248 auto pool = memoryPool();
249 QV4::CompiledData::Import *import = pool->New<QV4::CompiledData::Import>();
250 import->type = QV4::CompiledData::Import::ImportLibrary;
251 import->version = version;
252 import->uriIndex = moduleIdx;
253 import->qualifierIndex = qualifierIdx;
254 document->imports.append(import);
255}
256
257QQmlType QQmlTypeCompiler::qmlTypeForComponent(const QString &inlineComponentName) const
258{
259 return typeData->qmlType(inlineComponentName);
260}
261
263 : compiler(typeCompiler)
264{
265}
266
267SignalHandlerResolver::SignalHandlerResolver(QQmlTypeCompiler *typeCompiler)
268 : QQmlCompilePass(typeCompiler)
269 , typeLoader(typeCompiler->typeLoader())
270 , qmlObjects(*typeCompiler->qmlObjects())
271 , imports(typeCompiler->imports())
272 , customParsers(typeCompiler->customParserCache())
273 , propertyCaches(typeCompiler->propertyCaches())
274{
275}
276
278{
279 for (int objectIndex = 0; objectIndex < qmlObjects.size(); ++objectIndex) {
280 const QmlIR::Object * const obj = qmlObjects.at(objectIndex);
281 QQmlPropertyCache::ConstPtr cache = propertyCaches->at(objectIndex);
282 if (!cache)
283 continue;
284 if (QQmlCustomParser *customParser = customParsers.value(obj->inheritedTypeNameIndex)) {
285 if (!(customParser->flags() & QQmlCustomParser::AcceptsSignalHandlers))
286 continue;
287 }
288 const QString elementName = stringAt(obj->inheritedTypeNameIndex);
289 if (!resolveSignalHandlerExpressions(obj, elementName, cache))
290 return false;
291 }
292 return true;
293}
294
295bool SignalHandlerResolver::resolveSignalHandlerExpressions(
296 const QmlIR::Object *obj, const QString &typeName,
297 const QQmlPropertyCache::ConstPtr &propertyCache,
298 QQmlPropertyResolver::RevisionCheck checkRevision)
299{
300 // map from signal name defined in qml itself to list of parameters
301 QHash<QString, QStringList> customSignals;
302
303 for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
304 const QString bindingPropertyName = stringAt(binding->propertyNameIndex);
305 // Attached property?
306 const QV4::CompiledData::Binding::Type bindingType = binding->type();
307 if (bindingType == QV4::CompiledData::Binding::Type_AttachedProperty) {
308 const QmlIR::Object *attachedObj = qmlObjects.at(binding->value.objectIndex);
309 auto *typeRef = resolvedType(binding->propertyNameIndex);
310 QQmlType type = typeRef ? typeRef->type() : QQmlType();
311 if (!type.isValid())
312 imports->resolveType(typeLoader, bindingPropertyName, &type, nullptr, nullptr);
313
314 const QMetaObject *attachedType = type.attachedPropertiesType(typeLoader);
315 if (!attachedType)
316 COMPILE_EXCEPTION(binding, tr("Non-existent attached object"));
317 QQmlPropertyCache::ConstPtr cache = QQmlMetaType::propertyCache(attachedType);
318
319 // Ignore revisions of signals on attached objects. They are not unqualified.
320 if (!resolveSignalHandlerExpressions(
321 attachedObj, bindingPropertyName, cache,
322 QQmlPropertyResolver::IgnoreRevision)) {
323 return false;
324 }
325
326 continue;
327 }
328
329 QString qPropertyName;
330 QString signalName;
331 if (auto propertyName =
332 QQmlSignalNames::changedHandlerNameToPropertyName(bindingPropertyName)) {
333 qPropertyName = *propertyName;
334 signalName = *QQmlSignalNames::changedHandlerNameToSignalName(bindingPropertyName);
335 } else {
336 signalName = QQmlSignalNames::handlerNameToSignalName(bindingPropertyName)
337 .value_or(QString());
338 }
339 if (signalName.isEmpty())
340 continue;
341
342 QQmlPropertyResolver resolver(propertyCache);
343
344 bool notInRevision = false;
345 const QQmlPropertyData *const signal
346 = resolver.signal(signalName, &notInRevision, checkRevision);
347 const QQmlPropertyData *const signalPropertyData
348 = resolver.property(signalName, /*notInRevision ptr*/nullptr, checkRevision);
349 const QQmlPropertyData *const qPropertyData = !qPropertyName.isEmpty()
350 ? resolver.property(qPropertyName, nullptr, checkRevision)
351 : nullptr;
352 QString finalSignalHandlerPropertyName = signalName;
353 QV4::CompiledData::Binding::Flag flag
354 = QV4::CompiledData::Binding::IsSignalHandlerExpression;
355
356 const bool isPropertyObserver
357 = !signalPropertyData && qPropertyData && qPropertyData->notifiesViaBindable();
358 if (signal && !(qPropertyData && qPropertyData->isAlias() && isPropertyObserver)) {
359 int sigIndex = propertyCache->methodIndexToSignalIndex(signal->coreIndex());
360 sigIndex = propertyCache->originalClone(sigIndex);
361
362 bool unnamedParameter = false;
363
364 QList<QByteArray> parameterNames = propertyCache->signalParameterNames(sigIndex);
365 for (int i = 0; i < parameterNames.size(); ++i) {
366 const QString param = QString::fromUtf8(parameterNames.at(i));
367 if (param.isEmpty())
368 unnamedParameter = true;
369 else if (unnamedParameter) {
370 COMPILE_EXCEPTION(binding, tr("Signal uses unnamed parameter followed by named parameter."));
371 } else if (QV4::Compiler::Codegen::isNameGlobal(param)) {
372 COMPILE_EXCEPTION(binding, tr("Signal parameter \"%1\" hides global variable.").arg(param));
373 }
374 }
375 } else if (isPropertyObserver) {
376 finalSignalHandlerPropertyName = qPropertyName;
377 flag = QV4::CompiledData::Binding::IsPropertyObserver;
378 } else {
379 if (notInRevision) {
380 // Try assinging it as a property later
381 if (signalPropertyData)
382 continue;
383
384 const QString &originalPropertyName = stringAt(binding->propertyNameIndex);
385
386 auto *typeRef = resolvedType(obj->inheritedTypeNameIndex);
387 const QQmlType type = typeRef ? typeRef->type() : QQmlType();
388 if (type.isValid()) {
389 COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available in %3 %4.%5.")
390 .arg(typeName).arg(originalPropertyName).arg(type.module())
391 .arg(type.version().majorVersion())
392 .arg(type.version().minorVersion()));
393 } else {
394 COMPILE_EXCEPTION(binding, tr("\"%1.%2\" is not available due to component versioning.").arg(typeName).arg(originalPropertyName));
395 }
396 }
397
398 // Try to look up the signal parameter names in the object itself
399
400 // build cache if necessary
401 if (customSignals.isEmpty()) {
402 for (const QmlIR::Signal *signal = obj->firstSignal(); signal; signal = signal->next) {
403 const QString &signalName = stringAt(signal->nameIndex);
404 customSignals.insert(signalName, signal->parameterStringList(compiler->stringPool()));
405 }
406
407 for (const QmlIR::Property *property = obj->firstProperty(); property; property = property->next) {
408 const QString propName = stringAt(property->nameIndex());
409 customSignals.insert(propName, QStringList());
410 }
411 }
412
413 QHash<QString, QStringList>::ConstIterator entry = customSignals.constFind(signalName);
414 if (entry == customSignals.constEnd() && !qPropertyName.isEmpty())
415 entry = customSignals.constFind(qPropertyName);
416
417 if (entry == customSignals.constEnd()) {
418 // Can't find even a custom signal, then just don't do anything and try
419 // keeping the binding as a regular property assignment.
420 continue;
421 }
422 }
423
424 // Binding object to signal means connect the signal to the object's default method.
425 if (bindingType == QV4::CompiledData::Binding::Type_Object) {
426 binding->setFlag(QV4::CompiledData::Binding::IsSignalHandlerObject);
427 continue;
428 }
429
430 if (bindingType != QV4::CompiledData::Binding::Type_Script) {
431 if (bindingType < QV4::CompiledData::Binding::Type_Script) {
432 COMPILE_EXCEPTION(binding, tr("Cannot assign a value to a signal (expecting a script to be run)"));
433 } else {
434 COMPILE_EXCEPTION(binding, tr("Incorrectly specified signal assignment"));
435 }
436 }
437
438 binding->propertyNameIndex = compiler->registerString(finalSignalHandlerPropertyName);
439 binding->setFlag(flag);
440 }
441 return true;
442}
443
444QQmlEnumTypeResolver::QQmlEnumTypeResolver(QQmlTypeCompiler *typeCompiler)
445 : QQmlCompilePass(typeCompiler)
446 , qmlObjects(*typeCompiler->qmlObjects())
447 , propertyCaches(typeCompiler->propertyCaches())
448 , imports(typeCompiler->imports())
449{
450}
451
453{
454 for (int i = 0; i < qmlObjects.size(); ++i) {
455 QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
456 if (!propertyCache)
457 continue;
458 const QmlIR::Object *obj = qmlObjects.at(i);
459
460 QQmlPropertyResolver resolver(propertyCache);
461
462 for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
463 const QV4::CompiledData::Binding::Flags bindingFlags = binding->flags();
464 if (bindingFlags & QV4::CompiledData::Binding::IsSignalHandlerExpression
465 || bindingFlags & QV4::CompiledData::Binding::IsSignalHandlerObject
466 || bindingFlags & QV4::CompiledData::Binding::IsPropertyObserver)
467 continue;
468
469 if (binding->type() != QV4::CompiledData::Binding::Type_Script)
470 continue;
471
472 const QString propertyName = stringAt(binding->propertyNameIndex);
473 bool notInRevision = false;
474 const QQmlPropertyData *pd = resolver.property(propertyName, &notInRevision);
475 if (!pd || pd->isQList())
476 continue;
477
478 if (!pd->isEnum() && pd->propType().id() != QMetaType::Int)
479 continue;
480
481 if (!tryQualifiedEnumAssignment(obj, propertyCache, pd, binding))
482 return false;
483 }
484 }
485
486 return true;
487}
488
489bool QQmlEnumTypeResolver::assignEnumToBinding(QmlIR::Binding *binding, QStringView, int enumValue, bool)
490{
491 binding->setType(QV4::CompiledData::Binding::Type_Number);
492 binding->value.constantValueIndex = compiler->registerConstant(QV4::Encode((double)enumValue));
493// binding->setNumberValueInternal((double)enumValue);
494 binding->setFlag(QV4::CompiledData::Binding::IsResolvedEnum);
495 return true;
496}
497
498bool QQmlEnumTypeResolver::tryQualifiedEnumAssignment(
499 const QmlIR::Object *obj, const QQmlPropertyCache::ConstPtr &propertyCache,
500 const QQmlPropertyData *prop, QmlIR::Binding *binding)
501{
502 bool isIntProp = (prop->propType().id() == QMetaType::Int) && !prop->isEnum();
503 if (!prop->isEnum() && !isIntProp)
504 return true;
505
506 if (!prop->isWritable()
507 && !(binding->hasFlag(QV4::CompiledData::Binding::InitializerForReadOnlyDeclaration))) {
508 COMPILE_EXCEPTION(binding, tr("Invalid property assignment: \"%1\" is a read-only property")
509 .arg(stringAt(binding->propertyNameIndex)));
510 }
511
512 Q_ASSERT(binding->type() == QV4::CompiledData::Binding::Type_Script);
513 const QString string = compiler->bindingAsString(obj, binding->value.compiledScriptIndex);
514 if (!string.constData()->isUpper())
515 return true;
516
517 // reject any "complex" expression (even simple arithmetic)
518 // we do this by excluding everything that is not part of a
519 // valid identifier or a dot
520 for (const QChar &c : string)
521 if (!(c.isLetterOrNumber() || c == u'.' || c == u'_' || c.isSpace()))
522 return true;
523
524 // we support one or two '.' in the enum phrase:
525 // * <TypeName>.<EnumValue>
526 // * <TypeName>.<ScopedEnumName>.<EnumValue>
527
528 int dot = string.indexOf(QLatin1Char('.'));
529 if (dot == -1 || dot == string.size()-1)
530 return true;
531
532 int dot2 = string.indexOf(QLatin1Char('.'), dot+1);
533 if (dot2 != -1 && dot2 != string.size()-1) {
534 if (!string.at(dot+1).isUpper())
535 return true;
536 if (string.indexOf(QLatin1Char('.'), dot2+1) != -1)
537 return true;
538 }
539
540 QHashedStringRef typeName(string.constData(), dot);
541 const bool isQtObject = (typeName == QLatin1String("Qt"));
542 const QStringView scopedEnumName = (dot2 != -1 ? QStringView{string}.mid(dot + 1, dot2 - dot - 1) : QStringView());
543 // ### consider supporting scoped enums in Qt namespace
544 const QStringView enumValue = QStringView{string}.mid(!isQtObject && dot2 != -1 ? dot2 + 1 : dot + 1);
545
546 if (isIntProp) { // ### C++11 allows enums to be other integral types. Should we support other integral types here?
547 // Allow enum assignment to ints.
548 bool ok;
549 int enumval = evaluateEnum(typeName.toString(), scopedEnumName, enumValue, &ok);
550 if (ok) {
551 if (!assignEnumToBinding(binding, enumValue, enumval, isQtObject))
552 return false;
553 }
554 return true;
555 }
556 QQmlType type;
557 imports->resolveType(compiler->typeLoader(), typeName, &type, nullptr, nullptr);
558
559 if (!type.isValid() && !isQtObject)
560 return true;
561
562 int value = 0;
563 bool ok = false;
564
565 auto *tr = resolvedType(obj->inheritedTypeNameIndex);
566
567 // When these two match, we can short cut the search, unless...
568 bool useFastPath = type.isValid() && tr && tr->type() == type;
569 QMetaProperty mprop;
570 QMetaEnum menum;
571 if (useFastPath) {
572 mprop = propertyCache->firstCppMetaObject()->property(prop->coreIndex());
573 menum = mprop.enumerator();
574 // ...the enumerator merely comes from a related metaobject, but the enum scope does not match
575 // the typename we resolved
576 if (!menum.isScoped() && scopedEnumName.isEmpty() && typeName != QString::fromUtf8(menum.scope()))
577 useFastPath = false;;
578 }
579 if (useFastPath) {
580 QByteArray enumName = enumValue.toUtf8();
581 if (menum.isScoped() && !scopedEnumName.isEmpty() && enumName != scopedEnumName.toUtf8())
582 return true;
583
584 if (mprop.isFlagType()) {
585 value = menum.keysToValue(enumName.constData(), &ok);
586 } else {
587 value = menum.keyToValue(enumName.constData(), &ok);
588 }
589 } else {
590 // Otherwise we have to search the whole type
591 if (type.isValid()) {
592 if (!scopedEnumName.isEmpty()) {
593 value = type.scopedEnumValue(
594 compiler->typeLoader(), scopedEnumName, enumValue, &ok);
595 } else {
596 value = type.enumValue(compiler->typeLoader(), QHashedStringRef(enumValue), &ok);
597 }
598 } else {
599 QByteArray enumName = enumValue.toUtf8();
600 const QMetaObject *metaObject = &Qt::staticMetaObject;
601 for (int ii = metaObject->enumeratorCount() - 1; !ok && ii >= 0; --ii) {
602 QMetaEnum e = metaObject->enumerator(ii);
603 value = e.keyToValue(enumName.constData(), &ok);
604 }
605 }
606 }
607
608 if (!ok)
609 return true;
610
611 return assignEnumToBinding(binding, enumValue, value, isQtObject);
612}
613
614int QQmlEnumTypeResolver::evaluateEnum(const QString &scope, QStringView enumName, QStringView enumValue, bool *ok) const
615{
616 Q_ASSERT_X(ok, "QQmlEnumTypeResolver::evaluateEnum", "ok must not be a null pointer");
617 *ok = false;
618
619 if (scope != QLatin1String("Qt")) {
620 QQmlType type;
621 imports->resolveType(compiler->typeLoader(), scope, &type, nullptr, nullptr);
622 if (!type.isValid())
623 return -1;
624 if (!enumName.isEmpty())
625 return type.scopedEnumValue(compiler->typeLoader(), enumName, enumValue, ok);
626 return type.enumValue(
627 compiler->typeLoader(),
628 QHashedStringRef(enumValue.constData(), enumValue.size()), ok);
629 }
630
631 const QMetaObject *mo = &Qt::staticMetaObject;
632 int i = mo->enumeratorCount();
633 const QByteArray ba = enumValue.toUtf8();
634 while (i--) {
635 int v = mo->enumerator(i).keyToValue(ba.constData(), ok);
636 if (*ok)
637 return v;
638 }
639 return -1;
640}
641
648
650{
651 scanObjectRecursively(/*root object*/0);
652 for (int i = 0; i < qmlObjects.size(); ++i)
653 if (qmlObjects.at(i)->flags & QV4::CompiledData::Object::IsInlineComponentRoot)
654 scanObjectRecursively(i);
655}
656
657void QQmlCustomParserScriptIndexer::scanObjectRecursively(int objectIndex, bool annotateScriptBindings)
658{
659 const QmlIR::Object * const obj = qmlObjects.at(objectIndex);
660 if (!annotateScriptBindings)
661 annotateScriptBindings = customParsers.contains(obj->inheritedTypeNameIndex);
662 for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
663 switch (binding->type()) {
664 case QV4::CompiledData::Binding::Type_Script:
665 if (annotateScriptBindings) {
666 binding->stringIndex = compiler->registerString(
667 compiler->bindingAsString(obj, binding->value.compiledScriptIndex));
668 }
669 break;
670 case QV4::CompiledData::Binding::Type_Object:
671 case QV4::CompiledData::Binding::Type_AttachedProperty:
672 case QV4::CompiledData::Binding::Type_GroupProperty:
673 scanObjectRecursively(binding->value.objectIndex, annotateScriptBindings);
674 break;
675 default:
676 break;
677 }
678 }
679}
680
687
689{
690 for (int i = 0; i < qmlObjects.size(); ++i) {
691 QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
692 if (!propertyCache)
693 continue;
694
695 const QmlIR::Object *obj = qmlObjects.at(i);
696
697 QQmlPropertyResolver resolver(propertyCache);
698 const QQmlPropertyData *defaultProperty = obj->indexOfDefaultPropertyOrAlias != -1 ? propertyCache->parent()->defaultProperty() : propertyCache->defaultProperty();
699
700 for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
701 if (!binding->isValueBinding())
702 continue;
703 bool notInRevision = false;
704 const QQmlPropertyData *pd = binding->propertyNameIndex != quint32(0) ? resolver.property(stringAt(binding->propertyNameIndex), &notInRevision) : defaultProperty;
705 if (pd && pd->isAlias())
706 binding->setFlag(QV4::CompiledData::Binding::IsBindingToAlias);
707 }
708 }
709}
710
718
720{
721 const QMetaType scriptStringMetaType = QMetaType::fromType<QQmlScriptString>();
722 for (int i = 0; i < qmlObjects.size(); ++i) {
723 QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(i);
724 if (!propertyCache)
725 continue;
726
727 const QmlIR::Object *obj = qmlObjects.at(i);
728
729 QQmlPropertyResolver resolver(propertyCache);
730 const QQmlPropertyData *defaultProperty = obj->indexOfDefaultPropertyOrAlias != -1 ? propertyCache->parent()->defaultProperty() : propertyCache->defaultProperty();
731
732 for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
733 if (binding->type() != QV4::CompiledData::Binding::Type_Script)
734 continue;
735 bool notInRevision = false;
736 const QQmlPropertyData *pd = binding->propertyNameIndex != quint32(0) ? resolver.property(stringAt(binding->propertyNameIndex), &notInRevision) : defaultProperty;
737 if (!pd || pd->propType() != scriptStringMetaType)
738 continue;
739
740 QString script = compiler->bindingAsString(obj, binding->value.compiledScriptIndex);
741 binding->stringIndex = compiler->registerString(script);
742 }
743 }
744}
745
746template<>
747void QQmlComponentAndAliasResolver<QQmlTypeCompiler>::allocateNamedObjects(
748 QmlIR::Object *object) const
749{
750 object->namedObjectsInComponent.allocate(m_compiler->memoryPool(), m_idToObjectIndex);
751}
752
753template<>
754bool QQmlComponentAndAliasResolver<QQmlTypeCompiler>::markAsComponent(int index) const
755{
756 m_compiler->qmlObjects()->at(index)->flags |= QV4::CompiledData::Object::IsComponent;
757 return true;
758}
759
760template<>
761void QQmlComponentAndAliasResolver<QQmlTypeCompiler>::setObjectId(int index) const
762{
763 m_compiler->qmlObjects()->at(index)->id = m_idToObjectIndex.size();
764}
765
766template<>
767bool QQmlComponentAndAliasResolver<QQmlTypeCompiler>::wrapImplicitComponent(QmlIR::Binding *binding)
768{
769 QQmlJS::MemoryPool *pool = m_compiler->memoryPool();
770 QVector<QmlIR::Object *> *qmlObjects = m_compiler->qmlObjects();
771
772 // emulate "import QML 1.0" and then wrap the component in "QML.Component {}"
773 QQmlType componentType = QQmlMetaType::qmlType(
774 &QQmlComponent::staticMetaObject, QStringLiteral("QML"),
775 QTypeRevision::fromVersion(1, 0));
776 Q_ASSERT(componentType.isValid());
777 const QString qualifier = QStringLiteral("QML");
778
779 m_compiler->addImport(componentType.module(), qualifier, componentType.version());
780
781 QmlIR::Object *syntheticComponent = pool->New<QmlIR::Object>();
782 syntheticComponent->init(
783 pool,
784 m_compiler->registerString(
785 qualifier + QLatin1Char('.') + componentType.elementName()),
786 m_compiler->registerString(QString()), binding->valueLocation);
787 syntheticComponent->flags |= QV4::CompiledData::Object::IsComponent;
788
789 if (!m_compiler->resolvedTypes->contains(syntheticComponent->inheritedTypeNameIndex)) {
790 auto typeRef = new QV4::ResolvedTypeReference;
791 typeRef->setType(componentType);
792 typeRef->setVersion(componentType.version());
793 m_compiler->resolvedTypes->insert(syntheticComponent->inheritedTypeNameIndex, typeRef);
794 }
795
796 qmlObjects->append(syntheticComponent);
797 const int componentIndex = qmlObjects->size() - 1;
798 // Keep property caches symmetric
799 QQmlPropertyCache::ConstPtr componentCache
800 = QQmlMetaType::propertyCache(&QQmlComponent::staticMetaObject);
801 m_propertyCaches->append(componentCache);
802
803 QmlIR::Binding *syntheticBinding = pool->New<QmlIR::Binding>();
804 *syntheticBinding = *binding;
805
806 // The synthetic binding inside Component has no name. It's just "Component { Foo {} }".
807 syntheticBinding->propertyNameIndex = 0;
808
809 syntheticBinding->setType(QV4::CompiledData::Binding::Type_Object);
810 QString error = syntheticComponent->appendBinding(syntheticBinding, /*isListBinding*/false);
811 Q_ASSERT(error.isEmpty());
812 Q_UNUSED(error);
813
814 binding->value.objectIndex = componentIndex;
815
816 m_componentRoots.append(componentIndex);
817 return true;
818}
819
820template<>
821void QQmlComponentAndAliasResolver<QQmlTypeCompiler>::resolveGeneralizedGroupProperty(
822 const CompiledObject &component, CompiledBinding *binding)
823{
824 Q_UNUSED(component);
825 // We cannot make it fail here. It might be a custom-parsed property
826 const int targetObjectIndex = m_idToObjectIndex.value(binding->propertyNameIndex, -1);
827 if (targetObjectIndex != -1)
828 m_propertyCaches->set(binding->value.objectIndex, m_propertyCaches->at(targetObjectIndex));
829}
830
831template<>
832typename QQmlComponentAndAliasResolver<QQmlTypeCompiler>::AliasResolutionResult
833QQmlComponentAndAliasResolver<QQmlTypeCompiler>::resolveAliasesInObject(
834 const CompiledObject &component, int objectIndex,
835 QQmlPropertyCacheAliasCreator<QQmlTypeCompiler> *aliasCacheCreator, QQmlError *error)
836{
837 // TODO: This method should not modify the aliases themselves. Rather, all information
838 // needed for handling them later should be stored in the property cache.
839 // Some of the information calculated here could be calculated already at compile time.
840 // See QTBUG-136572.
841
842 Q_UNUSED(component);
843
844 const QmlIR::Object * const obj = m_compiler->objectAt(objectIndex);
845 if (!obj->aliasCount())
846 return AllAliasesResolved;
847
848 int aliasIndex = 0;
849 int numSkippedAliases = 0;
850
851 for (QmlIR::Alias *alias = obj->firstAlias(); alias; alias = alias->next, ++aliasIndex) {
852 if (resolvedAliases.contains(alias)) {
853 ++numSkippedAliases;
854 continue;
855 }
856
857
858 const int idIndex = alias->idIndex();
859 const int targetObjectIndex = m_idToObjectIndex.value(idIndex, -1);
860 if (targetObjectIndex == -1) {
861 *error = qQmlCompileError(
862 alias->referenceLocation,
863 QQmlComponentAndAliasResolverBase::tr("Invalid alias reference. Unable to find id \"%1\"").arg(stringAt(idIndex)));
864 break;
865 }
866
867 const QmlIR::Object *targetObject = m_compiler->objectAt(targetObjectIndex);
868 Q_ASSERT(targetObject->id >= 0);
869 alias->setTargetObjectId(targetObject->id);
870 alias->setIsAliasToLocalAlias(false);
871
872 const QString aliasPropertyValue = stringAt(alias->propertyNameIndex);
873
874 QStringView property;
875 QStringView subProperty;
876
877 const int propertySeparator = aliasPropertyValue.indexOf(QLatin1Char('.'));
878 if (propertySeparator != -1) {
879 property = QStringView{aliasPropertyValue}.left(propertySeparator);
880 subProperty = QStringView{aliasPropertyValue}.mid(propertySeparator + 1);
881 } else
882 property = QStringView(aliasPropertyValue);
883
884 QQmlPropertyIndex propIdx;
885
886 if (property.isEmpty()) {
887 alias->setFlag(QV4::CompiledData::Alias::AliasPointsToPointerObject);
888 } else {
889 QQmlPropertyCache::ConstPtr targetCache = m_propertyCaches->at(targetObjectIndex);
890 if (!targetCache) {
891 *error = qQmlCompileError(
892 alias->referenceLocation,
893 QQmlComponentAndAliasResolverBase::tr("Invalid alias target location: %1").arg(property.toString()));
894 break;
895 }
896
897 QQmlPropertyResolver resolver(targetCache);
898
899 const QQmlPropertyData *targetProperty = resolver.property(
900 property.toString(), nullptr, QQmlPropertyResolver::IgnoreRevision);
901
902 // If it's an alias that we haven't resolved yet, try again later.
903 if (!targetProperty) {
904 bool aliasPointsToOtherAlias = false;
905 int localAliasIndex = 0;
906 for (auto targetAlias = targetObject->aliasesBegin(), end = targetObject->aliasesEnd(); targetAlias != end; ++targetAlias, ++localAliasIndex) {
907 if (stringAt(targetAlias->nameIndex()) == property) {
908 aliasPointsToOtherAlias = true;
909 break;
910 }
911 }
912 if (aliasPointsToOtherAlias) {
913 if (targetObjectIndex == objectIndex) {
914 alias->localAliasIndex = localAliasIndex;
915 alias->setIsAliasToLocalAlias(true);
916 if (!appendAliasToPropertyCache(
917 &component, alias, objectIndex, aliasIndex, -1,
918 aliasCacheCreator, error)) {
919 break;
920 }
921 continue;
922 }
923
924 // restore
925 alias->setIdIndex(idIndex);
926 // Try again later and resolve the target alias first.
927 return aliasIndex == numSkippedAliases ? NoAliasResolved : SomeAliasesResolved;
928 }
929 }
930
931 if (!targetProperty || targetProperty->coreIndex() > 0x0000FFFF) {
932 *error = qQmlCompileError(
933 alias->referenceLocation,
934 QQmlComponentAndAliasResolverBase::tr("Invalid alias target location: %1").arg(property.toString()));
935 break;
936 }
937
938 propIdx = QQmlPropertyIndex(targetProperty->coreIndex());
939
940 if (!subProperty.isEmpty()) {
941 const QMetaObject *valueTypeMetaObject = QQmlMetaType::metaObjectForValueType(targetProperty->propType());
942 if (!valueTypeMetaObject) {
943 // could be a deep alias
944 bool isDeepAlias = subProperty.at(0).isLower();
945 if (isDeepAlias) {
946 isDeepAlias = false;
947 for (auto it = targetObject->bindingsBegin(); it != targetObject->bindingsEnd(); ++it) {
948 auto binding = *it;
949 if (m_compiler->stringAt(binding.propertyNameIndex) == property) {
950 resolver = QQmlPropertyResolver(m_propertyCaches->at(binding.value.objectIndex));
951 const QQmlPropertyData *actualProperty = resolver.property(subProperty.toString());
952 if (actualProperty) {
953 propIdx = QQmlPropertyIndex(propIdx.coreIndex(), actualProperty->coreIndex());
954 isDeepAlias = true;
955 }
956 }
957 }
958 }
959 if (!isDeepAlias) {
960 *error = qQmlCompileError(
961 alias->referenceLocation,
962 QQmlComponentAndAliasResolverBase::tr("Invalid alias target location: %1").arg(subProperty.toString()));
963 break;
964 }
965 } else {
966
967 int valueTypeIndex =
968 valueTypeMetaObject->indexOfProperty(subProperty.toString().toUtf8().constData());
969 if (valueTypeIndex == -1) {
970 *error = qQmlCompileError(
971 alias->referenceLocation,
972 QQmlComponentAndAliasResolverBase::tr("Invalid alias target location: %1").arg(subProperty.toString()));
973 break;
974 }
975 Q_ASSERT(valueTypeIndex <= 0x0000FFFF);
976
977 propIdx = QQmlPropertyIndex(propIdx.coreIndex(), valueTypeIndex);
978 }
979 } else {
980 if (targetProperty->isQObject())
981 alias->setFlag(QV4::CompiledData::Alias::AliasPointsToPointerObject);
982 }
983 }
984
985 if (!appendAliasToPropertyCache(
986 &component, alias, objectIndex, aliasIndex, propIdx.toEncoded(),
987 aliasCacheCreator, error)) {
988 break;
989 }
990 }
991
992 if (numSkippedAliases == aliasIndex)
993 return NoAliasResolved;
994
995 if (aliasIndex == obj->aliasCount())
996 return AllAliasesResolved;
997
998 return SomeAliasesResolved;
999}
1000
1001QQmlDeferredAndCustomParserBindingScanner::QQmlDeferredAndCustomParserBindingScanner(QQmlTypeCompiler *typeCompiler)
1002 : QQmlCompilePass(typeCompiler)
1003 , qmlObjects(typeCompiler->qmlObjects())
1004 , propertyCaches(typeCompiler->propertyCaches())
1005 , customParsers(typeCompiler->customParserCache())
1006 , _seenObjectWithId(false)
1007{
1008}
1009
1011{
1012 for (int i = 0; i < qmlObjects->size(); ++i) {
1013 if ((qmlObjects->at(i)->flags & QV4::CompiledData::Object::IsInlineComponentRoot)
1014 && !scanObject(i, ScopeDeferred::False)) {
1015 return false;
1016 }
1017 }
1018 return scanObject(/*root object*/0, ScopeDeferred::False);
1019}
1020
1022 int objectIndex, ScopeDeferred scopeDeferred)
1023{
1024 using namespace QV4::CompiledData;
1025
1026 QmlIR::Object *obj = qmlObjects->at(objectIndex);
1027 if (obj->idNameIndex != 0)
1028 _seenObjectWithId = true;
1029
1030 if (obj->flags & Object::IsComponent) {
1031 Q_ASSERT(obj->bindingCount() == 1);
1032 const Binding *componentBinding = obj->firstBinding();
1033 Q_ASSERT(componentBinding->type() == Binding::Type_Object);
1034 // Components are separate from their surrounding scope. They cannot be deferred.
1035 return scanObject(componentBinding->value.objectIndex, ScopeDeferred::False);
1036 }
1037
1038 QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(objectIndex);
1039 if (!propertyCache)
1040 return true;
1041
1042 QString defaultPropertyName;
1043 const QQmlPropertyData *defaultProperty = nullptr;
1044 if (obj->indexOfDefaultPropertyOrAlias != -1) {
1045 const QQmlPropertyCache *cache = propertyCache->parent().data();
1046 defaultPropertyName = cache->defaultPropertyName();
1047 defaultProperty = cache->defaultProperty();
1048 } else {
1049 defaultPropertyName = propertyCache->defaultPropertyName();
1050 defaultProperty = propertyCache->defaultProperty();
1051 }
1052
1053 QQmlCustomParser *customParser = customParsers.value(obj->inheritedTypeNameIndex);
1054
1055 QQmlPropertyResolver propertyResolver(propertyCache);
1056
1057 QStringList deferredPropertyNames;
1058 QStringList immediatePropertyNames;
1059 {
1060 const QMetaObject *mo = propertyCache->firstCppMetaObject();
1061 const int deferredNamesIndex = mo->indexOfClassInfo("DeferredPropertyNames");
1062 const int immediateNamesIndex = mo->indexOfClassInfo("ImmediatePropertyNames");
1063 if (deferredNamesIndex != -1) {
1064 if (immediateNamesIndex != -1) {
1065 COMPILE_EXCEPTION(obj, tr("You cannot define both DeferredPropertyNames and "
1066 "ImmediatePropertyNames on the same type."));
1067 }
1068 const QMetaClassInfo classInfo = mo->classInfo(deferredNamesIndex);
1069 deferredPropertyNames = QString::fromUtf8(classInfo.value()).split(u',');
1070 } else if (immediateNamesIndex != -1) {
1071 const QMetaClassInfo classInfo = mo->classInfo(immediateNamesIndex);
1072 immediatePropertyNames = QString::fromUtf8(classInfo.value()).split(u',');
1073
1074 // If the property contains an empty string, all properties shall be deferred.
1075 if (immediatePropertyNames.isEmpty())
1076 immediatePropertyNames.append(QString());
1077 }
1078 }
1079
1080 for (QmlIR::Binding *binding = obj->firstBinding(); binding; binding = binding->next) {
1081 QString name = stringAt(binding->propertyNameIndex);
1082
1083 if (customParser) {
1084 if (binding->type() == Binding::Type_AttachedProperty) {
1085 if (customParser->flags() & QQmlCustomParser::AcceptsAttachedProperties) {
1086 binding->setFlag(Binding::IsCustomParserBinding);
1087 obj->flags |= Object::HasCustomParserBindings;
1088 continue;
1089 }
1090 } else if (QQmlSignalNames::isHandlerName(name)
1091 && !(customParser->flags() & QQmlCustomParser::AcceptsSignalHandlers)) {
1092 obj->flags |= Object::HasCustomParserBindings;
1093 binding->setFlag(Binding::IsCustomParserBinding);
1094 continue;
1095 }
1096 }
1097
1098 const bool hasPropertyData = [&]() {
1099 if (name.isEmpty()) {
1100 name = defaultPropertyName;
1101 if (defaultProperty)
1102 return true;
1103 } else if (name.constData()->isUpper()) {
1104 // Upper case names cannot be custom-parsed unless they are attached properties
1105 // and the custom parser explicitly accepts them. See above for that case.
1106 return false;
1107 } else {
1108 bool notInRevision = false;
1109 if (propertyResolver.property(
1110 name, &notInRevision, QQmlPropertyResolver::CheckRevision)) {
1111 return true;
1112 }
1113 }
1114
1115 if (!customParser)
1116 return false;
1117
1118 const Binding::Flags bindingFlags = binding->flags();
1119 if (bindingFlags & Binding::IsSignalHandlerExpression
1120 || bindingFlags & Binding::IsSignalHandlerObject
1121 || bindingFlags & Binding::IsPropertyObserver) {
1122 // These signal handlers cannot be custom-parsed. We have already established
1123 // that the signal exists.
1124 return false;
1125 }
1126
1127 // If the property isn't found, we may want to custom-parse the binding.
1128 obj->flags |= Object::HasCustomParserBindings;
1129 binding->setFlag(Binding::IsCustomParserBinding);
1130 return false;
1131 }();
1132
1133 bool seenSubObjectWithId = false;
1134 bool isExternal = false;
1135 if (binding->type() >= Binding::Type_Object) {
1136 const bool isOwnProperty = hasPropertyData || binding->isAttachedProperty();
1137 isExternal = !isOwnProperty && binding->isGroupProperty();
1138 if (isOwnProperty || isExternal) {
1139 qSwap(_seenObjectWithId, seenSubObjectWithId);
1140 const bool subObjectValid = scanObject(
1141 binding->value.objectIndex,
1142 (isExternal || scopeDeferred == ScopeDeferred::True)
1143 ? ScopeDeferred::True
1144 : ScopeDeferred::False);
1145 qSwap(_seenObjectWithId, seenSubObjectWithId);
1146 if (!subObjectValid)
1147 return false;
1148 _seenObjectWithId |= seenSubObjectWithId;
1149 }
1150 }
1151
1152 bool isDeferred = false;
1153 if (!immediatePropertyNames.isEmpty() && !immediatePropertyNames.contains(name)) {
1154 if (seenSubObjectWithId) {
1155 COMPILE_EXCEPTION(binding, tr("You cannot assign an id to an object assigned "
1156 "to a deferred property."));
1157 }
1158 if (isExternal || !disableInternalDeferredProperties())
1159 isDeferred = true;
1160 } else if (!deferredPropertyNames.isEmpty() && deferredPropertyNames.contains(name)) {
1161 if (!seenSubObjectWithId && binding->type() != Binding::Type_GroupProperty) {
1162 if (isExternal || !disableInternalDeferredProperties())
1163 isDeferred = true;
1164 }
1165 }
1166
1167 if (binding->type() >= Binding::Type_Object) {
1168 if (isExternal && !isDeferred && !customParser) {
1170 binding, tr("Cannot assign to non-existent property \"%1\"").arg(name));
1171 }
1172 }
1173
1174 if (isDeferred) {
1175 binding->setFlag(Binding::IsDeferredBinding);
1176 obj->flags |= Object::HasDeferredBindings;
1177 }
1178 }
1179
1180 return true;
1181}
1182
1190
1192{
1193 for (int i = 0; i < qmlObjects.size(); ++i)
1194 mergeDefaultProperties(i);
1195}
1196
1197void QQmlDefaultPropertyMerger::mergeDefaultProperties(int objectIndex)
1198{
1199 QQmlPropertyCache::ConstPtr propertyCache = propertyCaches->at(objectIndex);
1200 if (!propertyCache)
1201 return;
1202
1203 QmlIR::Object *object = qmlObjects.at(objectIndex);
1204
1205 QString defaultProperty = object->indexOfDefaultPropertyOrAlias != -1 ? propertyCache->parent()->defaultPropertyName() : propertyCache->defaultPropertyName();
1206 QmlIR::Binding *bindingsToReinsert = nullptr;
1207 QmlIR::Binding *tail = nullptr;
1208
1209 QmlIR::Binding *previousBinding = nullptr;
1210 QmlIR::Binding *binding = object->firstBinding();
1211 while (binding) {
1212 if (binding->propertyNameIndex == quint32(0) || stringAt(binding->propertyNameIndex) != defaultProperty) {
1213 previousBinding = binding;
1214 binding = binding->next;
1215 continue;
1216 }
1217
1218 QmlIR::Binding *toReinsert = binding;
1219 binding = object->unlinkBinding(previousBinding, binding);
1220
1221 if (!tail) {
1222 bindingsToReinsert = toReinsert;
1223 tail = toReinsert;
1224 } else {
1225 tail->next = toReinsert;
1226 tail = tail->next;
1227 }
1228 tail->next = nullptr;
1229 }
1230
1231 binding = bindingsToReinsert;
1232 while (binding) {
1233 QmlIR::Binding *toReinsert = binding;
1234 binding = binding->next;
1235 object->insertSorted(toReinsert);
1236 }
1237}
1238
1239QT_END_NAMESPACE
QQmlAliasAnnotator(QQmlTypeCompiler *typeCompiler)
QQmlCustomParserScriptIndexer(QQmlTypeCompiler *typeCompiler)
QQmlDefaultPropertyMerger(QQmlTypeCompiler *typeCompiler)
QQmlScriptStringScanner(QQmlTypeCompiler *typeCompiler)
Definition qjsvalue.h:23
Q_LOGGING_CATEGORY(lcEventDispatcher, "qt.eventdispatcher")
#define COMPILE_EXCEPTION(location, desc)
QQmlCompilePass(QQmlTypeCompiler *typeCompiler)
QQmlTypeCompiler * compiler
int registerConstant(QV4::ReturnedValue v)
void recordError(const QQmlJS::DiagnosticMessage &message)
const QV4::CompiledData::Unit * qmlUnit() const
QQmlType qmlTypeForComponent(const QString &inlineComponentName=QString()) const
QQmlPropertyCacheVector * propertyCaches()
QQmlJS::MemoryPool * memoryPool()
void recordError(const QQmlError &e)
QString bindingAsString(const QmlIR::Object *object, int scriptIndex) const
const QQmlPropertyCacheVector * propertyCaches() const
int registerString(const QString &str)
const QV4::Compiler::StringTableGenerator * stringPool() const
void recordError(const QV4::CompiledData::Location &location, const QString &description)
QStringView newStringRef(const QString &string)
void addImport(const QString &module, const QString &qualifier, QTypeRevision version)
QQmlRefPointer< QV4::CompiledData::CompilationUnit > compile()
QVector< QmlIR::Object * > * qmlObjects() const
QString stringAt(int idx) const
const QQmlImports * imports() const