OpenASIP  2.0
NullProgram.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 NullProgram.cc
26  *
27  * Implementation of NullProgram class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "NullProgram.hh"
34 #include "NullProcedure.hh"
35 #include "NullInstruction.hh"
36 #include "NullAddress.hh"
37 #include "NullAddressSpace.hh"
38 #include "NullGlobalScope.hh"
40 #include "NullMachine.hh"
41 
42 using namespace TTAMachine;
43 
44 namespace TTAProgram {
45 
46 /////////////////////////////////////////////////////////////////////////////
47 // NullProgram
48 /////////////////////////////////////////////////////////////////////////////
49 
50 NullProgram NullProgram::instance_;
51 
52 /**
53  * The constructor.
54  */
55 NullProgram::NullProgram():
56  Program(
57  NullAddressSpace::instance(), NullAddress::instance()) {
58 }
59 
60 /**
61  * The destructor.
62  */
64 }
65 
66 /**
67  * Returns an instance of NullProgram class (singleton).
68  *
69  * @return Singleton instance of NullProgram class.
70  */
73  return instance_;
74 }
75 
76 /**
77  * Aborts program with error log message.
78  *
79  * @return Nothing.
80  */
83  abortWithError("globalScope()");
85 }
86 
87 const GlobalScope&
89  abortWithError("globalScopeConst()");
91 }
92 
93 /**
94  * Aborts program with error log message.
95  *
96  * @return Nothing
97  */
98 
101  abortWithError("targetProcessor()");
103 }
104 /**
105  * Aborts program with error log message.
106  *
107  * @return A null address.
108  */
109 Address
111  abortWithError("startAddress()");
112  return NullAddress::instance();
113 }
114 
115 /**
116  * Aborts program with error log message.
117  *
118  * @return A null address.
119  */
120 Address
122  abortWithError("entryAddress()");
123  return NullAddress::instance();
124 }
125 
126 /**
127  * Aborts program with error log message.
128  */
129 void
131  abortWithError("setEntryAddress()");
132 }
133 
134 /**
135  * Aborts program with error log message.
136  *
137  * @exception IllegalRegistration never.
138  */
139 void
141  abortWithError("addProcedure()");
142 }
143 
144 /**
145  * Aborts program with error log message.
146  *
147  * @exception IllegalRegistration never.
148  */
149 void
151  abortWithError("addInstruction()");
152 }
153 
154 /**
155  * Aborts program with error log message.
156  */
157 void
159  abortWithError("relocate()");
160 }
161 
162 /**
163  * Aborts program with error log message.
164  *
165  * @exception InstanceNotFound never.
166  * @return Nothing.
167  */
168 Procedure&
170  abortWithError("firstProcedure()");
171  return NullProcedure::instance();
172 }
173 
174 /**
175  * Aborts program with error log message.
176  *
177  * @exception InstanceNotFound never.
178  * @return Nothing.
179  */
180 Procedure&
182  abortWithError("lastProcedure()");
183  return NullProcedure::instance();
184 }
185 
186 /**
187  * Aborts program with error log message.
188  *
189  * @return Nothing.
190  */
191 Procedure&
193  abortWithError("nextProcedure()");
194  return NullProcedure::instance();
195 }
196 
197 /**
198  * Aborts program with error log message.
199  *
200  * @return -1.
201  */
202 int
204  abortWithError("addInstruction()");
205  return -1;
206 }
207 
208 /**
209  * Aborts program with error log message.
210  *
211  * @return a null procedure.
212  * @exception OutOfRange never.
213  */
214 Procedure&
216  abortWithError("addInstruction()");
217  return NullProcedure::instance();
218 }
219 
220 /**
221  * Aborts program with error log message.
222  *
223  * @exception KeyNotFound never.
224  * @return Nothing.
225  */
226 Procedure&
227 NullProgram::procedure(const std::string&) const {
228  abortWithError("procedure()");
229  return NullProcedure::instance();
230 }
231 
232 /**
233  * Aborts program with error log message.
234  *
235  * @exception InstanceNotFound never.
236  * @return Nothing.
237  */
240  abortWithError("firstInstruction()");
241  return NullInstruction::instance();
242 }
243 
244 /**
245  * Aborts program with error log message.
246  *
247  * @return A null instruction.
248  * @exception KeyNotFound never.
249  */
250 const Instruction&
252  abortWithError("instructionAt()");
253  return NullInstruction::instance();
254 }
255 
256 /**
257  * Aborts program with error log message.
258  *
259  * @return A null instruction.
260  */
261 const Instruction&
263  abortWithError("nextInstruction()");
264  return NullInstruction::instance();
265 }
266 
267 /**
268  * Aborts program with error log message.
269  *
270  * @exception InstanceNotFound never.
271  * @return Nothing.
272  */
275  abortWithError("lastInstruction()");
276  return NullInstruction::instance();
277 }
278 
279 /**
280  * Aborts program with error log message.
281  *
282  * @return Nothing.
283  */
286  abortWithError("instructionReferenceManager()");
288 }
289 
290 }
TTAProgram::NullProgram::lastInstruction
Instruction & lastInstruction() const
Definition: NullProgram.cc:274
TTAProgram
Definition: Estimator.hh:65
TTAProgram::NullProgram::entryAddress
Address entryAddress() const
Definition: NullProgram.cc:121
UIntWord
Word UIntWord
Definition: BaseType.hh:144
TTAProgram::Program
Definition: Program.hh:63
TTAProgram::NullProgram::instance_
static NullProgram instance_
Unique instance of NullProgram.
Definition: NullProgram.hh:88
NullProcedure.hh
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::NullProgram::nextProcedure
Procedure & nextProcedure(const Procedure &proc) const
Definition: NullProgram.cc:192
TTAProgram::Instruction
Definition: Instruction.hh:57
TTAProgram::NullProcedure::instance
static NullProcedure & instance()
Definition: NullProcedure.cc:68
TTAProgram::NullProgram::globalScopeConst
const GlobalScope & globalScopeConst() const
Definition: NullProgram.cc:88
NullAddress.hh
TTAProgram::NullGlobalScope::instance
static NullGlobalScope & instance()
Definition: NullGlobalScope.cc:64
TTAProgram::NullProgram::~NullProgram
virtual ~NullProgram()
Definition: NullProgram.cc:63
TTAProgram::NullAddress::instance
static NullAddress & instance()
Definition: NullAddress.cc:65
TTAProgram::NullProgram::setEntryAddress
void setEntryAddress(Address address)
Definition: NullProgram.cc:130
TTAProgram::NullProgram::instance
static NullProgram & instance()
Definition: NullProgram.cc:72
TTAMachine::NullAddressSpace
Definition: NullAddressSpace.hh:45
TTAProgram::NullProgram::targetProcessor
TTAMachine::Machine & targetProcessor() const
Definition: NullProgram.cc:100
NullMachine.hh
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
NullInstructionReferenceManager.hh
TTAProgram::NullProgram::instructionReferenceManager
InstructionReferenceManager & instructionReferenceManager()
Definition: NullProgram.cc:285
TTAProgram::NullInstructionReferenceManager::instance
static NullInstructionReferenceManager & instance()
Definition: NullInstructionReferenceManager.cc:63
TTAProgram::NullProgram::nextInstruction
const Instruction & nextInstruction(const Instruction &) const
Definition: NullProgram.cc:262
NullInstruction.hh
NullAddressSpace.hh
TTAProgram::GlobalScope
Definition: GlobalScope.hh:47
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
TTAProgram::NullProgram
Definition: NullProgram.hh:45
TTAMachine::NullMachine::instance
static NullMachine & instance()
Definition: NullMachine.cc:60
TTAProgram::NullProgram::lastProcedure
Procedure & lastProcedure() const
Definition: NullProgram.cc:181
TTAProgram::NullProgram::instructionAt
const Instruction & instructionAt(UIntWord address) const
Definition: NullProgram.cc:251
TTAProgram::InstructionReferenceManager
Definition: InstructionReferenceManager.hh:82
TTAProgram::NullProgram::globalScope
GlobalScope & globalScope()
Definition: NullProgram.cc:82
TTAProgram::NullProgram::addInstruction
void addInstruction(Instruction &ins)
Definition: NullProgram.cc:150
TTAProgram::NullProgram::addProcedure
void addProcedure(Procedure &proc)
Definition: NullProgram.cc:140
TTAProgram::NullProgram::procedure
Procedure & procedure(int index) const
Definition: NullProgram.cc:215
NullGlobalScope.hh
TTAProgram::NullProgram::firstProcedure
Procedure & firstProcedure() const
Definition: NullProgram.cc:169
TTAProgram::NullProgram::startAddress
Address startAddress() const
Definition: NullProgram.cc:110
TTAProgram::NullProgram::procedureCount
int procedureCount() const
Definition: NullProgram.cc:203
TTAProgram::NullAddress
Definition: NullAddress.hh:45
TTAMachine
Definition: Assembler.hh:48
NullProgram.hh
TTAProgram::NullProgram::firstInstruction
Instruction & firstInstruction() const
Definition: NullProgram.cc:239
TTAProgram::Procedure
Definition: Procedure.hh:55
TTAProgram::NullProgram::relocate
void relocate(const Procedure &proc, UIntWord howMuch)
Definition: NullProgram.cc:158
TTAMachine::Machine
Definition: Machine.hh:73