OpenASIP  2.0
DisassemblyMove.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 DisassemblyMove.cc
26  *
27  * Implementation of DisassemblyMove class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2008 (pjaaskel-no.spam-cs.tut.fi)
31  * @note rating: red
32  */
33 
34 #include "DisassemblyMove.hh"
35 #include "DisassemblyGuard.hh"
36 
37 /**
38  * Creates disassembler of a move.
39  *
40  * @param source The source element of the move.
41  * @param destination The destination element of the move.
42  * @param guard Move guard, or NULL if the move is not guarded.
43  */
45  DisassemblyElement* source,
46  DisassemblyElement* destination,
47  DisassemblyGuard* guard):
49  source_(source), destination_(destination), guard_(guard) {
50 
51 }
52 
53 
54 /**
55  * The destructor.
56  */
58  delete source_;
59  delete destination_;
60  if (guard_ != NULL) {
61  delete guard_;
62  guard_ = NULL;
63  }
64 }
65 
66 
67 /**
68  * Disassembles the move.
69  *
70  * @return Disassembled move as a string.
71  */
72 std::string
74 
75  std::string disassembly;
76  if (guard_ != NULL) {
77  disassembly = guard_->toString();
78  }
79 
80  disassembly =
81  disassembly + source_->toString() + " -> " + destination_->toString();
82 
83  for (int i = 0; i < annotationCount(); i++) {
84  disassembly += annotation(i).toString();
85  }
86 
87  return disassembly;
88 }
DisassemblyInstructionSlot::annotationCount
int annotationCount() const
Definition: DisassemblyInstructionSlot.cc:80
DisassemblyGuard::toString
virtual std::string toString() const
Definition: DisassemblyGuard.cc:84
DisassemblyInstructionSlot::annotation
DisassemblyAnnotation & annotation(int index) const
Definition: DisassemblyInstructionSlot.cc:60
DisassemblyGuard.hh
DisassemblyInstructionSlot
Definition: DisassemblyInstructionSlot.hh:43
DisassemblyMove::toString
virtual std::string toString() const
Definition: DisassemblyMove.cc:73
DisassemblyElement
Definition: DisassemblyElement.hh:41
DisassemblyMove::destination_
DisassemblyElement * destination_
The destination of the move.
Definition: DisassemblyMove.hh:63
DisassemblyAnnotation::toString
virtual std::string toString() const
Definition: DisassemblyAnnotation.cc:61
DisassemblyMove.hh
DisassemblyMove::guard_
DisassemblyGuard * guard_
Possible guard of the move.
Definition: DisassemblyMove.hh:65
DisassemblyGuard
Definition: DisassemblyGuard.hh:41
DisassemblyMove::DisassemblyMove
DisassemblyMove(DisassemblyElement *source, DisassemblyElement *destination, DisassemblyGuard *guard=NULL)
Definition: DisassemblyMove.cc:44
DisassemblyMove::source_
DisassemblyElement * source_
The source of the move.
Definition: DisassemblyMove.hh:61
DisassemblyMove::~DisassemblyMove
virtual ~DisassemblyMove()
Definition: DisassemblyMove.cc:57
DisassemblyElement::toString
virtual std::string toString() const =0