Package ghidra.program.model.pcode
Class PackedEncode
java.lang.Object
ghidra.program.model.pcode.PackedEncode
- All Implemented Interfaces:
Encoder
- Direct Known Subclasses:
PatchPackedEncode
A byte-based encoder designed to marshal to the decompiler efficiently
See
PackedDecode
for details of the encoding format-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
closeElement
(ElementId elemId) End the current element in the encoding The current element must match the given annotation or an exception is thrown.void
openElement
(ElementId elemId) Begin a new element in the encoding The element will have the given ElementId annotation and becomes the \e current element.void
writeBool
(AttributeId attribId, boolean val) Write an annotated boolean value into the encoding The boolean data is associated with the given AttributeId annotation and the current open element.protected void
writeHeader
(int header, int id) protected void
writeInteger
(int typeByte, long val) void
writeOpcode
(AttributeId attribId, int opcode) Write a p-code operation opcode into the encoding, associating it with the given annotation.void
writeSignedInteger
(AttributeId attribId, long val) Write an annotated signed integer value into the encoding The integer is associated with the given AttributeId annotation and the current open element.void
writeSpace
(AttributeId attribId, int index, String name) Write an address space reference into the encoding.void
writeSpace
(AttributeId attribId, AddressSpace spc) Write an address space reference into the encoding The address space is associated with the given AttributeId annotation and the current open element.void
writeString
(AttributeId attribId, String val) Write an annotated string into the encoding The string is associated with the given AttributeId annotation and the current open element.void
writeStringIndexed
(AttributeId attribId, int index, String val) Write an annotated string, using an indexed attribute, into the encoding.void
writeUnsignedInteger
(AttributeId attribId, long val) Write an annotated unsigned integer value into the encoding The integer is associated with the given AttributeId annotation and the current open element.
-
Field Details
-
outStream
-
-
Constructor Details
-
PackedEncode
public PackedEncode() -
PackedEncode
-
-
Method Details
-
writeHeader
- Throws:
IOException
-
writeInteger
- Throws:
IOException
-
openElement
Description copied from interface:Encoder
Begin a new element in the encoding The element will have the given ElementId annotation and becomes the \e current element.- Specified by:
openElement
in interfaceEncoder
- Parameters:
elemId
- is the given ElementId annotation- Throws:
IOException
- for errors in the underlying stream
-
closeElement
Description copied from interface:Encoder
End the current element in the encoding The current element must match the given annotation or an exception is thrown.- Specified by:
closeElement
in interfaceEncoder
- Parameters:
elemId
- is the given (expected) annotation for the current element- Throws:
IOException
- for errors in the underlying stream
-
writeBool
Description copied from interface:Encoder
Write an annotated boolean value into the encoding The boolean data is associated with the given AttributeId annotation and the current open element.- Specified by:
writeBool
in interfaceEncoder
- Parameters:
attribId
- is the given AttributeId annotationval
- is boolean value to encode- Throws:
IOException
- for errors in the underlying stream
-
writeSignedInteger
Description copied from interface:Encoder
Write an annotated signed integer value into the encoding The integer is associated with the given AttributeId annotation and the current open element.- Specified by:
writeSignedInteger
in interfaceEncoder
- Parameters:
attribId
- is the given AttributeId annotationval
- is the signed integer value to encode- Throws:
IOException
- for errors in the underlying stream
-
writeUnsignedInteger
Description copied from interface:Encoder
Write an annotated unsigned integer value into the encoding The integer is associated with the given AttributeId annotation and the current open element.- Specified by:
writeUnsignedInteger
in interfaceEncoder
- Parameters:
attribId
- is the given AttributeId annotationval
- is the unsigned integer value to encode- Throws:
IOException
- for errors in the underlying stream
-
writeString
Description copied from interface:Encoder
Write an annotated string into the encoding The string is associated with the given AttributeId annotation and the current open element.- Specified by:
writeString
in interfaceEncoder
- Parameters:
attribId
- is the given AttributeId annotationval
- is the string to encode- Throws:
IOException
- for errors in the underlying stream
-
writeStringIndexed
Description copied from interface:Encoder
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.- Specified by:
writeStringIndexed
in interfaceEncoder
- Parameters:
attribId
- is the shared AttributeIdindex
- is the unique index to associated with the stringval
- is the string to encode- Throws:
IOException
- for errors in the underlying stream
-
writeSpace
Description copied from interface:Encoder
Write an address space reference into the encoding The address space is associated with the given AttributeId annotation and the current open element.- Specified by:
writeSpace
in interfaceEncoder
- Parameters:
attribId
- is the given AttributeId annotationspc
- is the address space to encode- Throws:
IOException
- for errors in the underlying stream
-
writeSpace
Description copied from interface:Encoder
Write an address space reference into the encoding. An address space identified by its name and unique index is associated with the given annotation and the current open element.- Specified by:
writeSpace
in interfaceEncoder
- Parameters:
attribId
- is the given annotationindex
- is the unique index of the address spacename
- is the name of the address space- Throws:
IOException
- for errors in the underlying stream
-
writeOpcode
Description copied from interface:Encoder
Write a p-code operation opcode into the encoding, associating it with the given annotation. The opcode is specified based on the constants defined inPcodeOp
.- Specified by:
writeOpcode
in interfaceEncoder
- Parameters:
attribId
- is the given annotationopcode
- is the opcode constant- Throws:
IOException
- for errors in the underlying stream
-
getOutputStream
- Returns:
- the underlying stream
-