[BuilderTransform] Move buildCall to ResultBuilder type

This commit is contained in:
Pavel Yaskevich
2022-04-13 16:26:37 -07:00
parent 95d9362506
commit e087489f30
2 changed files with 59 additions and 47 deletions

View File

@@ -108,22 +108,15 @@ namespace constraints {
struct ResultBuilder {
private:
DeclContext *DC;
/// An implicit variable that represents `Self` type of the result builder.
VarDecl *BuilderSelf;
Type BuilderType;
llvm::SmallDenseMap<DeclName, bool> SupportedOps;
Identifier BuildOptionalId;
public:
ResultBuilder(DeclContext *DC, Type builderType)
: DC(DC), BuilderType(builderType) {
auto &ctx = DC->getASTContext();
// Use buildOptional(_:) if available, otherwise fall back to buildIf
// when available.
BuildOptionalId =
(supports(ctx.Id_buildOptional) || !supports(ctx.Id_buildIf))
? ctx.Id_buildOptional
: ctx.Id_buildIf;
}
ResultBuilder(ConstraintSystem *CS, DeclContext *DC, Type builderType);
DeclContext *getDeclContext() const { return DC; }
@@ -139,6 +132,10 @@ public:
bool checkAvailability = false);
bool supportsOptional() { return supports(getBuildOptionalId()); }
Expr *buildCall(SourceLoc loc, Identifier fnName,
ArrayRef<Expr *> argExprs,
ArrayRef<Identifier> argLabels) const;
};
/// Describes the algorithm to use for trailing closure matching.