decompiler 1.0.0
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
ConstantPoolInternal Class Reference

An implementation of the ConstantPool interface storing records internally in RAM. More...

#include <cpool.hh>

Inheritance diagram for ConstantPoolInternal:
ConstantPool

Classes

class  CheapSorter
 A cheap (efficient) placeholder for a reference to a constant pool record. More...
 

Public Member Functions

virtual const CPoolRecordgetRecord (const vector< uintb > &refs) const
 Retrieve a constant pool record (CPoolRecord) given a reference to it. More...
 
virtual bool empty (void) const
 Is the container empty of records. More...
 
virtual void clear (void)
 Release any (local) resources. More...
 
virtual void encode (Encoder &encoder) const
 Encode all records in this container to a stream. More...
 
virtual void decode (Decoder &decoder, TypeFactory &typegrp)
 Restore constant pool records from the given stream decoder. More...
 
- Public Member Functions inherited from ConstantPool
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)
 Allocate a new CPoolRecord object, given a reference to it. More...
 

Private Attributes

map< CheapSorter, CPoolRecordcpoolMap
 A map from reference to constant pool record.
 

Detailed Description

An implementation of the ConstantPool interface storing records internally in RAM.

The CPoolRecord objects are held directly in a map container. This class can be used as a stand-alone ConstantPool that holds all its records in RAM. Or, it can act as a local CPoolRecord cache for some other implementation.

Member Function Documentation

◆ clear()

virtual void ConstantPoolInternal::clear ( void  )
inlinevirtual

Release any (local) resources.

Implements ConstantPool.

References cpoolMap.

Referenced by ConstantPoolGhidra::clear().

◆ createRecord()

CPoolRecord * ConstantPoolInternal::createRecord ( const vector< uintb > &  refs)
privatevirtual

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

Implements ConstantPool.

References cpoolMap.

Referenced by decode().

◆ decode()

void ConstantPoolInternal::decode ( Decoder decoder,
TypeFactory typegrp 
)
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

Implements ConstantPool.

References ConstantPoolInternal::CheapSorter::apply(), Decoder::closeElement(), createRecord(), ConstantPoolInternal::CheapSorter::decode(), CPoolRecord::decode(), ELEM_CONSTANTPOOL, Decoder::openElement(), and Decoder::peekElement().

◆ empty()

virtual bool ConstantPoolInternal::empty ( void  ) const
inlinevirtual

Is the container empty of records.

Implements ConstantPool.

References cpoolMap.

◆ encode()

void ConstantPoolInternal::encode ( Encoder encoder) const
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

Implements ConstantPool.

References Encoder::closeElement(), cpoolMap, ELEM_CONSTANTPOOL, and Encoder::openElement().

◆ getRecord()

const CPoolRecord * ConstantPoolInternal::getRecord ( const vector< uintb > &  refs) const
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

Implements ConstantPool.

References cpoolMap.

Referenced by ConstantPoolGhidra::getRecord().


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