Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.dex.file

public final Class CodeItem

extends OffsettedItem
Class Inheritance
Imports
org.droidparts.dexmaker.dx.dex.code.DalvCode, .DalvInsnList, org.droidparts.dexmaker.dx.rop.cst.Constant, .CstMethodRef, org.droidparts.dexmaker.dx.rop.type.StdTypeList, .Type, .TypeList, org.droidparts.dexmaker.dx.util.AnnotatedOutput, .ExceptionWithContext, .Hex, java.io.PrintWriter

Representation of all the parts needed for concrete methods in a dex file.

Field Summary

Modifier and TypeField and Description
private static final int
ALIGNMENT

file alignment of this class, in bytes

private CatchStructs
catches

null-ok; the catches, if needed; set in addContents

private final DalvCode
code

non-null; the bytecode instructions and associated data

private DebugInfoItem
debugInfo

null-ok; the debug info or null if there is none; set in addContents

private static final int
HEADER_SIZE

write size of the header of this class, in bytes

private final boolean
isStatic

whether this instance is for a static method

private final CstMethodRef
ref

non-null; method that this code implements

private final TypeList
throwsList

non-null; list of possibly-thrown exceptions; just used in generating debugging output (listings)

Constructor Summary

AccessConstructor and Description
public
CodeItem(CstMethodRef
non-null; method that this code implements
ref
,
DalvCode
non-null; the underlying code
code
,
boolean
whether this instance is for a static method
isStatic
,
TypeList
non-null; list of possibly-thrown exceptions, just used in generating debugging output (listings)
throwsList
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
addContents(DexFile
non-null; the file to populate
file
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Populates a DexFile with items from within this instance.
public void
debugPrint(PrintWriter
non-null; where to dump
out
,
String
non-null; per-line prefix to use
prefix
,
boolean
whether to be verbose with the output
verbose
)

Does a human-friendly dump of this instance.

private int

Returns:

the count
getInsSize
()

Get the in registers count.

private int

Returns:

the count
getOutsSize
()

Get the out registers count.

public CstMethodRef

Returns:

non-null; the method reference
getRef
()

Gets the reference to the method this instance implements.

private int

Returns:

the count
getRegistersSize
()

Get the total registers count.

public ItemType
itemType()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Returns the item type for this instance.
protected void
place0(Section
non-null; the section this instance has been added to
addedTo
,
int
>= 0; the offset from the start of the section where this instance was placed
offset
)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Does additional work required when placing an instance.
public String
toHuman()

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Gets a short human-readable string representing this instance.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
private void
writeCodes(DexFile
non-null; file we are part of
file
,
AnnotatedOutput
non-null; where to write to
out
)

Helper for writeTo0 which writes out the actual bytecode.

protected void
writeTo0(DexFile
non-null; the file to use for reference
file
,
AnnotatedOutput
non-null; where to write to
out
)

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Performs the actual write of the contents of this instance to the given data section.
Inherited from org.droidparts.dexmaker.dx.dex.file.OffsettedItem:
compareTocompareTo0equalsgetAbsoluteOffsetgetAbsoluteOffsetOr0getAlignmentgetRelativeOffsetoffsetStringplacesetWriteSizewriteSizewriteTo

Field Detail

ALIGNMENTback to summary
private static final int ALIGNMENT

file alignment of this class, in bytes

catchesback to summary
private CatchStructs catches

null-ok; the catches, if needed; set in addContents

codeback to summary
private final DalvCode code

non-null; the bytecode instructions and associated data

debugInfoback to summary
private DebugInfoItem debugInfo

null-ok; the debug info or null if there is none; set in addContents

HEADER_SIZEback to summary
private static final int HEADER_SIZE

write size of the header of this class, in bytes

isStaticback to summary
private final boolean isStatic

whether this instance is for a static method

refback to summary
private final CstMethodRef ref

non-null; method that this code implements

throwsListback to summary
private final TypeList throwsList

non-null; list of possibly-thrown exceptions; just used in generating debugging output (listings)

Constructor Detail

CodeItemback to summary
public CodeItem(CstMethodRef ref, DalvCode code, boolean isStatic, TypeList throwsList)

Constructs an instance.

Parameters
ref:CstMethodRef

non-null; method that this code implements

code:DalvCode

non-null; the underlying code

isStatic:boolean

whether this instance is for a static method

throwsList:TypeList

non-null; list of possibly-thrown exceptions, just used in generating debugging output (listings)

Method Detail

addContentsback to summary
public void addContents(DexFile file)

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.addContents.

Populates a DexFile with items from within this instance. This will not add an item to the file for this instance itself (which should have been done by whatever refers to this instance).

Note

Subclasses must override this to do something appropriate.

Parameters
file:DexFile

non-null; the file to populate

debugPrintback to summary
public void debugPrint(PrintWriter out, String prefix, boolean verbose)

Does a human-friendly dump of this instance.

Parameters
out:PrintWriter

non-null; where to dump

prefix:String

non-null; per-line prefix to use

verbose:boolean

whether to be verbose with the output

getInsSizeback to summary
private int getInsSize()

Get the in registers count.

Returns:int

the count

getOutsSizeback to summary
private int getOutsSize()

Get the out registers count.

Returns:int

the count

getRefback to summary
public CstMethodRef getRef()

Gets the reference to the method this instance implements.

Returns:CstMethodRef

non-null; the method reference

getRegistersSizeback to summary
private int getRegistersSize()

Get the total registers count.

Returns:int

the count

itemTypeback to summary
public ItemType itemType()

Implements abstract org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Doc from org.droidparts.dexmaker.dx.dex.file.Item.itemType.

Returns the item type for this instance.

Returns:ItemType

non-null; the item type

Annotations
@Override
place0back to summary
protected void place0(Section addedTo, int offset)

Overrides org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.place0.

Does additional work required when placing an instance. The default implementation of this method is a no-op. If a particular class needs to do something special, then it should override this method. In particular, if this instance did not know its write size up-front, then this method is responsible for setting it.

Parameters
addedTo:Section

non-null; the section this instance has been added to

offset:int

>= 0; the offset from the start of the section where this instance was placed

Annotations
@Override
toHumanback to summary
public String toHuman()

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.toHuman.

Gets a short human-readable string representing this instance.

Returns:String

non-null; the human form

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
writeCodesback to summary
private void writeCodes(DexFile file, AnnotatedOutput out)

Helper for writeTo0 which writes out the actual bytecode.

Parameters
file:DexFile

non-null; file we are part of

out:AnnotatedOutput

non-null; where to write to

writeTo0back to summary
protected void writeTo0(DexFile file, AnnotatedOutput out)

Implements abstract org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Doc from org.droidparts.dexmaker.dx.dex.file.OffsettedItem.writeTo0.

Performs the actual write of the contents of this instance to the given data section. This is called by writeTo, which will have taken care of ensuring alignment.

Parameters
file:DexFile

non-null; the file to use for reference

out:AnnotatedOutput

non-null; where to write to

Annotations
@Override