Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.dex.code

public final Class LocalList

extends FixedSizeList
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.code.RegisterSpec, .RegisterSpecSet, org.droidparts.dexmaker.dx.rop.cst.CstString, .CstType, org.droidparts.dexmaker.dx.rop.type.Type, org.droidparts.dexmaker.dx.util.FixedSizeList, java.io.PrintStream, java.util.ArrayList, .Arrays

List of local variables. Each local variable entry indicates a range of code which it is valid for, a register number, a name, and a type.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
LocalList.Disposition

Disposition of a local entry.

public static class
LocalList.Entry

Entry in a local list.

public static class
LocalList.MakeState

Intermediate state when constructing a local list.

Field Summary

Modifier and TypeField and Description
private static final boolean
DEBUG

whether to run the self-check code

public static final LocalList
EMPTY

non-null; empty instance

Constructor Summary

AccessConstructor and Description
public
LocalList(int
>= 0; the size of the list
size
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
debugPrint(PrintStream
non-null; where to dump
out
,
String
non-null; prefix to attach to each line of output
prefix
)

Does a human-friendly dump of this instance.

private static void
debugVerify(LocalList locals)

Debugging helper that verifies the constraint that a list doesn't contain any redundant local starts and that local ends that are due to replacements are properly annotated.

private static void
debugVerify0(LocalList locals)

Helper for debugVerify which does most of the work.

public LocalList.Entry

Returns:

non-null; element at that index
get
(int
>= 0, < size(); which index
n
)

Gets the element at the given index.

public static LocalList

Returns:

non-null; the constructed list
make
(DalvInsnList
non-null; instructions to convert
insns
)

Constructs an instance for the given method, based on the given block order and intermediate local information.

public void
set(int
>= 0, < size(); which index
n
,
LocalList.Entry
non-null; the entry to set at n
entry
)

Sets the entry at the given index.

Inherited from org.droidparts.dexmaker.dx.util.FixedSizeList:
equalsget0getOrNull0hashCodeset0shrinkToFitsizetoHumantoHumantoStringtoString

Field Detail

DEBUGback to summary
private static final boolean DEBUG

whether to run the self-check code

EMPTYback to summary
public static final LocalList EMPTY

non-null; empty instance

Constructor Detail

LocalListback to summary
public LocalList(int size)

Constructs an instance. All indices initially contain null.

Parameters
size:int

>= 0; the size of the list

Method Detail

debugPrintback to summary
public void debugPrint(PrintStream out, String prefix)

Does a human-friendly dump of this instance.

Parameters
out:PrintStream

non-null; where to dump

prefix:String

non-null; prefix to attach to each line of output

debugVerifyback to summary
private static void debugVerify(LocalList locals)

Debugging helper that verifies the constraint that a list doesn't contain any redundant local starts and that local ends that are due to replacements are properly annotated.

debugVerify0back to summary
private static void debugVerify0(LocalList locals)

Helper for debugVerify which does most of the work.

getback to summary
public LocalList.Entry get(int n)

Gets the element at the given index. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException.

Parameters
n:int

>= 0, < size(); which index

Returns:LocalList.Entry

non-null; element at that index

makeback to summary
public static LocalList make(DalvInsnList insns)

Constructs an instance for the given method, based on the given block order and intermediate local information.

Parameters
insns:DalvInsnList

non-null; instructions to convert

Returns:LocalList

non-null; the constructed list

setback to summary
public void set(int n, LocalList.Entry entry)

Sets the entry at the given index.

Parameters
n:int

>= 0, < size(); which index

entry:LocalList.Entry

non-null; the entry to set at n

org.droidparts.dexmaker.dx.dex.code back to summary

public final Enum LocalList.Disposition

extends Enum<LocalList.Disposition>
Class Inheritance

Disposition of a local entry.

Field Summary

Modifier and TypeField and Description
public static final LocalList.Disposition
END_CLOBBERED_BY_NEXT

local ended because the next local clobbered this one (because this one is a category-2)

public static final LocalList.Disposition
END_CLOBBERED_BY_PREV

local ended because the previous local clobbered this one (because it is category-2)

public static final LocalList.Disposition
END_MOVED

local ended because it was moved to a different register

public static final LocalList.Disposition
END_REPLACED

local ended because it was directly replaced

public static final LocalList.Disposition
END_SIMPLY

local ended without being replaced

public static final LocalList.Disposition
START

local started (introduced)

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static LocalList.Disposition
public static LocalList.Disposition[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

END_CLOBBERED_BY_NEXTback to summary
public static final LocalList.Disposition END_CLOBBERED_BY_NEXT

local ended because the next local clobbered this one (because this one is a category-2)

END_CLOBBERED_BY_PREVback to summary
public static final LocalList.Disposition END_CLOBBERED_BY_PREV

local ended because the previous local clobbered this one (because it is category-2)

END_MOVEDback to summary
public static final LocalList.Disposition END_MOVED

local ended because it was moved to a different register

END_REPLACEDback to summary
public static final LocalList.Disposition END_REPLACED

local ended because it was directly replaced

END_SIMPLYback to summary
public static final LocalList.Disposition END_SIMPLY

local ended without being replaced

STARTback to summary
public static final LocalList.Disposition START

local started (introduced)

Constructor Detail

Dispositionback to summary
private Disposition()

Method Detail

valueOfback to summary
public static LocalList.Disposition valueOf(String name)
valuesback to summary
public static LocalList.Disposition[] values()
org.droidparts.dexmaker.dx.dex.code back to summary

public Class LocalList.Entry

extends Object
implements Comparable<LocalList.Entry>
Class Inheritance
All Implemented Interfaces
java.lang.Comparable

Entry in a local list.

Field Summary

Modifier and TypeField and Description
private final int
address

>= 0; address

private final LocalList.Disposition
disposition

non-null; disposition of the local

private final RegisterSpec
spec

non-null; register spec representing the variable

private final CstType
type

non-null; variable type (derived from spec)

Constructor Summary

AccessConstructor and Description
public
Entry(int
>= 0; address
address
,
LocalList.Disposition
non-null; disposition of the local
disposition
,
RegisterSpec
non-null; register spec representing the variable
spec
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

-1..1; standard result of comparison
compareTo
(LocalList.Entry
non-null; entry to compare to
other
)

Implements java.lang.Comparable.compareTo.

Compares by (in priority order) address, end then start disposition (variants of end are all consistered equivalent), and spec.
public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int

Returns:

>= 0; the address
getAddress
()

Gets the address.

public LocalList.Disposition

Returns:

non-null; the disposition
getDisposition
()

Gets the disposition.

public CstString

Returns:

null-ok; the variable name
getName
()

Gets the variable name.

public int

Returns:

>= 0; the number of the register holding the variable
getRegister
()

Gets the number of the register holding the variable.

public RegisterSpec

Returns:

non-null; RegisterSpec of the holding register.
getRegisterSpec
()

Gets the RegisterSpec of the register holding the variable.

public CstString

Returns:

null-ok; the variable signature
getSignature
()

Gets the variable signature.

public CstType

Returns:

non-null; the type
getType
()

Gets the variable's type.

public boolean

Returns:

true iff this is a start
isStart
()

Gets whether this is a local start.

public boolean

Returns:

true iff this instance matches spec
matches
(RegisterSpec
non-null; the spec in question
otherSpec
)

Returns whether or not this instance matches the given spec.

public boolean

Returns:

true iff this instance's spec matches other
matches
(LocalList.Entry
non-null; another entry
other
)

Returns whether or not this instance matches the spec in the given instance.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public LocalList.Entry

Returns:

non-null; an appropriately-constructed instance
withDisposition
(LocalList.Disposition
non-null; the new disposition
disposition
)

Returns an instance just like this one but with the disposition set as given.

Inherited from java.lang.Object:
clonefinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

addressback to summary
private final int address

>= 0; address

dispositionback to summary
private final LocalList.Disposition disposition

non-null; disposition of the local

specback to summary
private final RegisterSpec spec

non-null; register spec representing the variable

typeback to summary
private final CstType type

non-null; variable type (derived from spec)

Constructor Detail

Entryback to summary
public Entry(int address, LocalList.Disposition disposition, RegisterSpec spec)

Constructs an instance.

Parameters
address:int

>= 0; address

disposition:LocalList.Disposition

non-null; disposition of the local

spec:RegisterSpec

non-null; register spec representing the variable

Method Detail

compareToback to summary
public int compareTo(LocalList.Entry other)

Implements java.lang.Comparable.compareTo.

Compares by (in priority order) address, end then start disposition (variants of end are all consistered equivalent), and spec.

Parameters
other:LocalList.Entry

non-null; entry to compare to

Returns:int

-1..1; standard result of comparison

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

getAddressback to summary
public int getAddress()

Gets the address.

Returns:int

>= 0; the address

getDispositionback to summary
public LocalList.Disposition getDisposition()

Gets the disposition.

Returns:LocalList.Disposition

non-null; the disposition

getNameback to summary
public CstString getName()

Gets the variable name.

Returns:CstString

null-ok; the variable name

getRegisterback to summary
public int getRegister()

Gets the number of the register holding the variable.

Returns:int

>= 0; the number of the register holding the variable

getRegisterSpecback to summary
public RegisterSpec getRegisterSpec()

Gets the RegisterSpec of the register holding the variable.

Returns:RegisterSpec

non-null; RegisterSpec of the holding register.

getSignatureback to summary
public CstString getSignature()

Gets the variable signature.

Returns:CstString

null-ok; the variable signature

getTypeback to summary
public CstType getType()

Gets the variable's type.

Returns:CstType

non-null; the type

isStartback to summary
public boolean isStart()

Gets whether this is a local start. This is just shorthand for getDisposition() == Disposition.START.

Returns:boolean

true iff this is a start

matchesback to summary
public boolean matches(RegisterSpec otherSpec)

Returns whether or not this instance matches the given spec.

Parameters
otherSpec:RegisterSpec

non-null; the spec in question

Returns:boolean

true iff this instance matches spec

matchesback to summary
public boolean matches(LocalList.Entry other)

Returns whether or not this instance matches the spec in the given instance.

Parameters
other:LocalList.Entry

non-null; another entry

Returns:boolean

true iff this instance's spec matches other

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

withDispositionback to summary
public LocalList.Entry withDisposition(LocalList.Disposition disposition)

Returns an instance just like this one but with the disposition set as given.

Parameters
disposition:LocalList.Disposition

non-null; the new disposition

Returns:LocalList.Entry

non-null; an appropriately-constructed instance

org.droidparts.dexmaker.dx.dex.code back to summary

public Class LocalList.MakeState

extends Object
Class Inheritance

Intermediate state when constructing a local list.

Field Summary

Modifier and TypeField and Description
private int[]
endIndices

null-ok; result indices where local ends are stored

private int
lastAddress

>= 0; last address seen

private int
nullResultCount

>= 0; running count of nulled result entries, to help with sizing the final list

private RegisterSpecSet
regs

null-ok; current register mappings

private final ArrayList<LocalList.Entry>
result

non-null; result being collected

Constructor Summary

AccessConstructor and Description
public
MakeState(int initialSize)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
private void
aboutToProcess(int
>= 0; address about to be processed
address
,
int
>= 0; register number about to be processed
reg
)

Checks the address and other vitals as a prerequisite to further processing.

private void
add(int
>= 0; the address
address
,
LocalList.Disposition
non-null; the disposition
disposition
,
RegisterSpec
non-null; spec representing the local
spec
)

Adds an entry to the result, updating the adjunct tables accordingly.

private void
addOrUpdateEnd(int
>= 0; the address
address
,
LocalList.Disposition
non-null; the disposition
disposition
,
RegisterSpec
non-null; spec representing the local
spec
)

Adds or updates an end local (changing its disposition).

private boolean

Returns:

true iff this method found the case in question and adjusted things accordingly
checkForEmptyRange
(int
>= 0; the address
address
,
RegisterSpec
non-null; spec representing the local being ended
endedLocal
)

Helper for endLocal, which handles the cases where and end local is issued at the same address as a start local for the same register.

public void
endLocal(int
>= 0; the address
address
,
RegisterSpec
non-null; spec representing the local being ended
endedLocal
)

Ends a local at the given address, using the disposition END_SIMPLY.

public void
endLocal(int
>= 0; the address
address
,
RegisterSpec
non-null; spec representing the local being ended
endedLocal
,
LocalList.Disposition
reason for the end
disposition
)

Ends a local at the given address.

private static RegisterSpec

Returns:

null-ok; an appropriately modified spec, or the original if nothing needs to be done
filterSpec
(RegisterSpec
null-ok; the original spec
orig
)

Converts a given spec into the form acceptable for use in a local list.

public LocalList

Returns:

non-null; the result list
finish
()

Finishes processing altogether and gets the result.

public void
snapshot(int
>= 0; the address
address
,
RegisterSpecSet
non-null; spec set representing the locals
specs
)

Sets the local state at the given address to the given snapshot.

public void
startLocal(int
>= 0; the address
address
,
RegisterSpec
non-null; spec representing the started local
startedLocal
)

Starts a local at the given address.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

endIndicesback to summary
private int[] endIndices

null-ok; result indices where local ends are stored

lastAddressback to summary
private int lastAddress

>= 0; last address seen

nullResultCountback to summary
private int nullResultCount

>= 0; running count of nulled result entries, to help with sizing the final list

regsback to summary
private RegisterSpecSet regs

null-ok; current register mappings

resultback to summary
private final ArrayList<LocalList.Entry> result

non-null; result being collected

Constructor Detail

MakeStateback to summary
public MakeState(int initialSize)

Constructs an instance.

Method Detail

aboutToProcessback to summary
private void aboutToProcess(int address, int reg)

Checks the address and other vitals as a prerequisite to further processing.

Parameters
address:int

>= 0; address about to be processed

reg:int

>= 0; register number about to be processed

addback to summary
private void add(int address, LocalList.Disposition disposition, RegisterSpec spec)

Adds an entry to the result, updating the adjunct tables accordingly.

Parameters
address:int

>= 0; the address

disposition:LocalList.Disposition

non-null; the disposition

spec:RegisterSpec

non-null; spec representing the local

addOrUpdateEndback to summary
private void addOrUpdateEnd(int address, LocalList.Disposition disposition, RegisterSpec spec)

Adds or updates an end local (changing its disposition). If this would cause an empty range for a local, this instead removes the local entirely.

Parameters
address:int

>= 0; the address

disposition:LocalList.Disposition

non-null; the disposition

spec:RegisterSpec

non-null; spec representing the local

checkForEmptyRangeback to summary
private boolean checkForEmptyRange(int address, RegisterSpec endedLocal)

Helper for endLocal, which handles the cases where and end local is issued at the same address as a start local for the same register. If this case is found, then this method will remove the start (as the local was never actually active), update the endIndices to be accurate, and if needed update the newly-active end to reflect an altered disposition.

Parameters
address:int

>= 0; the address

endedLocal:RegisterSpec

non-null; spec representing the local being ended

Returns:boolean

true iff this method found the case in question and adjusted things accordingly

endLocalback to summary
public void endLocal(int address, RegisterSpec endedLocal)

Ends a local at the given address, using the disposition END_SIMPLY.

Parameters
address:int

>= 0; the address

endedLocal:RegisterSpec

non-null; spec representing the local being ended

endLocalback to summary
public void endLocal(int address, RegisterSpec endedLocal, LocalList.Disposition disposition)

Ends a local at the given address.

Parameters
address:int

>= 0; the address

endedLocal:RegisterSpec

non-null; spec representing the local being ended

disposition:LocalList.Disposition

reason for the end

filterSpecback to summary
private static RegisterSpec filterSpec(RegisterSpec orig)

Converts a given spec into the form acceptable for use in a local list. This, in particular, transforms the "known null" type into simply Object. This method needs to be called for any spec that is on its way into a locals list.

This isn't necessarily the cleanest way to achieve the goal of not representing known nulls in a locals list, but it gets the job done.

Parameters
orig:RegisterSpec

null-ok; the original spec

Returns:RegisterSpec

null-ok; an appropriately modified spec, or the original if nothing needs to be done

finishback to summary
public LocalList finish()

Finishes processing altogether and gets the result.

Returns:LocalList

non-null; the result list

snapshotback to summary
public void snapshot(int address, RegisterSpecSet specs)

Sets the local state at the given address to the given snapshot. The first call on this instance must be to this method, so that the register state can be properly sized.

Parameters
address:int

>= 0; the address

specs:RegisterSpecSet

non-null; spec set representing the locals

startLocalback to summary
public void startLocal(int address, RegisterSpec startedLocal)

Starts a local at the given address.

Parameters
address:int

>= 0; the address

startedLocal:RegisterSpec

non-null; spec representing the started local