mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Serialization] Use existing logic to print a hierarchical module name
No intended functionality change.
This commit is contained in:
@@ -193,7 +193,7 @@ public:
|
||||
|
||||
/// This is a convenience function that writes the entire name, in forward
|
||||
/// order, to \p out.
|
||||
void printForward(raw_ostream &out) const;
|
||||
void printForward(raw_ostream &out, StringRef delim = ".") const;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
@@ -1200,11 +1200,12 @@ ModuleDecl::ReverseFullNameIterator::operator++() {
|
||||
}
|
||||
|
||||
void
|
||||
ModuleDecl::ReverseFullNameIterator::printForward(raw_ostream &out) const {
|
||||
ModuleDecl::ReverseFullNameIterator::printForward(raw_ostream &out,
|
||||
StringRef delim) const {
|
||||
SmallVector<StringRef, 8> elements(*this, {});
|
||||
swift::interleave(swift::reversed(elements),
|
||||
[&out](StringRef next) { out << next; },
|
||||
[&out] { out << '.'; });
|
||||
[&out, delim] { out << delim; });
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -993,23 +993,19 @@ void Serializer::writeHeader(const SerializationOptions &options) {
|
||||
}
|
||||
}
|
||||
|
||||
using ImportPathBlob = llvm::SmallString<64>;
|
||||
static void flattenImportPath(const ModuleDecl::ImportedModule &import,
|
||||
ImportPathBlob &out) {
|
||||
SmallVector<StringRef, 4> reverseSubmoduleNames(
|
||||
import.second->getReverseFullModuleName(), {});
|
||||
|
||||
interleave(reverseSubmoduleNames.rbegin(), reverseSubmoduleNames.rend(),
|
||||
[&out](StringRef next) { out.append(next); },
|
||||
[&out] { out.push_back('\0'); });
|
||||
SmallVectorImpl<char> &out) {
|
||||
llvm::raw_svector_ostream outStream(out);
|
||||
import.second->getReverseFullModuleName().printForward(outStream,
|
||||
StringRef("\0", 1));
|
||||
|
||||
if (import.first.empty())
|
||||
return;
|
||||
|
||||
out.push_back('\0');
|
||||
outStream << '\0';
|
||||
assert(import.first.size() == 1 && "can only handle top-level decl imports");
|
||||
auto accessPathElem = import.first.front();
|
||||
out.append(accessPathElem.first.str());
|
||||
outStream << accessPathElem.first.str();
|
||||
}
|
||||
|
||||
uint64_t getRawModTimeOrHash(const SerializationOptions::FileDependency &dep) {
|
||||
@@ -1122,7 +1118,7 @@ void Serializer::writeInputBlock(const SerializationOptions &options) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ImportPathBlob importPath;
|
||||
SmallString<64> importPath;
|
||||
flattenImportPath(import, importPath);
|
||||
|
||||
serialization::ImportControl stableImportControl;
|
||||
|
||||
Reference in New Issue
Block a user