OpenASIP  2.0
ProximDisassemblyGridTable.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 ProximDisassemblyGridTable.cc
26  *
27  * Implementation of ProximDisassemblyGridTable class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2006 (vjaaskel-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <math.h>
35 #include "StopPointManager.hh"
36 #include "Breakpoint.hh"
37 #include "WxConversion.hh"
38 #include "ProximToolbox.hh"
40 #include "InstructionMemory.hh"
41 #include "ExecutableInstruction.hh"
42 #include "Instruction.hh"
43 #include "Move.hh"
45 
46 /**
47  * The Constructor.
48  */
50  DisassemblyGridTable(), bpManager_(NULL),
51  attrProvider_(NULL) {
52 
53 }
54 
55 
56 /**
57  * The Destructor.
58  */
60  if (attrProvider_ != NULL) {
61  delete attrProvider_;
62  }
63 }
64 
65 /**
66  * Sets the breakpoint manager containing program breakpoints to display.
67  *
68  * @param bpManager Breakpoint manager of the program.
69  */
70 void
72  StopPointManager& bpManager) {
73 
74  bpManager_ = &bpManager;
75 }
76 
77 
78 /**
79  * Returns text value of a cell.
80  *
81  * @param row Row of the cell.
82  * @param col Column of the cell.
83  * @return Value of the cell as wxString.
84  */
85 wxString
87 
88  if (!ProximToolbox::frontend()->isProgramLoaded()) {
89  return _T("");
90  }
91 
92  wxString value;
93 
94  if (col == 0 && bpManager_ != NULL) {
95  for (unsigned i = 0; i < bpManager_->stopPointCount(); i++) {
96  unsigned handle = bpManager_->stopPointHandle(i);
97 
98  const Breakpoint* bp =
99  dynamic_cast<const Breakpoint*>(
101 
102  if (bp != NULL) {
103  Word address = bp->address();
104  if (address == (Word)row) {
105  value.Append(WxConversion::toWxString(handle));
106  value.Append(_T(" "));
107  }
108  }
109  }
110  }
111 
112  if (col == 0 && showPCArrow_ && (Word)row == currentInstruction_) {
113  value.Append(_T("next>"));
114  }
115 
116  if (col > 0) {
117  value = DisassemblyGridTable::GetValue(row, col - 1);
118  }
119  return value;
120 }
121 
122 /**
123  * Returns number of columns in the grid.
124  *
125  * @return Number of columns.
126  */
127 int
129 
130  if (!ProximToolbox::frontend()->isProgramLoaded()) {
131  return 0;
132  }
133 
135 }
136 
137 
138 /**
139  * Returns number of rows in the grid.
140  *
141  * @return Number of rows.
142  */
143 int
145 
146  if (!ProximToolbox::frontend()->isProgramLoaded()) {
147  return 0;
148  }
149 
151 }
152 
153 /**
154  * Returns label for a column.
155  *
156  * @param col Column index.
157  * @return Column label.
158  */
159 wxString
161  if (col > 1) {
163  } else {
164  return _T("");
165  }
166 }
167 
168 /**
169  * Turns on showing of the arrow displaying the current instruction.
170  */
171 void
173  showPCArrow_ = true;
174 }
175 
176 /**
177  * Turns off showing of the arrow displaying the current instruction.
178  */
179 void
181  showPCArrow_ = false;
182 }
183 
184 
185 /**
186  * Sets address of the current instruction.
187  *
188  * @param address Address of the current instruction.
189  */
190 void
192  currentInstruction_ = address;
193 }
194 
195 /**
196  * Sets the cell attribute provider for cell's containing move disassembly.
197  *
198  * ProximDisassemblyGridTable take ownership of the pointer and deletes the
199  * object when it's no longer needed.
200  *
201  * @param attrProvider New move cell attribute provider.
202  */
203 void
205  ProximDisasmAttrProvider* attrProvider) {
206 
207  if (attrProvider_ != NULL) {
208  delete attrProvider_;
209  }
210  attrProvider_ = attrProvider;
211 }
212 
213 /**
214  * Returns the move cell attribute provider.
215  *
216  * @return Move cell attribute provider, or NULL is it's not set.
217  */
220  return attrProvider_;
221 }
222 
223 
224 /**
225  * Returns cell style attributes for a cell with given row and column.
226  *
227  * @paran row Row of the grid cell.
228  * @param col Column of the grid cell.
229  * @return Cell's style attribute.
230  */
231 wxGridCellAttr*
233  int row, int col, wxGridCellAttr::wxAttrKind /* kind */) {
234 
235  wxGridCellAttr* attr = new wxGridCellAttr();
236 
237  if (ProximToolbox::frontend()->isProgramLoaded() && row >= 0 && col > 1) {
238  if (attrProvider_ != NULL) {
239  return attrProvider_->moveCellAttr(addressOfRow(row), col - 2);
240  }
241  } else {
242  attr->SetBackgroundColour(wxColour(180, 180, 180));
243  }
244 
245  return attr;
246 }
StopPointManager.hh
Breakpoint::address
virtual InstructionAddress address() const
Definition: Breakpoint.cc:86
ProximToolbox::frontend
static TracedSimulatorFrontend * frontend()
Definition: ProximToolbox.cc:223
DisassemblyGridTable::GetColLabelValue
virtual wxString GetColLabelValue(int col)
Definition: DisassemblyGridTable.cc:180
WxConversion::toWxString
static wxString toWxString(const std::string &source)
DisassemblyGridTable::GetValue
virtual wxString GetValue(int row, int col)
Definition: DisassemblyGridTable.cc:121
ProximDisassemblyGridTable::GetNumberRows
virtual int GetNumberRows()
Definition: ProximDisassemblyGridTable.cc:144
ProximDisassemblyGridTable::ProximDisassemblyGridTable
ProximDisassemblyGridTable()
Definition: ProximDisassemblyGridTable.cc:49
Breakpoint
Definition: Breakpoint.hh:50
DisassemblyGridTable::addressOfRow
Word addressOfRow(int row)
Definition: DisassemblyGridTable.cc:254
ProximDisassemblyGridTable::moveCellAttrProvider
ProximDisasmAttrProvider * moveCellAttrProvider() const
Definition: ProximDisassemblyGridTable.cc:219
InstructionMemory.hh
ProximDisassemblyGridTable::GetColLabelValue
virtual wxString GetColLabelValue(int col)
Definition: ProximDisassemblyGridTable.cc:160
ProximDisassemblyGridTable::showPCArrow
void showPCArrow()
Definition: ProximDisassemblyGridTable.cc:172
ProximToolbox.hh
StopPointManager::stopPointCount
unsigned int stopPointCount()
Definition: StopPointManager.cc:269
ProximDisasmAttrProvider.hh
ProximDisasmAttrProvider
Definition: ProximDisasmAttrProvider.hh:44
StopPointManager::stopPointWithHandleConst
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
Definition: StopPointManager.cc:248
ProximDisassemblyGridTable::currentInstruction_
Word currentInstruction_
Program counter value.
Definition: ProximDisassemblyGridTable.hh:68
Instruction.hh
ProximDisassemblyGridTable::showPCArrow_
bool showPCArrow_
True, if the current istrcution arrow should be displayed.
Definition: ProximDisassemblyGridTable.hh:72
ProximDisassemblyGridTable::~ProximDisassemblyGridTable
~ProximDisassemblyGridTable()
Definition: ProximDisassemblyGridTable.cc:59
StopPointManager
Definition: StopPointManager.hh:50
DisassemblyGridTable::GetNumberRows
virtual int GetNumberRows()
Definition: DisassemblyGridTable.cc:79
Breakpoint.hh
ProximDisassemblyGridTable::GetNumberCols
virtual int GetNumberCols()
Definition: ProximDisassemblyGridTable.cc:128
DisassemblyGridTable
Definition: DisassemblyGridTable.hh:54
ProximDisasmAttrProvider::moveCellAttr
virtual wxGridCellAttr * moveCellAttr(InstructionAddress address, int move)=0
Definition: ProximDisasmAttrProvider.cc:56
ProximDisassemblyGridTable::setCurrentInstruction
void setCurrentInstruction(Word address)
Definition: ProximDisassemblyGridTable.cc:191
TracedSimulatorFrontend.hh
ProximDisassemblyGridTable::attrProvider_
ProximDisasmAttrProvider * attrProvider_
Definition: ProximDisassemblyGridTable.hh:74
ProximDisassemblyGridTable::bpManager_
StopPointManager * bpManager_
Stoppoint manager managing program breakpoints.
Definition: ProximDisassemblyGridTable.hh:70
ProximDisassemblyGridTable::hidePCArrow
void hidePCArrow()
Definition: ProximDisassemblyGridTable.cc:180
ExecutableInstruction.hh
DisassemblyGridTable::GetNumberCols
virtual int GetNumberCols()
Definition: DisassemblyGridTable.cc:92
ProximDisassemblyGridTable::setStopPointManager
void setStopPointManager(StopPointManager &manager)
Definition: ProximDisassemblyGridTable.cc:71
ProximDisassemblyGridTable::GetAttr
virtual wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind)
Definition: ProximDisassemblyGridTable.cc:232
WxConversion.hh
ProximDisassemblyGridTable::GetValue
virtual wxString GetValue(int row, int col)
Definition: ProximDisassemblyGridTable.cc:86
Move.hh
StopPointManager::stopPointHandle
unsigned int stopPointHandle(unsigned int index)
Definition: StopPointManager.cc:231
ProximDisassemblyGridTable.hh
ProximDisassemblyGridTable::setMoveCellAttrProvider
void setMoveCellAttrProvider(ProximDisasmAttrProvider *attrProvider)
Definition: ProximDisassemblyGridTable.cc:204