decompiler
1.0.0
|
A description of a byte-code object referenced by a constant. More...
#include <cpool.hh>
Public Types | |
enum | { primitive =0, string_literal =1, class_reference =2, pointer_method =3, pointer_field =4, array_length =5, instance_of =6, check_cast =7 } |
Generic constant pool tag types. More... | |
enum | { is_constructor = 0x1, is_destructor = 0x2 } |
Public Member Functions | |
CPoolRecord (void) | |
Construct an empty record. | |
~CPoolRecord (void) | |
Destructor. | |
uint4 | getTag (void) const |
Get the type of record. | |
const string & | getToken (void) const |
Get name of method or data-type. | |
const uint1 * | getByteData (void) const |
Get pointer to string literal data. | |
int4 | getByteDataLength (void) const |
Number of bytes of string literal data. | |
Datatype * | getType (void) const |
Get the data-type associated with this. | |
uintb | getValue (void) const |
Get the constant value associated with this. | |
bool | isConstructor (void) const |
Is object a constructor method. | |
bool | isDestructor (void) const |
Is object a destructor method. | |
void | encode (Encoder &encoder) const |
Encode this to a stream. More... | |
void | decode (Decoder &decoder, TypeFactory &typegrp) |
Decode this from a stream. More... | |
Private Attributes | |
uint4 | tag |
Descriptor of type of the object. | |
uint4 | flags |
Additional boolean properties on the record. | |
string | token |
Name or token associated with the object. | |
uintb | value |
Constant value of the object (if known) | |
Datatype * | type |
Data-type associated with the object. | |
uint1 * | byteData |
For string literals, the raw byte data of the string. | |
int4 | byteDataLen |
The number of bytes in the data for a string literal. | |
Friends | |
class | ConstantPool |
A description of a byte-code object referenced by a constant.
Byte-code languages can make use of objects that the system knows about but which aren't fully embedded in the encoding of instructions that use them. Instead the instruction refers to the object via a special encoded reference. This class describes one object described by such a reference. In order to provide a concrete interpretation of the instruction (i.e. a p-code translation), these objects generally resolve to some sort of constant value (hence the term constant pool). The type of constant goes to the formal CPoolRecord tag field which can be a:
For decompilation, knowing the actual constant a byte-code interpreter would need is secondary to knowing what object is being referenced. So the CPoolRecord can hold a constant value, but generally it provides a data-type associated with the object and a symbol name or other string token naming the object.
anonymous enum |
Generic constant pool tag types.
anonymous enum |
void ghidra::CPoolRecord::decode | ( | Decoder & | decoder, |
TypeFactory & | typegrp | ||
) |
Decode this from a stream.
Initialize this CPoolRecord instance from a <cpoolrec> element.
decoder | is the stream decoder |
typegrp | is the TypeFactory used to resolve data-types |
References array_length, byteData, byteDataLen, check_cast, class_reference, ghidra::Decoder::closeElement(), ghidra::TypeFactory::decodeType(), ghidra::TypeFactory::decodeTypeWithCodeFlags(), flags, ghidra::Decoder::getNextAttributeId(), instance_of, is_constructor, is_destructor, isConstructor(), isDestructor(), ghidra::Decoder::openElement(), pointer_field, pointer_method, primitive, ghidra::Decoder::readBool(), ghidra::Decoder::readSignedInteger(), ghidra::Decoder::readString(), ghidra::Decoder::readUnsignedInteger(), string_literal, tag, token, type, and value.
Referenced by ghidra::ConstantPoolInternal::CheapSorter::apply(), ghidra::ConstantPoolInternal::clear(), ghidra::ConstantPoolInternal::decode(), ghidra::ConstantPool::decodeRecord(), isDestructor(), and ghidra::ConstantPool::~ConstantPool().
void ghidra::CPoolRecord::encode | ( | Encoder & | encoder | ) | const |
Encode this to a stream.
Encode the constant pool object description as a <cpoolrec> element.
encoder | is the stream encoder |
References array_length, byteData, byteDataLen, check_cast, class_reference, ghidra::Encoder::closeElement(), ghidra::Datatype::encode(), instance_of, isConstructor(), isDestructor(), ghidra::Encoder::openElement(), pointer_field, pointer_method, primitive, string_literal, tag, token, type, value, ghidra::Encoder::writeBool(), ghidra::Encoder::writeSignedInteger(), ghidra::Encoder::writeString(), and ghidra::Encoder::writeUnsignedInteger().
Referenced by ghidra::ConstantPoolInternal::CheapSorter::apply(), ghidra::ConstantPoolInternal::clear(), isDestructor(), and ghidra::ConstantPool::~ConstantPool().