Package com.android.dx.rop.code
Class Insn
java.lang.Object
com.android.dx.rop.code.Insn
- All Implemented Interfaces:
ToHuman
- Direct Known Subclasses:
CstInsn
,FillArrayDataInsn
,InvokePolymorphicInsn
,PlainInsn
,SwitchInsn
,ThrowingInsn
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 Class Summary
Modifier and TypeClassDescriptionstatic class
Base implementation ofInsn.Visitor
, which has empty method bodies for all methods.static interface
Visitor interface for this (outer) class. -
Constructor Summary
ConstructorDescriptionInsn
(Rop opcode, SourcePosition position, RegisterSpec result, RegisterSpecList sources) Constructs an instance. -
Method Summary
Modifier and TypeMethodDescriptionabstract void
accept
(Insn.Visitor visitor) Calls the appropriate method on the given visitor, depending on the class of this instance.final boolean
canThrow()
Gets whether this instruction can possibly throw an exception.boolean
Compares Insn contents, sinceInsn.equals()
is defined to be an identity compare.copy()
Returns an exact copy of this Insnfinal boolean
Instances of this class compare by identity.abstract TypeList
Gets the list of possibly-caught exceptions.Gets an "inline" string portion for toHuman(), if available.final RegisterSpec
Gets the spec of a local variable assignment that occurs at this instruction, or null if no local variable assignment occurs.final Rop
Gets the opcode.final SourcePosition
Gets the source position.final RegisterSpec
Gets the result spec, if any.final RegisterSpecList
Gets the source specs.final int
hashCode()
This implementation returns the identity hashcode of this instance.toHuman()
Gets a human-oriented (and slightly lossy) string for this instance.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.toString()
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.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.abstract Insn
withNewRegisters
(RegisterSpec result, RegisterSpecList sources) Returns an instance that is just like this one, except with new result and source registers.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.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.
-
Constructor Details
-
Insn
Constructs an instance.- Parameters:
opcode
-non-null;
the opcodeposition
-non-null;
source positionresult
-null-ok;
spec for the result, if anysources
-non-null;
specs for all the sources
-
-
Method Details
-
equals
Instances of this class compare by identity. That is,x.equals(y)
is only true ifx == y
. -
hashCode
public final int hashCode()This implementation returns the identity hashcode of this instance. This is proper, since instances of this class compare by identity (seeequals(java.lang.Object)
). -
toString
-
toHuman
Gets a human-oriented (and slightly lossy) string for this instance. -
getInlineString
Gets an "inline" string portion for toHuman(), if available. This is the portion that appears after the Rop opcode- Returns:
null-ok;
if non-null, the inline text for toHuman()
-
getOpcode
Gets the opcode.- Returns:
non-null;
the opcode
-
getPosition
Gets the source position.- Returns:
non-null;
the source position
-
getResult
Gets the result spec, if any. A return value ofnull
means this instruction returns nothing.- Returns:
null-ok;
the result spec, if any
-
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 formark-local
insns it may be the source.- Returns:
null-ok;
a named register spec or null
-
getSources
Gets the source specs.- Returns:
non-null;
the source specs
-
canThrow
public final boolean canThrow()Gets whether this instruction can possibly throw an exception. This is just a convenient wrapper forgetOpcode().canThrow()
.- Returns:
true
iff this instruction can possibly throw
-
getCatches
Gets the list of possibly-caught exceptions. This returnsStdTypeList.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, usecanThrow()
.- Returns:
non-null;
the catches list
-
accept
Calls the appropriate method on the given visitor, depending on the class of this instance. Subclasses must override this.- Parameters:
visitor
-non-null;
the visitor to call on
-
withAddedCatch
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, usecanThrow()
.- Parameters:
type
-non-null;
type to append to the catch list- Returns:
non-null;
an appropriately-constructed instance
-
withRegisterOffset
Returns an instance that is just like this one, except that all register references have been offset by the given delta.- Parameters:
delta
- the amount to offset register references by- 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.this
is returned in cases where the translation is not possible.- Returns:
non-null;
an appropriately-constructed instance
-
copy
Returns an exact copy of this Insn- Returns:
non-null;
an appropriately-constructed instance
-
contentEquals
Compares Insn contents, sinceInsn.equals()
is defined to be an identity compare. Insn's arecontentEquals()
if they have the same opcode, registers, source position, and other metadata.- Returns:
- true in the case described above
-
withNewRegisters
Returns an instance that is just like this one, except with new result and source registers.- Parameters:
result
-null-ok;
new result registersources
-non-null;
new sources registers- Returns:
non-null;
an appropriately-constructed instance
-
toStringWithInline
Returns the string form of this instance, with the given bit added in the standard location for an inline argument.- Parameters:
extra
-null-ok;
the inline argument string- Returns:
non-null;
the string form
-
toHumanWithInline
Returns the human string form of this instance, with the given bit added in the standard location for an inline argument.- Parameters:
extra
-null-ok;
the inline argument string- Returns:
non-null;
the human string form
-