16
16
#include " swift/Basic/STLExtras.h"
17
17
#include " swift/AST/AttrKind.h"
18
18
#include " swift/AST/Identifier.h"
19
+ #include " llvm/ADT/Optional.h"
19
20
#include < limits.h>
20
21
#include < vector>
21
22
@@ -31,32 +32,21 @@ class DeclContext;
31
32
class Type ;
32
33
class ModuleDecl ;
33
34
enum DeclAttrKind : unsigned ;
34
- class PrinterTypeTransformer ;
35
35
class SynthesizedExtensionAnalyzer ;
36
36
struct PrintOptions ;
37
37
38
38
// / Necessary information for archetype transformation during printing.
39
39
struct TypeTransformContext {
40
- Type getTypeBase ();
41
- NominalTypeDecl *getNominal ();
42
- PrinterTypeTransformer *getTransformer ();
43
- bool isPrintingSynthesizedExtension ();
44
- bool isPrintingTypeInterface ();
45
- TypeTransformContext (PrinterTypeTransformer *Transformer);
46
- TypeTransformContext (PrinterTypeTransformer *Transformer,
47
- Type T);
48
- TypeTransformContext (PrinterTypeTransformer *Transformer,
49
- NominalTypeDecl *NTD,
50
- SynthesizedExtensionAnalyzer *Analyzer);
51
- Type transform (Type Input);
52
- StringRef transform (StringRef Input);
40
+ TypeBase *BaseType;
41
+ NominalTypeDecl *Nominal = nullptr ;
53
42
54
- bool shouldPrintRequirement (ExtensionDecl *ED, StringRef Req);
43
+ explicit TypeTransformContext (Type T);
44
+ explicit TypeTransformContext (NominalTypeDecl* NTD);
55
45
56
- ~TypeTransformContext () ;
57
- private:
58
- struct Implementation ;
59
- Implementation &Impl ;
46
+ Type getTypeBase () const ;
47
+ NominalTypeDecl * getNominal () const ;
48
+
49
+ bool isPrintingSynthesizedExtension () const ;
60
50
};
61
51
62
52
typedef std::pair<ExtensionDecl*, bool > ExtensionAndIsSynthesized;
@@ -196,6 +186,10 @@ struct PrintOptions {
196
186
// / ([] and ?), even if there are no sugar type nodes.
197
187
bool SynthesizeSugarOnTypes = false ;
198
188
189
+ // / \brief Print a dynamic Self type as its underlying type, rather than
190
+ // / the keyword `Self`.
191
+ bool StripDynamicSelf = false ;
192
+
199
193
// / \brief If true, the printer will explode a pattern like this:
200
194
// / \code
201
195
// / var (a, b) = f()
@@ -350,7 +344,7 @@ struct PrintOptions {
350
344
ModuleDecl *CurrentModule = nullptr ;
351
345
352
346
// / \brief The information for converting archetypes to specialized types.
353
- std::shared_ptr <TypeTransformContext> TransformContext;
347
+ llvm::Optional <TypeTransformContext> TransformContext;
354
348
355
349
// / \brief If this is not \c nullptr then functions (including accessors and
356
350
// / constructors) will be printed with a body that is determined by this
@@ -413,16 +407,15 @@ struct PrintOptions {
413
407
return result;
414
408
}
415
409
416
- static PrintOptions printTypeInterface (Type T, DeclContext *DC );
410
+ static PrintOptions printTypeInterface (Type T);
417
411
418
- void setArchetypeSelfTransform (Type T, DeclContext *DC );
412
+ void setArchetypeSelfTransform (Type T);
419
413
420
- void setArchetypeSelfTransformForQuickHelp (Type T, DeclContext *DC );
414
+ void setArchetypeSelfTransformForQuickHelp (Type T);
421
415
422
- void setArchetypeAndDynamicSelfTransform (Type T, DeclContext *DC );
416
+ void setArchetypeAndDynamicSelfTransform (Type T);
423
417
424
- void initArchetypeTransformerForSynthesizedExtensions (NominalTypeDecl *D,
425
- SynthesizedExtensionAnalyzer *SynAnalyzer);
418
+ void initArchetypeTransformerForSynthesizedExtensions (NominalTypeDecl *D);
426
419
427
420
void clearArchetypeTransformerForSynthesizedExtensions ();
428
421
0 commit comments