Package ghidra.program.model.lang

# Class InstructionSet

java.lang.Object
ghidra.program.model.lang.InstructionSet

All Implemented Interfaces:
  `Iterable<InstructionBlock>`

public class InstructionSet extends Object implements Iterable<InstructionBlock>
A set of instructions organized as a graph of basic blocks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `InstructionSet(AddressFactory addrFactory)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addBlock(InstructionBlock block)`
  Add an Instruction block to this Instruction Set.
  `boolean`
  `containsBlockAt(Address blockAddr)`
  `Iterator<InstructionBlock>`
  `emptyBlockIterator()`
  Returns an iterator over all empty blocks which likely contain a conflict error.
  `InstructionBlock`
  `findFirstIntersectingBlock(Address min, Address max)`
  Find the first block within this InstructionSet which intersects the specified range.
  `AddressSetView`
  `getAddressSet()`
  Returns the address set that makes up all the instructions contained in this set.
  `List<InstructionError>`
  `getConflicts()`
  Returns a list of conflicts for this set.
  `Instruction`
  `getInstructionAt(Address address)`
  Returns the instruction at the specified address within this instruction set
  `InstructionBlock`
  `getInstructionBlockContaining(Address address)`
  Returns the non-empty InstructionBlock containing the specified address
  `int`
  `getInstructionCount()`
  Returns the number of instructions in this instruction set.
  `Address`
  `getMinAddress()`
  Returns the minimum address for this Instruction set;
  `boolean`
  `intersects(Address minAddress, Address maxAddress)`
  Returns true if this instruction set intersects the specified range
  `Iterator<InstructionBlock>`
  `iterator()`
  Returns an iterator over the blocks in this Instruction set, giving preference to fall through flows.
  `String`
  `toString()`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface java.lang.Iterable

  `forEach, spliterator`

- ## Constructor Details

  - ### InstructionSet

    public InstructionSet(AddressFactory addrFactory)

- ## Method Details

  - ### addBlock

    public void addBlock(InstructionBlock block)
    Add an Instruction block to this Instruction Set. If the block is empty it will only be added to the empty-list and will not be added to the maps or block iterator
    Parameters:
      `block` - the block to add.

  - ### getInstructionBlockContaining

    public InstructionBlock getInstructionBlockContaining(Address address)
    Returns the non-empty InstructionBlock containing the specified address
    Parameters:
      `address` -
    Returns:
      the InstructionBlock containing the specified address or null if not found

  - ### findFirstIntersectingBlock

    public InstructionBlock findFirstIntersectingBlock(Address min, Address max)
    Find the first block within this InstructionSet which intersects the specified range. This method should be used sparingly since it uses a brute-force search.
    Parameters:
      `min` - the minimum intersection address
      `max` - the maximum intersection address
    Returns:
      block within this InstructionSet which intersects the specified range or null if not found

  - ### getInstructionAt

    public Instruction getInstructionAt(Address address)
    Returns the instruction at the specified address within this instruction set
    Parameters:
      `address` -
    Returns:
      instruction at the specified address within this instruction set or null if not found

  - ### getMinAddress

    public Address getMinAddress()
    Returns the minimum address for this Instruction set;
    Returns:
      the minimum address for this Instruction set;

  - ### getAddressSet

    public AddressSetView getAddressSet()
    Returns the address set that makes up all the instructions contained in this set.
    Returns:
      the address set that makes up all the instructions contained in this set.

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`

  - ### getInstructionCount

    public int getInstructionCount()
    Returns the number of instructions in this instruction set.
    Returns:
      the number of instructions in this instruction set.

  - ### containsBlockAt

    public boolean containsBlockAt(Address blockAddr)

  - ### intersects

    public boolean intersects(Address minAddress, Address maxAddress)
    Returns true if this instruction set intersects the specified range
    Parameters:
      `minAddress` -
      `maxAddress` -
    Returns:
      true if this instruction set intersects the specified range

  - ### iterator

    public Iterator<InstructionBlock> iterator()
    Returns an iterator over the blocks in this Instruction set, giving preference to fall through flows. This iterator will not follow any flows from a block that has a conflict. If the last block returned from the iterator is marked as a conflict before the next() or hasNext() methods are called, then this iterator will respect the conflict. In other words, this iterator follows block flows on the fly and doesn't pre-compute the blocks to return. Also, if any blocks in this set don't have a flow to path from the start block, it will not be included in this iterator.
    Specified by:
      `iterator` in interface `Iterable<InstructionBlock>`

  - ### emptyBlockIterator

    public Iterator<InstructionBlock> emptyBlockIterator()
    Returns an iterator over all empty blocks which likely contain a conflict error.
    Returns:
      empty block iterator

  - ### getConflicts

    public List<InstructionError> getConflicts()
    Returns a list of conflicts for this set. If a block is not reachable from a non-conflicted block, it's conflicts(if any) will not be included.
    Returns:
      the list of conflicts for this set.