FileDocCategorySizeDatePackage
DalvCode.javaAPI DocAndroid 5.1 API6669Thu Mar 12 22:18:28 GMT 2015com.android.dexgen.dex.code

DalvCode

public final class DalvCode extends Object
Container for all the pieces of a concrete method. Each instance corresponds to a {@code code} structure in a {@code .dex} file.

Fields Summary
private final int
positionInfo
how much position info to preserve; one of the static constants in {@link PositionList}
private OutputFinisher
unprocessedInsns
{@code null-ok;} the instruction list, ready for final processing; nulled out in {@link #finishProcessingIfNecessary}
private CatchBuilder
unprocessedCatches
{@code non-null;} unprocessed catch table; nulled out in {@link #finishProcessingIfNecessary}
private CatchTable
catches
{@code null-ok;} catch table; set in {@link #finishProcessingIfNecessary}
private PositionList
positions
{@code null-ok;} source positions list; set in {@link #finishProcessingIfNecessary}
private LocalList
locals
{@code null-ok;} local variable list; set in {@link #finishProcessingIfNecessary}
private DalvInsnList
insns
{@code null-ok;} the processed instruction list; set in {@link #finishProcessingIfNecessary}
Constructors Summary
public DalvCode(int positionInfo, OutputFinisher unprocessedInsns, CatchBuilder unprocessedCatches)
Constructs an instance.

param
positionInfo how much position info to preserve; one of the static constants in {@link PositionList}
param
unprocessedInsns {@code non-null;} the instruction list, ready for final processing
param
unprocessedCatches {@code non-null;} unprocessed catch (exception handler) table

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

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

        this.positionInfo = positionInfo;
        this.unprocessedInsns = unprocessedInsns;
        this.unprocessedCatches = unprocessedCatches;
        this.catches = null;
        this.positions = null;
        this.locals = null;
        this.insns = null;
    
Methods Summary
public voidassignIndices(com.android.dexgen.dex.code.DalvCode$AssignIndicesCallback callback)
Assign indices in all instructions that need them, using the given callback to perform lookups. This must be called before {@link #getInsns}.

param
callback {@code non-null;} callback object

        unprocessedInsns.assignIndices(callback);
    
private voidfinishProcessingIfNecessary()
Finish up processing of the method.

        if (insns != null) {
            return;
        }

        insns = unprocessedInsns.finishProcessingAndGetList();
        positions = PositionList.make(insns, positionInfo);
        locals = LocalList.make(insns);
        catches = unprocessedCatches.build();

        // Let them be gc'ed.
        unprocessedInsns = null;
        unprocessedCatches = null;
    
public java.util.HashSetgetCatchTypes()
Gets the set of catch types handled anywhere in the code.

return
{@code non-null;} the set of catch types

        return unprocessedCatches.getCatchTypes();
    
public CatchTablegetCatches()
Gets the catch (exception handler) table.

return
{@code non-null;} the catch table

        finishProcessingIfNecessary();
        return catches;
    
public java.util.HashSetgetInsnConstants()
Gets the set of all constants referred to by instructions in the code.

return
{@code non-null;} the set of constants

        return unprocessedInsns.getAllConstants();
    
public DalvInsnListgetInsns()
Gets the list of instructions.

return
{@code non-null;} the instruction list

        finishProcessingIfNecessary();
        return insns;
    
public LocalListgetLocals()
Gets the source positions list.

return
{@code non-null;} the source positions list

        finishProcessingIfNecessary();
        return locals;
    
public PositionListgetPositions()
Gets the source positions list.

return
{@code non-null;} the source positions list

        finishProcessingIfNecessary();
        return positions;
    
public booleanhasAnyCatches()
Gets whether this instance has any catches at all (either typed or catch-all).

return
whether this instance has any catches at all

        return unprocessedCatches.hasAnyCatches();
    
public booleanhasLocals()
Gets whether this instance has any local variable data to represent.

return
{@code true} iff this instance has any local variable data to represent

        return unprocessedInsns.hasAnyLocalInfo();
    
public booleanhasPositions()
Gets whether this instance has any position data to represent.

return
{@code true} iff this instance has any position data to represent

        return (positionInfo != PositionList.NONE)
            && unprocessedInsns.hasAnyPositionInfo();