OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Private Types | Private Attributes | List of all members
DisassemblyGridTable Class Reference

#include <DisassemblyGridTable.hh>

Inheritance diagram for DisassemblyGridTable:
Inheritance graph
Collaboration diagram for DisassemblyGridTable:
Collaboration graph

Public Member Functions

 DisassemblyGridTable ()
 
virtual ~DisassemblyGridTable ()
 
virtual int GetNumberRows ()
 
virtual int GetNumberCols ()
 
virtual bool IsEmptyCell (int row, int col)
 
virtual wxString GetValue (int row, int col)
 
virtual wxString GetRowLabelValue (int row)
 
virtual wxString GetColLabelValue (int col)
 
virtual void SetValue (int row, int col, const wxString &value)
 
virtual bool CanHaveAttributes ()
 
int rowOfAddress (Word address)
 
Word addressOfRow (int row)
 
void loadProgram (const TTAProgram::Program &program)
 

Protected Attributes

const TTAProgram::Programprogram_
 Program loaded in the table.
 

Private Types

typedef std::multimap< int, std::string > LabelMap
 Type for the labels multimap.
 

Private Attributes

POMDisassemblerdisassembler_
 Disassembler for generating instruction disassemblies.
 
LabelMap labels_
 Program labels.
 

Detailed Description

Grid table class which allows wxGrid to display disassembly of a tta program by disassembling only the currently visible instructions. Purpose of the 'lazy' disasembling is to conserve memory and processing time when the program is very large.

Definition at line 54 of file DisassemblyGridTable.hh.

Member Typedef Documentation

◆ LabelMap

typedef std::multimap<int, std::string> DisassemblyGridTable::LabelMap
private

Type for the labels multimap.

Definition at line 77 of file DisassemblyGridTable.hh.

Constructor & Destructor Documentation

◆ DisassemblyGridTable()

DisassemblyGridTable::DisassemblyGridTable ( )

The Constructor.

Definition at line 55 of file DisassemblyGridTable.cc.

55 :
56 wxGridTableBase(), program_(NULL), disassembler_(NULL) {
57
58}
POMDisassembler * disassembler_
Disassembler for generating instruction disassemblies.
const TTAProgram::Program * program_
Program loaded in the table.

◆ ~DisassemblyGridTable()

DisassemblyGridTable::~DisassemblyGridTable ( )
virtual

The Destructor.

Definition at line 64 of file DisassemblyGridTable.cc.

64 {
65 if (disassembler_ != NULL) {
66 delete disassembler_;
67 }
68}

References disassembler_.

Member Function Documentation

◆ addressOfRow()

Word DisassemblyGridTable::addressOfRow ( int  row)

Returns address of the instruction on a row.

Parameters
rowRow of the instruction.
Returns
Address of the instruction.

Definition at line 254 of file DisassemblyGridTable.cc.

254 {
255 return (Word)row;
256}

Referenced by ProximDisassemblyGridTable::GetAttr(), ProximDisassemblyWindow::onRightClick(), ProximDisassemblyWindow::onRunUntil(), ProximDisassemblyWindow::onSetBreakpoint(), and ProximDisassemblyWindow::onSetTempBp().

◆ CanHaveAttributes()

bool DisassemblyGridTable::CanHaveAttributes ( )
virtual

Returns true if the grid cells can have attributes.

Returns
Always true.

Definition at line 204 of file DisassemblyGridTable.cc.

204 {
205 return true;
206}

◆ GetColLabelValue()

wxString DisassemblyGridTable::GetColLabelValue ( int  col)
virtual

Returns column label of a grid column.

Parameters
colColumn number.
Returns
Label for the grid column.

Reimplemented in ProximDisassemblyGridTable.

Definition at line 180 of file DisassemblyGridTable.cc.

180 {
181
182 int busCount = program_->targetProcessor().busNavigator().count();
183
184 if (col > 0 && col < (busCount + 1)) {
185 const TTAMachine::Machine::BusNavigator& navigator =
187
188 string label = Conversion::toString(col - 1);
189 label += ": ";
190 label += navigator.item(col - 1)->name();
191 return WxConversion::toWxString(label);
192 } else {
193 return _T("");
194 }
195}
static std::string toString(const T &source)
ComponentType * item(int index) const
virtual BusNavigator busNavigator() const
Definition Machine.cc:356
TTAMachine::Machine & targetProcessor() const
Definition Program.cc:202
static wxString toWxString(const std::string &source)

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::Navigator< ComponentType >::item(), program_, TTAProgram::Program::targetProcessor(), Conversion::toString(), and WxConversion::toWxString().

Referenced by ProximDisassemblyGridTable::GetColLabelValue().

Here is the call graph for this function:

◆ GetNumberCols()

int DisassemblyGridTable::GetNumberCols ( )
virtual

Returns column count of the grid.

Returns
Number of coulmns in the table.

Reimplemented in ProximDisassemblyGridTable.

Definition at line 92 of file DisassemblyGridTable.cc.

92 {
93 int busCount = program_->targetProcessor().busNavigator().count();
94 int immSlotCount =
96 return busCount + immSlotCount + 1;
97}
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition Machine.cc:462

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), TTAMachine::Machine::immediateSlotNavigator(), program_, and TTAProgram::Program::targetProcessor().

Referenced by ProximDisassemblyGridTable::GetNumberCols().

Here is the call graph for this function:

◆ GetNumberRows()

int DisassemblyGridTable::GetNumberRows ( )
virtual

Returns row count of the grid.

The row count is limited to MAX_ROWS due to limtiations of wxGrid.

Returns
Number of rows in the table.

Reimplemented in ProximDisassemblyGridTable.

Definition at line 79 of file DisassemblyGridTable.cc.

79 {
80 Word firstAddress = program_->firstInstruction().address().location();
81 Word lastAddress = program_->lastInstruction().address().location();
82 return lastAddress - firstAddress + 1;
83}
InstructionAddress location() const
Address address() const
Instruction & firstInstruction() const
Definition Program.cc:353
Instruction & lastInstruction() const
Definition Program.cc:463

References TTAProgram::Instruction::address(), TTAProgram::Program::firstInstruction(), TTAProgram::Program::lastInstruction(), TTAProgram::Address::location(), and program_.

Referenced by ProximDisassemblyGridTable::GetNumberRows().

Here is the call graph for this function:

◆ GetRowLabelValue()

wxString DisassemblyGridTable::GetRowLabelValue ( int  row)
virtual

Returns row label of a grid row.

Parameters
rowRow number.
Returns
Label for the grid row.

Definition at line 168 of file DisassemblyGridTable.cc.

168 {
169 return WxConversion::toWxString(row);
170}

References WxConversion::toWxString().

Here is the call graph for this function:

◆ GetValue()

wxString DisassemblyGridTable::GetValue ( int  row,
int  col 
)
virtual

Returns cell value as a wxString.

Parameters
rowRow of the cell.
colColumn of the cell.
Returns
Cell contents as a wxString.

Reimplemented in ProximDisassemblyGridTable.

Definition at line 121 of file DisassemblyGridTable.cc.

121 {
122
123 int busCount = program_->targetProcessor().busNavigator().count();
124
125 if (col == 0) {
126 wxString labels = WxConversion::toWxString("");
127 std::pair<LabelMap::iterator, LabelMap::iterator> range =
128 labels_.equal_range(row);
129 LabelMap::iterator firstEqual = range.first;
130 LabelMap::iterator lastEqual = range.second;
131 while (firstEqual != lastEqual) {
132 labels += WxConversion::toWxString(firstEqual->second)
134 firstEqual++;
135 }
136 return labels;
137 } else if (col > 0) {
138 Word address = (Word) row;
139 DisassemblyInstruction* disassembly =
141
142 wxString disasm;
143 if (col < (busCount + 1)) {
145 disassembly->move(col - 1).toString());
146 } else {
147 int immCount = static_cast<int>(disassembly->longImmediateCount());
148 if (col < (busCount + 1 + immCount)) {
150 disassembly->longImmediate(col - 1 - busCount).toString());
151 }
152 }
153 delete disassembly;
154 return disasm;
155 }
156
157 return _T("");
158}
LabelMap labels_
Program labels.
virtual std::string toString() const =0
DisassemblyInstructionSlot & move(Word index) const
DisassemblyImmediateAssignment & longImmediate(Word index) const
virtual DisassemblyInstruction * createInstruction(Word instructionIndex) const

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), POMDisassembler::createInstruction(), disassembler_, labels_, DisassemblyInstruction::longImmediate(), DisassemblyInstruction::longImmediateCount(), DisassemblyInstruction::move(), program_, TTAProgram::Program::targetProcessor(), DisassemblyImmediateAssignment::toString(), DisassemblyInstructionSlot::toString(), and WxConversion::toWxString().

Referenced by ProximDisassemblyGridTable::GetValue().

Here is the call graph for this function:

◆ IsEmptyCell()

bool DisassemblyGridTable::IsEmptyCell ( int  row,
int  col 
)
virtual

Returns true, if the given cell is empty, false otherwise.

Parameters
rowRow of the cell.
colColumn of the cell.
Returns
True, if the column is empty.

Definition at line 108 of file DisassemblyGridTable.cc.

108 {
109 return false;
110}

◆ loadProgram()

void DisassemblyGridTable::loadProgram ( const TTAProgram::Program program)

Loads a new program in the grid table.

Parameters
programProgram to load.

Definition at line 224 of file DisassemblyGridTable.cc.

224 {
225
226 program_ = &program;
227
228 if (disassembler_ != NULL) {
229 delete disassembler_;
230 }
231
233
234 labels_.clear();
235
236 const GlobalScope& gScope = program_->globalScopeConst();
237 int labelCount = gScope.globalCodeLabelCount();
238
239 for (int i = 0; i < labelCount; i++) {
240 const CodeLabel& codeLabel = gScope.globalCodeLabel(i);
241 unsigned address = codeLabel.address().location();
242 std::string label = codeLabel.name();
243 labels_.insert(std::pair<unsigned, string>(address, label));
244 }
245}
find Finds info of the inner loops in the program
virtual Address address() const
Definition CodeLabel.cc:101
const CodeLabel & globalCodeLabel(Address address, int index) const
int globalCodeLabelCount(Address address) const
std::string name() const
Definition Label.cc:74
const GlobalScope & globalScopeConst() const
Definition Program.cc:192

References TTAProgram::CodeLabel::address(), disassembler_, TTAProgram::GlobalScope::globalCodeLabel(), TTAProgram::GlobalScope::globalCodeLabelCount(), TTAProgram::Program::globalScopeConst(), labels_, TTAProgram::Address::location(), TTAProgram::Label::name(), program, and program_.

Referenced by ProximDisassemblyWindow::loadProgram().

Here is the call graph for this function:

◆ rowOfAddress()

int DisassemblyGridTable::rowOfAddress ( Word  address)

Returns row of the instruction with given address.

Parameters
addressAddress of the instruction.
Returns
Row of the instruction.

Definition at line 266 of file DisassemblyGridTable.cc.

266 {
267 return (int)address;
268}

Referenced by ProximDisassemblyWindow::showAddress().

◆ SetValue()

void DisassemblyGridTable::SetValue ( int  row,
int  col,
const wxString &  value 
)
virtual

Not implemented, use setCellValue() instead.

Definition at line 213 of file DisassemblyGridTable.cc.

213 {
214 // Do nothing.
215}

Member Data Documentation

◆ disassembler_

POMDisassembler* DisassemblyGridTable::disassembler_
private

Disassembler for generating instruction disassemblies.

Definition at line 74 of file DisassemblyGridTable.hh.

Referenced by GetValue(), loadProgram(), and ~DisassemblyGridTable().

◆ labels_

LabelMap DisassemblyGridTable::labels_
private

Program labels.

Definition at line 80 of file DisassemblyGridTable.hh.

Referenced by GetValue(), and loadProgram().

◆ program_

const TTAProgram::Program* DisassemblyGridTable::program_
protected

Program loaded in the table.

Definition at line 71 of file DisassemblyGridTable.hh.

Referenced by GetColLabelValue(), GetNumberCols(), GetNumberRows(), GetValue(), and loadProgram().


The documentation for this class was generated from the following files: