OpenASIP  2.0
Protected Member Functions | Private Member Functions | Static Private Attributes | List of all members
TPEF::TPEFLineNumSectionWriter Class Reference

#include <TPEFLineNumSectionWriter.hh>

Inheritance diagram for TPEF::TPEFLineNumSectionWriter:
Inheritance graph
Collaboration diagram for TPEF::TPEFLineNumSectionWriter:
Collaboration graph

Protected Member Functions

 TPEFLineNumSectionWriter ()
 
virtual ~TPEFLineNumSectionWriter ()
 
virtual Section::SectionType type () const
 
virtual void actualWriteData (BinaryStream &stream, const Section *section) const
 
virtual Word elementSize (const Section *section) const
 
virtual void writeInfo (BinaryStream &stream, const Section *sect) const
 
- Protected Member Functions inherited from TPEF::TPEFSectionWriter
 TPEFSectionWriter ()
 
virtual ~TPEFSectionWriter ()
 
virtual const BinaryWriterparent () const
 
virtual void actualWriteHeader (BinaryStream &stream, const Section *sect) const
 
virtual void createKeys (const Section *sect) const
 
virtual void writeSize (BinaryStream &stream, const Section *sect) const
 
virtual SectionId getSectionId () const
 
- Protected Member Functions inherited from TPEF::SectionWriter
 SectionWriter ()
 
virtual ~SectionWriter ()
 
virtual void finalize (BinaryStream &stream, Section *section) const
 

Private Member Functions

 TPEFLineNumSectionWriter (const TPEFLineNumSectionWriter &)
 Copying not allowed. More...
 
TPEFLineNumSectionWriter operator= (const TPEFLineNumSectionWriter &)
 Assignment not allowed. More...
 

Static Private Attributes

static const TPEFLineNumSectionWriter instance_
 An unique instance of class. More...
 
static const Word elementSize_ = 6
 The fixed size address space element. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from TPEF::SectionWriter
static void writeHeader (BinaryStream &stream, const Section *sect, const BinaryWriter *writer)
 
static void writeData (BinaryStream &stream, const Section *sect, const BinaryWriter *writer)
 
static void finalizeBinary (BinaryStream &stream, const Binary *binaryToFinalize, const BinaryWriter *writer)
 
- Static Protected Member Functions inherited from TPEF::SectionWriter
static void registerSectionWriter (const SectionWriter *sWriter)
 
static SectionId getUniqueSectionId ()
 

Detailed Description

Writes TPEF line number section to stream.

Definition at line 46 of file TPEFLineNumSectionWriter.hh.

Constructor & Destructor Documentation

◆ TPEFLineNumSectionWriter() [1/2]

TPEF::TPEFLineNumSectionWriter::TPEFLineNumSectionWriter ( )
protected

Constructor.

Registers itself to SectionWriter.

Definition at line 66 of file TPEFLineNumSectionWriter.cc.

66  : TPEFSectionWriter() {
68 }

References TPEF::SectionWriter::registerSectionWriter().

Here is the call graph for this function:

◆ ~TPEFLineNumSectionWriter()

TPEF::TPEFLineNumSectionWriter::~TPEFLineNumSectionWriter ( )
protectedvirtual

Destructor.

Definition at line 73 of file TPEFLineNumSectionWriter.cc.

73  {
74 }

◆ TPEFLineNumSectionWriter() [2/2]

TPEF::TPEFLineNumSectionWriter::TPEFLineNumSectionWriter ( const TPEFLineNumSectionWriter )
private

Copying not allowed.

Member Function Documentation

◆ actualWriteData()

void TPEF::TPEFLineNumSectionWriter::actualWriteData ( BinaryStream stream,
const Section sect 
) const
protectedvirtual

Writes the data of the section in to stream.

Parameters
streamThe stream to be written to.
sectThe section to be written.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 93 of file TPEFLineNumSectionWriter.cc.

95  {
96 
97  FileOffset startOffset = stream.writePosition();
98  // file offset to data of section
100  FileOffsetKey(startOffset), sect->element(0));
101 
102  for (Word i = 0; i < sect->elementCount(); i++) {
103  LineNumProcedure* elem =
104  dynamic_cast<LineNumProcedure*>(sect->element(i));
105  assert(elem != NULL);
106 
107  if (elem->procedureSymbol() != NULL) {
108  SectionIndexReplacer
109  replacer(elem->procedureSymbol(), sizeof(Word));
110  replacer.resolve();
111  } else {
112  bool procedureSymbolMustBeSet = false;
113  assert(procedureSymbolMustBeSet);
114  }
115 
116  // line number zero represents procedure
117  stream.writeHalfWord(0);
118 
119  // write line nums...
120  for(Word lineIndex = 0; lineIndex < elem->lineCount(); lineIndex++) {
121 
122  const LineNumElement* lineElem = elem->line(lineIndex);
123 
124  // write each line
125  SectionOffsetReplacer replacer(lineElem->instruction());
126  replacer.resolve();
127  stream.writeHalfWord(lineElem->lineNumber());
128  }
129  }
130  SectionSizeReplacer::setSize(sect, stream.writePosition() - startOffset);
131 }

References TPEF::ReferenceManager::SafePointer::addObjectReference(), assert, TPEF::Section::element(), TPEF::Section::elementCount(), TPEF::LineNumElement::instruction(), TPEF::LineNumProcedure::line(), TPEF::LineNumProcedure::lineCount(), TPEF::LineNumElement::lineNumber(), TPEF::LineNumProcedure::procedureSymbol(), TPEF::ValueReplacer::resolve(), TPEF::SectionSizeReplacer::setSize(), TPEF::BinaryStream::writeHalfWord(), and TPEF::BinaryStream::writePosition().

Here is the call graph for this function:

◆ elementSize()

Word TPEF::TPEFLineNumSectionWriter::elementSize ( const Section section) const
protectedvirtual

Returns the fixed size length of section elements.

Returns
The fixed size length of section elements.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 139 of file TPEFLineNumSectionWriter.cc.

139  {
140  return elementSize_;
141 }

References elementSize_.

◆ operator=()

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

Assignment not allowed.

◆ type()

Section::SectionType TPEF::TPEFLineNumSectionWriter::type ( ) const
protectedvirtual

Returns the section type this writer can write.

Returns
The section type writer can write.

Implements TPEF::TPEFSectionWriter.

Definition at line 82 of file TPEFLineNumSectionWriter.cc.

82  {
83  return Section::ST_LINENO;
84 }

References TPEF::Section::ST_LINENO.

◆ writeInfo()

void TPEF::TPEFLineNumSectionWriter::writeInfo ( BinaryStream stream,
const Section sect 
) const
protectedvirtual

Writes Info field of section header.

Parameters
streamThe stream where to write.
sectSection to write.

Reimplemented from TPEF::TPEFSectionWriter.

Definition at line 150 of file TPEFLineNumSectionWriter.cc.

151  {
152 
153  const Section* codeSection =
154  dynamic_cast<const LineNumSection*>(sect)->codeSection();
155 
156  SectionIdReplacer idReplacer(codeSection);
157  idReplacer.resolve();
158 
159  stream.writeHalfWord(0);
160 }

References TPEF::ValueReplacer::resolve(), and TPEF::BinaryStream::writeHalfWord().

Here is the call graph for this function:

Member Data Documentation

◆ elementSize_

const Word TPEF::TPEFLineNumSectionWriter::elementSize_ = 6
staticprivate

The fixed size address space element.

Definition at line 70 of file TPEFLineNumSectionWriter.hh.

Referenced by elementSize().

◆ instance_

const TPEFLineNumSectionWriter TPEF::TPEFLineNumSectionWriter::instance_
staticprivate

An unique instance of class.

Definition at line 68 of file TPEFLineNumSectionWriter.hh.


The documentation for this class was generated from the following files:
TPEF::ReferenceManager::SafePointer::addObjectReference
static void addObjectReference(SectionIndexKey key, const SafePointable *obj)
Definition: SafePointer.cc:306
assert
#define assert(condition)
Definition: Application.hh:86
TPEF::SectionWriter::registerSectionWriter
static void registerSectionWriter(const SectionWriter *sWriter)
Definition: SectionWriter.cc:148
TPEF::FileOffset
Word FileOffset
Type for storing absolute file offsets.
Definition: TPEFBaseType.hh:52
TPEF::TPEFLineNumSectionWriter::elementSize_
static const Word elementSize_
The fixed size address space element.
Definition: TPEFLineNumSectionWriter.hh:70
TPEF::Section::ST_LINENO
@ ST_LINENO
Line number section.
Definition: Section.hh:75
TPEF::SectionSizeReplacer::setSize
static void setSize(const SafePointable *obj, Word size)
Definition: SectionSizeReplacer.cc:100
TPEF::TPEFSectionWriter::TPEFSectionWriter
TPEFSectionWriter()
Definition: TPEFSectionWriter.cc:63