Skip to content

Commit 0b3b0d8

Browse files
committed
[NFC] Use the generators library in SILGenPoly
1 parent 0cfbe8c commit 0b3b0d8

File tree

1 file changed

+4
-39
lines changed

1 file changed

+4
-39
lines changed

lib/SILGen/SILGenPoly.cpp

Lines changed: 4 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@
9191
#include "SILGenFunction.h"
9292
#include "SILGenFunctionBuilder.h"
9393
#include "Scope.h"
94+
#include "swift/Basic/Generators.h"
9495
#include "swift/AST/ASTMangler.h"
9596
#include "swift/AST/Decl.h"
9697
#include "swift/AST/DiagnosticsSIL.h"
@@ -892,47 +893,11 @@ class TranslateIndirect : public Cleanup {
892893
}
893894
};
894895

895-
/// A class for generating the elements of a collecttion.
896-
template <class CollectionType>
897-
class CollectionGenerator {
898-
typename CollectionType::iterator i, e;
899-
900-
using reference =
901-
typename std::iterator_traits<typename CollectionType::iterator>::reference;
902-
903-
public:
904-
CollectionGenerator(const CollectionType &collection)
905-
: i(collection.begin()), e(collection.end()) {}
906-
907-
reference getCurrent() const {
908-
assert(!isFinished());
909-
return *i;
910-
}
911-
912-
reference claimNext() {
913-
assert(!isFinished());
914-
return *i++;
915-
}
916-
917-
bool isFinished() const {
918-
return i == e;
919-
}
920-
921-
void advance() {
922-
assert(!isFinished());
923-
++i;
924-
}
925-
926-
void finish() {
927-
assert(isFinished() && "didn't finish generating the collection");
928-
}
929-
};
930-
931896
/// A class for destructuring a list of formal input parameters given
932897
/// an abstraction pattern for it.
933898
class InputParamGenerator {
934899
const ASTContext &ctx;
935-
CollectionGenerator<ArrayRef<ManagedValue>> &inputs;
900+
ArrayRefGenerator<ArrayRef<ManagedValue>> &inputs;
936901
FunctionParamGenerator inputParam;
937902

938903
/// If inputParam.isPackExpansion(), this is the pack currently
@@ -996,7 +961,7 @@ class InputParamGenerator {
996961

997962
public:
998963
InputParamGenerator(const ASTContext &ctx,
999-
CollectionGenerator<ArrayRef<ManagedValue>> &inputs,
964+
ArrayRefGenerator<ArrayRef<ManagedValue>> &inputs,
1000965
AbstractionPattern inputOrigFunctionType,
1001966
AnyFunctionType::CanParamArrayRef inputSubstParams,
1002967
bool ignoreFinalParam)
@@ -1190,7 +1155,7 @@ class InputParamGenerator {
11901155
class TranslateArguments {
11911156
SILGenFunction &SGF;
11921157
SILLocation Loc;
1193-
CollectionGenerator<ArrayRef<ManagedValue>> Inputs;
1158+
ArrayRefGenerator<ArrayRef<ManagedValue>> Inputs;
11941159
SmallVectorImpl<ManagedValue> &Outputs;
11951160
CanSILFunctionType OutputTypesFuncTy;
11961161
ArrayRef<SILParameterInfo> OutputTypes;

0 commit comments

Comments
 (0)