decompiler 1.0.0
Public Member Functions | Protected Attributes | Private Attributes | List of all members
ghidra::ParserWalker Class Reference

A class for walking the constructor tree (ParserContext) More...

#include <context.hh>

Inheritance diagram for ghidra::ParserWalker:
ghidra::ParserWalkerChange

Public Member Functions

 ParserWalker (const ParserContext *c)
 Constructor.
 
 ParserWalker (const ParserContext *c, const ParserContext *cross)
 Constructor for crossbuilds.
 
const ParserContext * getParserContext (void) const
 Get the current context.
 
void baseState (void)
 Initialize for a new walk.
 
void setOutOfBandState (Constructor *ct, int4 index, ConstructState *tempstate, const ParserWalker &otherwalker)
 Initialize this from another walker assuming a given constructor and operand is the current position in the walk. More...
 
bool isState (void) const
 Return true if there are more nodes to traverse.
 
void pushOperand (int4 i)
 Make the indicated child (operand) the current node. More...
 
void popOperand (void)
 Make the parent constructor the current node.
 
uint4 getOffset (int4 i) const
 Get the byte offset of the indicated operand within the instruction stream.
 
Constructor * getConstructor (void) const
 Get the current constructor.
 
int4 getOperand (void) const
 Get the operand index of the next constructor in the walk.
 
FixedHandle & getParentHandle (void)
 Get the resolved value associated with the current constructor.
 
const FixedHandle & getFixedHandle (int4 i) const
 Get the resolved value associated with the indicated child operand.
 
AddrSpace * getCurSpace (void) const
 Get the address space associated with the instruction stream.
 
AddrSpace * getConstSpace (void) const
 Get the constant address space.
 
const Address & getAddr (void) const
 Get the starting address of the instruction.
 
const Address & getNaddr (void) const
 Get the address of the next instruction.
 
const Address & getN2addr (void) const
 Get the address of the instruction after next.
 
const Address & getRefAddr (void) const
 Get the reference address (inst_ref) for the p-code snippet.
 
const Address & getDestAddr (void) const
 Get the destination address (inst_dest) for the overridden call.
 
int4 getLength (void) const
 Get the length of the instruction in bytes.
 
uintm getInstructionBytes (int4 byteoff, int4 numbytes) const
 Get packed instruction bytes associated with the current constructor. More...
 
uintm getContextBytes (int4 byteoff, int4 numbytes) const
 Get packed context bytes from the local context. More...
 
uintm getInstructionBits (int4 startbit, int4 size) const
 Get bits from the instruction stream associated with the current constructor. More...
 
uintm getContextBits (int4 startbit, int4 size) const
 Get a range of bits from the local context. More...
 

Protected Attributes

ConstructState * point
 The current node being visited.
 
int4 depth
 Depth of the current node.
 
int4 breadcrumb [ParserContext::MAX_DEPTH]
 Path of operands from root.
 

Private Attributes

const ParserContext * const_context
 Context for the main instruction parse.
 
const ParserContext * cross_context
 Context for an additional instruction parse needed to resolve a crossbuild.
 

Detailed Description

A class for walking the constructor tree (ParserContext)

Member Function Documentation

◆ getContextBits()

uintm ghidra::ParserWalker::getContextBits ( int4  startbit,
int4  size 
) const
inline

Get a range of bits from the local context.

Parameters
startbitis the offset of the first bit
sizeis the number of bits to return
Returns
the requested range of bits (in the least significant positions and padded out with zero bits)

References const_context, and ghidra::ParserContext::getContextBits().

◆ getContextBytes()

uintm ghidra::ParserWalker::getContextBytes ( int4  byteoff,
int4  numbytes 
) const
inline

Get packed context bytes from the local context.

Parameters
byteoffis the offset of the first byte to grab
numbytesis the number of bytes to grab
Returns
the context bytes in a packed value

References const_context, and ghidra::ParserContext::getContextBytes().

◆ getInstructionBits()

uintm ghidra::ParserWalker::getInstructionBits ( int4  startbit,
int4  size 
) const
inline

Get bits from the instruction stream associated with the current constructor.

Parameters
startbitis the offset of the first bit (relative to the starting point associated with the constructor)
sizeis the number of bits to grab
Returns
the requested range of bits (in the least significant positions and padded out with zero bits)

References const_context, ghidra::ParserContext::getInstructionBits(), ghidra::ConstructState::offset, and point.

◆ getInstructionBytes()

uintm ghidra::ParserWalker::getInstructionBytes ( int4  byteoff,
int4  numbytes 
) const
inline

Get packed instruction bytes associated with the current constructor.

Parameters
byteoffis an offset from the starting point associated with the constructor
numbytesis the number of bytes to pack
Returns
the packed instruction bytes in big endian encoding

References const_context, ghidra::ParserContext::getInstructionBytes(), ghidra::ConstructState::offset, and point.

◆ pushOperand()

void ghidra::ParserWalker::pushOperand ( int4  i)
inline

Make the indicated child (operand) the current node.

Parameters
iis the index of child/operand

References breadcrumb, depth, ghidra::ParserContext::MAX_DEPTH, point, and ghidra::ConstructState::resolve.

Referenced by ghidra::SleighBuilder::appendBuild(), ghidra::SleighBuilder::buildEmpty(), and ghidra::Sleigh::resolveHandles().

◆ setOutOfBandState()

void ghidra::ParserWalker::setOutOfBandState ( Constructor *  ct,
int4  index,
ConstructState *  tempstate,
const ParserWalker &  otherwalker 
)

Initialize this from another walker assuming a given constructor and operand is the current position in the walk.

The constructor tree state is simulated using only a single provided node. This allows TokenField to behave as if it were just parsed so its getValue() will return the correct value.

Parameters
ctis the given constructor
indexis the index of the operand
tempstateis provided storage used to simulate the mid-walk tree node
otherwalkeris the walker with the complete parse state

References breadcrumb, ghidra::ConstructState::ct, depth, ghidra::ConstructState::length, ghidra::ConstructState::offset, ghidra::ConstructState::parent, point, and ghidra::ConstructState::resolve.


The documentation for this class was generated from the following files: