prettyClassDef :: DexFile -> (TypeId, Class) -> PP.Doc
prettyClassDef dex (i, cls) =
  vsep [ PP.hcat [ "Class #", word16Dec i, " header:" ]
          , prettyField16 "class_idx" (classId cls)
          , prettyFieldHex4 "access_flags" (classAccessFlags cls)
          , prettyField16 "superclass_idx" (classSuperId cls)
          , prettyFieldHex "interfaces_off" (classInterfacesOff cls)
          , prettyField32 "source_file_idx" (classSourceNameId cls)
          , prettyFieldHex "annotations_off" (classAnnotsOff cls)
          , prettyFieldHex "class_data_off" (classDataOff cls)
          , prettyField32 "static_fields_size" (fromIntegral (length (classStaticFields cls)))
          , prettyField32 "instance_fields_size" (fromIntegral (length (classInstanceFields cls)))
          , prettyField32 "direct_methods_size" (fromIntegral (length (classDirectMethods cls)))
          , prettyField32 "virtual_methods_size" (fromIntegral (length (classVirtualMethods cls)))
          , ""
          , PP.hcat ["Class #", word16Dec i, "          -"]
          , prettyField "  Class descriptor" (PP.quotes (getTypeName' dex (classId cls)))
          , prettyFieldHexS "  Access flags" (classAccessFlags cls) (AF.flagsString AF.AClass (classAccessFlags cls))
          , prettyField "  Superclass" (PP.quotes (getTypeName' dex (classSuperId cls)))
          , "  Annotations      -"
          , PP.nest 4 $ vsep (map (prettyVisibleAnnotation dex) cannots)
          , "  Interfaces       -"
          , vsep (map (prettyInterface dex) (zip [0..] (classInterfaces cls)))
          , "  Static fields    -"
          , vsep (map (prettyEncodedField dex fannots) (zip [0..] (classStaticFields cls)))
          , "  Instance fields  -"
          , vsep (map (prettyEncodedField dex fannots) (zip [0..] (classInstanceFields cls)))
          , "  Direct methods   -"
          , vsep (map (prettyEncodedMethod dex mannots) (zip [0..] (classDirectMethods cls)))
          , "  Virtual methods  -"
          , vsep (map (prettyEncodedMethod dex mannots) (zip [0..] (classVirtualMethods cls)))
          ]
  where
    ClassAnnotations { classAnnotationsAnnot = cannots
                     , classFieldAnnotations = fannots
                     , classMethodAnnotations = mannots
                     } = classAnnotations cls
prettyClassDef :: DexFile -> (TypeId, Class) -> PP.Doc
prettyClassDef dex (i, cls) =
  vsep [ PP.hcat [ "Class #", word16Dec i, " header:" ]
          , prettyField16 "class_idx" (classId cls)
          , prettyFieldHex4 "access_flags" (classAccessFlags cls)
          , prettyField16 "superclass_idx" (classSuperId cls)
          , prettyFieldHex "interfaces_off" (classInterfacesOff cls)
          , prettyField32 "source_file_idx" (classSourceNameId cls)
          , prettyFieldHex "annotations_off" (classAnnotsOff cls)
          , prettyFieldHex "class_data_off" (classDataOff cls)
          , prettyField32 "static_fields_size" (fromIntegral (length (classStaticFields cls)))
          , prettyField32 "instance_fields_size" (fromIntegral (length (classInstanceFields cls)))
          , prettyField32 "direct_methods_size" (fromIntegral (length (classDirectMethods cls)))
          , prettyField32 "virtual_methods_size" (fromIntegral (length (classVirtualMethods cls)))
          , ""
          , PP.hcat ["Class #", word16Dec i, "          -"]
          , prettyField "  Class descriptor" (PP.quotes (getTypeName' dex (classId cls)))
          , prettyFieldHexS "  Access flags" (classAccessFlags cls) (AF.flagsString AF.AClass (classAccessFlags cls))
          , prettyField "  Superclass" (PP.quotes (getTypeName' dex (classSuperId cls)))
          , "  Annotations      -"
          , PP.nest 4 $ vsep (map (prettyVisibleAnnotation dex) cannots)
          , "  Interfaces       -"
          , vsep (map (prettyInterface dex) (zip [0..] (classInterfaces cls)))
          , "  Static fields    -"
          , vsep (map (prettyEncodedField dex fannots) (zip [0..] (classStaticFields cls)))
          , "  Instance fields  -"
          , vsep (map (prettyEncodedField dex fannots) (zip [0..] (classInstanceFields cls)))
          , "  Direct methods   -"
          , vsep (map (prettyEncodedMethod dex mannots) (zip [0..] (classDirectMethods cls)))
          , "  Virtual methods  -"
          , vsep (map (prettyEncodedMethod dex mannots) (zip [0..] (classVirtualMethods cls)))
          ]
  where
    ClassAnnotations { classAnnotationsAnnot = cannots
                     , classFieldAnnotations = fannots
                     , classMethodAnnotations = mannots
                     } = classAnnotations cls
prettyClassDef dex (i, cls) =
  vsep [ PP.hcat [ "Class #", word16Dec i, " header:" ]
          , prettyField16 "class_idx" (classId cls)
          , prettyFieldHex4 "access_flags" (classAccessFlags cls)
          , prettyField16 "superclass_idx" (classSuperId cls)
          , prettyFieldHex "interfaces_off" (classInterfacesOff cls)
          , prettyField32 "source_file_idx" (classSourceNameId cls)
          , prettyFieldHex "annotations_off" (classAnnotsOff cls)
          , prettyFieldHex "class_data_off" (classDataOff cls)
          , prettyField32 "static_fields_size" (fromIntegral (length (classStaticFields cls)))
          , prettyField32 "instance_fields_size" (fromIntegral (length (classInstanceFields cls)))
          , prettyField32 "direct_methods_size" (fromIntegral (length (classDirectMethods cls)))
          , prettyField32 "virtual_methods_size" (fromIntegral (length (classVirtualMethods cls)))
          , ""
          , PP.hcat ["Class #", word16Dec i, "          -"]
          , prettyField "  Class descriptor" (PP.quotes (getTypeName' dex (classId cls)))
          , prettyFieldHexS "  Access flags" (classAccessFlags cls) (AF.flagsString AF.AClass (classAccessFlags cls))
          , prettyField "  Superclass" (PP.quotes (getTypeName' dex (classSuperId cls)))
          , "  Annotations      -"
          , PP.nest 4 $ vsep (map (prettyVisibleAnnotation dex) cannots)
          , "  Interfaces       -"
          , vsep (map (prettyInterface dex) (zip [0..] (classInterfaces cls)))
          , "  Static fields    -"
          , vsep (map (prettyEncodedField dex fannots) (zip [0..] (classStaticFields cls)))
          , "  Instance fields  -"
          , vsep (map (prettyEncodedField dex fannots) (zip [0..] (classInstanceFields cls)))
          , "  Direct methods   -"
          , vsep (map (prettyEncodedMethod dex mannots) (zip [0..] (classDirectMethods cls)))
          , "  Virtual methods  -"
          , vsep (map (prettyEncodedMethod dex mannots) (zip [0..] (classVirtualMethods cls)))
          ]
  where
    ClassAnnotations { classAnnotationsAnnot = cannots
                     , classFieldAnnotations = fannots
                     , classMethodAnnotations = mannots
                     } = classAnnotations cls