FileDocCategorySizeDatePackage
LocalVariableList.javaAPI DocAndroid 5.1 API12585Thu Mar 12 22:18:30 GMT 2015com.android.dx.cf.code

LocalVariableList

public final class LocalVariableList extends com.android.dx.util.FixedSizeList
List of "local variable" entries, which are the contents of {@code LocalVariableTable} and {@code LocalVariableTypeTable} attributes, as well as combinations of the two.

Fields Summary
public static final LocalVariableList
EMPTY
{@code non-null;} zero-size instance
Constructors Summary
public LocalVariableList(int count)
Constructs an instance.

param
count the number of elements to be in the list

        super(count);
    
Methods Summary
public static com.android.dx.cf.code.LocalVariableListconcat(com.android.dx.cf.code.LocalVariableList list1, com.android.dx.cf.code.LocalVariableList list2)
Returns an instance which is the concatenation of the two given instances. The result is immutable.

param
list1 {@code non-null;} first instance
param
list2 {@code non-null;} second instance
return
{@code non-null;} combined instance


                                          
        
                                             
        if (list1 == EMPTY) {
            // easy case
            return list2;
        }

        int sz1 = list1.size();
        int sz2 = list2.size();
        LocalVariableList result = new LocalVariableList(sz1 + sz2);

        for (int i = 0; i < sz1; i++) {
            result.set(i, list1.get(i));
        }

        for (int i = 0; i < sz2; i++) {
            result.set(sz1 + i, list2.get(i));
        }

        result.setImmutable();
        return result;
    
public com.android.dx.cf.code.LocalVariableList$Itemget(int n)
Gets the indicated item.

param
n {@code >= 0;} which item
return
{@code null-ok;} the indicated item

        return (Item) get0(n);
    
public com.android.dx.cf.code.LocalVariableList$ItemitemToLocal(com.android.dx.cf.code.LocalVariableList$Item item)
Gets the local variable information in this instance which matches the given {@link com.android.dx.cf.code.LocalVariableList.Item} in all respects but the type descriptor and signature, if any.

param
item {@code non-null;} local variable information to match
return
{@code null-ok;} the corresponding local variable information stored in this instance, or {@code null} if there is no matching information

        int sz = size();

        for (int i = 0; i < sz; i++) {
            Item one = (Item) get0(i);

            if ((one != null) && one.matchesAllButType(item)) {
                return one;
            }
        }

        return null;
    
public static com.android.dx.cf.code.LocalVariableListmergeDescriptorsAndSignatures(com.android.dx.cf.code.LocalVariableList descriptorList, com.android.dx.cf.code.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.

param
descriptorList {@code non-null;} list with descriptors
param
signatureList {@code non-null;} list with signatures
return
{@code non-null;} the merged result

        int descriptorSize = descriptorList.size();
        LocalVariableList result = new LocalVariableList(descriptorSize);

        for (int i = 0; i < descriptorSize; i++) {
            Item item = descriptorList.get(i);
            Item signatureItem = signatureList.itemToLocal(item);
            if (signatureItem != null) {
                CstString signature = signatureItem.getSignature();
                item = item.withSignature(signature);
            }
            result.set(i, item);
        }

        result.setImmutable();
        return result;
    
public com.android.dx.cf.code.LocalVariableList$ItempcAndIndexToLocal(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.

param
pc {@code >= 0;} the address to look up
param
index {@code >= 0;} the local variable index
return
{@code null-ok;} the associated local variable information, or {@code null} if none is known

        int sz = size();

        for (int i = 0; i < sz; i++) {
            Item one = (Item) get0(i);

            if ((one != null) && one.matchesPcAndIndex(pc, index)) {
                return one;
            }
        }

        return null;
    
public voidset(int n, com.android.dx.cf.code.LocalVariableList$Item item)
Sets the item at the given index.

param
n {@code >= 0, < size();} which element
param
item {@code non-null;} the item

        if (item == null) {
            throw new NullPointerException("item == null");
        }

        set0(n, item);
    
public voidset(int n, int startPc, int length, com.android.dx.rop.cst.CstString name, com.android.dx.rop.cst.CstString descriptor, com.android.dx.rop.cst.CstString signature, int index)
Sets the item at the given index.

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

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

        set0(n, new Item(startPc, length, name, descriptor, signature, index));