Skip to content

Commit

Permalink
ModulePrinting: Merge synthesized extensions' bodies if they have the…
Browse files Browse the repository at this point in the history
… common constraints.
  • Loading branch information
nkcsgexi committed Mar 11, 2016
1 parent 74afb78 commit c22e9bc
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 120 deletions.
16 changes: 9 additions & 7 deletions include/swift/AST/PrintOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class Type;
enum DeclAttrKind : unsigned;
class PrinterArchetypeTransformer;
class SynthesizedExtensionAnalyzer;
struct PrintOptions;

/// Necessary information for archetype transformation during printing.
struct ArchetypeTransformContext {
Expand All @@ -47,29 +48,30 @@ struct ArchetypeTransformContext {
SynthesizedExtensionAnalyzer *Analyzer);
Type transform(Type Input);
StringRef transform(StringRef Input);

bool shouldPrintRequirement(ExtensionDecl *ED, StringRef Req);
bool shouldOpenExtension;
bool shouldCloseExtension;

~ArchetypeTransformContext();
private:
struct Implementation;
Implementation &Impl;
};

struct SynthesizedExtensionInfo {
ExtensionDecl *Ext = nullptr;
std::vector<StringRef> KnownSatisfiedRequirements;
operator bool() const { return Ext; }
};

class SynthesizedExtensionAnalyzer {
struct Implementation;
Implementation &Impl;

public:
SynthesizedExtensionAnalyzer(NominalTypeDecl *Target,
PrintOptions Options,
bool IncludeUnconditional = true);
~SynthesizedExtensionAnalyzer();
void forEachSynthesizedExtension(
llvm::function_ref<void(ExtensionDecl*)> Fn);
void forEachSynthesizedExtensionMergeGroup(
llvm::function_ref<void(ArrayRef<ExtensionDecl*>)> Fn);
bool isInSynthesizedExtension(const ValueDecl *VD);
bool shouldPrintRequirement(ExtensionDecl *ED, StringRef Req);
};
Expand Down Expand Up @@ -259,7 +261,7 @@ struct PrintOptions {
/// \brief Print dependent types as references into this generic parameter
/// list.
GenericParamList *ContextGenericParams = nullptr;

/// \brief Print types with alternative names from their canonical names.
llvm::DenseMap<CanType, Identifier> *AlternativeTypeNames = nullptr;

Expand Down
Loading

0 comments on commit c22e9bc

Please sign in to comment.