Skip to content

Commit c0e3327

Browse files
committed
AST: Convert builtins to use AnyFunctionType::Param
1 parent d31d35a commit c0e3327

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

lib/AST/Builtins.cpp

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ getBuiltinFunction(Identifier Id, ArrayRef<Type> argTypes, Type ResType,
184184
/// Build a builtin function declaration.
185185
static FuncDecl *
186186
getBuiltinGenericFunction(Identifier Id,
187-
ArrayRef<TupleTypeElt> ArgParamTypes,
187+
ArrayRef<AnyFunctionType::Param> ArgParamTypes,
188188
Type ResType,
189189
GenericParamList *GenericParams,
190190
GenericEnvironment *Env) {
@@ -196,7 +196,7 @@ getBuiltinGenericFunction(Identifier Id,
196196

197197
SmallVector<ParamDecl*, 4> params;
198198
for (unsigned i = 0, e = ArgParamTypes.size(); i < e; i++) {
199-
auto paramIfaceType = ArgParamTypes[i].getRawType();
199+
auto paramIfaceType = ArgParamTypes[i].getPlainType();
200200
auto specifier = (ArgParamTypes[i].getParameterFlags().isInOut())
201201
? VarDecl::Specifier::InOut
202202
: VarDecl::Specifier::Default;
@@ -211,7 +211,7 @@ getBuiltinGenericFunction(Identifier Id,
211211
}
212212

213213
auto *paramList = ParameterList::create(Context, params);
214-
214+
215215
DeclName Name(Context, Id, paramList);
216216
auto func = FuncDecl::create(Context, /*StaticLoc=*/SourceLoc(),
217217
StaticSpellingKind::None,
@@ -222,7 +222,7 @@ getBuiltinGenericFunction(Identifier Id,
222222
/*SelfDecl=*/nullptr,
223223
paramList,
224224
TypeLoc::withoutLoc(ResType), DC);
225-
225+
226226
func->setGenericEnvironment(Env);
227227
func->computeType();
228228
func->setValidationToChecked();
@@ -456,7 +456,7 @@ namespace {
456456
GenericParamList *TheGenericParamList;
457457
SmallVector<GenericTypeParamDecl*, 2> GenericTypeParams;
458458
GenericEnvironment *GenericEnv = nullptr;
459-
SmallVector<TupleTypeElt, 4> InterfaceParams;
459+
SmallVector<AnyFunctionType::Param, 4> InterfaceParams;
460460
Type InterfaceResult;
461461

462462
public:
@@ -478,16 +478,15 @@ namespace {
478478
template <class G>
479479
void addParameter(const G &generator) {
480480
Type gTyIface = generator.build(*this);
481-
InterfaceParams.push_back({gTyIface,
482-
Identifier(), ParameterTypeFlags()});
481+
auto flags = ParameterTypeFlags();
482+
InterfaceParams.emplace_back(gTyIface, Identifier(), flags);
483483
}
484484

485485
template <class G>
486486
void addInOutParameter(const G &generator) {
487487
Type gTyIface = generator.build(*this);
488-
auto iFaceflags = ParameterTypeFlags().withInOut(true);
489-
InterfaceParams.push_back(TupleTypeElt(gTyIface,
490-
Identifier(), iFaceflags));
488+
auto flags = ParameterTypeFlags().withInOut(true);
489+
InterfaceParams.emplace_back(gTyIface, Identifier(), flags);
491490
}
492491

493492
template <class G>
@@ -523,17 +522,6 @@ namespace {
523522
return TheFunction(builder);
524523
}
525524
};
526-
template <class T, class U>
527-
struct FunctionGenerator {
528-
T Arg;
529-
U Result;
530-
FunctionType::ExtInfo ExtInfo;
531-
Type build(BuiltinGenericSignatureBuilder &builder) const {
532-
return FunctionType::get(Arg.build(builder),
533-
Result.build(builder),
534-
ExtInfo);
535-
}
536-
};
537525
template <class T>
538526
struct MetatypeGenerator {
539527
T Object;
@@ -568,13 +556,6 @@ makeTuple(const Gs & ...elementGenerators) {
568556
};
569557
}
570558

571-
template <class T, class U>
572-
static BuiltinGenericSignatureBuilder::FunctionGenerator<T,U>
573-
makeFunction(const T &arg, const U &result,
574-
FunctionType::ExtInfo extInfo = FunctionType::ExtInfo()) {
575-
return { arg, result, extInfo };
576-
}
577-
578559
template <class T>
579560
static BuiltinGenericSignatureBuilder::MetatypeGenerator<T>
580561
makeMetatype(const T &object, Optional<MetatypeRepresentation> repr = None) {

0 commit comments

Comments
 (0)