OpenASIP  2.0
NullInstruction.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 NullInstruction.cc
26  *
27  * Implementation of NullInstruction class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @note rating: red
31  */
32 
33 #include "NullInstruction.hh"
35 #include "NullProcedure.hh"
36 #include "NullAddress.hh"
37 
38 namespace TTAProgram {
39 
40 /////////////////////////////////////////////////////////////////////////////
41 // NullInstruction
42 /////////////////////////////////////////////////////////////////////////////
43 
44 NullInstruction NullInstruction::instance_;
45 
46 /**
47  * The constructor.
48  */
50  Instruction(TTAMachine::NullInstructionTemplate::instance()) {
51 }
52 
53 /**
54  * The destructor.
55  */
57 }
58 
59 
60 /**
61  * Returns an instance of NullInstruction class (singleton).
62  *
63  * @return Singleton instance of NullInstruction class.
64  */
67  return instance_;
68 }
69 
70 /**
71  * Aborts program with error log message.
72  *
73  * @return A null procedure.
74  * @exception IllegalRegistration never.
75  */
76 Procedure&
78  abortWithError("parent()");
79  return NullProcedure::instance();
80 }
81 
82 /**
83  * Aborts program with error log message.
84  */
85 void
87  abortWithError("setParent()");
88 }
89 
90 /**
91  * Aborts program with error log message.
92  *
93  * @return False.
94  */
95 bool
97  abortWithError("isInProcedure()");
98  return false;
99 }
100 
101 /**
102  * Aborts program with error log message.
103  */
104 void
106  abortWithError("addMove()");
107 }
108 
109 /**
110  * Aborts program with error log message.
111  *
112  * @return -1.
113  */
115  abortWithError("addMove()");
116  return -1;
117 }
118 
119 /**
120  * Aborts program with error log message.
121  *
122  * @return A null move.
123  */
124 const Move&
126  abortWithError("addMove()");
127  throw OutOfRange(__FILE__,__LINE__,__func__, "Null intruction is empty.");
128 }
129 
130 /**
131  * Aborts program with error log message.
132  */
133 void
135  abortWithError("addMove()");
136 }
137 
138 /**
139  * Aborts program with error log message.
140  *
141  * @return -1.
142  */
144  abortWithError("addMove()");
145  return -1;
146 }
147 
148 /**
149  * Aborts program with error log message.
150  *
151  * @return A null immediate.
152  */
153 Immediate&
155  abortWithError("addMove()");
156  // to avoid warning:
157  throw new OutOfRange(__FILE__,__LINE__,__func__,"");
158 }
159 
160 /**
161  * Aborts program with error log message.
162  *
163  * @return A null address.
164  */
165 Address&
167  abortWithError("address()");
168  return NullAddress::instance();
169 }
170 
171 /**
172  * Aborts program with error log message.
173  *
174  * @return -1.
175  */
176 int
178  abortWithError("size()");
179  return -1;
180 }
181 
182 }
TTAProgram
Definition: Estimator.hh:65
TTAProgram::NullInstruction::address
Address & address() const
Definition: NullInstruction.cc:166
NullProcedure.hh
TTAProgram::Address
Definition: Address.hh:51
TTAProgram::NullInstruction::isInProcedure
bool isInProcedure() const
Definition: NullInstruction.cc:96
TTAProgram::NullInstruction
Definition: NullInstruction.hh:45
TTAProgram::NullInstruction::size
int size() const
Definition: NullInstruction.cc:177
TTAProgram::Instruction
Definition: Instruction.hh:57
OutOfRange
Definition: Exception.hh:320
TTAProgram::NullProcedure::instance
static NullProcedure & instance()
Definition: NullProcedure.cc:68
TTAProgram::NullInstruction::move
const Move & move(int i) const
Definition: NullInstruction.cc:125
NullAddress.hh
TTAProgram::NullInstruction::setParent
void setParent(const Procedure &proc)
Definition: NullInstruction.cc:86
TTAProgram::NullInstruction::addImmediate
void addImmediate(Immediate &imm)
Definition: NullInstruction.cc:134
TTAProgram::NullInstruction::instance_
static NullInstruction instance_
Unique instance of NullInstruction.
Definition: NullInstruction.hh:76
TTAProgram::NullInstruction::immediate
Immediate & immediate(int i)
Definition: NullInstruction.cc:154
TTAProgram::NullAddress::instance
static NullAddress & instance()
Definition: NullAddress.cc:65
TTAProgram::Immediate
Definition: Immediate.hh:54
abortWithError
#define abortWithError(message)
Definition: Application.hh:72
NullInstruction.hh
__func__
#define __func__
Definition: Application.hh:67
NullInstructionTemplate.hh
TTAProgram::Move
Definition: Move.hh:55
TTAProgram::NullInstruction::instance
static NullInstruction & instance()
Definition: NullInstruction.cc:66
TTAProgram::NullInstruction::immediateCount
int immediateCount()
Definition: NullInstruction.cc:143
TTAProgram::NullInstruction::NullInstruction
NullInstruction()
Definition: NullInstruction.cc:49
TTAProgram::NullInstruction::addMove
void addMove(Move &move)
Definition: NullInstruction.cc:105
TTAProgram::NullInstruction::~NullInstruction
virtual ~NullInstruction()
Definition: NullInstruction.cc:56
TTAMachine
Definition: Assembler.hh:48
TTAProgram::Procedure
Definition: Procedure.hh:55
TTAProgram::NullInstruction::moveCount
int moveCount()
Definition: NullInstruction.cc:114
TTAProgram::NullInstruction::parent
Procedure & parent() const
Definition: NullInstruction.cc:77