OpenASIP 2.2
Loading...
Searching...
No Matches
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"
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 */
64
65/**
66 * Sets the breakpoint manager containing program breakpoints to display.
67 *
68 * @param bpManager Breakpoint manager of the program.
69 */
70void
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 */
85wxString
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 */
127int
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 */
143int
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 */
159wxString
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 */
171void
175
176/**
177 * Turns off showing of the arrow displaying the current instruction.
178 */
179void
183
184
185/**
186 * Sets address of the current instruction.
187 *
188 * @param address Address of the current instruction.
189 */
190void
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 */
203void
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 */
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 */
231wxGridCellAttr*
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}
virtual InstructionAddress address() const
Definition Breakpoint.cc:86
virtual wxString GetColLabelValue(int col)
virtual wxString GetValue(int row, int col)
virtual wxGridCellAttr * moveCellAttr(InstructionAddress address, int move)=0
void setMoveCellAttrProvider(ProximDisasmAttrProvider *attrProvider)
virtual wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind)
Word currentInstruction_
Program counter value.
void setStopPointManager(StopPointManager &manager)
ProximDisasmAttrProvider * attrProvider_
virtual wxString GetColLabelValue(int col)
bool showPCArrow_
True, if the current istrcution arrow should be displayed.
StopPointManager * bpManager_
Stoppoint manager managing program breakpoints.
virtual wxString GetValue(int row, int col)
ProximDisasmAttrProvider * moveCellAttrProvider() const
static TracedSimulatorFrontend * frontend()
unsigned int stopPointCount()
const StopPoint & stopPointWithHandleConst(unsigned int handle) const
unsigned int stopPointHandle(unsigned int index)
static wxString toWxString(const std::string &source)