OpenASIP
2.0
src
base
tpef
SectionIdReplacer.cc
Go to the documentation of this file.
1
/*
2
Copyright (c) 2002-2009 Tampere University.
3
4
This file is part of TTA-Based Codesign Environment (TCE).
5
6
Permission is hereby granted, free of charge, to any person obtaining a
7
copy of this software and associated documentation files (the "Software"),
8
to deal in the Software without restriction, including without limitation
9
the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
and/or sell copies of the Software, and to permit persons to whom the
11
Software is furnished to do so, subject to the following conditions:
12
13
The above copyright notice and this permission notice shall be included in
14
all copies or substantial portions of the Software.
15
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22
DEALINGS IN THE SOFTWARE.
23
*/
24
/**
25
* @file SectionIdReplacer.cc
26
*
27
* Definition of SectionIdReplacer class.
28
*
29
* @author Mikael Lepistö 2003 (tmlepist-no.spam-cs.tut.fi)
30
*
31
* @note rating: yellow
32
*/
33
34
#include "
SectionIdReplacer.hh
"
35
#include "
SafePointer.hh
"
36
#include "
BinaryStream.hh
"
37
38
namespace
TPEF
{
39
40
using
ReferenceManager::SafePointer;
41
using
ReferenceManager::SectionKey;
42
43
/**
44
* Constructor.
45
*/
46
SectionIdReplacer::SectionIdReplacer
(
const
SafePointable
* obj) :
47
ValueReplacer
(obj) {
48
}
49
50
/**
51
* Copy constructor.
52
*/
53
SectionIdReplacer::SectionIdReplacer
(
const
SectionIdReplacer
& replacer) :
54
ValueReplacer
(replacer) {
55
}
56
57
/**
58
* Destructor.
59
*/
60
SectionIdReplacer::~SectionIdReplacer
() {
61
}
62
63
/**
64
* Tries to do replacement in to the stream.
65
*
66
* @return True if replacement were done.
67
*/
68
bool
69
SectionIdReplacer::tryToReplace
() {
70
try
{
71
SectionKey
key =
72
SafePointer::sectionKeyFor
(
reference
());
73
74
stream
().
setWritePosition
(
streamPosition
());
75
stream
().
writeHalfWord
(key.
sectionId
());
76
return
true
;
77
78
}
catch
(
KeyNotFound
& e) {
79
stream
().
writeHalfWord
(0);
80
return
false
;
81
}
82
}
83
84
/**
85
* Creates dynamically allocated copy of replacer.
86
*
87
* @return Dynamically allocated copy of replacer.
88
*/
89
ValueReplacer
*
90
SectionIdReplacer::clone
() {
91
return
new
SectionIdReplacer
(*
this
);
92
}
93
94
}
TPEF::BinaryStream::writeHalfWord
void writeHalfWord(HalfWord halfword)
Definition:
BinaryStream.cc:336
SectionIdReplacer.hh
TPEF::SectionIdReplacer::clone
virtual ValueReplacer * clone()
Definition:
SectionIdReplacer.cc:90
TPEF::SectionIdReplacer::SectionIdReplacer
SectionIdReplacer(const SafePointable *obj)
Definition:
SectionIdReplacer.cc:46
SafePointer.hh
TPEF::ReferenceManager::SectionKey::sectionId
SectionId sectionId() const
TPEF::ValueReplacer::stream
static BinaryStream & stream()
Definition:
ValueReplacer.cc:160
TPEF::SectionIdReplacer::~SectionIdReplacer
virtual ~SectionIdReplacer()
Definition:
SectionIdReplacer.cc:60
TPEF::SectionIdReplacer::tryToReplace
virtual bool tryToReplace()
Definition:
SectionIdReplacer.cc:69
TPEF::BinaryStream::setWritePosition
void setWritePosition(unsigned int position)
Definition:
BinaryStream.cc:689
TPEF::ReferenceManager::SafePointer::sectionKeyFor
static SectionKey sectionKeyFor(const SafePointable *obj)
Definition:
SafePointer.cc:408
TPEF::SafePointable
Definition:
SafePointable.hh:48
TPEF::ValueReplacer::streamPosition
unsigned int streamPosition() const
Definition:
ValueReplacer.cc:180
TPEF::SectionIdReplacer
Definition:
SectionIdReplacer.hh:47
TPEF::ReferenceManager::SectionKey
Definition:
ReferenceKey.hh:145
BinaryStream.hh
KeyNotFound
Definition:
Exception.hh:285
TPEF::ValueReplacer
Definition:
ValueReplacer.hh:71
TPEF
Definition:
Assembler.hh:43
TPEF::ValueReplacer::reference
const SafePointable * reference() const
Definition:
ValueReplacer.cc:170
Generated by
1.8.17