OpenASIP  2.0
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. More...
 

Private Types

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

Private Attributes

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

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 }

◆ ~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().

◆ 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 }

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 }

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 }

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)) {
144  disasm = WxConversion::toWxString(
145  disassembly->move(col - 1).toString());
146  } else {
147  int immCount = static_cast<int>(disassembly->longImmediateCount());
148  if (col < (busCount + 1 + immCount)) {
149  disasm = WxConversion::toWxString(
150  disassembly->longImmediate(col - 1 - busCount).toString());
151  }
152  }
153  delete disassembly;
154  return disasm;
155  }
156 
157  return _T("");
158 }

References TTAMachine::Machine::busNavigator(), TTAMachine::Machine::Navigator< ComponentType >::count(), POMDisassembler::createInstruction(), disassembler_, labels_, DisassemblyInstruction::longImmediate(), DisassemblyInstruction::longImmediateCount(), DisassemblyInstruction::move(), program_, TTAProgram::Program::targetProcessor(), DisassemblyInstructionSlot::toString(), DisassemblyImmediateAssignment::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 }

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

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 }

◆ 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:
TTAProgram::Program::firstInstruction
Instruction & firstInstruction() const
Definition: Program.cc:353
WxConversion::toWxString
static wxString toWxString(const std::string &source)
DisassemblyInstruction::longImmediateCount
Word longImmediateCount() const
Definition: DisassemblyInstruction.cc:109
DisassemblyGridTable::labels_
LabelMap labels_
Program labels.
Definition: DisassemblyGridTable.hh:80
TTAMachine::Machine::Navigator::count
int count() const
TTAProgram::GlobalScope::globalCodeLabelCount
int globalCodeLabelCount(Address address) const
Definition: GlobalScope.cc:93
TTAProgram::CodeLabel::address
virtual Address address() const
Definition: CodeLabel.cc:101
Conversion::toString
static std::string toString(const T &source)
TTAProgram::Program::globalScopeConst
const GlobalScope & globalScopeConst() const
Definition: Program.cc:192
TTAProgram::Label::name
std::string name() const
Definition: Label.cc:74
POMDisassembler
Definition: POMDisassembler.hh:70
TTAProgram::CodeLabel
Definition: CodeLabel.hh:49
TTAProgram::GlobalScope
Definition: GlobalScope.hh:47
TTAProgram::Address::location
InstructionAddress location() const
DisassemblyImmediateAssignment::toString
virtual std::string toString() const
Definition: DisassemblyImmediateAssignment.cc:67
TTAMachine::Machine::immediateSlotNavigator
virtual ImmediateSlotNavigator immediateSlotNavigator() const
Definition: Machine.cc:462
TTAMachine::Machine::busNavigator
virtual BusNavigator busNavigator() const
Definition: Machine.cc:356
TTAProgram::Program::targetProcessor
TTAMachine::Machine & targetProcessor() const
Definition: Program.cc:202
DisassemblyGridTable::program_
const TTAProgram::Program * program_
Program loaded in the table.
Definition: DisassemblyGridTable.hh:71
TTAProgram::GlobalScope::globalCodeLabel
const CodeLabel & globalCodeLabel(Address address, int index) const
Definition: GlobalScope.cc:118
TTAMachine::Machine::Navigator::item
ComponentType * item(int index) const
DisassemblyInstruction::move
DisassemblyInstructionSlot & move(Word index) const
Definition: DisassemblyInstruction.cc:82
program
find Finds info of the inner loops in the program
Definition: InnerLoopFinder.cc:80
TTAProgram::Program::lastInstruction
Instruction & lastInstruction() const
Definition: Program.cc:463
DisassemblyGridTable::disassembler_
POMDisassembler * disassembler_
Disassembler for generating instruction disassemblies.
Definition: DisassemblyGridTable.hh:74
DisassemblyInstructionSlot::toString
virtual std::string toString() const =0
DisassemblyInstruction::longImmediate
DisassemblyImmediateAssignment & longImmediate(Word index) const
Definition: DisassemblyInstruction.cc:122
TTAMachine::Machine::Navigator
Definition: Machine.hh:186
TTAProgram::Instruction::address
Address address() const
Definition: Instruction.cc:327
DisassemblyInstruction
Definition: DisassemblyInstruction.hh:46
POMDisassembler::createInstruction
virtual DisassemblyInstruction * createInstruction(Word instructionIndex) const
Definition: POMDisassembler.cc:137