FileDocCategorySizeDatePackage
DalvCode.javaAPI DocAndroid 1.5 API6583Wed May 06 22:41:02 BST 2009com.android.dx.dex.code

DalvCode

public final class DalvCode extends Object
Container for all the pieces of a concrete method. Each instance corresponds to a code structure in a .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
null-ok; the instruction list, ready for final processing; nulled out in {@link #finishProcessingIfNecessary}
private CatchBuilder
unprocessedCatches
non-null; unprocessed catch table; nulled out in {@link #finishProcessingIfNecessary}
private CatchTable
catches
null-ok; catch table; set in {@link #finishProcessingIfNecessary}
private PositionList
positions
null-ok; source positions list; set in {@link #finishProcessingIfNecessary}
private LocalList
locals
null-ok; local variable list; set in {@link #finishProcessingIfNecessary}
private DalvInsnList
insns
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 non-null; the instruction list, ready for final processing
param
unprocessedCatches 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.dx.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 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
non-null; the set of catch types

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

return
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
non-null; the set of constants

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

return
non-null; the instruction list

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

return
non-null; the source positions list

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

return
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
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
true iff this instance has any position data to represent

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