Package ghidra.app.plugin.processors.sleigh

# Class ParserWalker

java.lang.Object
ghidra.app.plugin.processors.sleigh.ParserWalker

public class ParserWalker extends Object
Class for walking the Sleigh Parser tree. The nodes of the tree are the Sleigh Constructors arranged for a particular instruction. This tree is walked for various purposes:

- SleighInstructionPrototype.resolve - initial parsing of instruction and building the tree
- SleighInstructionPrototype.resolveHandles - filling in Varnode values for all the Constructor exports
- PcodeEmit - for weaving together p-code for an instruction

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ParserWalker(SleighParserContext c)`
  `ParserWalker(SleighParserContext c, SleighParserContext cross)`
  For use with pcode cross-build

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `allocateOperand()`
  `void`
  `baseState()`
  Initialize a walk of the tree
  `void`
  `calcCurrentLength(int minLength, int numopers)`
  Calculate the length of the current constructor state assuming all its operands are constructed
  `Address`
  `getAddr()`
  `Constructor`
  `getConstructor()`
  `AddressSpace`
  `getConstSpace()`
  `int`
  `getContextBits(int startbit, int size)`
  `int`
  `getContextBytes(int byteoff, int numbytes)`
  `int`
  `getCurrentLength()`
  `String`
  `getCurrentSubtableName()`
  `AddressSpace`
  `getCurSpace()`
  `FixedHandle`
  `getFixedHandle(int i)`
  `Address`
  `getFlowDestAddr()`
  `Address`
  `getFlowRefAddr()`
  `int`
  `getInstructionBits(int startbit, int size)`
  `int`
  `getInstructionBytes(int byteoff, int numbytes)`
  `Address`
  `getN2addr()`
  `Address`
  `getNaddr()`
  `int`
  `getOffset(int i)`
  Get the offset into the instruction for the current node (i=-1) or one of the current node's children
  `int`
  `getOperand()`
  Find the next child that needs to be traversed
  `FixedHandle`
  `getParentHandle()`
  `SleighParserContext`
  `getParserContext()`
  `ConstructState`
  `getState()`
  `boolean`
  `isState()`
  Are we at the end of the tree walk
  `void`
  `popOperand()`
  Move to the parent of the current node
  `void`
  `pushOperand(int i)`
  Move down to a particular child of the current node.
  `void`
  `setConstructor(Constructor ct)`
  `void`
  `setCurrentLength(int len)`
  `void`
  `setOffset(int off)`
  `void`
  `setOutOfBandState(Constructor ct, int index, ConstructState tempstate, ParserWalker otherwalker)`
  `void`
  `snippetState()`
  Create state suitable for parsing a just a p-code semantics snippet
  `void`
  `subTreeState(ConstructState subtree)`

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

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

- ## Constructor Details

  - ### ParserWalker

    public ParserWalker(SleighParserContext c)

  - ### ParserWalker

    public ParserWalker(SleighParserContext c, SleighParserContext cross)
    For use with pcode cross-build
    Parameters:
      `c` - context
      `cross` - cross context

- ## Method Details

  - ### getParserContext

    public SleighParserContext getParserContext()

  - ### baseState

    public void baseState()
    Initialize a walk of the tree

  - ### subTreeState

    public void subTreeState(ConstructState subtree)

  - ### snippetState

    public void snippetState()
    Create state suitable for parsing a just a p-code semantics snippet

  - ### isState

    public boolean isState()
    Are we at the end of the tree walk
    Returns:
      true if there is more walk to go

  - ### getState

    public ConstructState getState()

  - ### pushOperand

    public void pushOperand(int i)
    Move down to a particular child of the current node. Store what would be the next sibling to walk
    Parameters:
      `i` - is the index of the desired child

  - ### allocateOperand

    public void allocateOperand() throws UnknownInstructionException
    Throws:
      `UnknownInstructionException`

  - ### popOperand

    public void popOperand()
    Move to the parent of the current node

  - ### getOperand

    public int getOperand()
    Find the next child that needs to be traversed
    Returns:
      the index of the child

  - ### getFixedHandle

    public FixedHandle getFixedHandle(int i)

  - ### getParentHandle

    public FixedHandle getParentHandle()

  - ### getOffset

    public int getOffset(int i)
    Get the offset into the instruction for the current node (i=-1) or one of the current node's children
    Parameters:
      `i` - selects the desired child of the current node
    Returns:
      the offset (in bytes) for the selected node

  - ### setOffset

    public void setOffset(int off)

  - ### getCurrentLength

    public int getCurrentLength()

  - ### setCurrentLength

    public void setCurrentLength(int len)

  - ### calcCurrentLength

    public void calcCurrentLength(int minLength, int numopers)
    Calculate the length of the current constructor state assuming all its operands are constructed

  - ### getConstructor

    public Constructor getConstructor()
    Returns:
      the Constructor for the current node in the walk

  - ### setConstructor

    public void setConstructor(Constructor ct)

  - ### getAddr

    public Address getAddr()

  - ### getNaddr

    public Address getNaddr()

  - ### getN2addr

    public Address getN2addr()

  - ### getCurSpace

    public AddressSpace getCurSpace()

  - ### getConstSpace

    public AddressSpace getConstSpace()

  - ### getFlowRefAddr

    public Address getFlowRefAddr()

  - ### getFlowDestAddr

    public Address getFlowDestAddr()

  - ### getInstructionBytes

    public int getInstructionBytes(int byteoff, int numbytes) throws MemoryAccessException
    Throws:
      `MemoryAccessException`

  - ### getContextBytes

    public int getContextBytes(int byteoff, int numbytes)

  - ### getInstructionBits

    public int getInstructionBits(int startbit, int size) throws MemoryAccessException
    Throws:
      `MemoryAccessException`

  - ### getContextBits

    public int getContextBits(int startbit, int size)

  - ### setOutOfBandState

    public void setOutOfBandState(Constructor ct, int index, ConstructState tempstate, ParserWalker otherwalker)

  - ### getCurrentSubtableName

    public String getCurrentSubtableName()