jvm-parser-0.2.1: A parser for JVM bytecode files

Portabilitynon-portable
Stabilitystable
Maintaineratomb@galois.com
Safe HaskellSafe-Inferred

Language.JVM.Common

Description

Basic datatypes and utilities for the JVM parser.

Synopsis

Documentation

slashesToDots :: String -> StringSource

Replace / characters with . characters

dotsToSlashes :: String -> StringSource

Replace . characters with / characters

data Type Source

JVM Type

Constructors

ArrayType Type 
BooleanType 
ByteType 
CharType 
ClassType String

ClassType with name of packages separated by slash /

DoubleType 
FloatType 
IntType 
LongType 
ShortType 

Instances

isIValue :: Type -> BoolSource

Returns true if type is an integer value.

isRValue :: Type -> BoolSource

Returns true if type is a reference value.

isPrimitiveType :: Type -> BoolSource

Returns true if Java type is a primitive type. Primitive types are the Boolean type or numeric types.

stackWidth :: Type -> IntSource

Returns number of bits that a Java type is expected to take on the stack. Type should be a primitive type.

isFloatType :: Type -> BoolSource

Returns true if Java type denotes a floating point.

isRefType :: Type -> BoolSource

Returns true if Java type denotes a reference.

data FieldId Source

Unique identifier of field

Constructors

FieldId 

Fields

fieldIdClass :: !String

Class name

fieldIdName :: !String

Field name

fieldIdType :: !Type

Field type

data MethodKey Source

A unique identifier for looking up a method in a class.

data ConstantPoolValue Source

A value stored in the constant pool.

type LocalVariableIndex = Word16Source

A local variable index.

type PC = Word16Source

A program counter value.

data Instruction Source

A JVM Instruction

Constructors

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

getfield instruction

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] 

ppInstruction :: Instruction -> DocSource

TODO: improve this

data ExceptionTableEntry Source

An entry in the exception table for a method

Constructors

ExceptionTableEntry 

Fields

startPc :: PC

The starting program counter value where the exception handler applies

endPc :: PC

The ending program counter value where the exception handler applies.

handlerPc :: PC

The program counter value to jump to when an exception is caught.

catchType :: Maybe Type

The type of exception that should be caught or Nothing if all types of exceptions should be caught.