Skip to content

Commit bcf6f26

Browse files
committed
Runtime: Make SubstGenericParametersFromWrittenArgs and _gatherWrittenGenericArgs() completely private to MetadataLoookup.cpp
1 parent 39aa4d4 commit bcf6f26

File tree

2 files changed

+42
-54
lines changed

2 files changed

+42
-54
lines changed

stdlib/public/runtime/MetadataLookup.cpp

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,8 +1181,47 @@ struct MetadataOrPack {
11811181
}
11821182
};
11831183

1184+
/// Function object that produces substitutions for the generic parameters
1185+
/// that occur within a mangled name, using the complete set of generic
1186+
/// arguments "as written".
1187+
///
1188+
/// Use with \c _getTypeByMangledName to decode potentially-generic types.
1189+
class SubstGenericParametersFromWrittenArgs {
1190+
/// The complete set of generic arguments.
1191+
const llvm::SmallVectorImpl<const Metadata *> &allGenericArgs;
1192+
1193+
/// The counts of generic parameters at each level.
1194+
const llvm::SmallVectorImpl<unsigned> &genericParamCounts;
1195+
1196+
public:
1197+
/// Initialize a new function object to handle substitutions. Both
1198+
/// parameters are references to vectors that must live longer than
1199+
/// this function object.
1200+
///
1201+
/// \param allGenericArgs The complete set of generic arguments, as written.
1202+
/// This could come directly from "source" (where all generic arguments are
1203+
/// encoded) or from metadata via gatherWrittenGenericArgs().
1204+
///
1205+
/// \param genericParamCounts The count of generic parameters at each
1206+
/// generic level, typically gathered by _gatherGenericParameterCounts.
1207+
explicit SubstGenericParametersFromWrittenArgs(
1208+
const llvm::SmallVectorImpl<const Metadata *> &allGenericArgs,
1209+
const llvm::SmallVectorImpl<unsigned> &genericParamCounts)
1210+
: allGenericArgs(allGenericArgs),
1211+
genericParamCounts(genericParamCounts) {}
1212+
1213+
const Metadata *getMetadata(unsigned depth, unsigned index) const;
1214+
const WitnessTable *getWitnessTable(const Metadata *type,
1215+
unsigned index) const;
1216+
};
1217+
11841218
} // end anonymous namespace
11851219

1220+
static void _gatherWrittenGenericArgs(
1221+
const Metadata *metadata, const TypeContextDescriptor *description,
1222+
llvm::SmallVectorImpl<const Metadata *> &allGenericArgs,
1223+
Demangler &BorrowFrom);
1224+
11861225
static llvm::Optional<TypeLookupError>
11871226
_gatherGenericParameters(const ContextDescriptor *context,
11881227
llvm::ArrayRef<const Metadata *> genericArgs,
@@ -1262,8 +1301,8 @@ _gatherGenericParameters(const ContextDescriptor *context,
12621301

12631302
// If we have a parent, gather it's generic arguments "as written".
12641303
if (parent) {
1265-
gatherWrittenGenericArgs(parent, parent->getTypeContextDescriptor(),
1266-
allGenericArgs, demangler);
1304+
_gatherWrittenGenericArgs(parent, parent->getTypeContextDescriptor(),
1305+
allGenericArgs, demangler);
12671306
}
12681307

12691308
// Add the generic arguments we were given.
@@ -2883,7 +2922,7 @@ demangleToGenericParamRef(StringRef typeName) {
28832922
node->getChild(1)->getIndex());
28842923
}
28852924

2886-
void swift::gatherWrittenGenericArgs(
2925+
static void _gatherWrittenGenericArgs(
28872926
const Metadata *metadata, const TypeContextDescriptor *description,
28882927
llvm::SmallVectorImpl<const Metadata *> &allGenericArgs,
28892928
Demangler &BorrowFrom) {

stdlib/public/runtime/Private.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -423,40 +423,6 @@ class TypeInfo {
423423
SubstDependentWitnessTableFn substWitnessTable);
424424
#pragma clang diagnostic pop
425425

426-
/// Function object that produces substitutions for the generic parameters
427-
/// that occur within a mangled name, using the complete set of generic
428-
/// arguments "as written".
429-
///
430-
/// Use with \c _getTypeByMangledName to decode potentially-generic types.
431-
class SWIFT_RUNTIME_LIBRARY_VISIBILITY SubstGenericParametersFromWrittenArgs {
432-
/// The complete set of generic arguments.
433-
const llvm::SmallVectorImpl<const Metadata *> &allGenericArgs;
434-
435-
/// The counts of generic parameters at each level.
436-
const llvm::SmallVectorImpl<unsigned> &genericParamCounts;
437-
438-
public:
439-
/// Initialize a new function object to handle substitutions. Both
440-
/// parameters are references to vectors that must live longer than
441-
/// this function object.
442-
///
443-
/// \param allGenericArgs The complete set of generic arguments, as written.
444-
/// This could come directly from "source" (where all generic arguments are
445-
/// encoded) or from metadata via gatherWrittenGenericArgs().
446-
///
447-
/// \param genericParamCounts The count of generic parameters at each
448-
/// generic level, typically gathered by _gatherGenericParameterCounts.
449-
explicit SubstGenericParametersFromWrittenArgs(
450-
const llvm::SmallVectorImpl<const Metadata *> &allGenericArgs,
451-
const llvm::SmallVectorImpl<unsigned> &genericParamCounts)
452-
: allGenericArgs(allGenericArgs),
453-
genericParamCounts(genericParamCounts) {}
454-
455-
const Metadata *getMetadata(unsigned depth, unsigned index) const;
456-
const WitnessTable *getWitnessTable(const Metadata *type,
457-
unsigned index) const;
458-
};
459-
460426
/// Gather generic parameter counts from a context descriptor.
461427
///
462428
/// \returns true if the innermost descriptor is generic.
@@ -534,23 +500,6 @@ class TypeInfo {
534500
SWIFT_RETURNS_NONNULL SWIFT_NODISCARD
535501
void *allocateMetadata(size_t size, size_t align);
536502

537-
/// Gather the set of generic arguments that would be written in the
538-
/// source.
539-
///
540-
/// This function computes generic arguments even when they are not
541-
/// directly represented in the metadata, e.g., generic parameters that
542-
/// are canonicalized away by same-type constraints and are therefore not
543-
/// "key" parameters.
544-
///
545-
/// \code
546-
/// extension Array where Element == String { }
547-
/// extension Dictionary where Key == Value { }
548-
/// \endcode
549-
void gatherWrittenGenericArgs(const Metadata *metadata,
550-
const TypeContextDescriptor *description,
551-
llvm::SmallVectorImpl<const Metadata *> &allGenericArgs,
552-
Demangler &BorrowFrom);
553-
554503
Demangle::NodePointer
555504
_buildDemanglingForContext(const ContextDescriptor *context,
556505
llvm::ArrayRef<NodePointer> demangledGenerics,

0 commit comments

Comments
 (0)