decompiler
1.0.0
|
A byte-based encoder designed to marshal from the decompiler efficiently. More...
#include <marshal.hh>
Public Member Functions | |
PackedEncode (ostream &s) | |
Construct from a stream. | |
virtual void | openElement (const ElementId &elemId) |
Begin a new element in the encoding. More... | |
virtual void | closeElement (const ElementId &elemId) |
End the current element in the encoding. More... | |
virtual void | writeBool (const AttributeId &attribId, bool val) |
Write an annotated boolean value into the encoding. More... | |
virtual void | writeSignedInteger (const AttributeId &attribId, intb val) |
Write an annotated signed integer value into the encoding. More... | |
virtual void | writeUnsignedInteger (const AttributeId &attribId, uintb val) |
Write an annotated unsigned integer value into the encoding. More... | |
virtual void | writeString (const AttributeId &attribId, const string &val) |
Write an annotated string into the encoding. More... | |
virtual void | writeStringIndexed (const AttributeId &attribId, uint4 index, const string &val) |
Write an annotated string, using an indexed attribute, into the encoding. More... | |
virtual void | writeSpace (const AttributeId &attribId, const AddrSpace *spc) |
Write an address space reference into the encoding. More... | |
Public Member Functions inherited from ghidra::Encoder | |
virtual | ~Encoder (void) |
Destructor. | |
Private Member Functions | |
void | writeHeader (uint1 header, uint4 id) |
Write a header, element or attribute, to stream. More... | |
void | writeInteger (uint1 typeByte, uint8 val) |
Write an integer value to the stream. More... | |
Private Attributes | |
ostream & | outStream |
The stream receiving the encoded data. | |
A byte-based encoder designed to marshal from the decompiler efficiently.
See PackedDecode for details of the encoding format.
|
virtual |
End the current element in the encoding.
The current element must match the given annotation or an exception is thrown.
elemId | is the given (expected) annotation for the current element |
Implements ghidra::Encoder.
Referenced by ghidra::ArchitectureGhidra::getBytes(), ghidra::ArchitectureGhidra::getCodeLabel(), ghidra::ArchitectureGhidra::getComments(), ghidra::ArchitectureGhidra::getCPoolRef(), ghidra::ArchitectureGhidra::getDataType(), ghidra::ArchitectureGhidra::getExternalRef(), ghidra::ArchitectureGhidra::getMappedSymbolsXML(), ghidra::ArchitectureGhidra::getNamespacePath(), ghidra::ArchitectureGhidra::getPcode(), ghidra::ArchitectureGhidra::getPcodeInject(), ghidra::ArchitectureGhidra::getRegister(), ghidra::ArchitectureGhidra::getRegisterName(), ghidra::ArchitectureGhidra::getStringData(), ghidra::ArchitectureGhidra::getTrackedRegisters(), ghidra::ArchitectureGhidra::getUserOpName(), ghidra::ArchitectureGhidra::isNameUsed(), and ghidra::DecompileAt::rawAction().
|
virtual |
Begin a new element in the encoding.
The element will have the given ElementId annotation and becomes the current element.
elemId | is the given ElementId annotation |
Implements ghidra::Encoder.
Referenced by ghidra::ArchitectureGhidra::getBytes(), ghidra::ArchitectureGhidra::getCodeLabel(), ghidra::ArchitectureGhidra::getComments(), ghidra::ArchitectureGhidra::getCPoolRef(), ghidra::ArchitectureGhidra::getDataType(), ghidra::ArchitectureGhidra::getExternalRef(), ghidra::ArchitectureGhidra::getMappedSymbolsXML(), ghidra::ArchitectureGhidra::getNamespacePath(), ghidra::ArchitectureGhidra::getPcode(), ghidra::ArchitectureGhidra::getPcodeInject(), ghidra::ArchitectureGhidra::getRegister(), ghidra::ArchitectureGhidra::getRegisterName(), ghidra::ArchitectureGhidra::getStringData(), ghidra::ArchitectureGhidra::getTrackedRegisters(), ghidra::ArchitectureGhidra::getUserOpName(), ghidra::ArchitectureGhidra::isNameUsed(), and ghidra::DecompileAt::rawAction().
|
virtual |
Write an annotated boolean value into the encoding.
The boolean data is associated with the given AttributeId annotation and the current open element.
attribId | is the given AttributeId annotation |
val | is boolean value to encode |
Implements ghidra::Encoder.
|
inlineprivate |
Write a header, element or attribute, to stream.
header | is the type of header |
id | is the id associated with the element or attribute |
References ghidra::PackedFormat::HEADEREXTEND_MASK, ghidra::AttributeId::id, ghidra::PackedFormat::RAWDATA_BITSPERBYTE, ghidra::PackedFormat::RAWDATA_MARKER, and ghidra::PackedFormat::RAWDATA_MASK.
|
private |
Write an integer value to the stream.
The value is either an unsigned integer, an address space index, or (the absolute value of) a signed integer. A type header is passed in with the particular type code for the value already filled in. This method then fills in the length code, outputs the full type header and the encoded bytes of the integer.
typeByte | is the type header |
val | is the integer value |
|
virtual |
Write an annotated signed integer value into the encoding.
The integer is associated with the given AttributeId annotation and the current open element.
attribId | is the given AttributeId annotation |
val | is the signed integer value to encode |
Implements ghidra::Encoder.
Referenced by ghidra::ArchitectureGhidra::getCPoolRef(), ghidra::ArchitectureGhidra::getDataType(), ghidra::ArchitectureGhidra::getStringData(), and ghidra::ArchitectureGhidra::getUserOpName().
|
virtual |
Write an address space reference into the encoding.
The address space is associated with the given AttributeId annotation and the current open element.
attribId | is the given AttributeId annotation |
spc | is the address space to encode |
Implements ghidra::Encoder.
|
virtual |
Write an annotated string into the encoding.
The string is associated with the given AttributeId annotation and the current open element.
attribId | is the given AttributeId annotation |
val | is the string to encode |
Implements ghidra::Encoder.
Referenced by ghidra::ArchitectureGhidra::getDataType(), ghidra::ArchitectureGhidra::getPcodeInject(), ghidra::ArchitectureGhidra::getRegister(), ghidra::ArchitectureGhidra::getStringData(), and ghidra::ArchitectureGhidra::isNameUsed().
|
virtual |
Write an annotated string, using an indexed attribute, into the encoding.
Multiple attributes with a shared name can be written to the same element by calling this method multiple times with a different index value. The encoding will use attribute ids up to the base id plus the maximum index passed in. Implementors must be careful to not use other attributes with ids bigger than the base id within the element taking the indexed attribute.
attribId | is the shared AttributeId |
index | is the unique index to associated with the string |
val | is the string to encode |
Implements ghidra::Encoder.
|
virtual |
Write an annotated unsigned integer value into the encoding.
The integer is associated with the given AttributeId annotation and the current open element.
attribId | is the given AttributeId annotation |
val | is the unsigned integer value to encode |
Implements ghidra::Encoder.
Referenced by ghidra::ArchitectureGhidra::getComments(), ghidra::ArchitectureGhidra::getCPoolRef(), ghidra::ArchitectureGhidra::getNamespacePath(), ghidra::ArchitectureGhidra::getStringData(), and ghidra::ArchitectureGhidra::isNameUsed().