Top Description Fields Constructors Methods
org.droidparts.dexmaker.dx.rop.code

public final Class LocalVariableInfo

extends MutabilityControl
Class Inheritance
Imports
org.droidparts.dexmaker.dx.rop.type.TypeBearer, org.droidparts.dexmaker.dx.util.MutabilityControl, java.util.HashMap

Container for local variable information for a particular RopMethod.

Field Summary

Modifier and TypeField and Description
private final RegisterSpecSet[]
blockStarts

non-null; array consisting of register sets representing the sets of variables already assigned upon entry to each block, where array indices correspond to block labels

private final RegisterSpecSet
emptySet

non-null; RegisterSpecSet to use when indicating a block that has no locals; it is empty and immutable but has an appropriate max size for the method

private final HashMap<Insn, RegisterSpec>
insnAssignments

non-null; map from instructions to the variable each assigns

private final int
regCount

>= 0; the register count for the method

Constructor Summary

AccessConstructor and Description
public
LocalVariableInfo(RopMethod
non-null; the method being represented by this instance
method
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public void
addAssignment(Insn
non-null; the instruction in question
insn
,
RegisterSpec
non-null; the associated register spec
spec
)

Adds an assignment association for the given instruction and register spec.

public void
public RegisterSpec

Returns:

null-ok; the named register being assigned, if any
getAssignment
(Insn
non-null; instruction in question
insn
)

Gets the named register being assigned by the given instruction, if previously stored in this instance.

public int

Returns:

>= 0; the number of assignments
getAssignmentCount
()

Gets the number of assignments recorded by this instance.

public RegisterSpecSet

Returns:

non-null; the associated register set
getStarts
(int
>= 0; the block label
label
)

Gets the register set associated with the start of the block with the given label.

public RegisterSpecSet

Returns:

non-null; the associated register set
getStarts
(BasicBlock
non-null; the block in question
block
)

Gets the register set associated with the start of the given block.

private RegisterSpecSet

Returns:

null-ok; associated register set or null if there is none
getStarts0
(int
>= 0; the block label
label
)

Helper method, to get the starts for a label, throwing the right exception for range problems.

public boolean

Returns:

true if the merge resulted in an actual change to the associated set (including storing one for the first time) or false if there was no change
mergeStarts
(int
>= 0; the block label
label
,
RegisterSpecSet
non-null; the register set to merge into the start set for the block
specs
)

Merges the given register set into the set for the block with the given label.

public RegisterSpecSet

Returns:

non-null; the associated register set
mutableCopyOfStarts
(int
>= 0; the block label
label
)

Gets a mutable copy of the register set associated with the start of the block with the given label.

public void
setStarts(int
>= 0; the block label
label
,
RegisterSpecSet
non-null; the register set to associate with the block
specs
)

Sets the register set associated with the start of the block with the given label.

Inherited from org.droidparts.dexmaker.dx.util.MutabilityControl:
isImmutableisMutablesetImmutablethrowIfImmutablethrowIfMutable

Field Detail

blockStartsback to summary
private final RegisterSpecSet[] blockStarts

non-null; array consisting of register sets representing the sets of variables already assigned upon entry to each block, where array indices correspond to block labels

emptySetback to summary
private final RegisterSpecSet emptySet

non-null; RegisterSpecSet to use when indicating a block that has no locals; it is empty and immutable but has an appropriate max size for the method

insnAssignmentsback to summary
private final HashMap<Insn, RegisterSpec> insnAssignments

non-null; map from instructions to the variable each assigns

regCountback to summary
private final int regCount

>= 0; the register count for the method

Constructor Detail

LocalVariableInfoback to summary
public LocalVariableInfo(RopMethod method)

Constructs an instance.

Parameters
method:RopMethod

non-null; the method being represented by this instance

Method Detail

addAssignmentback to summary
public void addAssignment(Insn insn, RegisterSpec spec)

Adds an assignment association for the given instruction and register spec. This throws an exception if the instruction doesn't actually perform a named variable assignment

Note

Although the instruction contains its own spec for the result, it still needs to be passed in explicitly to this method, since the spec that is stored here should always have a simple type and the one in the instruction can be an arbitrary TypeBearer (such as a constant value).

Parameters
insn:Insn

non-null; the instruction in question

spec:RegisterSpec

non-null; the associated register spec

debugDumpback to summary
public void debugDump()
getAssignmentback to summary
public RegisterSpec getAssignment(Insn insn)

Gets the named register being assigned by the given instruction, if previously stored in this instance.

Parameters
insn:Insn

non-null; instruction in question

Returns:RegisterSpec

null-ok; the named register being assigned, if any

getAssignmentCountback to summary
public int getAssignmentCount()

Gets the number of assignments recorded by this instance.

Returns:int

>= 0; the number of assignments

getStartsback to summary
public RegisterSpecSet getStarts(int label)

Gets the register set associated with the start of the block with the given label. This returns an empty set with the appropriate max size if no set was associated with the block in question.

Parameters
label:int

>= 0; the block label

Returns:RegisterSpecSet

non-null; the associated register set

getStartsback to summary
public RegisterSpecSet getStarts(BasicBlock block)

Gets the register set associated with the start of the given block. This is just convenient shorthand for getStarts(block.getLabel()).

Parameters
block:BasicBlock

non-null; the block in question

Returns:RegisterSpecSet

non-null; the associated register set

getStarts0back to summary
private RegisterSpecSet getStarts0(int label)

Helper method, to get the starts for a label, throwing the right exception for range problems.

Parameters
label:int

>= 0; the block label

Returns:RegisterSpecSet

null-ok; associated register set or null if there is none

mergeStartsback to summary
public boolean mergeStarts(int label, RegisterSpecSet specs)

Merges the given register set into the set for the block with the given label. If there was not already an associated set, then this is the same as calling setStarts. Otherwise, this will merge the two sets and call setStarts on the result of the merge.

Parameters
label:int

>= 0; the block label

specs:RegisterSpecSet

non-null; the register set to merge into the start set for the block

Returns:boolean

true if the merge resulted in an actual change to the associated set (including storing one for the first time) or false if there was no change

mutableCopyOfStartsback to summary
public RegisterSpecSet mutableCopyOfStarts(int label)

Gets a mutable copy of the register set associated with the start of the block with the given label. This returns a newly-allocated empty RegisterSpecSet of appropriate max size if there is not yet any set associated with the block.

Parameters
label:int

>= 0; the block label

Returns:RegisterSpecSet

non-null; the associated register set

setStartsback to summary
public void setStarts(int label, RegisterSpecSet specs)

Sets the register set associated with the start of the block with the given label.

Parameters
label:int

>= 0; the block label

specs:RegisterSpecSet

non-null; the register set to associate with the block