OpenASIP  2.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
DisassemblyInstruction Class Reference

#include <DisassemblyInstruction.hh>

Collaboration diagram for DisassemblyInstruction:
Collaboration graph

Public Member Functions

 DisassemblyInstruction ()
 
 ~DisassemblyInstruction ()
 
Word moveCount () const
 
void addMove (DisassemblyInstructionSlot *move)
 
DisassemblyInstructionSlotmove (Word index) const
 
Word longImmediateCount () const
 
void addLongImmediate (DisassemblyImmediateAssignment *longImm)
 
DisassemblyImmediateAssignmentlongImmediate (Word index) const
 
std::string toString () const
 
DisassemblyAnnotationannotation (int index) const
 
void addAnnotation (DisassemblyAnnotation *annotation)
 
int annotationCount () const
 

Private Types

typedef std::vector< DisassemblyInstructionSlot * > MoveTable
 Vector of DisassemblyMoves. More...
 
typedef std::vector< DisassemblyImmediateAssignment * > LongImmediateTable
 Vector of DisassemblyMoves. More...
 

Private Member Functions

 DisassemblyInstruction (const DisassemblyInstruction &)
 Copying not allowed. More...
 
DisassemblyInstruction operator= (const DisassemblyInstruction &)
 Assignment not allowed. More...
 

Private Attributes

MoveTable moves_
 List of instruction moves. More...
 
LongImmediateTable longImmediates_
 List of instruction long immediates. More...
 
std::vector< DisassemblyAnnotation * > annotations_
 Annotationes of instruction itself. More...
 

Detailed Description

Represents an instruction in the disassembler.

Definition at line 46 of file DisassemblyInstruction.hh.

Member Typedef Documentation

◆ LongImmediateTable

Vector of DisassemblyMoves.

Definition at line 70 of file DisassemblyInstruction.hh.

◆ MoveTable

Vector of DisassemblyMoves.

Definition at line 67 of file DisassemblyInstruction.hh.

Constructor & Destructor Documentation

◆ DisassemblyInstruction() [1/2]

DisassemblyInstruction::DisassemblyInstruction ( )

Constructor.

Definition at line 39 of file DisassemblyInstruction.cc.

39  {
40 }

◆ ~DisassemblyInstruction()

DisassemblyInstruction::~DisassemblyInstruction ( )

Destructor.

Definition at line 46 of file DisassemblyInstruction.cc.

46  {
47  // Delete all moves of the instruction.
49 }

References SequenceTools::deleteAllItems(), and moves_.

Here is the call graph for this function:

◆ DisassemblyInstruction() [2/2]

DisassemblyInstruction::DisassemblyInstruction ( const DisassemblyInstruction )
private

Copying not allowed.

Member Function Documentation

◆ addAnnotation()

void DisassemblyInstruction::addAnnotation ( DisassemblyAnnotation annotation)

Adds an annotation to instruction.

Parameters
annotationAnnotation to add.

Definition at line 175 of file DisassemblyInstruction.cc.

175  {
176  annotations_.push_back(annotation);
177 }

References annotation(), and annotations_.

Referenced by TPEFDisassembler::createInstruction().

Here is the call graph for this function:

◆ addLongImmediate()

void DisassemblyInstruction::addLongImmediate ( DisassemblyImmediateAssignment longImm)

Adds a long immediate to the instruction.

Parameters
longImmImmediate to be added.

Definition at line 96 of file DisassemblyInstruction.cc.

97  {
98 
99  longImmediates_.push_back(longImm);
100 }

References longImmediates_.

Referenced by TPEFDisassembler::createInstruction(), POMDisassembler::createInstruction(), and POMDisassembler::disassemble().

◆ addMove()

void DisassemblyInstruction::addMove ( DisassemblyInstructionSlot move)

Adds a move to the instruction.

Parameters
moveMove to be added.

Definition at line 58 of file DisassemblyInstruction.cc.

58  {
59  moves_.push_back(move);
60 }

References move(), and moves_.

Referenced by TPEFDisassembler::createInstruction(), POMDisassembler::createInstruction(), and POMDisassembler::disassemble().

Here is the call graph for this function:

◆ annotation()

DisassemblyAnnotation & DisassemblyInstruction::annotation ( int  index) const

Returns annotation of requested index.

Parameters
indexIndex of annotation to return.
Returns
Annotation of requested index.

Definition at line 165 of file DisassemblyInstruction.cc.

165  {
166  return *(annotations_.at(index));
167 }

References annotations_.

Referenced by addAnnotation(), and toString().

◆ annotationCount()

int DisassemblyInstruction::annotationCount ( ) const

Returns the number of annotationes stored for the instruction.

Returns
The number of annotationes stored for the instruction.

Definition at line 185 of file DisassemblyInstruction.cc.

185  {
186  return static_cast<int>(annotations_.size());
187 }

References annotations_.

Referenced by toString().

◆ longImmediate()

DisassemblyImmediateAssignment & DisassemblyInstruction::longImmediate ( Word  index) const

Returns the long immediate at a given index.

Parameters
indexIndex of the long immediate.
Returns
The long immediate at the index.
Exceptions
OutOfRangeIf the give index is out of range.

Definition at line 122 of file DisassemblyInstruction.cc.

122  {
123  if (index >= longImmediateCount()) {
124  throw OutOfRange(__FILE__, __LINE__, __func__);
125  }
126  return *longImmediates_[index];
127 }

References __func__, longImmediateCount(), and longImmediates_.

Referenced by DisassemblyGridTable::GetValue(), and toString().

Here is the call graph for this function:

◆ longImmediateCount()

Word DisassemblyInstruction::longImmediateCount ( ) const

Returns number of long immediates in the instruction.

Returns
Instruction's long immediate count.

Definition at line 109 of file DisassemblyInstruction.cc.

109  {
110  return longImmediates_.size();
111 }

References longImmediates_.

Referenced by DisassemblyGridTable::GetValue(), longImmediate(), and toString().

◆ move()

DisassemblyInstructionSlot & DisassemblyInstruction::move ( Word  index) const

Returns the isntruction move at a given index.

Parameters
indexIndex of the move.
Returns
The move at the index.
Exceptions
OutOfRangeIf the give index is out of range.

Definition at line 82 of file DisassemblyInstruction.cc.

82  {
83  if (index >= moveCount()) {
84  std::string procName = "DisassemblyInstruction::move";
85  throw OutOfRange(__FILE__, __LINE__, procName);
86  }
87  return *moves_[index];
88 }

References moveCount(), and moves_.

Referenced by addMove(), DisassemblyGridTable::GetValue(), and toString().

Here is the call graph for this function:

◆ moveCount()

Word DisassemblyInstruction::moveCount ( ) const

Returns number of moves in the instruction.

Returns
Instruction move count.

Definition at line 69 of file DisassemblyInstruction.cc.

69  {
70  return moves_.size();
71 }

References moves_.

Referenced by move(), and toString().

◆ operator=()

DisassemblyInstruction DisassemblyInstruction::operator= ( const DisassemblyInstruction )
private

Assignment not allowed.

◆ toString()

std::string DisassemblyInstruction::toString ( ) const

Returns disassembly of the instruction.

Returns
Disassembly of the instruction as a string.

Definition at line 135 of file DisassemblyInstruction.cc.

135  {
136  std::string disassembly;
137  for (Word i = 0; i < moveCount(); i++) {
138  if (i > 0) {
139  disassembly = disassembly + ", ";
140  }
141  disassembly = disassembly + move(i).toString();
142  }
143 
144  for (Word i = 0; i < longImmediateCount(); i++) {
145 
146  disassembly = disassembly + " " + longImmediate(i).toString();
147  }
148 
149  for (int i = 0; i < annotationCount(); i++) {
150  disassembly += annotation(i).toString();
151  }
152 
153  disassembly = disassembly + " ;";
154  return disassembly;
155 }

References annotation(), annotationCount(), longImmediate(), longImmediateCount(), move(), moveCount(), DisassemblyInstructionSlot::toString(), DisassemblyAnnotation::toString(), and DisassemblyImmediateAssignment::toString().

Referenced by POMDisassembler::disassemble(), and TPEFDumper::section().

Here is the call graph for this function:

Member Data Documentation

◆ annotations_

std::vector<DisassemblyAnnotation*> DisassemblyInstruction::annotations_
private

Annotationes of instruction itself.

Definition at line 84 of file DisassemblyInstruction.hh.

Referenced by addAnnotation(), annotation(), and annotationCount().

◆ longImmediates_

LongImmediateTable DisassemblyInstruction::longImmediates_
private

List of instruction long immediates.

Definition at line 81 of file DisassemblyInstruction.hh.

Referenced by addLongImmediate(), longImmediate(), and longImmediateCount().

◆ moves_

MoveTable DisassemblyInstruction::moves_
private

List of instruction moves.

Definition at line 78 of file DisassemblyInstruction.hh.

Referenced by addMove(), move(), moveCount(), and ~DisassemblyInstruction().


The documentation for this class was generated from the following files:
DisassemblyInstruction::longImmediateCount
Word longImmediateCount() const
Definition: DisassemblyInstruction.cc:109
DisassemblyInstruction::annotation
DisassemblyAnnotation & annotation(int index) const
Definition: DisassemblyInstruction.cc:165
OutOfRange
Definition: Exception.hh:320
DisassemblyInstruction::annotations_
std::vector< DisassemblyAnnotation * > annotations_
Annotationes of instruction itself.
Definition: DisassemblyInstruction.hh:84
DisassemblyInstruction::moves_
MoveTable moves_
List of instruction moves.
Definition: DisassemblyInstruction.hh:78
DisassemblyAnnotation::toString
virtual std::string toString() const
Definition: DisassemblyAnnotation.cc:61
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
DisassemblyInstruction::annotationCount
int annotationCount() const
Definition: DisassemblyInstruction.cc:185
__func__
#define __func__
Definition: Application.hh:67
DisassemblyImmediateAssignment::toString
virtual std::string toString() const
Definition: DisassemblyImmediateAssignment.cc:67
DisassemblyInstruction::move
DisassemblyInstructionSlot & move(Word index) const
Definition: DisassemblyInstruction.cc:82
DisassemblyInstructionSlot::toString
virtual std::string toString() const =0
DisassemblyInstruction::moveCount
Word moveCount() const
Definition: DisassemblyInstruction.cc:69
DisassemblyInstruction::longImmediate
DisassemblyImmediateAssignment & longImmediate(Word index) const
Definition: DisassemblyInstruction.cc:122
DisassemblyInstruction::longImmediates_
LongImmediateTable longImmediates_
List of instruction long immediates.
Definition: DisassemblyInstruction.hh:81