Top Description Inners Fields Constructors Methods
org.droidparts.dexmaker.dx.rop.code

public abstract Class Insn

extends Object
implements ToHuman
Class Inheritance
All Implemented Interfaces
org.droidparts.dexmaker.dx.util.ToHuman
Known Direct Subclasses
org.droidparts.dexmaker.dx.rop.code.PlainInsn, org.droidparts.dexmaker.dx.rop.code.SwitchInsn, org.droidparts.dexmaker.dx.rop.code.ThrowingInsn, org.droidparts.dexmaker.dx.rop.code.CstInsn, org.droidparts.dexmaker.dx.rop.code.FillArrayDataInsn
Imports
org.droidparts.dexmaker.dx.rop.type.StdTypeList, .Type, .TypeList, org.droidparts.dexmaker.dx.util.ToHuman

A register-based instruction. An instruction is the combination of an opcode (which specifies operation and source/result types), a list of actual sources and result registers/values, and additional information.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Insn.BaseVisitor

Base implementation of Visitor, which has empty method bodies for all methods.

public static interface
Insn.Visitor

Visitor interface for this (outer) class.

Field Summary

Modifier and TypeField and Description
private final Rop
opcode

non-null; opcode

private final SourcePosition
position

non-null; source position

private final RegisterSpec
result

null-ok; spec for the result of this instruction, if any

private final RegisterSpecList
sources

non-null; specs for all the sources of this instruction

Constructor Summary

AccessConstructor and Description
public
Insn(Rop
non-null; the opcode
opcode
,
SourcePosition
non-null; source position
position
,
RegisterSpec
null-ok; spec for the result, if any
result
,
RegisterSpecList
non-null; specs for all the sources
sources
)

Constructs an instance.

Method Summary

Modifier and TypeMethod and Description
public abstract void
accept(Insn.Visitor
non-null; the visitor to call on
visitor
)

Calls the appropriate method on the given visitor, depending on the class of this instance.

public final boolean

Returns:

true iff this instruction can possibly throw
canThrow
()

Gets whether this instruction can possibly throw an exception.

public boolean

Returns:

true in the case described above
contentEquals
(Insn b)

Compares Insn contents, since Insn.equals() is defined to be an identity compare.

public Insn

Returns:

non-null; an appropriately-constructed instance
copy
()

Returns an exact copy of this Insn

public final boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
private static boolean

Returns:

true if they're equal or both null.
equalsHandleNulls
(Object
first object
a
,
Object
second object
b
)

Compares, handling nulls safely

public abstract TypeList

Returns:

non-null; the catches list
getCatches
()

Gets the list of possibly-caught exceptions.

public String

Returns:

null-ok; if non-null, the inline text for toHuman()
getInlineString
()

Gets an "inline" string portion for toHuman(), if available.

public final RegisterSpec

Returns:

null-ok; a named register spec or null
getLocalAssignment
()

Gets the spec of a local variable assignment that occurs at this instruction, or null if no local variable assignment occurs.

public final Rop

Returns:

non-null; the opcode
getOpcode
()

Gets the opcode.

public final SourcePosition

Returns:

non-null; the source position
getPosition
()

Gets the source position.

public final RegisterSpec

Returns:

null-ok; the result spec, if any
getResult
()

Gets the result spec, if any.

public final RegisterSpecList

Returns:

non-null; the source specs
getSources
()

Gets the source specs.

public final int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.
public String

Returns:

non-null; the human string form
toHuman
()

Implements org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Gets a human-oriented (and slightly lossy) string for this instance.
protected final String

Returns:

non-null; the human string form
toHumanWithInline
(String
null-ok; the inline argument string
extra
)

Returns the human string form of this instance, with the given bit added in the standard location for an inline argument.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
protected final String

Returns:

non-null; the string form
toStringWithInline
(String
null-ok; the inline argument string
extra
)

Returns the string form of this instance, with the given bit added in the standard location for an inline argument.

public abstract Insn

Returns:

non-null; an appropriately-constructed instance
withAddedCatch
(Type
non-null; type to append to the catch list
type
)

Returns an instance that is just like this one, except that it has a catch list with the given item appended to the end.

public abstract Insn

Returns:

non-null; an appropriately-constructed instance
withNewRegisters
(RegisterSpec
null-ok; new result register
result
,
RegisterSpecList
non-null; new sources registers
sources
)

Returns an instance that is just like this one, except with new result and source registers.

public abstract Insn

Returns:

non-null; an appropriately-constructed instance
withRegisterOffset
(int
the amount to offset register references by
delta
)

Returns an instance that is just like this one, except that all register references have been offset by the given delta.

public Insn

Returns:

non-null; an appropriately-constructed instance
withSourceLiteral
()

Returns an instance that is just like this one, except that, if possible, the insn is converted into a version in which a source (if it is a constant) is represented directly rather than as a register reference.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

opcodeback to summary
private final Rop opcode

non-null; opcode

positionback to summary
private final SourcePosition position

non-null; source position

resultback to summary
private final RegisterSpec result

null-ok; spec for the result of this instruction, if any

sourcesback to summary
private final RegisterSpecList sources

non-null; specs for all the sources of this instruction

Constructor Detail

Insnback to summary
public Insn(Rop opcode, SourcePosition position, RegisterSpec result, RegisterSpecList sources)

Constructs an instance.

Parameters
opcode:Rop

non-null; the opcode

position:SourcePosition

non-null; source position

result:RegisterSpec

null-ok; spec for the result, if any

sources:RegisterSpecList

non-null; specs for all the sources

Method Detail

acceptback to summary
public abstract void accept(Insn.Visitor visitor)

Calls the appropriate method on the given visitor, depending on the class of this instance. Subclasses must override this.

Parameters
visitor:Insn.Visitor

non-null; the visitor to call on

canThrowback to summary
public final boolean canThrow()

Gets whether this instruction can possibly throw an exception. This is just a convenient wrapper for getOpcode().canThrow().

Returns:boolean

true iff this instruction can possibly throw

contentEqualsback to summary
public boolean contentEquals(Insn b)

Compares Insn contents, since Insn.equals() is defined to be an identity compare. Insn's are contentEquals() if they have the same opcode, registers, source position, and other metadata.

Returns:boolean

true in the case described above

copyback to summary
public Insn copy()

Returns an exact copy of this Insn

Returns:Insn

non-null; an appropriately-constructed instance

equalsback to summary
public final boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. Instances of this class compare by identity. That is, x.equals(y) is only true if x == y.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
equalsHandleNullsback to summary
private static boolean equalsHandleNulls(Object a, Object b)

Compares, handling nulls safely

Parameters
a:Object

first object

b:Object

second object

Returns:boolean

true if they're equal or both null.

getCatchesback to summary
public abstract TypeList getCatches()

Gets the list of possibly-caught exceptions. This returns StdTypeList#EMPTY if this instruction has no handlers, which can be either if this instruction can't possibly throw or if it merely doesn't handle any of its possible exceptions. To determine whether this instruction can throw, use canThrow.

Returns:TypeList

non-null; the catches list

getInlineStringback to summary
public String getInlineString()

Gets an "inline" string portion for toHuman(), if available. This is the portion that appears after the Rop opcode

Returns:String

null-ok; if non-null, the inline text for toHuman()

getLocalAssignmentback to summary
public final RegisterSpec getLocalAssignment()

Gets the spec of a local variable assignment that occurs at this instruction, or null if no local variable assignment occurs. This may be the result register, or for mark-local insns it may be the source.

Returns:RegisterSpec

null-ok; a named register spec or null

getOpcodeback to summary
public final Rop getOpcode()

Gets the opcode.

Returns:Rop

non-null; the opcode

getPositionback to summary
public final SourcePosition getPosition()

Gets the source position.

Returns:SourcePosition

non-null; the source position

getResultback to summary
public final RegisterSpec getResult()

Gets the result spec, if any. A return value of null means this instruction returns nothing.

Returns:RegisterSpec

null-ok; the result spec, if any

getSourcesback to summary
public final RegisterSpecList getSources()

Gets the source specs.

Returns:RegisterSpecList

non-null; the source specs

hashCodeback to summary
public final int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
This implementation returns the identity hashcode of this instance. This is proper, since instances of this class compare by identity (see equals).
Returns:int

a hash code value for this object

Annotations
@Override
toHumanback to summary
public String toHuman()

Implements org.droidparts.dexmaker.dx.util.ToHuman.toHuman.

Gets a human-oriented (and slightly lossy) string for this instance.

Returns:String

non-null; the human string form

toHumanWithInlineback to summary
protected final String toHumanWithInline(String extra)

Returns the human string form of this instance, with the given bit added in the standard location for an inline argument.

Parameters
extra:String

null-ok; the inline argument string

Returns:String

non-null; the human string form

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
toStringWithInlineback to summary
protected final String toStringWithInline(String extra)

Returns the string form of this instance, with the given bit added in the standard location for an inline argument.

Parameters
extra:String

null-ok; the inline argument string

Returns:String

non-null; the string form

withAddedCatchback to summary
public abstract Insn withAddedCatch(Type type)

Returns an instance that is just like this one, except that it has a catch list with the given item appended to the end. This method throws an exception if this instance can't possibly throw. To determine whether this instruction can throw, use canThrow.

Parameters
type:Type

non-null; type to append to the catch list

Returns:Insn

non-null; an appropriately-constructed instance

withNewRegistersback to summary
public abstract Insn withNewRegisters(RegisterSpec result, RegisterSpecList sources)

Returns an instance that is just like this one, except with new result and source registers.

Parameters
result:RegisterSpec

null-ok; new result register

sources:RegisterSpecList

non-null; new sources registers

Returns:Insn

non-null; an appropriately-constructed instance

withRegisterOffsetback to summary
public abstract Insn withRegisterOffset(int delta)

Returns an instance that is just like this one, except that all register references have been offset by the given delta.

Parameters
delta:int

the amount to offset register references by

Returns:Insn

non-null; an appropriately-constructed instance

withSourceLiteralback to summary
public Insn withSourceLiteral()

Returns an instance that is just like this one, except that, if possible, the insn is converted into a version in which a source (if it is a constant) is represented directly rather than as a register reference. this is returned in cases where the translation is not possible.

Returns:Insn

non-null; an appropriately-constructed instance

org.droidparts.dexmaker.dx.rop.code back to summary

public Class Insn.BaseVisitor

extends Object
implements Visitor
Class Inheritance
All Implemented Interfaces
org.droidparts.dexmaker.dx.rop.code.Insn.Visitor

Base implementation of Visitor, which has empty method bodies for all methods.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
public void
public void
visitPlainInsn(PlainInsn
non-null; the instruction to visit
insn
)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitPlainInsn.

Visits a PlainInsn.
public void
public void
public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

BaseVisitorback to summary
public BaseVisitor()

Method Detail

visitFillArrayDataInsnback to summary
public void visitFillArrayDataInsn(FillArrayDataInsn insn)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitFillArrayDataInsn.

Doc from org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitFillArrayDataInsn.

Visits a FillArrayDataInsn.

Parameters
insn:FillArrayDataInsn

non-null; the instruction to visit

visitPlainCstInsnback to summary
public void visitPlainCstInsn(PlainCstInsn insn)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitPlainCstInsn.

Doc from org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitPlainCstInsn.

Visits a PlainCstInsn.

Parameters
insn:PlainCstInsn

non-null; the instruction to visit

visitPlainInsnback to summary
public void visitPlainInsn(PlainInsn insn)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitPlainInsn.

Doc from org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitPlainInsn.

Visits a PlainInsn.

Parameters
insn:PlainInsn

non-null; the instruction to visit

visitSwitchInsnback to summary
public void visitSwitchInsn(SwitchInsn insn)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitSwitchInsn.

Doc from org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitSwitchInsn.

Visits a SwitchInsn.

Parameters
insn:SwitchInsn

non-null; the instruction to visit

visitThrowingCstInsnback to summary
public void visitThrowingCstInsn(ThrowingCstInsn insn)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitThrowingCstInsn.

Doc from org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitThrowingCstInsn.

Visits a ThrowingCstInsn.

Parameters
insn:ThrowingCstInsn

non-null; the instruction to visit

visitThrowingInsnback to summary
public void visitThrowingInsn(ThrowingInsn insn)

Implements org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitThrowingInsn.

Doc from org.droidparts.dexmaker.dx.rop.code.Insn.Visitor.visitThrowingInsn.

Visits a ThrowingInsn.

Parameters
insn:ThrowingInsn

non-null; the instruction to visit

org.droidparts.dexmaker.dx.rop.code back to summary

public Interface Insn.Visitor

Known Direct Implementers
org.droidparts.dexmaker.dx.rop.code.Insn.BaseVisitor, org.droidparts.dexmaker.dx.dex.code.RopTranslator.TranslationVisitor, org.droidparts.dexmaker.dx.rop.code.BasicBlockList.RegCountVisitor

Visitor interface for this (outer) class.

Method Summary

Modifier and TypeMethod and Description
public void
visitFillArrayDataInsn(FillArrayDataInsn
non-null; the instruction to visit
insn
)

Visits a FillArrayDataInsn.

public void
visitPlainCstInsn(PlainCstInsn
non-null; the instruction to visit
insn
)

Visits a PlainCstInsn.

public void
visitPlainInsn(PlainInsn
non-null; the instruction to visit
insn
)

Visits a PlainInsn.

public void
visitSwitchInsn(SwitchInsn
non-null; the instruction to visit
insn
)

Visits a SwitchInsn.

public void
visitThrowingCstInsn(ThrowingCstInsn
non-null; the instruction to visit
insn
)

Visits a ThrowingCstInsn.

public void
visitThrowingInsn(ThrowingInsn
non-null; the instruction to visit
insn
)

Visits a ThrowingInsn.

Method Detail

visitFillArrayDataInsnback to summary
public void visitFillArrayDataInsn(FillArrayDataInsn insn)

Visits a FillArrayDataInsn.

Parameters
insn:FillArrayDataInsn

non-null; the instruction to visit

visitPlainCstInsnback to summary
public void visitPlainCstInsn(PlainCstInsn insn)

Visits a PlainCstInsn.

Parameters
insn:PlainCstInsn

non-null; the instruction to visit

visitPlainInsnback to summary
public void visitPlainInsn(PlainInsn insn)

Visits a PlainInsn.

Parameters
insn:PlainInsn

non-null; the instruction to visit

visitSwitchInsnback to summary
public void visitSwitchInsn(SwitchInsn insn)

Visits a SwitchInsn.

Parameters
insn:SwitchInsn

non-null; the instruction to visit

visitThrowingCstInsnback to summary
public void visitThrowingCstInsn(ThrowingCstInsn insn)

Visits a ThrowingCstInsn.

Parameters
insn:ThrowingCstInsn

non-null; the instruction to visit

visitThrowingInsnback to summary
public void visitThrowingInsn(ThrowingInsn insn)

Visits a ThrowingInsn.

Parameters
insn:ThrowingInsn

non-null; the instruction to visit