Class Insn

All Implemented Interfaces:
ExtContainer, Iterable<Var>

public final class Insn extends DelegatingExtHolder implements Iterable<Var>
An instruction, encapsulating an operation and its arguments.
  • Field Details

    • TRACK_INSN_CREATIONS

      public static boolean TRACK_INSN_CREATIONS
      Whether instruction creations should be tracked.
    • created

      public Throwable created
      Where this variable was created, for debugging purposes. Only if TRACK_INSN_CREATIONS was true at the time.
    • op

      public Op op
      The underlying operation.
  • Constructor Details

    • Insn

      public Insn(Op op, List<Var> args)
      Construct an instruction with the given operator and arguments.
      Parameters:
      op - The operator.
      args - The arguments.
    • Insn

      public Insn(Op op, Var... args)
      Construct an instruction with the given operator and arguments.
      Parameters:
      op - The operator.
      args - The arguments.
  • Method Details

    • getDelegate

      protected ExtContainer getDelegate()
      Description copied from class: DelegatingExtHolder
      Get the ExtHolder to delegate to.
      Specified by:
      getDelegate in class DelegatingExtHolder
      Returns:
      The delegate.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • assignTo

      public Effect assignTo(Var... vars)
      Create an effect that assigns the result of this instruction.
      Parameters:
      vars - The variables to assign to.
      Returns:
      The effect.
    • assignTo

      public Effect assignTo(List<Var> vars)
      Create an effect that assigns the result of this instruction.
      Parameters:
      vars - The variables to assign to.
      Returns:
      The effect.
    • jumpsTo

      public Control jumpsTo(BasicBlock... targets)
      Create a control instruction that jumps to the given targets.
      Parameters:
      targets - The jump targets.
      Returns:
      The control instruction.
    • jumpsTo

      public Control jumpsTo(List<BasicBlock> targets)
      Create a control instruction that jumps to the given targets.
      Parameters:
      targets - The jump targets.
      Returns:
      The control instruction.
    • copyFrom

      public Effect copyFrom(Effect fx)
      Create a new effect that assigns to the same variables as the given one.
      Parameters:
      fx - The effect to copy from.
      Returns:
      The new effect.
    • getNullable

      @Nullable public <T> T getNullable(Ext<T> ext)
      Description copied from interface: ExtContainer
      Get the value associated with ext in this container, or null if not present.

      If an ext was attached with ExtContainer.attachExt(Ext, Object), it should be returned, unless it was later removed with a call to ExtContainer.removeExt(Ext).

      Specified by:
      getNullable in interface ExtContainer
      Overrides:
      getNullable in class DelegatingExtHolder
      Type Parameters:
      T - The type of the ext.
      Parameters:
      ext - The ext.
      Returns:
      The value associated with ext in this container.
    • attachExt

      public <T> void attachExt(Ext<T> ext, T value)
      Description copied from interface: ExtContainer
      Associate ext with value in this container.
      Specified by:
      attachExt in interface ExtContainer
      Overrides:
      attachExt in class ExtHolder
      Type Parameters:
      T - The type of the ext.
      Parameters:
      ext - The ext.
      value - The value the ext has in this container.
    • removeExt

      public <T> void removeExt(Ext<T> ext)
      Description copied from interface: ExtContainer
      Disassociate the value of ext (if any) in this container.
      Specified by:
      removeExt in interface ExtContainer
      Overrides:
      removeExt in class ExtHolder
      Type Parameters:
      T - The type of the ext.
      Parameters:
      ext - The ext.
    • args

      public List<Var> args()
      Get the arguments to the instruction.
      Returns:
      The arguments.
    • iterator

      @NotNull public @NotNull Iterator<Var> iterator()
      Specified by:
      iterator in interface Iterable<Var>