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

TargetInsn

public final class TargetInsn extends FixedSizeInsn
Instruction which has a single branch target.

Fields Summary
private CodeAddress
target
non-null; the branch target
Constructors Summary
public TargetInsn(Dop opcode, com.android.dx.rop.code.SourcePosition position, com.android.dx.rop.code.RegisterSpecList registers, CodeAddress target)
Constructs an instance. The output address of this instance is initially unknown (-1), and the target is initially null.

param
opcode the opcode; one of the constants from {@link Dops}
param
position non-null; source position
param
registers non-null; register list, including a result register if appropriate (that is, registers may be either ins or outs)
param
target non-null; the branch target

        super(opcode, position, registers);

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

        this.target = target;
    
Methods Summary
protected java.lang.StringargString()
{@inheritDoc}

        if (target == null) {
            return "????";
        }

        return target.identifierString();
    
public CodeAddressgetTarget()
Gets the unique branch target of this instruction.

return
non-null; the branch target

        return target;
    
public intgetTargetAddress()
Gets the target address of this instruction. This is only valid to call if the target instruction has been assigned an address, and it is merely a convenient shorthand for getTarget().getAddress().

return
>= 0; the target address

        return target.getAddress();
    
public intgetTargetOffset()
Gets the branch offset of this instruction. This is only valid to call if both this and the target instruction each has been assigned an address, and it is merely a convenient shorthand for getTargetAddress() - getAddress().

return
the branch offset

        return target.getAddress() - getAddress();
    
public booleanhasTargetOffset()
Returns whether the target offset is known.

return
true if the target offset is known or false if not

        return hasAddress() && target.hasAddress();
    
public com.android.dx.dex.code.TargetInsnwithNewTargetAndReversed(CodeAddress target)
Returns an instance that is just like this one, except that its opcode has the opposite sense (as a test; e.g. a lt test becomes a ge), and its branch target is replaced by the one given, and all set-once values associated with the class (such as its address) are reset.

param
target non-null; the new branch target
return
non-null; an appropriately-constructed instance

        Dop opcode = getOpcode().getOppositeTest();

        return new TargetInsn(opcode, getPosition(), getRegisters(), target);
    
public DalvInsnwithOpcode(Dop opcode)
{@inheritDoc}

        return new TargetInsn(opcode, getPosition(), getRegisters(), target);
    
public DalvInsnwithRegisters(com.android.dx.rop.code.RegisterSpecList registers)
{@inheritDoc}

        return new TargetInsn(getOpcode(), getPosition(), registers, target);