@@ -121,21 +121,16 @@ void TypeVisitor::visitParenType(swift::ParenType* type) {
121121 dispatcher_.emit (ParenTypesTrap{label, typeLabel});
122122}
123123
124- void TypeVisitor::visitUnarySyntaxSugarType (swift::UnarySyntaxSugarType* type) {
125- auto label = dispatcher_.assignNewLabel (type);
126- emitUnarySyntaxSugarType (type, label);
124+ codeql::OptionalType TypeVisitor::translateOptionalType (const swift::OptionalType& type) {
125+ codeql::OptionalType entry{dispatcher_.assignNewLabel (type)};
126+ fillUnarySyntaxSugarType (type, entry);
127+ return entry;
127128}
128129
129- void TypeVisitor::visitOptionalType (swift::OptionalType* type) {
130- auto label = dispatcher_.assignNewLabel (type);
131- dispatcher_.emit (OptionalTypesTrap{label});
132- emitUnarySyntaxSugarType (type, label);
133- }
134-
135- void TypeVisitor::visitArraySliceType (swift::ArraySliceType* type) {
136- auto label = dispatcher_.assignNewLabel (type);
137- dispatcher_.emit (ArraySliceTypesTrap{label});
138- emitUnarySyntaxSugarType (type, label);
130+ codeql::ArraySliceType TypeVisitor::translateArraySliceType (const swift::ArraySliceType& type) {
131+ codeql::ArraySliceType entry{dispatcher_.assignNewLabel (type)};
132+ fillUnarySyntaxSugarType (type, entry);
133+ return entry;
139134}
140135
141136void TypeVisitor::visitDictionaryType (swift::DictionaryType* type) {
@@ -166,11 +161,11 @@ void TypeVisitor::visitLValueType(swift::LValueType* type) {
166161 dispatcher_.emit (LValueTypesTrap{label, dispatcher_.fetchLabel (type->getObjectType ())});
167162}
168163
169- void TypeVisitor::visitPrimaryArchetypeType (swift::PrimaryArchetypeType* type) {
170- auto label = dispatcher_. assignNewLabel ( type);
171- assert (type-> getInterfaceType () && " expect PrimaryArchetypeType to have InterfaceType " ) ;
172- dispatcher_. emit (
173- PrimaryArchetypeTypesTrap{label, dispatcher_. fetchLabel (type-> getInterfaceType ())}) ;
164+ codeql::PrimaryArchetypeType TypeVisitor::translatePrimaryArchetypeType (
165+ const swift::PrimaryArchetypeType& type) {
166+ PrimaryArchetypeType entry{dispatcher_. assignNewLabel (type)} ;
167+ fillArchetypeType (type, entry);
168+ return entry ;
174169}
175170
176171void TypeVisitor::visitUnboundGenericType (swift::UnboundGenericType* type) {
@@ -184,10 +179,11 @@ void TypeVisitor::visitBoundGenericType(swift::BoundGenericType* type) {
184179 emitBoundGenericType (type, label);
185180}
186181
187- void TypeVisitor::emitUnarySyntaxSugarType (const swift::UnarySyntaxSugarType* type,
188- TrapLabel<UnarySyntaxSugarTypeTag> label) {
189- assert (type->getBaseType () && " expect UnarySyntaxSugarType to have BaseType" );
190- dispatcher_.emit (UnarySyntaxSugarTypesTrap{label, dispatcher_.fetchLabel (type->getBaseType ())});
182+ void TypeVisitor::fillUnarySyntaxSugarType (const swift::UnarySyntaxSugarType& type,
183+ codeql::UnarySyntaxSugarType& entry) {
184+ assert (type.getBaseType () && " expect UnarySyntaxSugarType to have BaseType" );
185+ entry.base_type = dispatcher_.fetchLabel (type.getBaseType ());
186+ fillType (type, entry);
191187}
192188
193189void TypeVisitor::emitAnyFunctionType (const swift::AnyFunctionType* type,
@@ -232,4 +228,80 @@ void TypeVisitor::emitAnyGenericType(swift::AnyGenericType* type,
232228 }
233229}
234230
231+ codeql::NestedArchetypeType TypeVisitor::translateNestedArchetypeType (
232+ const swift::NestedArchetypeType& type) {
233+ codeql::NestedArchetypeType entry{dispatcher_.assignNewLabel (type)};
234+ entry.parent = dispatcher_.fetchLabel (type.getParent ());
235+ entry.associated_type_declaration = dispatcher_.fetchLabel (type.getAssocType ());
236+ fillArchetypeType (type, entry);
237+ return entry;
238+ }
239+
240+ void TypeVisitor::fillType (const swift::TypeBase& type, codeql::Type& entry) {
241+ entry.diagnostics_name = type.getString ();
242+ entry.canonical_type = dispatcher_.fetchLabel (type.getCanonicalType ());
243+ }
244+
245+ void TypeVisitor::fillArchetypeType (const swift::ArchetypeType& type, ArchetypeType& entry) {
246+ entry.interface_type = dispatcher_.fetchLabel (type.getInterfaceType ());
247+ entry.name = type.getName ().str ().str ();
248+ entry.protocols = dispatcher_.fetchRepeatedLabels (type.getConformsTo ());
249+ entry.superclass = dispatcher_.fetchOptionalLabel (type.getSuperclass ());
250+ fillType (type, entry);
251+ }
252+
253+ codeql::ExistentialType TypeVisitor::translateExistentialType (const swift::ExistentialType& type) {
254+ codeql::ExistentialType entry{dispatcher_.assignNewLabel (type)};
255+ entry.constraint = dispatcher_.fetchLabel (type.getConstraintType ());
256+ fillType (type, entry);
257+ return entry;
258+ }
259+
260+ codeql::DynamicSelfType TypeVisitor::translateDynamicSelfType (const swift::DynamicSelfType& type) {
261+ codeql::DynamicSelfType entry{dispatcher_.assignNewLabel (type)};
262+ entry.static_self_type = dispatcher_.fetchLabel (type.getSelfType ());
263+ fillType (type, entry);
264+ return entry;
265+ }
266+
267+ codeql::VariadicSequenceType TypeVisitor::translateVariadicSequenceType (
268+ const swift::VariadicSequenceType& type) {
269+ codeql::VariadicSequenceType entry{dispatcher_.assignNewLabel (type)};
270+ fillUnarySyntaxSugarType (type, entry);
271+ return entry;
272+ }
273+
274+ codeql::InOutType TypeVisitor::translateInOutType (const swift::InOutType& type) {
275+ codeql::InOutType entry{dispatcher_.assignNewLabel (type)};
276+ entry.object_type = dispatcher_.fetchLabel (type.getObjectType ());
277+ fillType (type, entry);
278+ return entry;
279+ }
280+
281+ codeql::UnmanagedStorageType TypeVisitor::translateUnmanagedStorageType (
282+ const swift::UnmanagedStorageType& type) {
283+ codeql::UnmanagedStorageType entry{dispatcher_.assignNewLabel (type)};
284+ fillReferenceStorageType (type, entry);
285+ return entry;
286+ }
287+
288+ codeql::UnownedStorageType TypeVisitor::translateUnownedStorageType (
289+ const swift::UnownedStorageType& type) {
290+ codeql::UnownedStorageType entry{dispatcher_.assignNewLabel (type)};
291+ fillReferenceStorageType (type, entry);
292+ return entry;
293+ }
294+
295+ codeql::WeakStorageType TypeVisitor::translateWeakStorageType (const swift::WeakStorageType& type) {
296+ codeql::WeakStorageType entry{dispatcher_.assignNewLabel (type)};
297+ fillReferenceStorageType (type, entry);
298+ return entry;
299+ }
300+
301+ void TypeVisitor::fillReferenceStorageType (const swift::ReferenceStorageType& type,
302+ codeql::ReferenceStorageType& entry) {
303+ entry.referent_type = dispatcher_.fetchLabel (type.getReferentType ());
304+ fillType (type, entry);
305+ }
306+
235307} // namespace codeql
0 commit comments