@@ -54,21 +54,10 @@ class CompilerPlugin {
54
54
// stdlib/toolchain/CompilerPluginSupport.swift.
55
55
enum class WitnessTableEntry : unsigned {
56
56
ConformanceDescriptor = 0 ,
57
- // static func _name() -> (UnsafePointer<UInt8>, count: Int8)
58
- Name = 1 ,
59
57
// static func _kind() -> _CompilerPluginKind
60
- Kind = 2 ,
58
+ Kind = 1 ,
61
59
// static func _rewrite(...) -> (UnsafePointer<UInt8>?, count: Int)
62
- Rewrite = 3 ,
63
- // static func _genericSignature(...) -> (UnsafePointer<UInt8>?, count: Int)
64
- GenericSignature = 4 ,
65
- // static func _typeSignature(...) -> (UnsafePointer<UInt8>, count: Int)
66
- TypeSignature = 5 ,
67
- // static func _owningModule(...) -> (UnsafePointer<UInt8>, count: Int)
68
- OwningModule = 6 ,
69
- // static func _supplementalSignatureModules(...)
70
- // -> (UnsafePointer<UInt8>, count: Int)
71
- SupplementalSignatureModules = 7 ,
60
+ Rewrite = 2 ,
72
61
};
73
62
74
63
// / The plugin type metadata.
@@ -77,8 +66,6 @@ class CompilerPlugin {
77
66
void *parentLibrary;
78
67
// / The witness table proving that the plugin conforms to `_CompilerPlugin`.
79
68
const void *witnessTable;
80
- // / The plugin name, aka. result of the `_name()` method.
81
- StringRef name;
82
69
// / The plugin's kind, aka. result of the `_kind()` method.
83
70
Kind kind;
84
71
@@ -87,14 +74,10 @@ class CompilerPlugin {
87
74
return reinterpret_cast <const Func *const *>(witnessTable)[(unsigned )entry];
88
75
}
89
76
90
- protected:
91
- CompilerPlugin ( const void *metadata, void *parentLibrary, ASTContext &ctx );
77
+ CompilerPlugin (
78
+ const void *metadata, void *parentLibrary, const void *witnessTable );
92
79
93
80
private:
94
- // / Invoke the `_name` method. The caller assumes ownership of the result
95
- // / string buffer.
96
- StringRef invokeName () const ;
97
-
98
81
// / Invoke the `_kind` method.
99
82
Kind invokeKind () const ;
100
83
@@ -103,33 +86,16 @@ class CompilerPlugin {
103
86
CompilerPlugin (const CompilerPlugin &) = delete ;
104
87
CompilerPlugin (CompilerPlugin &&) = default ;
105
88
89
+ // / Try to resolve a compiler plugin given the metadata point.
90
+ static CompilerPlugin *fromMetatype (const void *metadata, ASTContext &ctx);
91
+
106
92
// / Invoke the `_rewrite` method. The caller assumes ownership of the result
107
93
// / string buffer and diagnostic buffers.
108
94
Optional<NullTerminatedStringRef> invokeRewrite (
109
95
StringRef targetModuleName, StringRef filePath, StringRef sourceFileText,
110
96
CharSourceRange range, ASTContext &ctx,
111
97
SmallVectorImpl<Diagnostic> &diagnostics) const ;
112
98
113
- // / Invoke the `_genericSignature` method. The caller assumes ownership of the
114
- // / result string buffer.
115
- Optional<StringRef> invokeGenericSignature () const ;
116
-
117
- // / Invoke the `_typeSignature` method. The caller assumes ownership of the
118
- // / result string buffer.
119
- StringRef invokeTypeSignature () const ;
120
-
121
- // / Invoke the `_owningModule` method. The caller assumes ownership of the
122
- // / result string buffer.
123
- StringRef invokeOwningModule () const ;
124
-
125
- // / Invoke the `_supplementalSignatureModules` method. The caller assumes
126
- // / ownership of the result string buffer.
127
- StringRef invokeSupplementalSignatureModules () const ;
128
-
129
- StringRef getName () const {
130
- return name;
131
- }
132
-
133
99
Kind getKind () const {
134
100
return kind;
135
101
}
0 commit comments