OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
TPEF::SectionIndexReplacer Class Reference

#include <SectionIndexReplacer.hh>

Inheritance diagram for TPEF::SectionIndexReplacer:
Inheritance graph
Collaboration diagram for TPEF::SectionIndexReplacer:
Collaboration graph

Public Member Functions

 SectionIndexReplacer (const SafePointable *obj, Byte fieldSize)
 
virtual ~SectionIndexReplacer ()
 
- Public Member Functions inherited from TPEF::ValueReplacer
void resolve ()
 

Protected Member Functions

virtual bool tryToReplace ()
 
virtual ValueReplacerclone ()
 
- Protected Member Functions inherited from TPEF::ValueReplacer
 ValueReplacer (const SafePointable *obj)
 
 ValueReplacer (const ValueReplacer &replacer)
 
virtual ~ValueReplacer ()
 
const SafePointablereference () const
 
unsigned int streamPosition () const
 

Private Member Functions

 SectionIndexReplacer (const SectionIndexReplacer &replacer)
 
SectionIndexReplacer operator= (const SectionIndexReplacer &)
 
void writeReplacement (Word value)
 

Private Attributes

const Byte fieldSize_
 Field how many bytes of stream are replaced with section index.
 

Additional Inherited Members

- Static Public Member Functions inherited from TPEF::ValueReplacer
static void finalize ()
 
static void initialize (BinaryStream &stream)
 
- Static Protected Member Functions inherited from TPEF::ValueReplacer
static BinaryStreamstream ()
 

Detailed Description

Replaces object reference with section index. Section index key must be stored in reference manager for that object whose section index is written.

Definition at line 48 of file SectionIndexReplacer.hh.

Constructor & Destructor Documentation

◆ SectionIndexReplacer() [1/2]

TPEF::SectionIndexReplacer::SectionIndexReplacer ( const SafePointable obj,
Byte  size 
)

Constructor.

Definition at line 46 of file SectionIndexReplacer.cc.

47 :
48 ValueReplacer(obj), fieldSize_(size) {
49}
const Byte fieldSize_
Field how many bytes of stream are replaced with section index.
ValueReplacer(const SafePointable *obj)

◆ ~SectionIndexReplacer()

TPEF::SectionIndexReplacer::~SectionIndexReplacer ( )
virtual

Destructor.

Definition at line 62 of file SectionIndexReplacer.cc.

62 {
63}

◆ SectionIndexReplacer() [2/2]

TPEF::SectionIndexReplacer::SectionIndexReplacer ( const SectionIndexReplacer replacer)
private

Copy constructor.

Definition at line 54 of file SectionIndexReplacer.cc.

55 :
56 ValueReplacer(replacer), fieldSize_(replacer.fieldSize_) {
57}

Member Function Documentation

◆ clone()

ValueReplacer * TPEF::SectionIndexReplacer::clone ( )
protectedvirtual

Creates dynamically allocated copy of replacer.

Returns
Dynamically allocated copy of replacer.

Implements TPEF::ValueReplacer.

Definition at line 92 of file SectionIndexReplacer.cc.

92 {
93 return new SectionIndexReplacer(*this);
94}
SectionIndexReplacer(const SafePointable *obj, Byte fieldSize)

◆ operator=()

SectionIndexReplacer TPEF::SectionIndexReplacer::operator= ( const SectionIndexReplacer )
private

◆ tryToReplace()

bool TPEF::SectionIndexReplacer::tryToReplace ( )
protectedvirtual

Tries to do replacement in to the stream.

Returns
True if replacement were done.

Implements TPEF::ValueReplacer.

Definition at line 71 of file SectionIndexReplacer.cc.

71 {
72 try {
73 SectionIndexKey key =
75
77 writeReplacement(key.index());
78 return true;
79
80 } catch (KeyNotFound& e) {
82 return false;
83 }
84}
void setWritePosition(unsigned int position)
static SectionIndexKey sectionIndexKeyFor(const SafePointable *obj)
static BinaryStream & stream()
unsigned int streamPosition() const
const SafePointable * reference() const

References TPEF::ReferenceManager::SectionIndexKey::index(), TPEF::ValueReplacer::reference(), TPEF::ReferenceManager::SafePointer::sectionIndexKeyFor(), TPEF::BinaryStream::setWritePosition(), TPEF::ValueReplacer::stream(), TPEF::ValueReplacer::streamPosition(), and writeReplacement().

Here is the call graph for this function:

◆ writeReplacement()

void TPEF::SectionIndexReplacer::writeReplacement ( Word  value)
private

Writes value with one, two or four bytes wide.

Parameters
valueValue to be written.

Definition at line 102 of file SectionIndexReplacer.cc.

102 {
103 switch (fieldSize_) {
104 case 1: {
105 stream().writeByte(value);
106 break;
107 }
108 case 2: {
109 stream().writeHalfWord(value);
110 break;
111 }
112 case 3: {
113 Byte firstByte = (value >> HALFWORD_BITWIDTH);
114 HalfWord lastBytes = (value << HALFWORD_BITWIDTH)
116
117 // writing three bytes in big endian format
118 stream().writeHalfWord(lastBytes);
119 stream().writeByte(firstByte);
120 break;
121 }
122 case 4: {
123 stream().writeWord(value);
124 break;
125 }
126 default:
127 bool unsupportedFieldSizeOfReplacement = false;
128 assert(unsupportedFieldSizeOfReplacement);
129 }
130}
#define assert(condition)
const Byte HALFWORD_BITWIDTH
Definition BaseType.hh:137
unsigned char Byte
Definition BaseType.hh:116
void writeByte(Byte byte)
void writeHalfWord(HalfWord halfword)
void writeWord(Word word)

References assert, fieldSize_, HALFWORD_BITWIDTH, TPEF::ValueReplacer::stream(), TPEF::BinaryStream::writeByte(), TPEF::BinaryStream::writeHalfWord(), and TPEF::BinaryStream::writeWord().

Referenced by tryToReplace().

Here is the call graph for this function:

Member Data Documentation

◆ fieldSize_

const Byte TPEF::SectionIndexReplacer::fieldSize_
private

Field how many bytes of stream are replaced with section index.

Definition at line 65 of file SectionIndexReplacer.hh.

Referenced by writeReplacement().


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