-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | A library for reading Java class-files
--
-- A library for reading Java class-files.
@package jvm-binary
@version 0.0.2
-- | This module contains utilities missing not in other libraries.
module Language.JVM.Utils
-- | SizedList is a binary type, that reads a list of elements. It first
-- reads a length N of type w and then N items of type
-- a.
newtype SizedList w a
SizedList :: [a] -> SizedList w a
[unSizedList] :: SizedList w a -> [a]
-- | Get the size of the sized list.
listSize :: Num w => SizedList w a -> w
-- | A byte string with a size w.
newtype SizedByteString w
SizedByteString :: ByteString -> SizedByteString w
[unSizedByteString] :: SizedByteString w -> ByteString
-- | Get the size of a SizedByteString
byteStringSize :: (Num w) => SizedByteString w -> w
-- | A sized list using a 16 bit word as length
type SizedList16 = SizedList Word16
-- | A sized bytestring using a 32 bit word as length
type SizedByteString32 = SizedByteString Word32
-- | A sized bytestring using a 16 bit word as length
type SizedByteString16 = SizedByteString Word16
-- | A bit set of size w
newtype BitSet w a
BitSet :: Set a -> BitSet w a
[toSet] :: BitSet w a -> Set a
-- | An Enumish value, all maps to a number, but not all integers maps to a
-- enumsish value. There is no guarantee that the integers will be
-- subsequent.
class (Eq a, Ord a) => Enumish a where fromEnumish a = let Just (i, _) = find ((== a) . snd) $ inOrder in i toEnumish i = snd <$> (find ((== i) . fst) $ inOrder)
-- | The only needed implementation is a list of integer-enum pairs in
-- ascending order, corresponding to their integer value.
inOrder :: Enumish a => [(Int, a)]
fromEnumish :: Enumish a => a -> Int
toEnumish :: Enumish a => Int -> Maybe a
-- | A BitSet using a 16 bit word
type BitSet16 = BitSet Word16
-- | Takes the third element of a triple.
trd :: (a, b, c) -> c
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.JVM.Utils.BitSet w a)
instance GHC.Show.Show a => GHC.Show.Show (Language.JVM.Utils.BitSet w a)
instance GHC.Classes.Ord a => GHC.Classes.Ord (Language.JVM.Utils.BitSet w a)
instance GHC.Classes.Eq (Language.JVM.Utils.SizedByteString w)
instance GHC.Show.Show (Language.JVM.Utils.SizedByteString w)
instance GHC.Base.Functor (Language.JVM.Utils.SizedList w)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.JVM.Utils.SizedList w a)
instance GHC.Show.Show a => GHC.Show.Show (Language.JVM.Utils.SizedList w a)
instance Data.Foldable.Foldable (Language.JVM.Utils.SizedList w)
instance Data.Traversable.Traversable (Language.JVM.Utils.SizedList w)
instance (Data.Binary.Class.Binary w, GHC.Real.Integral w, Data.Binary.Class.Binary a) => Data.Binary.Class.Binary (Language.JVM.Utils.SizedList w a)
instance (Data.Binary.Class.Binary w, GHC.Real.Integral w) => Data.Binary.Class.Binary (Language.JVM.Utils.SizedByteString w)
instance (Data.Bits.Bits w, Data.Binary.Class.Binary w, Language.JVM.Utils.Enumish a) => Data.Binary.Class.Binary (Language.JVM.Utils.BitSet w a)
-- | This module contains the Constant type and the
-- ConstantPool. These are essential for accessing data in the
-- class-file.
module Language.JVM.Constant
-- | A constant is a multi word item in the ConstantPool. Each of
-- the constructors are pretty much self expiatory from the types.
data Constant
String :: !SizedByteString16 -> Constant
Integer :: !Word32 -> Constant
Float :: !Word32 -> Constant
Long :: !Word64 -> Constant
Double :: !Word64 -> Constant
ClassRef :: !ConstantRef -> Constant
StringRef :: !ConstantRef -> Constant
FieldRef :: !ConstantRef -> !ConstantRef -> Constant
MethodRef :: !ConstantRef -> !ConstantRef -> Constant
InterfaceMethodRef :: !ConstantRef -> !ConstantRef -> Constant
NameAndType :: !ConstantRef -> !ConstantRef -> Constant
MethodHandle :: !Word8 -> !ConstantRef -> Constant
MethodType :: !ConstantRef -> Constant
InvokeDynamic :: !ConstantRef -> !ConstantRef -> Constant
-- | Some of the Constants take up more space in the constant pool
-- than other. Notice that String and MethodType is not of
-- size 32, but is still awarded value 1. This is due to an
-- inconsistency in JVM.
constantSize :: Constant -> Int
-- | A constant is referenced by the ConstantRef data type. It is just a 16
-- bit word, but wrapped for type safety.
newtype ConstantRef
ConstantRef :: Word16 -> ConstantRef
-- | A ConstantPool is just an IntMap. A IntMap is used,
-- because constants are accessed after their byte-offset.
-- constantSize
newtype ConstantPool
ConstantPool :: IntMap Constant -> ConstantPool
[unConstantPool] :: ConstantPool -> IntMap Constant
-- | Lookup a Constant in the ConstantPool.
lookupConstant :: ConstantRef -> ConstantPool -> Maybe Constant
-- | Lookup a Text in the ConstantPool, returns
-- Nothing if the reference does not point to something in the
-- ConstantPool, if it points to something not a String Constant,
-- or if it is impossible to decode the ByteString as Utf8.
lookupText :: ConstantRef -> ConstantPool -> Maybe Text
-- | Lookup a class name in the ConstantPool, returns Nothing
-- otherwise.
lookupClassName :: ConstantRef -> ConstantPool -> Maybe Text
-- | Return a list of reference-constant pairs.
toListOfConstants :: ConstantPool -> [(ConstantRef, Constant)]
instance GHC.Classes.Eq Language.JVM.Constant.ConstantPool
instance GHC.Show.Show Language.JVM.Constant.ConstantPool
instance GHC.Classes.Eq Language.JVM.Constant.Constant
instance GHC.Show.Show Language.JVM.Constant.Constant
instance GHC.Generics.Generic Language.JVM.Constant.ConstantRef
instance GHC.Show.Show Language.JVM.Constant.ConstantRef
instance GHC.Classes.Eq Language.JVM.Constant.ConstantRef
instance Data.Binary.Class.Binary Language.JVM.Constant.ConstantRef
instance Data.Binary.Class.Binary Language.JVM.Constant.Constant
instance Data.Binary.Class.Binary Language.JVM.Constant.ConstantPool
-- | Based on the StackMapTable Attribute, as documented here.
module Language.JVM.Attribute.StackMapTable
-- | An Exceptions attribute is a list of references into the constant
-- pool.
data StackMapTable
StackMapTable :: SizedList16 StackMapFrame -> StackMapTable
[stackMapTable] :: StackMapTable -> SizedList16 StackMapFrame
-- | A delta offset
type DeltaOffset = Word8
-- | An stack map frame
data StackMapFrame
StackMapFrame :: DeltaOffset -> StackMapFrameType -> StackMapFrame
[deltaOffset] :: StackMapFrame -> DeltaOffset
[frameType] :: StackMapFrame -> StackMapFrameType
-- | An stack map frame type
data StackMapFrameType
SameFrame :: StackMapFrameType
SameLocals1StackItemFrame :: VerificationTypeInfo -> StackMapFrameType
ChopFrame :: Word8 -> StackMapFrameType
AppendFrame :: [VerificationTypeInfo] -> StackMapFrameType
FullFrame :: (SizedList16 VerificationTypeInfo) -> (SizedList16 VerificationTypeInfo) -> StackMapFrameType
-- | The types info of the stack map frame.
data VerificationTypeInfo
VTop :: VerificationTypeInfo
VInteger :: VerificationTypeInfo
VFloat :: VerificationTypeInfo
VLong :: VerificationTypeInfo
VDouble :: VerificationTypeInfo
VNull :: VerificationTypeInfo
VUninitializedThis :: VerificationTypeInfo
VObject :: !ConstantRef -> VerificationTypeInfo
VUninitialized :: !Word16 -> VerificationTypeInfo
instance GHC.Generics.Generic Language.JVM.Attribute.StackMapTable.StackMapTable
instance GHC.Classes.Eq Language.JVM.Attribute.StackMapTable.StackMapTable
instance GHC.Show.Show Language.JVM.Attribute.StackMapTable.StackMapTable
instance GHC.Classes.Eq Language.JVM.Attribute.StackMapTable.StackMapFrame
instance GHC.Show.Show Language.JVM.Attribute.StackMapTable.StackMapFrame
instance GHC.Classes.Eq Language.JVM.Attribute.StackMapTable.StackMapFrameType
instance GHC.Show.Show Language.JVM.Attribute.StackMapTable.StackMapFrameType
instance GHC.Classes.Eq Language.JVM.Attribute.StackMapTable.VerificationTypeInfo
instance GHC.Show.Show Language.JVM.Attribute.StackMapTable.VerificationTypeInfo
instance Data.Binary.Class.Binary Language.JVM.Attribute.StackMapTable.StackMapTable
instance Data.Binary.Class.Binary Language.JVM.Attribute.StackMapTable.StackMapFrame
instance Data.Binary.Class.Binary Language.JVM.Attribute.StackMapTable.VerificationTypeInfo
-- | Based on the Exceptions Attribute, as documented here. It
-- describes the checked exceptions that a method can make.
module Language.JVM.Attribute.Exceptions
-- | An Exceptions attribute is a list of references into the constant
-- pool.
data Exceptions
Exceptions :: SizedList16 ConstantRef -> Exceptions
[exceptionIndexTable'] :: Exceptions -> SizedList16 ConstantRef
-- | Get the constant refs that points .
exceptionIndexTable :: Exceptions -> [ConstantRef]
instance GHC.Generics.Generic Language.JVM.Attribute.Exceptions.Exceptions
instance GHC.Classes.Eq Language.JVM.Attribute.Exceptions.Exceptions
instance GHC.Show.Show Language.JVM.Attribute.Exceptions.Exceptions
instance Data.Binary.Class.Binary Language.JVM.Attribute.Exceptions.Exceptions
-- | Based on the ConstantValue, as documented here.
module Language.JVM.Attribute.ConstantValue
-- | A constant value is just a index into the constant pool.
data ConstantValue
ConstantValue :: !ConstantRef -> ConstantValue
[constantValueIndex] :: ConstantValue -> !ConstantRef
instance GHC.Generics.Generic Language.JVM.Attribute.ConstantValue.ConstantValue
instance GHC.Classes.Eq Language.JVM.Attribute.ConstantValue.ConstantValue
instance GHC.Show.Show Language.JVM.Attribute.ConstantValue.ConstantValue
instance Data.Binary.Class.Binary Language.JVM.Attribute.ConstantValue.ConstantValue
module Language.JVM.Attribute.Code
data Code a
Code :: Int16 -> Int16 -> ByteCode -> SizedList16 ExceptionTable -> SizedList16 a -> Code a
[maxStack] :: Code a -> Int16
[maxLocals] :: Code a -> Int16
[bytecode] :: Code a -> ByteCode
[exceptionTable] :: Code a -> SizedList16 ExceptionTable
[attributes] :: Code a -> SizedList16 a
newtype ByteCode
ByteCode :: [ByteCodeInst] -> ByteCode
[unByteCode] :: ByteCode -> [ByteCodeInst]
data ExceptionTable
ExceptionTable :: !Word16 -> !Word16 -> !Word16 -> !ConstantRef -> ExceptionTable
-- | Inclusive program counter into code
[start] :: ExceptionTable -> !Word16
-- | Exclusive program counter into code
[end] :: ExceptionTable -> !Word16
-- | A program counter into code indicating the handler.
[handler] :: ExceptionTable -> !Word16
[catchType] :: ExceptionTable -> !ConstantRef
data ByteCodeInst
ByteCodeInst :: LongOffset -> ByteCodeOpr -> ByteCodeInst
[offset] :: ByteCodeInst -> LongOffset
[opcode] :: ByteCodeInst -> ByteCodeOpr
data ByteCodeOpr
-- | aaload baload ...
ArrayLoad :: (ArrayType ()) -> ByteCodeOpr
-- | aastore bastore ...
ArrayStore :: (ArrayType ()) -> ByteCodeOpr
Push :: Constant -> ByteCodeOpr
-- | aload_0, bload_2, iload 5 ...
Load :: LocalType -> LocalAddress -> ByteCodeOpr
-- | aload, bload ...
Store :: LocalType -> LocalAddress -> ByteCodeOpr
-- | iadd ...
BinaryOpr :: BinOpr -> ArithmeticType -> ByteCodeOpr
-- | ineg ...
Neg :: ArithmeticType -> ByteCodeOpr
-- | Exclusively on int and long, identified by the word-size
BitOpr :: BitOpr -> WordSize -> ByteCodeOpr
-- | Only works on ints, increment local 2
IncrLocal :: !LocalAddress -> !IncrementAmount -> ByteCodeOpr
-- | Only valid on different types
Cast :: ArithmeticType -> ArithmeticType -> ByteCodeOpr
-- | Only valid on different types
CastDown :: SmallArithmeticType -> ByteCodeOpr
CompareLongs :: ByteCodeOpr
-- | Compare two floating values, 2 is if float or double should be used.
CompareFloating :: Bool -> WordSize -> ByteCodeOpr
-- | compare with 0 if #2 is False, and two ints from the stack if True.
-- the last value is the offset
If :: CmpOpr -> OneOrTwo -> Offset -> ByteCodeOpr
-- | check if two objects are equal, or not equal. If #2 is True, compare
-- with null.
IfRef :: Bool -> OneOrTwo -> Offset -> ByteCodeOpr
Goto :: LongOffset -> ByteCodeOpr
Jsr :: LongOffset -> ByteCodeOpr
Ret :: LocalAddress -> ByteCodeOpr
-- | a table switch has 3 values `default` low high and a
-- list of offets.
TableSwitch :: Int32 -> Int32 -> Int32 -> (Vector Int32) -> ByteCodeOpr
-- | a lookup switch has a `default` value and a list of pairs.
LookupSwitch :: Int32 -> (Vector (Int32, Int32)) -> ByteCodeOpr
Get :: FieldAccess -> ConstantRef -> ByteCodeOpr
Put :: FieldAccess -> ConstantRef -> ByteCodeOpr
Invoke :: Invokation -> ConstantRef -> ByteCodeOpr
New :: ConstantRef -> ByteCodeOpr
NewArray :: (ArrayType ConstantRef) -> ByteCodeOpr
ArrayLength :: ByteCodeOpr
Throw :: ByteCodeOpr
CheckCast :: ConstantRef -> ByteCodeOpr
InstanceOf :: ConstantRef -> ByteCodeOpr
-- | True => Enter, False => Exit
Monitor :: Bool -> ByteCodeOpr
-- | Create a new multi array of 2 dimensions
MultiNewArray :: ConstantRef -> Word8 -> ByteCodeOpr
Return :: (Maybe LocalType) -> ByteCodeOpr
Nop :: ByteCodeOpr
Pop :: WordSize -> ByteCodeOpr
Dup :: WordSize -> ByteCodeOpr
DupX1 :: WordSize -> ByteCodeOpr
DupX2 :: WordSize -> ByteCodeOpr
Swap :: ByteCodeOpr
data Constant
CNull :: Constant
CIntM1 :: Constant
CInt0 :: Constant
CInt1 :: Constant
CInt2 :: Constant
CInt3 :: Constant
CInt4 :: Constant
CInt5 :: Constant
CLong0 :: Constant
CLong1 :: Constant
CFloat0 :: Constant
CFloat1 :: Constant
CFloat2 :: Constant
CDouble0 :: Constant
CDouble1 :: Constant
CByte :: Int8 -> Constant
CShort :: Int16 -> Constant
CHalfRef :: ConstantRef -> Constant
CRef :: WordSize -> ConstantRef -> Constant
type WordSize = OneOrTwo
data OneOrTwo
One :: OneOrTwo
Two :: OneOrTwo
data ArithmeticType
MInt :: ArithmeticType
MLong :: ArithmeticType
MFloat :: ArithmeticType
MDouble :: ArithmeticType
data SmallArithmeticType
MByte :: SmallArithmeticType
MChar :: SmallArithmeticType
MShort :: SmallArithmeticType
data BinOpr
Add :: BinOpr
Sub :: BinOpr
Mul :: BinOpr
Div :: BinOpr
Rem :: BinOpr
data LocalType
LInt :: LocalType
LLong :: LocalType
LFloat :: LocalType
LDouble :: LocalType
LRef :: LocalType
data ArrayType a
ABoolean :: ArrayType a
AByte :: ArrayType a
AChar :: ArrayType a
AShort :: ArrayType a
AInt :: ArrayType a
ALong :: ArrayType a
AFloat :: ArrayType a
ADouble :: ArrayType a
ARef :: a -> ArrayType a
data CmpOpr
CEq :: CmpOpr
CNe :: CmpOpr
CLt :: CmpOpr
CGe :: CmpOpr
CGt :: CmpOpr
CLe :: CmpOpr
type LongOffset = Int32
type Offset = Int16
data LocalAddress
LWide :: Word16 -> LocalAddress
LSingle :: Word8 -> LocalAddress
data IncrementAmount
IWide :: Int16 -> IncrementAmount
ISingle :: Int8 -> IncrementAmount
data BitOpr
ShL :: BitOpr
ShR :: BitOpr
UShR :: BitOpr
And :: BitOpr
Or :: BitOpr
XOr :: BitOpr
data FieldAccess
FldStatic :: FieldAccess
FldField :: FieldAccess
data Invokation
InvkSpecial :: Invokation
InvkVirtual :: Invokation
InvkStatic :: Invokation
InvkInterface :: Word8 -> Invokation
InvkDynamic :: Invokation
instance GHC.Generics.Generic (Language.JVM.Attribute.Code.Code a)
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.JVM.Attribute.Code.Code a)
instance GHC.Show.Show a => GHC.Show.Show (Language.JVM.Attribute.Code.Code a)
instance GHC.Classes.Eq Language.JVM.Attribute.Code.ByteCode
instance GHC.Show.Show Language.JVM.Attribute.Code.ByteCode
instance GHC.Generics.Generic Language.JVM.Attribute.Code.ByteCodeInst
instance GHC.Classes.Eq Language.JVM.Attribute.Code.ByteCodeInst
instance GHC.Show.Show Language.JVM.Attribute.Code.ByteCodeInst
instance GHC.Classes.Eq Language.JVM.Attribute.Code.ByteCodeOpr
instance GHC.Show.Show Language.JVM.Attribute.Code.ByteCodeOpr
instance GHC.Classes.Eq Language.JVM.Attribute.Code.CmpOpr
instance GHC.Show.Show Language.JVM.Attribute.Code.CmpOpr
instance GHC.Classes.Eq Language.JVM.Attribute.Code.IncrementAmount
instance GHC.Show.Show Language.JVM.Attribute.Code.IncrementAmount
instance GHC.Classes.Eq Language.JVM.Attribute.Code.LocalAddress
instance GHC.Show.Show Language.JVM.Attribute.Code.LocalAddress
instance GHC.Classes.Eq Language.JVM.Attribute.Code.BitOpr
instance GHC.Show.Show Language.JVM.Attribute.Code.BitOpr
instance GHC.Classes.Eq Language.JVM.Attribute.Code.BinOpr
instance GHC.Show.Show Language.JVM.Attribute.Code.BinOpr
instance GHC.Classes.Eq Language.JVM.Attribute.Code.Constant
instance GHC.Show.Show Language.JVM.Attribute.Code.Constant
instance GHC.Enum.Enum Language.JVM.Attribute.Code.OneOrTwo
instance GHC.Classes.Eq Language.JVM.Attribute.Code.OneOrTwo
instance GHC.Enum.Bounded Language.JVM.Attribute.Code.OneOrTwo
instance GHC.Classes.Ord Language.JVM.Attribute.Code.OneOrTwo
instance GHC.Show.Show Language.JVM.Attribute.Code.OneOrTwo
instance GHC.Classes.Eq Language.JVM.Attribute.Code.FieldAccess
instance GHC.Show.Show Language.JVM.Attribute.Code.FieldAccess
instance GHC.Classes.Eq Language.JVM.Attribute.Code.Invokation
instance GHC.Show.Show Language.JVM.Attribute.Code.Invokation
instance GHC.Classes.Eq a => GHC.Classes.Eq (Language.JVM.Attribute.Code.ArrayType a)
instance GHC.Show.Show a => GHC.Show.Show (Language.JVM.Attribute.Code.ArrayType a)
instance GHC.Enum.Bounded Language.JVM.Attribute.Code.LocalType
instance GHC.Enum.Enum Language.JVM.Attribute.Code.LocalType
instance GHC.Classes.Eq Language.JVM.Attribute.Code.LocalType
instance GHC.Show.Show Language.JVM.Attribute.Code.LocalType
instance GHC.Enum.Bounded Language.JVM.Attribute.Code.SmallArithmeticType
instance GHC.Enum.Enum Language.JVM.Attribute.Code.SmallArithmeticType
instance GHC.Classes.Eq Language.JVM.Attribute.Code.SmallArithmeticType
instance GHC.Show.Show Language.JVM.Attribute.Code.SmallArithmeticType
instance GHC.Enum.Bounded Language.JVM.Attribute.Code.ArithmeticType
instance GHC.Enum.Enum Language.JVM.Attribute.Code.ArithmeticType
instance GHC.Classes.Eq Language.JVM.Attribute.Code.ArithmeticType
instance GHC.Show.Show Language.JVM.Attribute.Code.ArithmeticType
instance GHC.Generics.Generic Language.JVM.Attribute.Code.ExceptionTable
instance GHC.Classes.Eq Language.JVM.Attribute.Code.ExceptionTable
instance GHC.Show.Show Language.JVM.Attribute.Code.ExceptionTable
instance Data.Binary.Class.Binary a => Data.Binary.Class.Binary (Language.JVM.Attribute.Code.Code a)
instance Data.Binary.Class.Binary Language.JVM.Attribute.Code.ByteCode
instance Data.Binary.Class.Binary Language.JVM.Attribute.Code.ExceptionTable
instance Data.Binary.Class.Binary Language.JVM.Attribute.Code.ByteCodeInst
instance Data.Binary.Class.Binary Language.JVM.Attribute.Code.ByteCodeOpr
-- | Based on the BootstrapMethods Attribute, as documented
-- [here](http:/docs.oracle.comjavasespecsjvmsse8html/jvms-4.html#jvms-4.7.23).
module Language.JVM.Attribute.BootstrapMethods
-- | Is a list of bootstrapped methods.
data BootstrapMethods
BootstrapMethods :: SizedList16 BootstrapMethod -> BootstrapMethods
[methods'] :: BootstrapMethods -> SizedList16 BootstrapMethod
-- | The methods as list
methods :: BootstrapMethods -> [BootstrapMethod]
-- | A bootstraped methods.
data BootstrapMethod
BootstrapMethod :: ConstantRef -> SizedList16 ConstantRef -> BootstrapMethod
[methodIndex] :: BootstrapMethod -> ConstantRef
[arguments'] :: BootstrapMethod -> SizedList16 ConstantRef
-- | The arguments is a cool
arguments :: BootstrapMethod -> [ConstantRef]
instance GHC.Generics.Generic Language.JVM.Attribute.BootstrapMethods.BootstrapMethods
instance GHC.Classes.Eq Language.JVM.Attribute.BootstrapMethods.BootstrapMethods
instance GHC.Show.Show Language.JVM.Attribute.BootstrapMethods.BootstrapMethods
instance GHC.Generics.Generic Language.JVM.Attribute.BootstrapMethods.BootstrapMethod
instance GHC.Classes.Eq Language.JVM.Attribute.BootstrapMethods.BootstrapMethod
instance GHC.Show.Show Language.JVM.Attribute.BootstrapMethods.BootstrapMethod
instance Data.Binary.Class.Binary Language.JVM.Attribute.BootstrapMethods.BootstrapMethods
instance Data.Binary.Class.Binary Language.JVM.Attribute.BootstrapMethods.BootstrapMethod
-- | This is the main module for accessing all kinds of Attributes.
module Language.JVM.Attribute
-- | An Attribute, simply contains of a reference to a name and contains
-- info.
data Attribute
Attribute :: !ConstantRef -> !SizedByteString32 -> Attribute
[aNameIndex] :: Attribute -> !ConstantRef
[aInfo'] :: Attribute -> !SizedByteString32
-- | A small helper function to extract the info as a lazy
-- ByteString.
aInfo :: Attribute -> ByteString
-- | Extracts the name from the attribute, if it exists in the
-- ConstantPool.
aName :: ConstantPool -> Attribute -> Maybe Text
-- | A class-type that describes a data-type a as an Attribute.
-- Most notable it provides the fromAttribute' method that enables
-- converting an Attribute to a data-type a.
class IsAttribute a where fromAttribute' cp as = do { name <- aName cp as; if name == unConst (attrName :: Const Text a) then return $ fromAttribute as else Nothing }
-- | The name of the attribute.
attrName :: IsAttribute a => Const Text a
-- | Generate a a from an Attribute.
fromAttribute :: IsAttribute a => Attribute -> Either String a
fromAttribute' :: IsAttribute a => ConstantPool -> Attribute -> Maybe (Either String a)
-- | Code is redefined with Attribute, as it is recursively containing
-- Attribute. This is a small hack to fix it.
type Code = Code Attribute
-- | The a attribute of the code is the StackMapTable. There can be at most
-- one. If the version number of the file is more than 50, and there is
-- no StackMapTable. there is an implicit empty StackMapTable.
codeStackMapTable :: ConstantPool -> Code -> Maybe (Either String BootstrapMethods)
-- | A constant value is just a index into the constant pool.
data ConstantValue
-- | An Exceptions attribute is a list of references into the constant
-- pool.
data Exceptions
-- | An Exceptions attribute is a list of references into the constant
-- pool.
data StackMapTable
-- | Is a list of bootstrapped methods.
data BootstrapMethods
-- | Create a type dependent on another type b, used for accessing
-- the correct attrName in IsAttribute.
data Const a b
instance GHC.Generics.Generic Language.JVM.Attribute.Attribute
instance GHC.Classes.Eq Language.JVM.Attribute.Attribute
instance GHC.Show.Show Language.JVM.Attribute.Attribute
instance Data.Binary.Class.Binary Language.JVM.Attribute.Attribute
instance Language.JVM.Attribute.IsAttribute Language.JVM.Attribute.Code
instance Language.JVM.Attribute.IsAttribute Language.JVM.Attribute.ConstantValue.ConstantValue
instance Language.JVM.Attribute.IsAttribute Language.JVM.Attribute.Exceptions.Exceptions
instance Language.JVM.Attribute.IsAttribute Language.JVM.Attribute.StackMapTable.StackMapTable
instance Language.JVM.Attribute.IsAttribute Language.JVM.Attribute.BootstrapMethods.BootstrapMethods
-- | Contains the AccessFlags used in the different modules.
module Language.JVM.AccessFlag
-- | Access flags for the Method
data MAccessFlag
MPublic :: MAccessFlag
MPrivate :: MAccessFlag
MProtected :: MAccessFlag
MStatic :: MAccessFlag
MFinal :: MAccessFlag
MSynchronized :: MAccessFlag
MBridge :: MAccessFlag
MVarargs :: MAccessFlag
MNative :: MAccessFlag
MAbstract :: MAccessFlag
MStrictFP :: MAccessFlag
MSynthetic :: MAccessFlag
-- | The Enumish mapping of the MAccessFlag
mflags :: [(Int, MAccessFlag)]
-- | Access flags for the Field
data FAccessFlag
FPublic :: FAccessFlag
FPrivate :: FAccessFlag
FProtected :: FAccessFlag
FStatic :: FAccessFlag
FFinal :: FAccessFlag
FSynchronized :: FAccessFlag
FUnused6 :: FAccessFlag
FVolatile :: FAccessFlag
FTransient :: FAccessFlag
FSynthetic :: FAccessFlag
FEnum :: FAccessFlag
-- | The Enumish mapping of the FAccessFlag
fflags :: [(Int, FAccessFlag)]
-- | Access flags for the ClassFile
data CAccessFlag
CPublic :: CAccessFlag
CFinal :: CAccessFlag
CSuper :: CAccessFlag
CAbstract :: CAccessFlag
CSynthetic :: CAccessFlag
CAnnotation :: CAccessFlag
CEnum :: CAccessFlag
-- | The Enumish mapping of the CAccessFlag
cflags :: [(Int, CAccessFlag)]
instance GHC.Classes.Eq Language.JVM.AccessFlag.FAccessFlag
instance GHC.Show.Show Language.JVM.AccessFlag.FAccessFlag
instance GHC.Classes.Ord Language.JVM.AccessFlag.FAccessFlag
instance GHC.Classes.Eq Language.JVM.AccessFlag.CAccessFlag
instance GHC.Show.Show Language.JVM.AccessFlag.CAccessFlag
instance GHC.Classes.Ord Language.JVM.AccessFlag.CAccessFlag
instance GHC.Classes.Eq Language.JVM.AccessFlag.MAccessFlag
instance GHC.Show.Show Language.JVM.AccessFlag.MAccessFlag
instance GHC.Classes.Ord Language.JVM.AccessFlag.MAccessFlag
instance Language.JVM.Utils.Enumish Language.JVM.AccessFlag.MAccessFlag
instance Language.JVM.Utils.Enumish Language.JVM.AccessFlag.CAccessFlag
instance Language.JVM.Utils.Enumish Language.JVM.AccessFlag.FAccessFlag
module Language.JVM.Field
-- | A Field in the class-file, as described here.
data Field
Field :: BitSet16 FAccessFlag -> !ConstantRef -> !ConstantRef -> SizedList16 Attribute -> Field
[fAccessFlags] :: Field -> BitSet16 FAccessFlag
[fNameIndex] :: Field -> !ConstantRef
[fDescriptorIndex] :: Field -> !ConstantRef
[fAttributes] :: Field -> SizedList16 Attribute
-- | Fetch the ConstantValue attribute. There can only one be one
-- exceptions attribute on a field.
fConstantValue :: ConstantPool -> Field -> Maybe (Either String ConstantValue)
instance GHC.Generics.Generic Language.JVM.Field.Field
instance GHC.Classes.Eq Language.JVM.Field.Field
instance GHC.Show.Show Language.JVM.Field.Field
instance Data.Binary.Class.Binary Language.JVM.Field.Field
module Language.JVM.Method
-- | A Method in the class-file, as described here.
data Method
Method :: BitSet16 MAccessFlag -> !ConstantRef -> !ConstantRef -> SizedList16 Attribute -> Method
[mAccessFlags'] :: Method -> BitSet16 MAccessFlag
[mNameIndex] :: Method -> !ConstantRef
[mDescriptorIndex] :: Method -> !ConstantRef
[mAttributes'] :: Method -> SizedList16 Attribute
-- | Unpack the BitSet and get the AccessFlags as a Set.
mAccessFlags :: Method -> Set MAccessFlag
-- | Unpack the SizedList and get the attributes as a List.
mAttributes :: Method -> [Attribute]
-- | Lookup the name of the method in the ConstantPool.
mName :: ConstantPool -> Method -> Maybe Text
-- | Lookup the descriptor of the method in the ConstantPool.
mDescriptor :: ConstantPool -> Method -> Maybe Text
-- | Fetch the Code attribute, if any. There can only one be one
-- code attribute on a method.
mCode :: ConstantPool -> Method -> Maybe (Either String Code)
-- | Fetch the Exceptions attribute. There can only one be one
-- exceptions attribute on a method.
mExceptions :: ConstantPool -> Method -> Maybe (Either String Exceptions)
instance GHC.Generics.Generic Language.JVM.Method.Method
instance GHC.Classes.Eq Language.JVM.Method.Method
instance GHC.Show.Show Language.JVM.Method.Method
instance Data.Binary.Class.Binary Language.JVM.Method.Method
-- | The class file is described in this module.
module Language.JVM.ClassFile
-- | A ClassFile as described here.
data ClassFile
ClassFile :: !Word32 -> !Word16 -> !Word16 -> !ConstantPool -> BitSet16 CAccessFlag -> !ConstantRef -> !ConstantRef -> SizedList16 ConstantRef -> SizedList16 Field -> SizedList16 Method -> SizedList16 Attribute -> ClassFile
[cMagicNumber] :: ClassFile -> !Word32
[cMinorVersion] :: ClassFile -> !Word16
[cMajorVersion] :: ClassFile -> !Word16
[cConstantPool] :: ClassFile -> !ConstantPool
[cAccessFlags] :: ClassFile -> BitSet16 CAccessFlag
[cThisClassIndex] :: ClassFile -> !ConstantRef
[cSuperClassIndex] :: ClassFile -> !ConstantRef
[cInterfaces'] :: ClassFile -> SizedList16 ConstantRef
[cFields'] :: ClassFile -> SizedList16 Field
[cMethods'] :: ClassFile -> SizedList16 Method
[cAttributes'] :: ClassFile -> SizedList16 Attribute
-- | Get a list of ConstantRefs to interfaces.
cInterfaces :: ClassFile -> [ConstantRef]
-- | Get a list of Fields of a ClassFile.
cFields :: ClassFile -> [Field]
-- | Get a list of Methods of a ClassFile.
cMethods :: ClassFile -> [Method]
-- | Get a list of Attributes of a ClassFile.
cAttributes :: ClassFile -> [Attribute]
-- | Lookup the this class in a ConstantPool
cThisClass :: ConstantPool -> ClassFile -> Maybe Text
-- | Lookup the super class in the ConstantPool
cSuperClass :: ConstantPool -> ClassFile -> Maybe Text
-- | Fetch the BootstrapMethods attribute. There can only one be one
-- exceptions attribute on a class-file.
cBootstrapMethods :: ConstantPool -> ClassFile -> Maybe (Either String BootstrapMethods)
instance GHC.Generics.Generic Language.JVM.ClassFile.ClassFile
instance GHC.Classes.Eq Language.JVM.ClassFile.ClassFile
instance GHC.Show.Show Language.JVM.ClassFile.ClassFile
instance Data.Binary.Class.Binary Language.JVM.ClassFile.ClassFile
-- | The main entry point for using the library.
module Language.JVM
-- | Create a class file from a lazy ByteString
decodeClassFile :: ByteString -> Either String ClassFile