xref: /aosp_15_r20/external/leakcanary2/shark-hprof/src/main/java/shark/PrimitiveType.kt (revision d9e8da70d8c9df9a41d7848ae506fb3115cae6e6)
1 package shark
2 
3 /**
4  * A primitive type in the prof.
5  */
6 enum class PrimitiveType(
7   /**
8    * The hprof defined "basic type".
9    */
10   val hprofType: Int,
11   /**
12    * The size in bytes for each value of that type.
13    */
14   val byteSize: Int
15 ) {
16   BOOLEAN(4, 1),
17   CHAR(5, 2),
18   FLOAT(6, 4),
19   DOUBLE(7, 8),
20   BYTE(8, 1),
21   SHORT(9, 2),
22   INT(10, 4),
23   LONG(11, 8);
24 
25   companion object {
26     /**
27      * The hprof defined "basic type" for references.
28      */
29     const val REFERENCE_HPROF_TYPE = 2
30 
<lambda>null31     val byteSizeByHprofType = values().associate { it.hprofType to it.byteSize }
32 
<lambda>null33     val primitiveTypeByHprofType = values().associateBy { it.hprofType }
34   }
35 }
36