6#include <private/qv4staticvalue_p.h>
7#include <private/qv4compileddata_p.h>
8#include <private/qqmljsparser_p.h>
9#include <private/qqmljslexer_p.h>
10#include <private/qv4compilerscanfunctions_p.h>
11#include <QCoreApplication>
12#include <QCryptographicHash>
23#define COMPILE_EXCEPTION(location, desc) \
25 recordError(location, desc); \
29void Object::simplifyRequiredProperties() {
34 for (
auto it = this->requiredPropertyExtraDataBegin();
it != this->requiredPropertyExtraDataEnd(); ++
it)
38 for (
auto it = this->propertiesBegin();
it != this->propertiesEnd(); ++
it) {
39 auto requiredIt = required.
find(
it->nameIndex);
40 if (requiredIt != required.
end()) {
41 it->setIsRequired(
true);
42 required.
erase(requiredIt);
46 auto current = this->requiredPropertyExtraDatas->first;
48 if (required.
contains(current->nameIndex))
51 requiredPropertyExtraDatas->unlink(prev, current);
52 current = current->
next;
64 paramType->
set(listFlag, 0);
68 paramType->
set(listFlag, typeNameIndex);
72 static_cast<quint32>(builtinType));
79 static const struct TypeNameToType {
83 } propTypeNameToTypes[] = {
99 static const int propTypeNameToTypesCount =
sizeof(propTypeNameToTypes) /
100 sizeof(propTypeNameToTypes[0]);
102 for (
int typeIndex = 0; typeIndex < propTypeNameToTypesCount; ++typeIndex) {
103 const TypeNameToType *
t = propTypeNameToTypes + typeIndex;
137 for (
auto functionit =
obj->functionsBegin(); functionit !=
obj->functionsEnd(); ++functionit) {
139 errorLocation->
startLine =
f->location.line();
141 if (functionNames.
contains(
f->nameIndex))
142 return tr(
"Duplicate method name");
143 functionNames.
insert(
f->nameIndex);
145 for (
auto signalit =
obj->signalsBegin(); signalit !=
obj->signalsEnd(); ++signalit) {
147 if (
s->nameIndex ==
f->nameIndex)
148 return tr(
"Duplicate method name");
152 if (
name.at(0).isUpper())
153 return tr(
"Method names cannot begin with an upper case letter");
155 return tr(
"Illegal method name");
166 for (
Enum *
e = qmlEnums->first;
e;
e =
e->next) {
168 return tr(
"Duplicate scoped enum name");
171 target->qmlEnums->append(enumeration);
181 for (
Signal *
s = qmlSignals->first;
s;
s =
s->next) {
182 if (
s->nameIndex ==
signal->nameIndex)
183 return tr(
"Duplicate signal name");
198 return tr(
"Duplicate property name");
202 return tr(
"Property duplicates alias name");
205 return tr(
"Property names cannot begin with an upper case letter");
207 const int index =
target->properties->append(prop);
208 if (isDefaultProperty) {
209 if (
target->indexOfDefaultPropertyOrAlias != -1) {
210 *errorLocation = defaultToken;
211 return tr(
"Duplicate default property");
224 const auto aliasWithSameName = std::find_if(
target->aliases->begin(),
target->aliases->end(), [&alias](
const Alias &targetAlias){
225 return targetAlias.nameIndex() == alias->nameIndex();
227 if (aliasWithSameName !=
target->aliases->end())
228 return tr(
"Duplicate alias name");
230 const auto aliasSameAsProperty = std::find_if(
target->properties->begin(),
target->properties->end(), [&alias](
const Property &targetProp){
231 return targetProp.nameIndex == alias->nameIndex();
234 if (aliasSameAsProperty !=
target->properties->end())
235 return tr(
"Alias has same name as existing property");
238 return tr(
"Alias names cannot begin with an upper case letter");
242 if (isDefaultProperty) {
243 if (
target->indexOfDefaultPropertyOrAlias != -1) {
244 *errorLocation = defaultToken;
245 return tr(
"Duplicate default property");
248 target->defaultPropertyIsAlias =
true;
260 functions->append(
f);
265 inlineComponents->append(ic);
270 requiredPropertyExtraDatas->append(extraData);
275 const bool bindingToDefaultProperty = (
b->propertyNameIndex ==
quint32(0));
277 && !bindingToDefaultProperty
285 return tr(
"Property value set multiple times");
288 if (bindingToDefaultProperty)
291 bindings->prepend(
b);
298 if (
b->propertyNameIndex == nameIndex)
306 bindings->insertAfter(insertionPoint,
b);
314 node = exprStmt->expression;
330 : jsModule(debugMode)
332 , jsGenerator(&jsModule)
338 ,
engine(&doc->jsParserEngine)
339 , jsGenerator(&doc->jsGenerator)
354 import->location.set(lineNumber,
column);
365 import->location.set(lineNumber,
column);
370 : illegalNames(illegalNames)
372 , _propertyDeclaration(
nullptr)
385 QQmlJS::Parser parser(&
output->jsParserEngine);
387 const bool parseResult = parser.parse();
388 const auto diagnosticMessages = parser.diagnosticMessages();
389 if (!parseResult || !diagnosticMessages.isEmpty()) {
430 int rootObjectIndex = -1;
439 for (
auto object:
output->objects)
440 object->simplifyRequiredProperties();
447 if (
name.size() < 3)
return false;
450 for (
int i = 2;
i <
ns; ++
i) {
452 if (curr.
unicode() ==
'_')
continue;
453 if (curr.
isUpper())
return true;
462 QString signalNameCandidate = signalPropertyName;
463 signalNameCandidate.
remove(0, 2);
467 for (
int firstAlphaIndex = 0; firstAlphaIndex < signalNameCandidate.
size(); ++firstAlphaIndex) {
468 if (signalNameCandidate.
at(firstAlphaIndex).
isUpper()) {
469 signalNameCandidate[firstAlphaIndex] = signalNameCandidate.
at(firstAlphaIndex).
toLower();
470 return signalNameCandidate;
474 Q_UNREACHABLE_RETURN(
QString());
479 return QQmlJS::AST::Visitor::visit(ast);
500 lastId = lastId->
next;
544 auto inlineComponent = New<InlineComponent>();
546 inlineComponent->objectIndex = idx;
558 { location.startLine, location.startColumn }, node->
initializer)) {
583 if (
bindingsTarget()->findBinding(propertyNameIndex) !=
nullptr) {
591 memberList.
append(member);
592 member = member->
next;
594 for (
int i = memberList.
size() - 1;
i >= 0; --
i) {
595 member = memberList.
at(
i);
601 appendBinding(qualifiedNameLocation,
name->identifierToken, propertyNameIndex, idx,
true);
610 return QQmlJS::AST::Visitor::visit(
list);
615 return QQmlJS::AST::Visitor::visit(ast);
620 return QQmlJS::AST::Visitor::visit(ast);
625 return QQmlJS::AST::Visitor::visit(ast);
630 return QQmlJS::AST::Visitor::visit(
id);
641 Object *declarationsOverride)
644 while (lastName->next)
645 lastName = lastName->next;
646 if (!lastName->name.constData()->isUpper()) {
647 recordError(lastName->identifierToken,
tr(
"Expected type name"));
679 if (!
error.isEmpty()) {
754template<
typename Argument>
763 if (!isUnique(builder)) {
766 "QQmlParser",
"Multiple %1 pragmas found").
arg(
name()));
775 "QQmlParser",
"Unknown %1 '%2' in pragma").
arg(
name(), bad->value));
785 if constexpr (std::is_same_v<Argument, Pragma::ComponentBehaviorValue>) {
787 }
else if constexpr (std::is_same_v<Argument, Pragma::ListPropertyAssignBehaviorValue>) {
789 }
else if constexpr (std::is_same_v<Argument, Pragma::FunctionSignatureBehaviorValue>) {
791 }
else if constexpr (std::is_same_v<Argument, Pragma::NativeMethodBehaviorValue>) {
793 }
else if constexpr (std::is_same_v<Argument, Pragma::ValueTypeBehaviorValue>) {
805 if (!process(
i->value))
817 if constexpr (std::is_same_v<Argument, Pragma::ComponentBehaviorValue>) {
819 if (
value ==
"Unbound"_L1) {
823 if (
value ==
"Bound"_L1) {
829 }
else if constexpr (std::is_same_v<Argument, Pragma::ListPropertyAssignBehaviorValue>) {
831 if (
value ==
"Append"_L1) {
835 if (
value ==
"Replace"_L1) {
839 if (
value ==
"ReplaceIfNotDefault"_L1) {
845 }
else if constexpr (std::is_same_v<Argument, Pragma::FunctionSignatureBehaviorValue>) {
847 if (
value ==
"Ignored"_L1) {
851 if (
value ==
"Enforced"_L1) {
857 }
else if constexpr (std::is_same_v<Argument, Pragma::NativeMethodBehaviorValue>) {
859 if (
value ==
"AcceptThisObject"_L1) {
863 if (
value ==
"RejectThisObject"_L1) {
869 }
else if constexpr (std::is_same_v<Argument, Pragma::ValueTypeBehaviorValue>) {
875 .setFlag(flag,
value).toInt();
878 if (
value ==
"Reference"_L1) {
882 if (
value ==
"Copy"_L1) {
887 if (
value ==
"Inaddressable"_L1) {
891 if (
value ==
"Addressable"_L1) {
900 Q_UNREACHABLE_RETURN(
nullptr);
905 for (
const Pragma *prev : builder->_pragmas) {
906 if (prev->type ==
type())
916 return "list property assign behavior"_L1;
918 return "component behavior"_L1;
920 return "function signature behavior"_L1;
922 return "native method behavior"_L1;
924 return "value type behavior"_L1;
934 Pragma *pragma = New<Pragma>();
937 if (node->
name ==
"Singleton"_L1) {
939 }
else if (node->
name ==
"Strict"_L1) {
941 }
else if (node->
name ==
"ComponentBehavior"_L1) {
944 }
else if (node->
name ==
"ListPropertyAssignBehavior"_L1) {
947 }
else if (node->
name ==
"FunctionSignatureBehavior"_L1) {
950 }
else if (node->
name ==
"NativeMethodBehavior"_L1) {
953 }
else if (node->
name ==
"ValueTypeBehavior"_L1) {
958 "QQmlParser",
"Unknown pragma '%1'").
arg(node->
name));
963 "QQmlParser",
"Empty pragma found"));
993 Enum *enumeration = New<Enum>();
1002 enumeration->
enumValues = New<PoolList<EnumValue>>();
1006 EnumValue *enumValue = New<EnumValue>();
1007 QString member =
e->member.toString();
1013 if (std::modf(
e->value, &part) != 0.0)
1015 if (
e->value > std::numeric_limits<qint32>::max() ||
e->value < std::numeric_limits<qint32>::min())
1017 enumValue->value =
e->value;
1019 enumValue->location.set(
e->memberToken.startLine,
e->memberToken.startColumn);
1026 if (!
error.isEmpty()) {
1045 signal->parameters = New<PoolList<Parameter> >();
1057 &
param->type, [
this](
const QString &
str) { return registerString(str); },
1060 errStr.
append(
p->type->toString());
1068 for (
const QChar &
ch : signalName) {
1073 tr(
"Signal names cannot begin with an upper case letter"));
1081 if (!
error.isEmpty()) {
1092 Property *
property = New<Property>();
1099 property->setCommonType(builtinPropertyType);
1105 property->setIsList(
true);
1106 }
else if (!typeModifier.
isEmpty()) {
1121 error =
tr(
"Illegal property name");
1125 if (!
error.isEmpty()) {
1155 "QQmlParser",
"Function declaration inside grouped property"));
1160 foe->
node = funDecl;
1174 &
f->returnType, idGenerator,
1175 funDecl->typeAnnotation ? funDecl->typeAnnotation->type :
nullptr);
1178 int formalsCount = formals.size();
1179 f->formals.allocate(
pool, formalsCount);
1182 for (
const auto &
arg : formals) {
1186 &functionParameter->
type, idGenerator,
1187 arg.typeAnnotation.isNull() ?
nullptr :
arg.typeAnnotation->type);
1200 auto extraData = New<RequiredPropertyExtraData>();
1230 if (
string.isEmpty())
1269 binding->
value.
b =
false;
1279 }
else if (QQmlJS::AST::cast<QQmlJS::AST::FunctionExpression *>(expr)) {
1286 }
else if (QQmlJS::AST::cast<QQmlJS::AST::NullExpression *>(expr)) {
1297 expr->
node = statement;
1323 const auto finalizeTranslationData = [&](
1343 Object *
object =
nullptr;
1358 Object *
object =
nullptr;
1369 Binding *binding = New<Binding>();
1376 if (!
error.isEmpty()) {
1384 recordError(nameLocation,
tr(
"Invalid component id specification"));
1388 Binding *binding = New<Binding>();
1414 if (!
error.isEmpty()) {
1421 Alias *alias = New<Alias>();
1450 if (aliasReference.isEmpty()) {
1452 COMPILE_EXCEPTION(rhsLoc,
tr(
"Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
1458 COMPILE_EXCEPTION(rhsLoc,
tr(
"Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
1461 if (aliasReference.size() < 1 || aliasReference.size() > 3)
1462 COMPILE_EXCEPTION(rhsLoc,
tr(
"Invalid alias reference. An alias reference must be specified as <id>, <id>.<property> or <id>.<value property>.<property>"));
1466 QString propertyValue = aliasReference.value(1);
1467 if (aliasReference.size() == 3)
1468 propertyValue +=
QLatin1Char(
'.') + aliasReference.at(2);
1475 error =
tr(
"Illegal property name");
1479 if (!
error.isEmpty()) {
1508 node = stmt->expression;
1518 if (
ch.isLetter() && !
ch.isLower())
1522 if (!
ch.isLetter() &&
ch != u)
1525 for (
int ii = 1; ii <
str.
size(); ++ii) {
1527 if (!
ch.isLetterOrNumber() &&
ch != u)
1553 if (qualifiedIdElement->
next) {
1556 &&
stringAt(import->qualifierIndex) == currentName) {
1557 qualifiedIdElement = qualifiedIdElement->
next;
1568 while (qualifiedIdElement->
next) {
1570 const bool isAttachedProperty = qualifiedIdElement->
name.
data()->
isUpper();
1572 Binding *binding = (*object)->findBinding(propertyNameIndex);
1574 if (isAttachedProperty) {
1582 binding = New<Binding>();
1594 if (isAttachedProperty)
1604 QString error = (*object)->appendBinding(binding,
false);
1605 if (!
error.isEmpty()) {
1615 qualifiedIdElement = qualifiedIdElement->
next;
1616 if (qualifiedIdElement)
1619 *nameToResolve = qualifiedIdElement;
1627 error.message = description;
1635 if (QQmlJS::AST::cast<QQmlJS::AST::StringLiteral *>(expr))
1641 else if (QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(expr))
1646 if (QQmlJS::AST::cast<QQmlJS::AST::NumericLiteral *>(unaryMinus->expression)) {
1664 return QQmlJS::AST::cast<QQmlJS::AST::NullExpression *>(expr);
1671 output.jsGenerator.stringTable.registerString(
output.jsModule.fileName);
1672 output.jsGenerator.stringTable.registerString(
output.jsModule.finalUrl);
1674 Unit *jsUnit =
nullptr;
1677 if (
output.javaScriptCompilationUnit.data) {
1678 jsUnit =
const_cast<Unit *
>(
output.javaScriptCompilationUnit.data);
1679 output.javaScriptCompilationUnit.dynamicStrings =
output.jsGenerator.stringTable.allStrings();
1682 jsUnit = createdUnit =
output.jsGenerator.generateUnit();
1688 createdUnit->
flags |= Unit::IsSingleton;
1691 createdUnit->
flags |= Unit::IsStrict;
1695 switch (
p->componentBehavior) {
1697 createdUnit->
flags |= Unit::ComponentsBound;
1705 switch (
p->listPropertyAssignBehavior) {
1707 createdUnit->
flags |= Unit::ListPropertyAssignReplace;
1710 createdUnit->
flags |= Unit::ListPropertyAssignReplaceIfNotDefault;
1718 switch (
p->functionSignatureBehavior) {
1722 createdUnit->
flags |= Unit::FunctionSignaturesIgnored;
1727 switch (
p->nativeMethodBehavior) {
1729 createdUnit->
flags |= Unit::NativeMethodsAcceptThisObject;
1737 if (Pragma::ValueTypeBehaviorValues(
p->valueTypeBehavior)
1739 createdUnit->
flags |= Unit::ValueTypesCopied;
1741 if (Pragma::ValueTypeBehaviorValues(
p->valueTypeBehavior)
1743 createdUnit->
flags |= Unit::ValueTypesAddressable;
1749 if (dependencyHasher) {
1762 output.jsGenerator.stringTable.freeze();
1770 uint nextOffset = objectOffset + objectOffsetTableSize;
1772 objectOffsets.
insert(
o, nextOffset);
1775 int signalTableSize = 0;
1776 for (
const Signal *
s =
o->firstSignal();
s;
s =
s->next)
1779 nextOffset += signalTableSize;
1781 int enumTableSize = 0;
1782 for (
const Enum *
e =
o->firstEnum();
e;
e =
e->next)
1785 nextOffset += enumTableSize;
1788 const uint totalSize = nextOffset;
1789 char *
data = (
char*)malloc(totalSize);
1790 memset(
data, 0, totalSize);
1801 *importToWrite = *imp;
1807 for (
int i = 0;
i <
output.objects.size(); ++
i) {
1809 char *
const objectPtr =
data + objectOffsets.
value(
o);
1810 *objectTable++ = objectOffsets.
value(
o);
1816 objectToWrite->
setFlags(QV4::CompiledData::Object::Flags(
o->flags));
1832 objectToWrite->
nAliases =
o->aliasCount();
1836 objectToWrite->
nEnums =
o->enumCount();
1840 objectToWrite->
nSignals =
o->signalCount();
1844 objectToWrite->
nBindings =
o->bindingCount();
1861 for (
const Function *
f =
o->firstFunction();
f;
f =
f->next)
1862 *functionsTable++ =
o->runtimeFunctionIndices.at(
f->index);
1865 for (
const Property *
p =
o->firstProperty();
p;
p =
p->next) {
1867 *propertyToWrite = *
p;
1872 for (
const Alias *
a =
o->firstAlias();
a;
a =
a->next) {
1888 char *signalPtr = objectPtr + nextOffset;
1889 for (
const Signal *
s =
o->firstSignal();
s;
s =
s->next) {
1890 *signalOffsetTable++ = signalPtr - objectPtr;
1899 *parameterToWrite = *
param;
1902 signalTableSize +=
size;
1905 nextOffset += signalTableSize;
1908 char *enumPtr = objectPtr + nextOffset;
1909 for (
const Enum *
e =
o->firstEnum();
e;
e =
e->next) {
1910 *enumOffsetTable++ = enumPtr - objectPtr;
1918 for (
EnumValue *enumValue =
e->enumValues->first; enumValue; enumValue = enumValue->next, ++enumValueToWrite)
1919 *enumValueToWrite = *enumValue;
1926 for (
int i = 0;
i <
o->namedObjectsInComponent.size(); ++
i) {
1927 *namedObjectInComponentPtr++ =
o->namedObjectsInComponent.at(
i);
1931 for (
auto it =
o->inlineComponentsBegin();
it !=
o->inlineComponentsEnd(); ++
it) {
1939 for (
auto it =
o->requiredPropertyExtraDataBegin();
it !=
o->requiredPropertyExtraDataEnd(); ++
it) {
1942 *extraDataToWrite = *extraData;
1947 if (!
output.javaScriptCompilationUnit.data) {
1952 memcpy(jsUnit->
qmlUnit(), qmlUnit, totalSize);
1960 qDebug() <<
"Generated QML unit that is" << totalSize <<
"bytes big contains:";
1963 qDebug() <<
" " << importSize <<
"for imports";
1964 qDebug() <<
" " << nextOffset - objectOffset - objectOffsetTableSize <<
"for" << qmlUnit->
nObjects <<
"objects";
1965 quint32 totalBindingCount = 0;
1968 qDebug() <<
" " << totalBindingCount <<
"bindings";
1972 qDebug() <<
" " << totalCodeSize <<
"bytes total byte code";
1977 qDebug() <<
" " << totalStringSize <<
"bytes total strings";
1980 output.javaScriptCompilationUnit.setUnitData(jsUnit, qmlUnit,
output.jsModule.fileName,
1981 output.jsModule.finalUrl);
1984char *QmlUnitGenerator::writeBindings(
char *bindingPtr,
const Object *
o, BindingFilter
filter)
const
1986 for (
const Binding *
b =
o->firstBinding();
b;
b =
b->next) {
1990 *bindingToWrite = *
b;
2000 bool storeSourceLocations)
2001 :
QV4::Compiler::Codegen(&document->jsGenerator,
false, iface,
2002 storeSourceLocations),
2006 _module = &document->jsModule;
2014 if (
c.nameIndex != 0)
2026 auto function =
f.node->asFunctionDefinition();
2051 for (
int i = 0;
i < functions.
size(); ++
i) {
2062 name = qmlName(qmlFunction);
2083 runtimeFunctionIndices[
i] = idx;
2086 return runtimeFunctionIndices;
2091 if (
object->functionsAndExpressions->count == 0)
2095 functionsToCompile.
reserve(
object->functionsAndExpressions->count);
2098 functionsToCompile << *foe;
2106 runtimeFunctionIndices);
QChar toLower() const noexcept
Returns the lowercase equivalent if the character is uppercase or titlecase; otherwise returns the ch...
constexpr char16_t unicode() const noexcept
Returns the numeric Unicode value of the QChar.
constexpr bool isLower() const noexcept
Returns true if the character is a lowercase letter, for example category() is Letter_Lowercase.
constexpr bool isUpper() const noexcept
Returns true if the character is an uppercase letter, for example category() is Letter_Uppercase.
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
T value(const Key &key) const noexcept
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void reserve(qsizetype size)
void append(parameter_type t)
ExpressionNode * expression
virtual SourceLocation firstSourceLocation() const =0
void accept(BaseVisitor *visitor)
virtual Statement * statementCast()
virtual SourceLocation lastSourceLocation() const =0
virtual ExpressionNode * expressionCast()
virtual FunctionExpression * asFunctionDefinition()
@ Kind_IdentifierExpression
@ Kind_FieldMemberExpression
UiQualifiedId * qualifiedId
UiArrayMemberList * members
UiEnumMemberList * members
UiVersionSpecifier * version
SourceLocation importIdToken
UiQualifiedId * importUri
SourceLocation fileNameToken
SourceLocation importToken
SourceLocation firstSourceLocation() const override
UiObjectDefinition * component
UiQualifiedId * qualifiedTypeNameId
UiQualifiedId * qualifiedId
UiObjectInitializer * initializer
UiQualifiedId * qualifiedTypeNameId
UiObjectInitializer * initializer
SourceLocation firstSourceLocation() const override=0
UiPragmaValueList * values
SourceLocation pragmaToken
SourceLocation semicolonToken
UiParameterList * parameters
SourceLocation identifierToken
SourceLocation firstSourceLocation() const override
enum QQmlJS::AST::UiPublicMember::@695 type
SourceLocation defaultToken() const
bool isDefaultMember() const
SourceLocation typeModifierToken
UiQualifiedId * memberType
SourceLocation firstSourceLocation() const override
SourceLocation identifierToken
UiQualifiedId * qualifiedId
SourceLocation firstSourceLocation() const override
void setCode(const QString &code, int lineno, bool qmlMode=true, CodeContinuation codeContinuation=CodeContinuation::Reset)
iterator erase(const_iterator i)
iterator find(const T &value)
bool contains(const T &value) const
iterator insert(const T &value)
constexpr bool isEmpty() const noexcept
Returns whether this string view is empty - that is, whether {size() == 0}.
const_pointer data() const noexcept
QString toString() const
Returns a deep copy of this string view's data as a QString.
constexpr bool isNull() const noexcept
Returns whether this string view is null - that is, whether {data() == nullptr}.
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
const QChar * constData() const
Returns a pointer to the data stored in the QString.
qsizetype size() const
Returns the number of characters in this string.
QString arg(qlonglong a, int fieldwidth=0, int base=10, QChar fillChar=u' ') const
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
const QChar at(qsizetype i) const
Returns the character at the given index position in the string.
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString & append(QChar c)
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
static constexpr QTypeRevision fromMajorVersion(Major majorVersion)
Produces a QTypeRevision from the given majorVersion with an invalid minor version.
QSet< QString > m_globalNames
virtual int defineFunction(const QString &name, QQmlJS::AST::Node *ast, QQmlJS::AST::FormalParameterList *formals, QQmlJS::AST::StatementList *body)
void enterQmlFunction(QQmlJS::AST::FunctionExpression *ast)
void handleTopLevelFunctionFormals(QQmlJS::AST::FunctionExpression *node)
void enterEnvironment(QQmlJS::AST::Node *node, ContextType compilationMode, const QString &name)
void enterGlobalEnvironment(ContextType compilationMode)
constexpr size_type size() const noexcept
const T & at(qsizetype idx) const
void importFile(const QString &jsfile, const QString &module, int lineNumber, int column) override
void importModule(const QString &uri, const QString &version, const QString &module, int lineNumber, int column) override
void pragmaLibrary() override
ScriptDirectivesCollector(QmlIR::Document *doc)
QSet< QString >::iterator it
std::function< QByteArray()> DependentTypesHasher
\qmltype Particle \inqmlmodule QtQuick.Particles
void tryGeneratingTranslationBindingBase(QStringView base, QQmlJS::AST::ArgumentList *args, RegisterMainString registerMainString, RegisterCommentString registerCommentString, RegisterContextString registerContextString, FinalizeTranslationData finalizeTranslationData)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
DBusConnection const char DBusError * error
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static quint32 checksum(const QByteArray &table)
static bool isScript(QStringView tag)
GLenum GLsizei GLsizei GLint * values
[15]
GLboolean GLboolean GLboolean b
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
GLint GLsizei GLsizei GLenum GLenum GLsizei void * data
GLenum const GLint * param
GLenum GLenum GLsizei void GLsizei void * column
GLenum GLenum GLenum input
GLsizei const GLchar *const * string
[0]
static qreal dot(const QPointF &a, const QPointF &b)
static const quint32 emptyStringIndex
#define COMPILE_EXCEPTION(location, desc)
static QStringList astNodeToStringList(QQmlJS::AST::Node *node)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
Q_CORE_EXPORT bool qEnvironmentVariableIsSet(const char *varName) noexcept
static int toInt(const QChar &qc, int R)
QT_BEGIN_NAMESPACE typedef uchar * output
QUrl url("example.com")
[constructor-url-reference]
char * toString(const MyType &t)
[31]
static bool run(IRBuilder *builder, QQmlJS::AST::UiPragma *node, Pragma *pragma)
\inmodule QtCore \reentrant
Location referenceLocation
quint32_le propertyNameIndex
void setNameIndex(quint32 nameIndex)
void setIdIndex(quint32 idIndex)
quint32_le propertyNameIndex
bool isSignalHandler() const
bool isAttachedProperty() const
union QV4::CompiledData::Binding::@543 value
bool hasFlag(Flag flag) const
bool isGroupProperty() const
bool isValueBindingNoAlias() const
bool isValueBinding() const
quint32_le translationDataIndex
quint32_le constantValueIndex
bool isValueBindingToAlias() const
@ InitializerForReadOnlyDeclaration
quint32_le compiledScriptIndex
static int calculateSize(int nEnumValues)
void set(quint32 line, quint32 column)
void setFlags(Flags flags)
quint32_le offsetToBindings
quint32_le offsetToAliases
quint32_le offsetToProperties
quint32_le offsetToSignals
quint32_le offsetToInlineComponents
quint32_le inheritedTypeNameIndex
@ IsPartOfInlineComponent
quint32_le offsetToNamedObjectsInComponent
qint32_le indexOfDefaultPropertyOrAlias
quint16_le nInlineComponents
void setObjectId(qint32 id)
quint32_le offsetToRequiredPropertyExtraData
quint32_le nNamedObjectsInComponent
quint16_le nRequiredPropertyExtraData
Location locationOfIdProperty
static int calculateSizeExcludingSignalsAndEnums(int nFunctions, int nProperties, int nAliases, int nEnums, int nSignals, int nBindings, int nNamedObjectsInComponent, int nInlineComponents, int nRequiredPropertyExtraData)
quint32_le offsetToFunctions
void setHasAliasAsDefaultProperty(bool defaultAlias)
void set(Flags flags, quint32 typeNameIndexOrCommonType)
quint32_le offsetToObjects
const Object * objectAt(int idx) const
quint32_le offsetToImports
static int calculateSize(int nParameters)
static int calculateSize(const QString &str)
quint32_le functionTableSize
QString stringAtInternal(uint idx) const
quint32_le offsetToQmlUnit
const Function * functionAt(int idx) const
quint32_le sourceFileIndex
quint32_le stringTableSize
char dependencyMD5Checksum[16]
const QmlUnit * qmlUnit() const
static void generateUnitChecksum(CompiledData::Unit *unit)
int registerTranslation(const CompiledData::TranslationData &translation)
QString stringForIndex(int index) const
int registerConstant(ReturnedValue v)
int registerString(const QString &str)
QString stringForIndex(int index) const
QQmlJS::AST::Node * parentNode
QQmlJS::AST::UiProgram * program
QString stringAt(int index) const
QV4::Compiler::Module jsModule
QV4::Compiler::JSUnitGenerator jsGenerator
QList< const QV4::CompiledData::Import * > imports
QQmlJS::Engine jsParserEngine
QV4::CompiledData::Location location
PoolList< EnumValue > * enumValues
QVector< Object * > _objects
bool resolveQualifiedId(QQmlJS::AST::UiQualifiedId **nameToResolve, Object **object, bool onAssignment=false)
QList< const QV4::CompiledData::Import * > _imports
QList< Pragma * > _pragmas
bool defineQMLObject(int *objectIndex, QQmlJS::AST::UiQualifiedId *qualifiedTypeNameId, const QV4::CompiledData::Location &location, QQmlJS::AST::UiObjectInitializer *initializer, Object *declarationsOverride=nullptr)
QStringView asStringRef(QQmlJS::AST::Node *node)
static QTypeRevision extractVersion(QStringView string)
Object * bindingsTarget() const
IRBuilder(const QSet< QString > &illegalNames)
bool setId(const QQmlJS::SourceLocation &idLocation, QQmlJS::AST::Statement *value)
static bool isRedundantNullInitializerForPropertyDeclaration(Property *property, QQmlJS::AST::Statement *statement)
void appendBinding(QQmlJS::AST::UiQualifiedId *name, QQmlJS::AST::Statement *value, QQmlJS::AST::Node *parentNode)
QString stringAt(int index) const
void setBindingValue(QV4::CompiledData::Binding *binding, QQmlJS::AST::Statement *statement, QQmlJS::AST::Node *parentNode)
QQmlJS::MemoryPool * pool
void accept(QQmlJS::AST::Node *node)
static QString signalNameFromSignalPropertyName(const QString &signalPropertyName)
static bool isSignalPropertyName(const QString &name)
bool visit(QQmlJS::AST::UiArrayMemberList *ast) override
Property * _propertyDeclaration
bool generateFromQml(const QString &code, const QString &url, Document *output)
QList< QQmlJS::DiagnosticMessage > errors
bool insideInlineComponent
static bool isStatementNodeScript(QQmlJS::AST::Statement *statement)
QV4::Compiler::JSUnitGenerator * jsGenerator
bool appendAlias(QQmlJS::AST::UiPublicMember *node)
quint32 registerString(const QString &str) const
QSet< QString > inlineComponentsNames
void tryGeneratingTranslationBinding(QStringView base, QQmlJS::AST::ArgumentList *args, QV4::CompiledData::Binding *binding)
static QString asString(QQmlJS::AST::UiQualifiedId *node)
void recordError(const QQmlJS::SourceLocation &location, const QString &description)
QString sanityCheckFunctionNames(Object *obj, const QSet< QString > &illegalNames, QQmlJS::SourceLocation *errorLocation)
QSet< QString > illegalNames
QStringView textRefAt(const QQmlJS::SourceLocation &loc) const
bool generateRuntimeFunctions(QmlIR::Object *object)
JSCodeGen(Document *document, const QSet< QString > &globalNames, QV4::Compiler::CodegenWarningInterface *iface=QV4::Compiler::defaultCodegenWarningInterface(), bool storeSourceLocations=false)
QVector< int > generateJSCodeForFunctionsAndBindings(const QList< CompiledFunctionOrExpression > &functions)
int indexOfDefaultPropertyOrAlias
QString appendEnum(Enum *enumeration)
void appendRequiredPropertyExtraData(RequiredPropertyExtraData *extraData)
void insertSorted(Binding *b)
QString appendBinding(Binding *b, bool isListBinding)
void appendInlineComponent(InlineComponent *ic)
bool defaultPropertyIsAlias
QString appendSignal(Signal *signal)
QString bindingAsString(Document *doc, int scriptIndex) const
void init(QQmlJS::MemoryPool *pool, int typeNameIndex, int idIndex, const QV4::CompiledData::Location &location)
Object * declarationsOverride
QString appendAlias(Alias *prop, const QString &aliasName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation)
QString appendProperty(Property *prop, const QString &propertyName, bool isDefaultProperty, const QQmlJS::SourceLocation &defaultToken, QQmlJS::SourceLocation *errorLocation)
PoolList< CompiledFunctionOrExpression > * functionsAndExpressions
void appendFunction(QmlIR::Function *f)
quint32 inheritedTypeNameIndex
QV4::CompiledData::Location locationOfIdProperty
Binding * findBinding(quint32 nameIndex) const
static bool initType(QV4::CompiledData::ParameterType *type, const IdGenerator &idGenerator, const QQmlJS::AST::Type *annotation)
static QV4::CompiledData::CommonType stringToBuiltinType(const QString &typeName)
NativeMethodBehaviorValue nativeMethodBehavior
ComponentBehaviorValue componentBehavior
ValueTypeBehaviorValues::Int valueTypeBehavior
QV4::CompiledData::Location location
FunctionSignatureBehaviorValue functionSignatureBehavior
ListPropertyAssignBehaviorValue listPropertyAssignBehavior
@ FunctionSignatureBehavior
@ ListPropertyAssignBehavior
void generate(Document &output, const QV4::CompiledData::DependentTypesHasher &dependencyHasher=QV4::CompiledData::DependentTypesHasher())
PoolList< Parameter > * parameters
QStringList parameterStringList(const QV4::Compiler::StringTableGenerator *stringPool) const