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

#include <TPEFLineNumSectionReader.hh>

Inheritance diagram for TPEF::TPEFLineNumSectionReader:
Inheritance graph
Collaboration diagram for TPEF::TPEFLineNumSectionReader:
Collaboration graph

Protected Member Functions

 TPEFLineNumSectionReader ()
 
virtual ~TPEFLineNumSectionReader ()
 
virtual void readData (BinaryStream &stream, Section *section) const
 
virtual Section::SectionType type () const
 
virtual void readInfo (BinaryStream &stream, Section *sect) const
 
- Protected Member Functions inherited from TPEF::TPEFSectionReader
 TPEFSectionReader ()
 
virtual BinaryReaderparent () const
 
- Protected Member Functions inherited from TPEF::SectionReader
 SectionReader ()
 
virtual void finalize (Section *section) const
 

Private Member Functions

 TPEFLineNumSectionReader (const TPEFLineNumSectionReader &)
 Copying not allowed.
 
TPEFLineNumSectionReaderoperator= (TPEFLineNumSectionReader &)
 Assignment not allowed.
 

Static Private Attributes

static TPEFLineNumSectionReader proto_
 Prototype instance of TPEFLineNumSectionReader to be registered to SectionReader.
 
static SectionId codeSectionId_ = 0
 Identification code of text section which is referenced from currently read section.
 

Additional Inherited Members

- Public Types inherited from TPEF::SectionReader
typedef BinaryReader::Length Length
 
- Public Member Functions inherited from TPEF::TPEFSectionReader
virtual ~TPEFSectionReader ()
 
- Public Member Functions inherited from TPEF::SectionReader
virtual ~SectionReader ()
 
- Static Public Member Functions inherited from TPEF::SectionReader
static void readSection (BinaryStream &stream, Section *section, BinaryReader *reader)
 
static void finalizeBinary (Binary *binaryToFinalize, BinaryReader *reader)
 
- Static Protected Member Functions inherited from TPEF::TPEFSectionReader
static const Headerheader ()
 
- Static Protected Member Functions inherited from TPEF::SectionReader
static const SectionReaderfindSectionReader (const Section::SectionType type, const BinaryReader *bReader)
 
static void registerSectionReader (const SectionReader *sReader)
 

Detailed Description

Reads line number section from TPEF binary file.

Definition at line 47 of file TPEFLineNumSectionReader.hh.

Constructor & Destructor Documentation

◆ TPEFLineNumSectionReader() [1/2]

TPEF::TPEFLineNumSectionReader::TPEFLineNumSectionReader ( )
protected

Constructor.

Registers itself to SectionReader.

Definition at line 59 of file TPEFLineNumSectionReader.cc.

61}
static void registerSectionReader(const SectionReader *sReader)

References TPEF::SectionReader::registerSectionReader().

Here is the call graph for this function:

◆ ~TPEFLineNumSectionReader()

TPEF::TPEFLineNumSectionReader::~TPEFLineNumSectionReader ( )
protectedvirtual

Destructor.

Definition at line 66 of file TPEFLineNumSectionReader.cc.

66 {
67}

◆ TPEFLineNumSectionReader() [2/2]

TPEF::TPEFLineNumSectionReader::TPEFLineNumSectionReader ( const TPEFLineNumSectionReader )
private

Copying not allowed.

Member Function Documentation

◆ operator=()

TPEFLineNumSectionReader & TPEF::TPEFLineNumSectionReader::operator= ( TPEFLineNumSectionReader )
private

Assignment not allowed.

◆ readData()

void TPEF::TPEFLineNumSectionReader::readData ( BinaryStream stream,
Section section 
) const
protectedvirtual

Reads section data from TPEF binary file.

Parameters
streamStream to be read from.
sectionSection where the information is to be stored.
Exceptions
UnreachableStreamIf reading of section fails.
KeyAlreadyExistsKey was in use when trying to register object.
EndOfFileIf end of file were reached while it shouldn't.
OutOfRangeSome of read value were out of range.
WrongSubclassSome class couldn't do what it was asked for.
UnexpectedValueIf there was unexpected value when reading.

Reimplemented from TPEF::TPEFSectionReader.

Definition at line 92 of file TPEFLineNumSectionReader.cc.

93 {
94 // base classes implementation must be called with these.
95 TPEFSectionReader::readData(stream, section);
96
97 LineNumSection* lineNumSection = dynamic_cast<LineNumSection*>(section);
98 assert(lineNumSection != NULL);
99
100 // check that link section is defined properly
101 assert(header().linkId != 0);
102
103 if (!section->noBits()) {
104 // mark start of first element
105 SectionOffset elementStart = header().bodyOffset;
106
107 LineNumProcedure *procedure = NULL;
108
109 while (elementStart + header().elementSize <=
110 header().bodyOffset + header().bodyLength) {
111
112 Word elementOffset = stream.readWord();
113 HalfWord lineNum = stream.readHalfWord();
114
115 // Let's create new procedure for our line numbers if needed.
116 if (lineNum == 0) {
117 procedure = new LineNumProcedure();
118
119 SectionIndexKey indexKey(header().linkId, elementOffset);
120
121 if (elementOffset != 0) {
122 procedure->setProcedureSymbol(
123 CREATE_SAFEPOINTER(indexKey));
124 }
125
126 section->addElement(procedure);
127
128 } else if (procedure != NULL) {
129 LineNumElement *elem = new LineNumElement();
130
131 // where is section id off data section stored
132 SectionOffsetKey instrKey(codeSectionId_, elementOffset);
133 elem->setInstruction(CREATE_SAFEPOINTER(instrKey));
134 elem->setLineNumber(lineNum);
135
136 // add line to last created procedure
137 procedure->addLine(elem);
138
139 } else {
140 bool sectionShouldNotHaveLineNumbersBeforeProcedure = false;
141 assert(sectionShouldNotHaveLineNumbersBeforeProcedure);
142 }
143
144 elementStart += header().elementSize;
145 stream.setReadPosition(elementStart);
146 }
147 }
148}
#define assert(condition)
static SectionId codeSectionId_
Identification code of text section which is referenced from currently read section.
virtual void readData(BinaryStream &stream, Section *section) const
static const Header & header()
Word SectionOffset
Type for storing offsets relative to a given base offset value.

References TPEF::Section::addElement(), TPEF::LineNumProcedure::addLine(), assert, TPEF::TPEFSectionReader::Header::bodyOffset, codeSectionId_, TPEF::TPEFSectionReader::Header::elementSize, TPEF::TPEFSectionReader::header(), TPEF::Section::noBits(), TPEF::TPEFSectionReader::readData(), TPEF::BinaryStream::readHalfWord(), TPEF::BinaryStream::readWord(), TPEF::LineNumElement::setInstruction(), TPEF::LineNumElement::setLineNumber(), TPEF::LineNumProcedure::setProcedureSymbol(), and TPEF::BinaryStream::setReadPosition().

Here is the call graph for this function:

◆ readInfo()

void TPEF::TPEFLineNumSectionReader::readInfo ( BinaryStream stream,
Section sect 
) const
protectedvirtual

Reads info field of section header, which contains the identification code of the code section to which the line number section applies.

Read position of stream will be moved 4 bytes forward.

Parameters
streamStream where from info word is read.
sectSection whose info field is interpreted.

Reimplemented from TPEF::TPEFSectionReader.

Definition at line 160 of file TPEFLineNumSectionReader.cc.

161 {
162
163 // identification code of referenced section is in first 2 bytes of info
164 // field
165 codeSectionId_ = stream.readHalfWord();
166
167 if (codeSectionId_ != 0) {
168 SectionKey sKey(codeSectionId_);
169 dynamic_cast<LineNumSection*>(sect)->setCodeSection(
170 CREATE_SAFEPOINTER(sKey));
171 } else {
172 dynamic_cast<LineNumSection*>(sect)->setCodeSection(
174 }
175
176 // skip rest 2 of 4 bytes
177 stream.readHalfWord();
178}
static const SafePointer null
The default SafePointer that is used in null references.

References codeSectionId_, TPEF::ReferenceManager::SafePointer::null, and TPEF::BinaryStream::readHalfWord().

Here is the call graph for this function:

◆ type()

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

Returns the type of section it is meant to read.

Returns
The type of section it can read.

Implements TPEF::SectionReader.

Definition at line 75 of file TPEFLineNumSectionReader.cc.

75 {
76 return Section::ST_LINENO;
77}
@ ST_LINENO
Line number section.
Definition Section.hh:75

References TPEF::Section::ST_LINENO.

Member Data Documentation

◆ codeSectionId_

SectionId TPEF::TPEFLineNumSectionReader::codeSectionId_ = 0
staticprivate

Identification code of text section which is referenced from currently read section.

Definition at line 65 of file TPEFLineNumSectionReader.hh.

Referenced by readData(), and readInfo().

◆ proto_

TPEFLineNumSectionReader TPEF::TPEFLineNumSectionReader::proto_
staticprivate

Prototype instance of TPEFLineNumSectionReader to be registered to SectionReader.

Definition at line 61 of file TPEFLineNumSectionReader.hh.


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