OpenASIP  2.0
TerminalImmediate.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 TerminalImmediate.cc
26  *
27  * Implementation of TerminalImmediate class.
28  *
29  * @author Ari Metsähalme 2005 (ari.metsahalme-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2011
31  * @note rating: red
32  */
33 
34 #include "TerminalImmediate.hh"
35 #include "DisassemblyImmediate.hh"
36 #include "POMDisassembler.hh"
37 #include <typeinfo>
38 
39 using namespace TTAMachine;
40 
41 namespace TTAProgram {
42 
43 /**
44  * The constructor.
45  *
46  * @param value The value of the inline immediate.
47  */
48 TerminalImmediate::TerminalImmediate(SimValue value):
49  value_(value) {
50 }
51 
52 /**
53  * The destructor.
54  */
56 }
57 
58 /**
59  * Tells whether the terminal is an inline immediate value.
60  *
61  * @return true always.
62  */
63 bool
65  return true;
66 }
67 
68 /**
69  * Returns the value of the inline immediate.
70  *
71  * @return The value of the inline immediate.
72  * @exception WrongSubclass never.
73  */
76  return value_;
77 }
78 
79 /**
80  * Creates an exact copy of the terminal and returns it.
81  *
82  * @return A copy of the terminal.
83  */
84 Terminal*
86  return new TerminalImmediate(value_);
87 }
88 
89 /**
90  * Checks if terminals are equal.
91  *
92  * @param other Terminal to compare.
93  * @return true if terminals are equal.
94  */
95 bool
96 TerminalImmediate::equals(const Terminal& other) const {
97 
98  if (other.isImmediate() != true) {
99  return false;
100  }
101  if (typeid(*this) != typeid(other)) {
102  return false;
103  }
104  return value() == other.value();
105 }
106 
107 TCEString
109  DisassemblyImmediate* disasm =
111  TCEString dis = disasm->toString();
112  delete disasm;
113  return dis;
114 }
115 
116 
117 }
TTAProgram
Definition: Estimator.hh:65
DisassemblyImmediate::toString
virtual std::string toString() const
Definition: DisassemblyImmediate.cc:61
TTAProgram::TerminalImmediate::TerminalImmediate
TerminalImmediate(SimValue value)
Definition: TerminalImmediate.cc:48
POMDisassembler::createInlineImmediate
static DisassemblyImmediate * createInlineImmediate(const TTAProgram::Terminal &terminal, bool signExtend)
Definition: POMDisassembler.cc:296
SimValue
Definition: SimValue.hh:96
POMDisassembler.hh
TTAProgram::TerminalImmediate::toString
virtual TCEString toString() const
Definition: TerminalImmediate.cc:108
TTAProgram::TerminalImmediate::value
virtual SimValue value() const
Definition: TerminalImmediate.cc:75
TTAProgram::TerminalImmediate::~TerminalImmediate
virtual ~TerminalImmediate()
Definition: TerminalImmediate.cc:55
TTAProgram::TerminalImmediate::equals
virtual bool equals(const Terminal &other) const
Definition: TerminalImmediate.cc:96
TTAProgram::TerminalImmediate::value_
SimValue value_
Value of the inline immediate.
Definition: TerminalImmediate.hh:62
TTAProgram::TerminalImmediate::copy
virtual Terminal * copy() const
Definition: TerminalImmediate.cc:85
DisassemblyImmediate
Definition: DisassemblyImmediate.hh:42
TTAProgram::Terminal::value
virtual SimValue value() const
Definition: Terminal.cc:178
TTAProgram::TerminalImmediate::isImmediate
virtual bool isImmediate() const
Definition: TerminalImmediate.cc:64
TerminalImmediate.hh
TCEString
Definition: TCEString.hh:53
TTAProgram::Terminal
Definition: Terminal.hh:60
DisassemblyImmediate.hh
TTAMachine
Definition: Assembler.hh:48
TTAProgram::Terminal::isImmediate
virtual bool isImmediate() const
Definition: Terminal.cc:63