decompiler 1.0.0
Public Member Functions | Private Member Functions | List of all members
ConstantPool Class Referenceabstract

An interface to the pool of constant objects for byte-code languages. More...

#include <cpool.hh>

Inheritance diagram for ConstantPool:
ConstantPoolGhidra ConstantPoolInternal

Public Member Functions

virtual ~ConstantPool ()
 Destructor.
 
virtual const CPoolRecordgetRecord (const vector< uintb > &refs) const =0
 Retrieve a constant pool record (CPoolRecord) given a reference to it. More...
 
void putRecord (const vector< uintb > &refs, uint4 tag, const string &tok, Datatype *ct)
 A a new constant pool record to this database. More...
 
const CPoolRecorddecodeRecord (const vector< uintb > &refs, Decoder &decoder, TypeFactory &typegrp)
 Restore a CPoolRecord given a reference and a stream decoder. More...
 
virtual bool empty (void) const =0
 Is the container empty of records. More...
 
virtual void clear (void)=0
 Release any (local) resources. More...
 
virtual void encode (Encoder &encoder) const =0
 Encode all records in this container to a stream. More...
 
virtual void decode (Decoder &decoder, TypeFactory &typegrp)=0
 Restore constant pool records from the given stream decoder. More...
 

Private Member Functions

virtual CPoolRecordcreateRecord (const vector< uintb > &refs)=0
 Allocate a new CPoolRecord object, given a reference to it. More...
 

Detailed Description

An interface to the pool of constant objects for byte-code languages.

This is an abstract base class that acts as a container for CPoolRecords. A reference (1 or more integer constants) maps to an individual CPoolRecord. A CPoolRecord object can be queried for using getRecord(), and a new object can be added with putRecord(). Internally, the actual CPoolRecord object is produced by createRecord().

Member Function Documentation

◆ clear()

virtual void ConstantPool::clear ( void  )
pure virtual

Release any (local) resources.

Implemented in ConstantPoolInternal, and ConstantPoolGhidra.

Referenced by FlushNative::rawAction().

◆ createRecord()

virtual CPoolRecord * ConstantPool::createRecord ( const vector< uintb > &  refs)
privatepure virtual

Allocate a new CPoolRecord object, given a reference to it.

The object will still need to be initialized but is already associated with the reference. Any issue with allocation (like a dupicate reference) causes an exception.

Parameters
refsis the reference of 1 or more identifying integers
Returns
the new CPoolRecord

Implemented in ConstantPoolInternal, and ConstantPoolGhidra.

Referenced by decodeRecord(), and putRecord().

◆ decode()

virtual void ConstantPool::decode ( Decoder decoder,
TypeFactory typegrp 
)
pure virtual

Restore constant pool records from the given stream decoder.

(If supported) The container is populated with CPoolRecords initialized from a <constantpool> element.

Parameters
decoderis the given stream decoder
typegrpis the TypeFactory used to resolve data-type references in the XML

Implemented in ConstantPoolInternal, and ConstantPoolGhidra.

Referenced by Architecture::restoreXml().

◆ decodeRecord()

const CPoolRecord * ConstantPool::decodeRecord ( const vector< uintb > &  refs,
Decoder decoder,
TypeFactory typegrp 
)

Restore a CPoolRecord given a reference and a stream decoder.

A <cpoolrec> element initializes the new record which is immediately associated with the reference.

Parameters
refsis the reference (made up of 1 or more identifying integers)
decoderis the given stream decoder
typegrpis the TypeFactory used to resolve data-type references in XML
Returns
the newly allocated and initialized CPoolRecord

References createRecord(), and CPoolRecord::decode().

Referenced by ConstantPoolGhidra::getRecord().

◆ empty()

virtual bool ConstantPool::empty ( void  ) const
pure virtual

Is the container empty of records.

Implemented in ConstantPoolInternal, and ConstantPoolGhidra.

Referenced by Architecture::encode().

◆ encode()

virtual void ConstantPool::encode ( Encoder encoder) const
pure virtual

Encode all records in this container to a stream.

(If supported) A <constantpool> element is written containing <cpoolrec> child elements for each CPoolRecord in the container.

Parameters
encoderis the stream encoder

Implemented in ConstantPoolInternal, and ConstantPoolGhidra.

Referenced by Architecture::encode().

◆ getRecord()

virtual const CPoolRecord * ConstantPool::getRecord ( const vector< uintb > &  refs) const
pure virtual

Retrieve a constant pool record (CPoolRecord) given a reference to it.

Parameters
refsis the reference (made up of 1 or more identifying integers)
Returns
the matching CPoolRecord or NULL if none matches the reference

Implemented in ConstantPoolInternal, and ConstantPoolGhidra.

Referenced by RuleTransformCpool::applyOp(), TypeOpCpoolref::getOutputLocal(), PrintC::opCpoolRefOp(), PrintJava::opCpoolRefOp(), and TypeOpCpoolref::printRaw().

◆ putRecord()

void ConstantPool::putRecord ( const vector< uintb > &  refs,
uint4  tag,
const string &  tok,
Datatype ct 
)

A a new constant pool record to this database.

Given the basic constituents of the record, type, name, and data-type, create a new CPoolRecord object and associate it with the given reference.

Parameters
refsis the reference (made up of 1 or more identifying integers)
tagis the type of record to create
tokis the name associated with the object
ctis the data-type associated with the object

References createRecord(), CPoolRecord::tag, CPoolRecord::token, and CPoolRecord::type.


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