Package ghidra.pcode.exec

# Class PcodeProgram

java.lang.Object
ghidra.pcode.exec.PcodeProgram

Direct Known Subclasses:
  `JitControlFlowModel.JitBlock`, `JitPassage`, `PcodeExpression`

public class PcodeProgram extends Object
A p-code program to be executed by a `PcodeExecutor`

This is a list of p-code operations together with a map of expected userops.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected static class`
  `PcodeProgram.MyAppender`
  `protected static class`
  `PcodeProgram.MyFormatter`

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final List<PcodeOp>`
  `code`
  `protected final SleighLanguage`
  `language`
  `protected final Map<Integer,String>`
  `useropNames`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `PcodeProgram(SleighLanguage language, List<PcodeOp> code, Map<Integer,ghidra.pcodeCPort.slghsymbol.UserOpSymbol> useropSymbols)`
  Construct a p-code program with the given bindings
  ``
  `PcodeProgram(PcodeProgram program, List<PcodeOp> code)`
  Construct a p-code program from a derivative of the given one

- ## Method Summary

  Modifier and Type
  Method
  Description
  `<T> void`
  `execute(PcodeExecutor<T> executor, PcodeUseropLibrary<T> library)`
  Execute this program using the given executor and library
  `String`
  `format()`
  `String`
  `format(boolean numberOps)`
  `static PcodeProgram`
  `fromInject(Program program, String name, int type)`
  Generate a p-code program from a given program's inject library
  `static PcodeProgram`
  `fromInstruction(Instruction instruction)`
  Generate a p-code program from the given instruction, without overrides
  `static PcodeProgram`
  `fromInstruction(Instruction instruction, boolean includeOverrides)`
  Generate a p-code program from the given instruction
  `List<PcodeOp>`
  `getCode()`
  `protected String`
  `getHead()`
  For display purposes, get the header above the frame, usually the class name
  `SleighLanguage`
  `getLanguage()`
  Get the language generating this program
  `String`
  `getUseropName(int opNo)`
  `String`
  `toString()`

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

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

- ## Field Details

  - ### language

    protected final SleighLanguage language

  - ### code

    protected final List<PcodeOp> code

  - ### useropNames

    protected final Map<Integer,String> useropNames

- ## Constructor Details

  - ### PcodeProgram

    protected PcodeProgram(SleighLanguage language, List<PcodeOp> code, Map<Integer,ghidra.pcodeCPort.slghsymbol.UserOpSymbol> useropSymbols)
    Construct a p-code program with the given bindings
    Parameters:
      `language` - the language that generated the p-code
      `code` - the list of p-code ops
      `useropSymbols` - a map of expected userop symbols

  - ### PcodeProgram

    public PcodeProgram(PcodeProgram program, List<PcodeOp> code)
    Construct a p-code program from a derivative of the given one
    Parameters:
      `program` - the original program
      `code` - the code portion for this program

- ## Method Details

  - ### fromInstruction

    public static PcodeProgram fromInstruction(Instruction instruction)
    Generate a p-code program from the given instruction, without overrides
    Parameters:
      `instruction` - the instruction
    Returns:
      the p-code program

  - ### fromInstruction

    public static PcodeProgram fromInstruction(Instruction instruction, boolean includeOverrides)
    Generate a p-code program from the given instruction
    Parameters:
      `instruction` - the instruction
      `includeOverrides` - as in `Instruction.getPcode(boolean)`
    Returns:
      the p-code program

  - ### fromInject

    public static PcodeProgram fromInject(Program program, String name, int type) throws MemoryAccessException, UnknownInstructionException, NotFoundException, IOException
    Generate a p-code program from a given program's inject library
    Parameters:
      `program` - the program
      `name` - the name of the snippet
      `type` - the type of the snippet
    Returns:
      the p-code program
    Throws:
      `MemoryAccessException` - for problems establishing the injection context
      `IOException` - for problems while emitting the injection p-code
      `UnknownInstructionException` - if there is no underlying instruction being injected
      `NotFoundException` - if an expected aspect of the injection is not present in context

  - ### getLanguage

    public SleighLanguage getLanguage()
    Get the language generating this program
    Returns:
      the language

  - ### getCode

    public List<PcodeOp> getCode()

  - ### execute

    public <T> void execute(PcodeExecutor<T> executor, PcodeUseropLibrary<T> library)
    Execute this program using the given executor and library
    Type Parameters:
      `T` - the type of values to be operated on
    Parameters:
      `executor` - the executor
      `library` - the library

  - ### getHead

    protected String getHead()
    For display purposes, get the header above the frame, usually the class name
    Returns:
      the frame's display header

  - ### toString

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

  - ### format

    public String format(boolean numberOps)

  - ### format

    public String format()

  - ### getUseropName

    public String getUseropName(int opNo)