Copyright | Galois, Inc. 2012-2014 |
---|---|
License | BSD3 |
Maintainer | atomb@galois.com |
Stability | stable |
Portability | portable |
Safe Haskell | None |
Language | Haskell98 |
Parser for the JVM bytecode format.
- data Type
- isIValue :: Type -> Bool
- isPrimitiveType :: Type -> Bool
- isRValue :: Type -> Bool
- stackWidth :: Type -> Int
- isFloatType :: Type -> Bool
- isRefType :: Type -> Bool
- data ConstantPoolValue
- data Attribute = Attribute {}
- data Visibility
- getClass :: Get Class
- data Class
- className :: Class -> String
- superClass :: Class -> Maybe String
- classIsPublic :: Class -> Bool
- classIsFinal :: Class -> Bool
- classIsInterface :: Class -> Bool
- classIsAbstract :: Class -> Bool
- classHasSuperAttribute :: Class -> Bool
- classInterfaces :: Class -> [String]
- classFields :: Class -> [Field]
- classMethods :: Class -> [Method]
- classAttributes :: Class -> [Attribute]
- loadClass :: FilePath -> IO Class
- lookupMethod :: Class -> MethodKey -> Maybe Method
- showClass :: Class -> String
- data FieldId = FieldId {
- fieldIdClass :: !String
- fieldIdName :: !String
- fieldIdType :: !Type
- data Field
- fieldName :: Field -> String
- fieldType :: Field -> Type
- fieldVisibility :: Field -> Visibility
- fieldIsStatic :: Field -> Bool
- fieldIsFinal :: Field -> Bool
- fieldIsVolatile :: Field -> Bool
- fieldIsTransient :: Field -> Bool
- fieldConstantValue :: Field -> Maybe ConstantPoolValue
- fieldIsSynthetic :: Field -> Bool
- fieldIsDeprecated :: Field -> Bool
- fieldIsEnum :: Field -> Bool
- fieldSignature :: Field -> Maybe String
- fieldAttributes :: Field -> [Attribute]
- data MethodKey = MethodKey {}
- makeMethodKey :: String -> String -> MethodKey
- data Method
- methodName :: Method -> String
- methodParameterTypes :: Method -> [Type]
- localIndexOfParameter :: Method -> Int -> LocalVariableIndex
- methodReturnType :: Method -> Maybe Type
- methodMaxLocals :: Method -> LocalVariableIndex
- methodIsNative :: Method -> Bool
- methodIsAbstract :: Method -> Bool
- methodBody :: Method -> MethodBody
- data MethodBody
- = Code Word16 Word16 CFG [ExceptionTableEntry] LineNumberTable LocalVariableTable [Attribute]
- | AbstractMethod
- | NativeMethod
- methodExceptionTable :: Method -> [ExceptionTableEntry]
- methodKey :: Method -> MethodKey
- methodIsStatic :: Method -> Bool
- type LocalVariableIndex = Word16
- data LocalVariableTableEntry = LocalVariableTableEntry {
- localStart :: PC
- localExtent :: PC
- localName :: String
- localType :: Type
- localIdx :: LocalVariableIndex
- type PC = Word16
- data Instruction
- = Aaload
- | Aastore
- | Aconst_null
- | Aload LocalVariableIndex
- | Areturn
- | Arraylength
- | Astore LocalVariableIndex
- | Athrow
- | Baload
- | Bastore
- | Caload
- | Castore
- | Checkcast Type
- | D2f
- | D2i
- | D2l
- | Dadd
- | Daload
- | Dastore
- | Dcmpg
- | Dcmpl
- | Ddiv
- | Dload LocalVariableIndex
- | Dmul
- | Dneg
- | Drem
- | Dreturn
- | Dstore LocalVariableIndex
- | Dsub
- | Dup
- | Dup_x1
- | Dup_x2
- | Dup2
- | Dup2_x1
- | Dup2_x2
- | F2d
- | F2i
- | F2l
- | Fadd
- | Faload
- | Fastore
- | Fcmpg
- | Fcmpl
- | Fdiv
- | Fload LocalVariableIndex
- | Fmul
- | Fneg
- | Frem
- | Freturn
- | Fstore LocalVariableIndex
- | Fsub
- | Getfield FieldId
- | Getstatic FieldId
- | Goto PC
- | I2b
- | I2c
- | I2d
- | I2f
- | I2l
- | I2s
- | Iadd
- | Iaload
- | Iand
- | Iastore
- | Idiv
- | If_acmpeq PC
- | If_acmpne PC
- | If_icmpeq PC
- | If_icmpne PC
- | If_icmplt PC
- | If_icmpge PC
- | If_icmpgt PC
- | If_icmple PC
- | Ifeq PC
- | Ifne PC
- | Iflt PC
- | Ifge PC
- | Ifgt PC
- | Ifle PC
- | Ifnonnull PC
- | Ifnull PC
- | Iinc LocalVariableIndex Int16
- | Iload LocalVariableIndex
- | Imul
- | Ineg
- | Instanceof Type
- | Invokeinterface String MethodKey
- | Invokespecial Type MethodKey
- | Invokestatic String MethodKey
- | Invokevirtual Type MethodKey
- | Ior
- | Irem
- | Ireturn
- | Ishl
- | Ishr
- | Istore LocalVariableIndex
- | Isub
- | Iushr
- | Ixor
- | Jsr PC
- | L2d
- | L2f
- | L2i
- | Ladd
- | Laload
- | Land
- | Lastore
- | Lcmp
- | Ldc ConstantPoolValue
- | Ldiv
- | Lload LocalVariableIndex
- | Lmul
- | Lneg
- | Lookupswitch PC [(Int32, PC)]
- | Lor
- | Lrem
- | Lreturn
- | Lshl
- | Lshr
- | Lstore LocalVariableIndex
- | Lsub
- | Lushr
- | Lxor
- | Monitorenter
- | Monitorexit
- | Multianewarray Type Word8
- | New String
- | Newarray Type
- | Nop
- | Pop
- | Pop2
- | Putfield FieldId
- | Putstatic FieldId
- | Ret LocalVariableIndex
- | Return
- | Saload
- | Sastore
- | Swap
- | Tableswitch PC Int32 Int32 [PC]
- lookupInstruction :: Method -> PC -> Instruction
- nextPc :: Method -> PC -> PC
- data ExceptionTableEntry
- catchType :: ExceptionTableEntry -> Maybe Type
- startPc :: ExceptionTableEntry -> PC
- endPc :: ExceptionTableEntry -> PC
- handlerPc :: ExceptionTableEntry -> PC
- byteArrayTy :: Type
- charArrayTy :: Type
- getElemTy :: Type -> Type
- intArrayTy :: Type
- stringTy :: Type
- unparseMethodDescriptor :: MethodKey -> String
- mainKey :: MethodKey
- hasDebugInfo :: Method -> Bool
- classSourceFile :: Class -> Maybe String
- sourceLineNumberInfo :: Method -> [(Word16, PC)]
- sourceLineNumberOrPrev :: Method -> PC -> Maybe Word16
- lookupLineStartPC :: Method -> Word16 -> Maybe PC
- lookupLineMethodStartPC :: Class -> Word16 -> Maybe (Method, PC)
- localVariableEntries :: Method -> PC -> [LocalVariableTableEntry]
- lookupLocalVariableByIdx :: Method -> PC -> LocalVariableIndex -> Maybe LocalVariableTableEntry
- lookupLocalVariableByName :: Method -> PC -> String -> Maybe LocalVariableTableEntry
- ppInst :: Instruction -> String
- slashesToDots :: String -> String
- cfgToDot :: ExceptionTable -> CFG -> String -> String
Basic types
JVM Type
isPrimitiveType :: Type -> Bool Source
Returns true if Java type is a primitive type. Primitive types are the Boolean type or numeric types.
stackWidth :: Type -> Int Source
Returns number of bits that a Java type is expected to take on the stack. Type should be a primitive type.
isFloatType :: Type -> Bool Source
Returns true if Java type denotes a floating point.
data ConstantPoolValue Source
A value stored in the constant pool.
An uninterpreted user defined attribute in the class file.
SerDes helpers
Class declarations
superClass :: Class -> Maybe String Source
Returns name of the super class of this class or Nothing if this class has no super class.
classIsPublic :: Class -> Bool Source
Returns true if class is public.
classIsFinal :: Class -> Bool Source
Returns true if class is final.
classIsInterface :: Class -> Bool Source
Returns true if class is an interface
classIsAbstract :: Class -> Bool Source
Returns true if class is abstract.
classHasSuperAttribute :: Class -> Bool Source
Returns true if class was annotated with the super attribute.
classInterfaces :: Class -> [String] Source
Returns interfaces this clas implements
classFields :: Class -> [Field] Source
Returns fields in the class
classMethods :: Class -> [Method] Source
Returns methods in class
classAttributes :: Class -> [Attribute] Source
Returns user-defined attributes on class.
lookupMethod :: Class -> MethodKey -> Maybe Method Source
Returns method with given key in class or Nothing if no method with that key is found.
Field declarations
Unique identifier of field
FieldId | |
|
fieldVisibility :: Field -> Visibility Source
Returns visibility of field.
fieldIsStatic :: Field -> Bool Source
Returns true if field is static.
fieldIsFinal :: Field -> Bool Source
Returns true if field is final.
fieldIsVolatile :: Field -> Bool Source
Returns true if field is volatile.
fieldIsTransient :: Field -> Bool Source
Returns true if field is transient.
fieldConstantValue :: Field -> Maybe ConstantPoolValue Source
Returns initial value of field or Nothing if not assigned.
Only static fields may have a constant value.
fieldIsSynthetic :: Field -> Bool Source
Returns true if field is synthetic.
fieldIsDeprecated :: Field -> Bool Source
Returns true if field is deprecated.
fieldIsEnum :: Field -> Bool Source
Returns true if field is transient.
fieldSignature :: Field -> Maybe String Source
fieldAttributes :: Field -> [Attribute] Source
Method declarations
A unique identifier for looking up a method in a class.
Returns method key with the given name and descriptor.
methodName :: Method -> String Source
Returns name of method
methodParameterTypes :: Method -> [Type] Source
Return parameter types for method.
localIndexOfParameter :: Method -> Int -> LocalVariableIndex Source
Returns the local variable index that the parameter is stored in when the method is invoked.
methodReturnType :: Method -> Maybe Type Source
Return parameter types for method.
methodMaxLocals :: Method -> LocalVariableIndex Source
Returns maxinum number of local variables in method.
methodIsNative :: Method -> Bool Source
methodIsAbstract :: Method -> Bool Source
Returns true if method is abstract.
methodBody :: Method -> MethodBody Source
data MethodBody Source
Code Word16 Word16 CFG [ExceptionTableEntry] LineNumberTable LocalVariableTable [Attribute] | |
AbstractMethod | |
NativeMethod |
methodExceptionTable :: Method -> [ExceptionTableEntry] Source
Exception table entries for method.
methodIsStatic :: Method -> Bool Source
Instruction declarations
type LocalVariableIndex = Word16 Source
A local variable index.
data Instruction Source
A JVM Instruction
lookupInstruction :: Method -> PC -> Instruction Source
Exception table declarations
data ExceptionTableEntry Source
An entry in the exception table for a method
catchType :: ExceptionTableEntry -> Maybe Type Source
The type of exception that should be caught or Nothing if all types of exceptions should be caught.
startPc :: ExceptionTableEntry -> PC Source
The starting program counter value where the exception handler applies
endPc :: ExceptionTableEntry -> PC Source
The ending program counter value where the exception handler applies.
handlerPc :: ExceptionTableEntry -> PC Source
The program counter value to jump to when an exception is caught.
Misc utility functions/values
intArrayTy :: Type Source
Debugging information
hasDebugInfo :: Method -> Bool Source
Returns true if method has debug informaiton available.
classSourceFile :: Class -> Maybe String Source
Returns name of source file where class was defined.
sourceLineNumberInfo :: Method -> [(Word16, PC)] Source
sourceLineNumberOrPrev :: Method -> PC -> Maybe Word16 Source
Returns source line number of an instruction in a method at a given PC, or the line number of the nearest predecessor instruction, or Nothing if neither is available.
lookupLineStartPC :: Method -> Word16 -> Maybe PC Source
Returns the starting PC for the source at the given line number.
lookupLineMethodStartPC :: Class -> Word16 -> Maybe (Method, PC) Source
Returns the enclosing method and starting PC for the source at the given line number.
localVariableEntries :: Method -> PC -> [LocalVariableTableEntry] Source
lookupLocalVariableByIdx :: Method -> PC -> LocalVariableIndex -> Maybe LocalVariableTableEntry Source
Returns local variable entry at given PC and local variable index or Nothing if no mapping is found.
lookupLocalVariableByName :: Method -> PC -> String -> Maybe LocalVariableTableEntry Source
Returns local variable entry at given PC and local variable string or Nothing if no mapping is found.
ppInst :: Instruction -> String Source