@@ -292,168 +292,14 @@ RT_API_ATTRS void Descriptor::Check() const {
292292 // TODO
293293}
294294
295- static const char *GetTypeStr (ISO::CFI_type_t type, bool dumpRawType) {
296- if (dumpRawType) {
297- #define CASE (x ) \
298- case (x): \
299- return #x;
300- switch (type) {
301- CASE (CFI_type_signed_char)
302- CASE (CFI_type_short)
303- CASE (CFI_type_int)
304- CASE (CFI_type_long)
305- CASE (CFI_type_long_long)
306- CASE (CFI_type_size_t)
307- CASE (CFI_type_int8_t)
308- CASE (CFI_type_int16_t)
309- CASE (CFI_type_int32_t)
310- CASE (CFI_type_int64_t)
311- CASE (CFI_type_int128_t)
312- CASE (CFI_type_int_least8_t)
313- CASE (CFI_type_int_least16_t)
314- CASE (CFI_type_int_least32_t)
315- CASE (CFI_type_int_least64_t)
316- CASE (CFI_type_int_least128_t)
317- CASE (CFI_type_int_fast8_t)
318- CASE (CFI_type_int_fast16_t)
319- CASE (CFI_type_int_fast32_t)
320- CASE (CFI_type_int_fast64_t)
321- CASE (CFI_type_int_fast128_t)
322- CASE (CFI_type_intmax_t)
323- CASE (CFI_type_intptr_t)
324- CASE (CFI_type_ptrdiff_t)
325- CASE (CFI_type_half_float)
326- CASE (CFI_type_bfloat)
327- CASE (CFI_type_float)
328- CASE (CFI_type_double)
329- CASE (CFI_type_extended_double)
330- CASE (CFI_type_long_double)
331- CASE (CFI_type_float128)
332- CASE (CFI_type_half_float_Complex)
333- CASE (CFI_type_bfloat_Complex)
334- CASE (CFI_type_float_Complex)
335- CASE (CFI_type_double_Complex)
336- CASE (CFI_type_extended_double_Complex)
337- CASE (CFI_type_long_double_Complex)
338- CASE (CFI_type_float128_Complex)
339- CASE (CFI_type_Bool)
340- CASE (CFI_type_char)
341- CASE (CFI_type_cptr)
342- CASE (CFI_type_struct)
343- CASE (CFI_type_char16_t)
344- CASE (CFI_type_char32_t)
345- CASE (CFI_type_uint8_t)
346- CASE (CFI_type_uint16_t)
347- CASE (CFI_type_uint32_t)
348- CASE (CFI_type_uint64_t)
349- CASE (CFI_type_uint128_t)
350- }
351- #undef CASE
352- return nullptr ;
353- }
354- TypeCode code{type};
355-
356- if (!code.IsValid ())
357- return " invalid" ;
358-
359- common::optional<std::pair<TypeCategory, int >> categoryAndKind =
360- code.GetCategoryAndKind ();
361- if (!categoryAndKind)
362- return nullptr ;
363-
364- TypeCategory tcat;
365- int kind;
366- std::tie (tcat, kind) = *categoryAndKind;
367-
368- #define CASE (cat, k ) \
369- case (k): \
370- return #cat " (kind=" #k " )" ;
371- switch (tcat) {
372- case TypeCategory::Integer:
373- switch (kind) {
374- CASE (INTEGER, 1 )
375- CASE (INTEGER, 2 )
376- CASE (INTEGER, 4 )
377- CASE (INTEGER, 8 )
378- CASE (INTEGER, 16 )
379- }
380- break ;
381- case TypeCategory::Unsigned:
382- switch (kind) {
383- CASE (UNSIGNED, 1 )
384- CASE (UNSIGNED, 2 )
385- CASE (UNSIGNED, 4 )
386- CASE (UNSIGNED, 8 )
387- CASE (UNSIGNED, 16 )
388- }
389- break ;
390- case TypeCategory::Real:
391- switch (kind) {
392- CASE (REAL, 2 )
393- CASE (REAL, 3 )
394- CASE (REAL, 4 )
395- CASE (REAL, 8 )
396- CASE (REAL, 10 )
397- CASE (REAL, 16 )
398- }
399- break ;
400- case TypeCategory::Complex:
401- switch (kind) {
402- CASE (COMPLEX, 2 )
403- CASE (COMPLEX, 3 )
404- CASE (COMPLEX, 4 )
405- CASE (COMPLEX, 8 )
406- CASE (COMPLEX, 10 )
407- CASE (COMPLEX, 16 )
408- }
409- break ;
410- case TypeCategory::Character:
411- switch (kind) {
412- CASE (CHARACTER, 1 )
413- CASE (CHARACTER, 2 )
414- CASE (CHARACTER, 4 )
415- }
416- break ;
417- case TypeCategory::Logical:
418- switch (kind) {
419- CASE (LOGICAL, 1 )
420- CASE (LOGICAL, 2 )
421- CASE (LOGICAL, 4 )
422- CASE (LOGICAL, 8 )
423- }
424- break ;
425- case TypeCategory::Derived:
426- return " DERIVED" ;
427- }
428- #undef CASE
429- return nullptr ;
430- }
431-
432- void Descriptor::Dump (FILE *f, bool dumpRawType) const {
295+ void Descriptor::Dump (FILE *f) const {
433296 std::fprintf (f, " Descriptor @ %p:\n " , reinterpret_cast <const void *>(this ));
434297 std::fprintf (f, " base_addr %p\n " , raw_.base_addr );
435- std::fprintf (f, " elem_len %zd\n " , ElementBytes ( ));
298+ std::fprintf (f, " elem_len %zd\n " , static_cast <std:: size_t >(raw_. elem_len ));
436299 std::fprintf (f, " version %d\n " , static_cast <int >(raw_.version ));
437- if (rank () > 0 ) {
438- std::fprintf (f, " rank %d\n " , rank ());
439- } else {
440- std::fprintf (f, " scalar\n " );
441- }
442- int ty = static_cast <int >(raw_.type );
443- if (const char *tyStr = GetTypeStr (raw_.type , dumpRawType)) {
444- std::fprintf (f, " type %d \" %s\"\n " , ty, tyStr);
445- } else {
446- std::fprintf (f, " type %d\n " , ty);
447- }
448- int attr = static_cast <int >(raw_.attribute );
449- if (IsPointer ()) {
450- std::fprintf (f, " attribute %d (pointer) \n " , attr);
451- } else if (IsAllocatable ()) {
452- std::fprintf (f, " attribute %d (allocatable)\n " , attr);
453- } else {
454- std::fprintf (f, " attribute %d\n " , attr);
455- }
456-
300+ std::fprintf (f, " rank %d\n " , static_cast <int >(raw_.rank ));
301+ std::fprintf (f, " type %d\n " , static_cast <int >(raw_.type ));
302+ std::fprintf (f, " attribute %d\n " , static_cast <int >(raw_.attribute ));
457303 std::fprintf (f, " extra %d\n " , static_cast <int >(raw_.extra ));
458304 std::fprintf (f, " addendum %d\n " , static_cast <int >(HasAddendum ()));
459305 std::fprintf (f, " alloc_idx %d\n " , static_cast <int >(GetAllocIdx ()));
0 commit comments