Class InsnNode

All Implemented Interfaces:
IAttributeNode, ILineAttributeNode
Direct Known Subclasses:
ArithNode, BaseInvokeNode, ConstClassNode, ConstStringNode, FillArrayData, FillArrayInsn, FilledNewArrayNode, IndexInsnNode, NewArrayNode, PhiInsn, SwitchData, TargetInsnNode, TernaryInsn

public class InsnNode extends LineAttrNode
  • Field Details

    • insnType

      protected final InsnType insnType
    • result

      private RegisterArg result
    • arguments

      private final List<InsnArg> arguments
    • offset

      protected int offset
  • Constructor Details

  • Method Details

    • wrapArg

      public static InsnNode wrapArg(InsnArg arg)
    • setResult

      public void setResult(@Nullable @Nullable RegisterArg res)
    • addArg

      public void addArg(InsnArg arg)
    • setArg

      public void setArg(int n, InsnArg arg)
    • attachArg

      protected void attachArg(InsnArg arg)
    • getType

      public InsnType getType()
    • getResult

      public RegisterArg getResult()
    • getArguments

      public Iterable<InsnArg> getArguments()
    • getArgList

      public List<InsnArg> getArgList()
    • getArgsCount

      public int getArgsCount()
    • getArg

      public InsnArg getArg(int n)
    • containsArg

      public boolean containsArg(InsnArg arg)
    • containsVar

      public boolean containsVar(RegisterArg arg)
    • replaceArg

      public boolean replaceArg(InsnArg from, InsnArg to)
      Replace instruction arg with another using recursive search.
    • removeArg

      protected boolean removeArg(InsnArg arg)
    • removeArg

      public InsnArg removeArg(int index)
    • getArgIndex

      public int getArgIndex(InsnArg arg)
    • addReg

      protected void addReg(InsnData insn, int i, ArgType type)
    • addReg

      protected void addReg(int regNum, ArgType type)
    • addLit

      protected void addLit(long literal, ArgType type)
    • addLit

      protected void addLit(InsnData insn, ArgType type)
    • getOffset

      public int getOffset()
    • setOffset

      public void setOffset(int offset)
    • getRegisterArgs

      public void getRegisterArgs(Collection<RegisterArg> collection)
    • isConstInsn

      public boolean isConstInsn()
    • isExitEdgeInsn

      public boolean isExitEdgeInsn()
    • canRemoveResult

      public boolean canRemoveResult()
    • canReorder

      public boolean canReorder()
    • containsWrappedInsn

      public boolean containsWrappedInsn()
    • visitInsns

      public void visitInsns(Consumer<InsnNode> visitor)
      Visit this instruction and all inner (wrapped) instructions
    • visitInsns

      @Nullable public <R> R visitInsns(Function<InsnNode,R> visitor)
      Visit this instruction and all inner (wrapped) instructions To terminate visiting return non-null value
    • visitArgs

      public void visitArgs(Consumer<InsnArg> visitor)
      Visit all args recursively (including inner instructions), but excluding wrapped args
    • visitArgs

      @Nullable public <R> R visitArgs(Function<InsnArg,R> visitor)
      Visit all args recursively (including inner instructions), but excluding wrapped args. To terminate visiting return non-null value
    • isSame

      public boolean isSame(InsnNode other)
      'Soft' equals, don't compare arguments, only instruction specific parameters.
    • isDeepEquals

      public boolean isDeepEquals(InsnNode other)
      'Hard' equals, compare all arguments
    • duplicateArg

      @Nullable public static <T extends InsnArg> T duplicateArg(@Nullable T arg)
    • copyCommonParams

      protected final <T extends InsnNode> T copyCommonParams(T copy)
    • copyAttributesFrom

      public void copyAttributesFrom(InsnNode attrNode)
    • copy

      public InsnNode copy()
      Make copy of InsnNode object.
      NOTE: can't copy instruction with result argument (SSA variable can't be used in two different assigns).
      Prefer use next methods:
    • copyWithoutResult

      public <T extends InsnNode> T copyWithoutResult()
      See copy()
    • copyWithoutSsa

      public InsnNode copyWithoutSsa()
    • copy

      public InsnNode copy(RegisterArg newReturnArg)
      See copy()
    • copyWithNewSsaVar

      public InsnNode copyWithNewSsaVar(MethodNode mth)
      See copy()
    • rebindArgs

      public void rebindArgs()
      Fix SSAVar info in register arguments. Must be used after altering instructions.
    • canThrowException

      public boolean canThrowException()
    • inheritMetadata

      public void inheritMetadata(InsnNode sourceInsn)
    • hashCode

      public final int hashCode()
      Compare instruction only by identity.
      Overrides:
      hashCode in class Object
    • equals

      public final boolean equals(Object obj)
      Compare instruction only by identity.
      Overrides:
      equals in class Object
    • appendArgs

      protected boolean appendArgs(StringBuilder sb)
      Append arguments type, wrap line if too long
      Returns:
      true if args wrapped
    • attributesString

      protected String attributesString()
    • appendAttributes

      protected void appendAttributes(StringBuilder sb)
    • baseString

      protected String baseString()
    • toString

      public String toString()
      Overrides:
      toString in class Object