OpenASIP  2.0
NullProcedure.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 NullProcedure.cc
26  *
27  * Implementation of NullProcedure class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "NullProcedure.hh"
34 #include "NullProgram.hh"
35 #include "NullInstruction.hh"
36 #include "NullAddress.hh"
37 #include "NullAddressSpace.hh"
38 
39 using namespace TTAMachine;
40 
41 namespace TTAProgram {
42 
43 /////////////////////////////////////////////////////////////////////////////
44 // NullProcedure
45 /////////////////////////////////////////////////////////////////////////////
46 
47 NullProcedure NullProcedure::instance_;
48 
49 /**
50  * The constructor.
51  */
52 NullProcedure::NullProcedure() :
53  Procedure("NULL", NullAddressSpace::instance()) {
54 }
55 
56 /**
57  * The destructor.
58  */
60 }
61 
62 /**
63  * Returns an instance of NullProcedure class (singleton).
64  *
65  * @return Singleton instance of NullProcedure class.
66  */
69  return instance_;
70 }
71 
72 /**
73  * Aborts program with error log message.
74  *
75  * @return A null program.
76  * @exception IllegalRegistration never.
77  */
78 Program&
80  abortWithError("parent()");
81  return NullProgram::instance();
82 }
83 
84 /**
85  * Aborts program with error log message.
86  */
87 void
89  abortWithError("setParent()");
90 }
91 
92 /**
93  * Aborts program with error log message.
94  *
95  * @return False.
96  */
97 bool
99  abortWithError("isInProgram()");
100  return false;
101 }
102 
103 std::string
105  abortWithError("name()");
106  return "";
107 }
108 
109 int
111  abortWithError("alignment()");
112  return -1;
113 }
114 
115 /**
116  * Aborts program with error log message.
117  *
118  * @return A null address.
119  * @exception IllegalRegistration never.
120  */
121 Address
123  abortWithError("address()");
124  return NullAddress::instance();
125 }
126 
127 /**
128  * Aborts program with error log message.
129  *
130  * @return A null address.
131  */
132 Address
134  abortWithError("startAddress()");
135  return NullAddress::instance();
136 }
137 
138 /**
139  * Aborts program with error log message.
140  */
141 void
143  abortWithError("setStartAddress()");
144 }
145 
146 /**
147  * Aborts program with error log message.
148  *
149  * @return A null address.
150  */
151 Address
153  abortWithError("endAddress()");
154  return NullAddress::instance();
155 }
156 
157 /**
158  * Aborts program with error log message.
159  *
160  * @return -1.
161  */
162 int
164  abortWithError("instructionCount()");
165  return -1;
166 }
167 
170  abortWithError("firstInstruction()");
171  return NullInstruction::instance();
172 }
173 
174 /**
175  * Aborts program with error log message.
176  *
177  * @return A null instruction.
178  * @exception KeyNotFound never.
179  */
182  abortWithError("instructionAt()");
183  return NullInstruction::instance();
184 }
185 
186 /**
187  * Aborts program with error log message.
188  *
189  * @return False.
190  * @exception IllegalRegistration never.
191  */
192 bool
194  abortWithError("hasNextInstruction()");
195  return false;
196 }
197 
198 /**
199  * Aborts program with error log message.
200  *
201  * @return A null instruction.
202  * @exception IllegalRegistration never.
203  */
206  abortWithError("nextInstruction()");
207  return NullInstruction::instance();
208 }
209 
210 /**
211  * Aborts program with error log message.
212  *
213  * @return A null instruction.
214  * @exception IllegalRegistration never.
215  */
218  abortWithError("previousInstruction()");
219  return NullInstruction::instance();
220 }
221 
222 /**
223  * Aborts program with error log message.
224  *
225  * @return A null instruction.
226  * @exception IllegalRegistration never.
227  */
230  abortWithError("lastInstruction()");
231  return NullInstruction::instance();
232 }
233 
234 /**
235  * Aborts program with error log message.
236  *
237  * @exception IllegalRegistration never.
238  */
239 void
241  abortWithError("addInstruction()");
242 }
243 
244 /**
245  * Aborts program with error log message.
246  *
247  * @exception IllegalRegistration never.
248  */
249 void
251  abortWithError("insertInstructionAfter()");
252 }
253 }
TTAProgram
Definition: Estimator.hh:65
UIntWord
Word UIntWord
Definition: BaseType.hh:144
TTAProgram::NullProcedure::insertInstructionAfter
void insertInstructionAfter(const Instruction &pos, Instruction *ins)
Definition: NullProcedure.cc:250
TTAProgram::Program
Definition: Program.hh:63
TTAProgram::NullProcedure::addInstruction
void addInstruction(Instruction &ins)
Definition: NullProcedure.cc:240
NullProcedure.hh
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::NullProcedure::instructionAt
Instruction & instructionAt(UIntWord address) const
Definition: NullProcedure.cc:181
TTAProgram::NullProcedure::~NullProcedure
virtual ~NullProcedure()
Definition: NullProcedure.cc:59
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAProgram::NullProcedure::alignment
int alignment() const
Definition: NullProcedure.cc:110
TTAProgram::NullProcedure::instance
static NullProcedure & instance()
Definition: NullProcedure.cc:68
TTAProgram::NullProcedure
Definition: NullProcedure.hh:50
TTAProgram::NullProcedure::instructionCount
int instructionCount() const
Definition: NullProcedure.cc:163
NullAddress.hh
TTAProgram::NullProcedure::parent
Program & parent() const
Definition: NullProcedure.cc:79
TTAProgram::NullAddress::instance
static NullAddress & instance()
Definition: NullAddress.cc:65
TTAProgram::NullProcedure::isInProgram
bool isInProgram() const
Definition: NullProcedure.cc:98
TTAProgram::NullProgram::instance
static NullProgram & instance()
Definition: NullProgram.cc:72
TTAProgram::NullProcedure::previousInstruction
Instruction & previousInstruction(const Instruction &ins) const
Definition: NullProcedure.cc:217
TTAProgram::NullProcedure::setParent
void setParent(Program &prog)
Definition: NullProcedure.cc:88
TTAMachine::NullAddressSpace
Definition: NullAddressSpace.hh:45
TTAProgram::NullProcedure::setStartAddress
void setStartAddress(Address start)
Definition: NullProcedure.cc:142
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
NullInstruction.hh
NullAddressSpace.hh
TTAProgram::NullProcedure::name
std::string name() const
Definition: NullProcedure.cc:104
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
TTAProgram::NullProcedure::startAddress
Address startAddress() const
Definition: NullProcedure.cc:133
TTAProgram::NullProcedure::endAddress
Address endAddress() const
Definition: NullProcedure.cc:152
TTAProgram::NullProcedure::instance_
static NullProcedure instance_
Unique instance of NullProcedure.
Definition: NullProcedure.hh:88
TTAProgram::NullProcedure::address
Address address(const Instruction &ins) const
Definition: NullProcedure.cc:122
TTAProgram::NullProcedure::nextInstruction
Instruction & nextInstruction(const Instruction &ins) const
Definition: NullProcedure.cc:205
TTAProgram::NullProcedure::firstInstruction
Instruction & firstInstruction() const
Definition: NullProcedure.cc:169
TTAMachine
Definition: Assembler.hh:48
TTAProgram::NullProcedure::hasNextInstruction
bool hasNextInstruction(const Instruction &ins) const
Definition: NullProcedure.cc:193
NullProgram.hh
TTAProgram::Procedure
Definition: Procedure.hh:55
TTAProgram::NullProcedure::lastInstruction
Instruction & lastInstruction() const
Definition: NullProcedure.cc:229