|
91 | 91 | #include "SILGenFunction.h" |
92 | 92 | #include "SILGenFunctionBuilder.h" |
93 | 93 | #include "Scope.h" |
| 94 | +#include "swift/Basic/Generators.h" |
94 | 95 | #include "swift/AST/ASTMangler.h" |
95 | 96 | #include "swift/AST/Decl.h" |
96 | 97 | #include "swift/AST/DiagnosticsSIL.h" |
@@ -892,47 +893,11 @@ class TranslateIndirect : public Cleanup { |
892 | 893 | } |
893 | 894 | }; |
894 | 895 |
|
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 | | - |
931 | 896 | /// A class for destructuring a list of formal input parameters given |
932 | 897 | /// an abstraction pattern for it. |
933 | 898 | class InputParamGenerator { |
934 | 899 | const ASTContext &ctx; |
935 | | - CollectionGenerator<ArrayRef<ManagedValue>> &inputs; |
| 900 | + ArrayRefGenerator<ArrayRef<ManagedValue>> &inputs; |
936 | 901 | FunctionParamGenerator inputParam; |
937 | 902 |
|
938 | 903 | /// If inputParam.isPackExpansion(), this is the pack currently |
@@ -996,7 +961,7 @@ class InputParamGenerator { |
996 | 961 |
|
997 | 962 | public: |
998 | 963 | InputParamGenerator(const ASTContext &ctx, |
999 | | - CollectionGenerator<ArrayRef<ManagedValue>> &inputs, |
| 964 | + ArrayRefGenerator<ArrayRef<ManagedValue>> &inputs, |
1000 | 965 | AbstractionPattern inputOrigFunctionType, |
1001 | 966 | AnyFunctionType::CanParamArrayRef inputSubstParams, |
1002 | 967 | bool ignoreFinalParam) |
@@ -1190,7 +1155,7 @@ class InputParamGenerator { |
1190 | 1155 | class TranslateArguments { |
1191 | 1156 | SILGenFunction &SGF; |
1192 | 1157 | SILLocation Loc; |
1193 | | - CollectionGenerator<ArrayRef<ManagedValue>> Inputs; |
| 1158 | + ArrayRefGenerator<ArrayRef<ManagedValue>> Inputs; |
1194 | 1159 | SmallVectorImpl<ManagedValue> &Outputs; |
1195 | 1160 | CanSILFunctionType OutputTypesFuncTy; |
1196 | 1161 | ArrayRef<SILParameterInfo> OutputTypes; |
|
0 commit comments