module Jvm.Data.ClassFormat where
import qualified Data.ByteString.Lazy as BS
data ClassFile = ClassFile { magic :: Magic
, minver :: MinorVersion
, maxver :: MajorVersion
, count_cp :: ConstantPool_Count
, array_cp :: CP_Infos
, acfg :: AccessFlags
, this :: ThisClass
, super :: SuperClass
, count_interfaces :: Interfaces_Count
, array_interfaces :: Interfaces
, count_fields :: Fields_Count
, array_fields :: Field_Infos
, count_methods :: Methods_Count
, array_methods :: Method_Infos
, count_attributes :: Attributes_Count
, array_attributes :: Attribute_Infos
}
deriving Show
type CP_Infos = [CP_Info]
type Interfaces = [Interface]
type Field_Infos = [Field_Info]
type Method_Infos = [Method_Info]
type Attribute_Infos = [Attribute_Info]
data Magic = Magic
deriving Show
data MinorVersion = MinorVersion {
numMinVer :: Int
}
deriving Show
data MajorVersion = MajorVersion {
numMaxVer :: Int
}
deriving Show
data CP_Info =
Class_Info
{ tag_cp :: Tag
, index_cp :: Index_Constant_Pool
, desc :: String
}
| FieldRef_Info
{ tag_cp :: Tag
, index_name_cp :: Index_Constant_Pool
, index_nameandtype_cp :: Index_Constant_Pool
, desc :: String
}
| MethodRef_Info
{ tag_cp :: Tag
, index_name_cp :: Index_Constant_Pool
, index_nameandtype_cp :: Index_Constant_Pool
, desc :: String
}
| InterfaceMethodRef_Info
{ tag_cp :: Tag
, index_name_cp :: Index_Constant_Pool
, index_nameandtype_cp :: Index_Constant_Pool
, desc :: String
}
| String_Info
{ tag_cp :: Tag
, index_cp :: Index_Constant_Pool
, desc :: String
}
| Integer_Info
{ tag_cp :: Tag
, numi_cp :: Int
, desc :: String
}
| Float_Info
{ tag_cp :: Tag
, numf_cp :: Float
, desc :: String
}
| Long_Info
{ tag_cp :: Tag
, numi_l1_cp :: Int
, numi_l2_cp :: Int
, desc :: String
}
| Double_Info
{ tag_cp :: Tag
, numi_d1_cp :: Int
, numi_d2_cp :: Int
, desc :: String
}
| NameAndType_Info
{ tag_cp :: Tag
, index_name_cp :: Index_Constant_Pool
, index_descr_cp :: Index_Constant_Pool
, desc :: String
}
| Utf8_Info
{ tag_cp :: Tag
, tam_cp :: Int
, cad_cp :: String
, desc :: String
}
deriving Show
data Tag = TagClass
| TagFieldRef
| TagMethodRef
| TagInterfaceMethodRef
| TagString
| TagInteger
| TagFloat
| TagLong
| TagDouble
| TagNameAndType
| TagUtf8
deriving Show
data AccessFlags = AccessFlags [Int]
deriving Show
acc_Public :: Int
acc_Public = 1
acc_Private :: Int
acc_Private = 2
acc_Protected :: Int
acc_Protected = 4
acc_Static :: Int
acc_Static = 8
acc_Final :: Int
acc_Final = 16
acc_Super_Synchronized :: Int
acc_Super_Synchronized = 32
acc_Volatile_Bridge :: Int
acc_Volatile_Bridge = 64
acc_Transient_Varargs :: Int
acc_Transient_Varargs = 128
acc_Native :: Int
acc_Native = 256
acc_Interface :: Int
acc_Interface = 512
acc_Abstract :: Int
acc_Abstract = 1024
acc_Strict :: Int
acc_Strict = 2048
acc_Synthetic :: Int
acc_Synthetic = 4096
acc_Annotation :: Int
acc_Annotation = 8192
acc_Enum :: Int
acc_Enum = 16384
data ThisClass = ThisClass {
index_th :: Index_Constant_Pool
}
deriving Show
data SuperClass = SuperClass {
index_sp :: Index_Constant_Pool
}
deriving Show
data Interface = Interface {
index_if :: Index_Constant_Pool
}
deriving Show
data Field_Info = Field_Info
{ af_fi :: AccessFlags
, index_name_fi :: Index_Constant_Pool
, index_descr_fi :: Index_Constant_Pool
, tam_fi :: Int
, array_attr_fi :: Attribute_Infos
}
deriving Show
data Method_Info = Method_Info
{ af_mi :: AccessFlags
, index_name_mi :: Index_Constant_Pool
, index_descr_mi :: Index_Constant_Pool
, tam_mi :: Int
, array_attr_mi :: Attribute_Infos
}
deriving Show
data Attribute_Info =
AttributeGeneric
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, rest_attr :: BS.ByteString
}
| AttributeConstantValue
{ index_name_attr :: Index_Constant_Pool
, tam_attr :: Int
, index_value_attr :: Index_Constant_Pool
}
| AttributeCode
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, len_stack_attr :: Int
, len_local_attr :: Int
, tam_code_attr :: Int
, array_code_attr :: ListaInt
, tam_ex_attr :: Int
, array_ex_attr :: Tupla4Int
, tam_atrr_attr :: Int
, array_attr_attr :: Attribute_Infos
}
| AttributeExceptions
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, tam_num_ex_attr :: Int
, exception_index_table :: [Int]
}
| AttributeInnerClasses
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, tam_classes :: Int
, array_classes :: [(Int,Int,Int,AccessFlags)]
}
| AttributeSynthetic
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
}
| AttributeSourceFile
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, index_src_attr :: Index_Constant_Pool
}
| AttributeLineNumberTable
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, tam_table_attr :: Int
, array_line_attr :: Tupla2Int
}
| AttributeLocalVariableTable
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
, tam__table_attr :: Int
, array_var_attr :: Tupla5Int
}
| AttributeDeprecated
{ index_name_attr :: Index_Constant_Pool
, tam_len_attr :: Int
}
deriving Show
type Tupla5Int = [(Int, Int, Int, Int, Int)]
type Tupla2Int = [(Int, Int)]
type Tupla4Int = [(Int, Int, Int, Int)]
type ListaInt = [Int]
type ConstantPool_Count = Int
type Interfaces_Count = Int
type Fields_Count = Int
type Methods_Count = Int
type Attributes_Count = Int
type Index_Constant_Pool = Int