com.android.dx.cf.code
Class LocalVariableList

java.lang.Object
  extended by com.android.dx.util.MutabilityControl
      extended by com.android.dx.util.FixedSizeList
          extended by com.android.dx.cf.code.LocalVariableList
All Implemented Interfaces:
ToHuman

public final class LocalVariableList
extends FixedSizeList

List of "local variable" entries, which are the contents of LocalVariableTable and LocalVariableTypeTable attributes, as well as combinations of the two.


Nested Class Summary
static class LocalVariableList.Item
          Item in a local variable table.
 
Field Summary
static LocalVariableList EMPTY
          non-null; zero-size instance
 
Constructor Summary
LocalVariableList(int count)
          Constructs an instance.
 
Method Summary
static LocalVariableList concat(LocalVariableList list1, LocalVariableList list2)
          Returns an instance which is the concatenation of the two given instances.
 LocalVariableList.Item get(int n)
          Gets the indicated item.
 LocalVariableList.Item itemToLocal(LocalVariableList.Item item)
          Gets the local variable information in this instance which matches the given LocalVariableList.Item in all respects but the type descriptor and signature, if any.
static LocalVariableList mergeDescriptorsAndSignatures(LocalVariableList descriptorList, LocalVariableList signatureList)
          Returns an instance which is the result of merging the two given instances, where one instance should have only type descriptors and the other only type signatures.
 LocalVariableList.Item pcAndIndexToLocal(int pc, int index)
          Gets the local variable information associated with a given address and local index, if any.
 void set(int n, int startPc, int length, CstString name, CstString descriptor, CstString signature, int index)
          Sets the item at the given index.
 void set(int n, LocalVariableList.Item item)
          Sets the item at the given index.
 
Methods inherited from class com.android.dx.util.FixedSizeList
equals, get0, getOrNull0, hashCode, set0, shrinkToFit, size, toHuman, toHuman, toString, toString
 
Methods inherited from class com.android.dx.util.MutabilityControl
isImmutable, isMutable, setImmutable, throwIfImmutable, throwIfMutable
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

EMPTY

public static final LocalVariableList EMPTY
non-null; zero-size instance

Constructor Detail

LocalVariableList

public LocalVariableList(int count)
Constructs an instance.

Parameters:
count - the number of elements to be in the list
Method Detail

concat

public static LocalVariableList concat(LocalVariableList list1,
                                       LocalVariableList list2)
Returns an instance which is the concatenation of the two given instances. The result is immutable.

Parameters:
list1 - non-null; first instance
list2 - non-null; second instance
Returns:
non-null; combined instance

mergeDescriptorsAndSignatures

public static LocalVariableList mergeDescriptorsAndSignatures(LocalVariableList descriptorList,
                                                              LocalVariableList signatureList)
Returns an instance which is the result of merging the two given instances, where one instance should have only type descriptors and the other only type signatures. The merged result is identical to the one with descriptors, except that any element whose {name, index, start, length} matches an element in the signature list gets augmented with the corresponding signature. The result is immutable.

Parameters:
descriptorList - non-null; list with descriptors
signatureList - non-null; list with signatures
Returns:
non-null; the merged result

get

public LocalVariableList.Item get(int n)
Gets the indicated item.

Parameters:
n - >= 0; which item
Returns:
null-ok; the indicated item

set

public void set(int n,
                LocalVariableList.Item item)
Sets the item at the given index.

Parameters:
n - >= 0, < size(); which element
item - non-null; the item

set

public void set(int n,
                int startPc,
                int length,
                CstString name,
                CstString descriptor,
                CstString signature,
                int index)
Sets the item at the given index.

Note: At least one of descriptor or signature must be passed as non-null.

Parameters:
n - >= 0, < size(); which element
startPc - >= 0; the start pc of this variable's scope
length - >= 0; the length (in bytecodes) of this variable's scope
name - non-null; the variable's name
descriptor - null-ok; the variable's type descriptor
signature - null-ok; the variable's type signature
index - >= 0; the variable's local index

itemToLocal

public LocalVariableList.Item itemToLocal(LocalVariableList.Item item)
Gets the local variable information in this instance which matches the given LocalVariableList.Item in all respects but the type descriptor and signature, if any.

Parameters:
item - non-null; local variable information to match
Returns:
null-ok; the corresponding local variable information stored in this instance, or null if there is no matching information

pcAndIndexToLocal

public LocalVariableList.Item pcAndIndexToLocal(int pc,
                                                int index)
Gets the local variable information associated with a given address and local index, if any. Note: In standard classfiles, a variable's start point is listed as the address of the instruction just past the one that sets the variable.

Parameters:
pc - >= 0; the address to look up
index - >= 0; the local variable index
Returns:
null-ok; the associated local variable information, or null if none is known


Copyright © 2015. All rights reserved.