70 AdjacencyList &adjacencyList, NodeList &nodes,
71 const std::vector<InlineComponent> &allICs)
73 using CompiledObject =
typename ObjectContainer::CompiledObject;
77 for (
typename std::vector<InlineComponent>::size_type i = 0; i < allICs.size(); ++i) {
78 const auto& ic = allICs[i];
79 const CompiledObject *obj = objectContainer->objectAt(ic.objectIndex);
80 QV4::ResolvedTypeReference *currentICTypeRef = objectContainer->resolvedType(ic.nameIndex);
81 auto createEdgeFromTypeRef = [&](QV4::ResolvedTypeReference *targetTypeRef) {
85 const QQmlType targetType = targetTypeRef->type();
86 if (!targetType.isInlineComponent()
87 || !containedInSameType(targetType, currentICTypeRef->type())) {
92 std::find_if(allICs.cbegin(), allICs.cend(),
93 [&](
const QV4::CompiledData::InlineComponent &icSearched) {
94 return objectContainer->stringAt(icSearched.nameIndex)
95 == targetType.elementName();
97 Q_ASSERT(icIt != allICs.cend());
99 adjacencyList[std::distance(allICs.cbegin(), icIt)].push_back(&nodes[i]);
101 if (obj->inheritedTypeNameIndex != 0) {
102 QV4::ResolvedTypeReference *parentTypeRef = objectContainer->resolvedType(obj->inheritedTypeNameIndex);
103 createEdgeFromTypeRef(parentTypeRef);
106 auto referencedInICObjectIndex = ic.objectIndex + 1;
107 while (
int(referencedInICObjectIndex) < objectContainer->objectCount()) {
108 auto potentiallyReferencedInICObject = objectContainer->objectAt(referencedInICObjectIndex);
110 = !potentiallyReferencedInICObject->hasFlag(
111 QV4::CompiledData::Object::IsInlineComponentRoot)
112 && potentiallyReferencedInICObject->hasFlag(
113 QV4::CompiledData::Object::IsPartOfInlineComponent);
116 createEdgeFromTypeRef(objectContainer->resolvedType(potentiallyReferencedInICObject->inheritedTypeNameIndex));
117 ++referencedInICObjectIndex;
122inline void topoVisit(
Node *node, AdjacencyList &adjacencyList,
bool &hasCycle,
123 NodeList &nodesSorted)
133 auto const &edges = adjacencyList[node->index()];
134 for (
auto edgeTarget =edges.begin(); edgeTarget != edges.end(); ++edgeTarget) {
135 topoVisit(*edgeTarget, adjacencyList, hasCycle, nodesSorted);
139 nodesSorted.push_back(*node);
145 NodeList nodesSorted;
146 nodesSorted.reserve(nodes.size());
149 auto currentNodeIt = std::find_if(nodes.begin(), nodes.end(), [](
const Node& node) {
150 return !node.hasPermanentMark();
154 while (currentNodeIt != nodes.end() && !hasCycle) {
155 Node& currentNode = *currentNodeIt;
156 topoVisit(¤tNode, adjacencyList, hasCycle, nodesSorted);
157 currentNodeIt = std::find_if(nodes.begin(), nodes.end(), [](
const Node& node) {
158 return !node.hasPermanentMark();