@@ -172,55 +172,6 @@ RsExpr *ConverterRefCount::VisitLValueReferenceType(
172172 return Cat (Text (" Ptr<" ), Convert (type->getPointeeType ()), Text (' >' ));
173173}
174174
175- RsExpr *ConverterRefCount::VisitPointerType (const clang::PointerType *type) {
176- if (auto proto = type->getPointeeType ()->getAs <clang::FunctionProtoType>()) {
177- return Cat (Text (" FnPtr<" ), ConvertFunctionPointerType (proto), Text (' >' ));
178- }
179-
180- if (IsVaListType (clang::QualType (type, 0 ))) {
181- return Text (" VaList" );
182- }
183-
184- if (type->isVoidPointerType ()) {
185- return Text (" AnyPtr" );
186- }
187-
188- auto pointee_type = type->getPointeeType ();
189- PushConversionKind push1 (*this , ConversionKind::Ptr,
190- !pointee_type->isArrayType ());
191- PushConversionKind push2 (*this , ConversionKind::FullRefCount,
192- pointee_type->isArrayType ());
193- const char *open = " Ptr<" ;
194- if (pointee_type->isRecordType () &&
195- abstract_structs_.contains (GetID (pointee_type->getAsRecordDecl ()))) {
196- open = " PtrDyn<dyn" ;
197- }
198- return Cat (Text (open), Convert (pointee_type), Text (' >' ));
199- }
200-
201- RsExpr *ConverterRefCount::VisitRecordType (const clang::RecordType *type) {
202- PushConversionKind push (*this , ConversionKind::Unboxed);
203- return Converter::VisitRecordType (type);
204- }
205-
206- RsExpr *ConverterRefCount::VisitConstantArrayType (
207- const clang::ConstantArrayType *type) {
208- auto conv = getConversionKind ();
209- PushConversionKind push (*this , ConversionKind::Unboxed);
210-
211- switch (conv) {
212- case ConversionKind::Unboxed:
213- return Cat (
214- Text (' [' ), Convert (type->getElementType ()),
215- Text (std::format (" ; {}]" , GetNumAsString (type->getSize ()).c_str ())));
216- case ConversionKind::Ptr:
217- return Convert (type->getElementType ());
218- case ConversionKind::FullRefCount:
219- return Cat (Text (" Box<[" ), Convert (type->getElementType ()), Text (" ]>" ));
220- }
221- std::unreachable ();
222- }
223-
224175RsExpr *ConverterRefCount::BuildFnAdapter (
225176 const clang::FunctionDecl *src_fn,
226177 const clang::FunctionProtoType *src_proto,
@@ -291,6 +242,55 @@ RsExpr *ConverterRefCount::ConvertFunctionPointerType(
291242 return Converter::ConvertFunctionPointerType (proto, kind);
292243}
293244
245+ RsExpr *ConverterRefCount::VisitPointerType (const clang::PointerType *type) {
246+ if (auto proto = type->getPointeeType ()->getAs <clang::FunctionProtoType>()) {
247+ return Cat (Text (" FnPtr<" ), ConvertFunctionPointerType (proto), Text (' >' ));
248+ }
249+
250+ if (IsVaListType (clang::QualType (type, 0 ))) {
251+ return Text (" VaList" );
252+ }
253+
254+ if (type->isVoidPointerType ()) {
255+ return Text (" AnyPtr" );
256+ }
257+
258+ auto pointee_type = type->getPointeeType ();
259+ PushConversionKind push1 (*this , ConversionKind::Ptr,
260+ !pointee_type->isArrayType ());
261+ PushConversionKind push2 (*this , ConversionKind::FullRefCount,
262+ pointee_type->isArrayType ());
263+ const char *open = " Ptr<" ;
264+ if (pointee_type->isRecordType () &&
265+ abstract_structs_.contains (GetID (pointee_type->getAsRecordDecl ()))) {
266+ open = " PtrDyn<dyn" ;
267+ }
268+ return Cat (Text (open), Convert (pointee_type), Text (' >' ));
269+ }
270+
271+ RsExpr *ConverterRefCount::VisitRecordType (const clang::RecordType *type) {
272+ PushConversionKind push (*this , ConversionKind::Unboxed);
273+ return Converter::VisitRecordType (type);
274+ }
275+
276+ RsExpr *ConverterRefCount::VisitConstantArrayType (
277+ const clang::ConstantArrayType *type) {
278+ auto conv = getConversionKind ();
279+ PushConversionKind push (*this , ConversionKind::Unboxed);
280+
281+ switch (conv) {
282+ case ConversionKind::Unboxed:
283+ return Cat (
284+ Text (' [' ), Convert (type->getElementType ()),
285+ Text (std::format (" ; {}]" , GetNumAsString (type->getSize ()).c_str ())));
286+ case ConversionKind::Ptr:
287+ return Convert (type->getElementType ());
288+ case ConversionKind::FullRefCount:
289+ return Cat (Text (" Box<[" ), Convert (type->getElementType ()), Text (" ]>" ));
290+ }
291+ std::unreachable ();
292+ }
293+
294294RsExpr *ConverterRefCount::ConvertFreshLValue (clang::Expr *expr) {
295295 auto *node = ConvertLValue (expr);
296296 if (isFresh ()) {
0 commit comments