![]() |
KoMo2
1.0.0
A modern ARM emulator GUI.
|
The declaration of the DisassemblyModel class. More...
#include <DisassemblyModel.h>
Public Member Functions | |
| DisassemblyModel (DisassemblyView *const view, KoMo2Model *const parent) | |
| Construct a new DisassemblyModel::DisassemblyModel object. More... | |
| void | refreshViews () |
| Refreshes the values in the views to display the new values fetched from Jimulator. | |
| DisassemblyView *const | getView () |
| Returns a pointer to the view object. More... | |
| void | setPCValue (const std::string val) |
| Updates the value of PCValue. More... | |
| virtual void | changeJimulatorState (const JimulatorState newState) override |
| Handles changes of Jimulator state. More... | |
| virtual const bool | handleKeyPress (const GdkEventKey *const e) override |
| Handles any key press events. More... | |
| void | setEnglishMnemonic (const bool val) |
| Set the value of the englishMnemonic member variable. More... | |
Private Member Functions | |
| const std::string | intToFormattedHexString (const uint32_t formatMe) const |
| Converts a fixed width 32-bit integer to a hex string, padded with 0's to 8 characters, pre-fixed with "0x", and raised to all capitals. More... | |
| const bool | handleScroll (GdkEventScroll *const e) |
| Handles the scroll events. More... | |
| void | incrementMemoryIndex (const uint32_t val) |
Updates the list pointers to a new value. Val is multipled by 4 - for example, if val is 1, memoryIndex is incremented by 4, as this is the gap between memory registers. More... | |
| void | addScrollRecognition () |
Adds scroll recognition to the container object, which causes scroll events to be sent to the member function handleScroll. | |
| const std::array< Jimulator::MemoryValues, 13 > | getMemoryValues () const |
| Reads memory values from Jimulator. More... | |
| void | onBreakpointToggle (DisassemblyRows *const row) |
Handle the toggling of a breakpoint within the DisassemblyView. More... | |
| void | setupButtonHandlers () |
| Adds button handlers to every breakpoint button. | |
| void | updateCSSFlags (const Gtk::StateFlags state, DisassemblyRows &row, const uint32_t address) |
| Handles setting the CSS flags for each disassembly row, which determines which CSS class it uses and therefore how it looks. More... | |
| const std::string | buildDisassemblyRowAccessibilityString (DisassemblyRows &val) |
| Generates the string to set for the accessibility model. More... | |
| const std::string | convertMnemonicToEnglish (const std::string mnemonic) const |
| Converts a mnemonic into plain English. More... | |
| const std::string | sanitizeParamters (std::string param) const |
| Sanitizes any of the paramters used with an ARM mnemonic. More... | |
| const std::string | toLowerCase (std::string s) const |
| Converts a string to lower case. More... | |
| const std::vector< std::string > | parseDEFB (std::vector< std::string > v) const |
| Parses the DEFB ARM mnemonic - since a single ARM command is broken into a vector by the spaces between strings, the string that the DEFB command defines will be split across several vector indexes. This function packs this string back into a single index of the vector. More... | |
| const std::vector< std::string > | parseSWI (std::vector< std::string > m) const |
Parses the SWI ARM mnemonic - the SWI command always takes 1 paramter, but means very different things depending on the parameter, meaning that a single entry in mnemonicsMap for the SWI command cannot work. This function packs the paramter of the SWI command in with the SWI key word for easier lookup in the map, if the first key word in the vector is SWI. More... | |
| const std::pair< std::vector< std::string >, std::string > | parseLabel (std::vector< std::string > m) const |
| Parses labels from an ARM command. If the first index in the vector is not a recognised keyword, then it must be a label. This function defines an initial string that is only defined if the first index is a label. It then updates the vector such that upon returning, the first index is the keyword. It returns this parsed vector along with the new output text. More... | |
| const std::string | buildMnemonicString (std::string s, std::vector< std::string > m) const |
| Builds the output mnemonics string from the vector making up the current ARM command and the value read from the map. See the comment for mnemonicMap for details on the syntax of the value read from the map. More... | |
| DisassemblyModel (const DisassemblyModel &)=delete | |
| DisassemblyModel (const DisassemblyModel &&)=delete | |
| DisassemblyModel & | operator= (const DisassemblyModel &)=delete |
| DisassemblyModel & | operator= (const DisassemblyModel &&)=delete |
Private Member Functions inherited from Model | |
| Model (KoMo2Model *const parent) | |
| Constructs a new Model object - just assigns the parent variable. More... | |
| KoMo2Model *const | getParent () const |
| Returns the parent pointer. More... | |
| template<class T1 , class T2 > | |
| void | setButtonListener (Gtk::Button *const button, const T1 b, const T2 c) |
| Connect any button to any member function of. More... | |
| void | setButtonState (Gtk::Button *const button, const bool state, Gtk::Image *const img=nullptr, const std::string newTooltip="", const std::string newLabelText="") const |
Sets the state of a button to some boolean - the assumption is that if a button is not meant to be sensitive (get_sensitive() == false) then it should also not have a tooltip or many other attributes. You can also optionally update the buttons image, tooltip text, and label text. More... | |
| JimulatorState | getJimulatorState () const |
| Return the jimulatorState member object. More... | |
Private Attributes | |
| DisassemblyView *const | view |
| The view this model represents. | |
| std::string | PCValue = "0x00000000" |
| Stores the value currently in the program counter. | |
| const Gtk::StateFlags | NORMAL = Gtk::STATE_FLAG_DIR_LTR |
| The CSS state flags for an un-highlighted memory row. | |
| const Gtk::StateFlags | PC_ADDRESS |
| The CSS state flags for if the memory row is currently stored in the Program Counter. More... | |
| const Gtk::StateFlags | FOCUSED |
| The CSS state flags for a memory row that has keyboard focus. More... | |
| const Gtk::StateFlags | PC_ADDRESS_FOCUSED |
| The CSS state flags for e memory row that has keyboard focus and is currently stored in the Program Counter. More... | |
| const std::unordered_map< std::string, std::string > | mnemonicsMap |
| A map pairing ARM mnemonic commands with the English translation string associated with them for the screenreader. For ARM commands that take paramters, the English equivalent string has a paramter notation that is regexed away. This notation is: ?'paramter_number'?. More... | |
| bool | englishMnemonic = false |
| Whether or not ARM mnemonics should be read in English when being read by a screenreader, or if they should be left as ARM mnemonics. | |
Static Private Attributes | |
| static uint32_t | memoryIndex = 0 |
| Fixed width integer representing the memory address of the view at the top of the container. | |
The declaration of the DisassemblyModel class.
Definition at line 23 of file DisassemblyModel.h.
| DisassemblyModel::DisassemblyModel | ( | DisassemblyView *const | view, |
| KoMo2Model *const | parent | ||
| ) |
Construct a new DisassemblyModel::DisassemblyModel object.
| view | A pointer to the view object, set at initialisation. |
| parent | A pointer to the parent object, set at initialisation. |
Definition at line 26 of file DisassemblyModel.cpp.
|
private |
Generates the string to set for the accessibility model.
| row | The row to build to accessibility string from. |
Definition at line 143 of file DisassemblyModel.cpp.
|
private |
Builds the output mnemonics string from the vector making up the current ARM command and the value read from the map. See the comment for mnemonicMap for details on the syntax of the value read from the map.
| s | The value read from the map. |
| m | The vector making up the current ARM command. |
Definition at line 283 of file DisassemblyModel.cpp.
|
overridevirtual |
Handles changes of Jimulator state.
| newState | The state Jimulator has changed into. |
Implements Model.
Definition at line 374 of file DisassemblyModel.cpp.
|
private |
Converts a mnemonic into plain English.
| mnemonic | An ARM instruction mnemonic. |
Definition at line 170 of file DisassemblyModel.cpp.
|
private |
Reads memory values from Jimulator.
Definition at line 474 of file DisassemblyModel.cpp.
| DisassemblyView *const DisassemblyModel::getView | ( | ) |
Returns a pointer to the view object.
Definition at line 464 of file DisassemblyModel.cpp.
|
overridevirtual |
Handles any key press events.
| e | The key press event. |
Implements Model.
Definition at line 381 of file DisassemblyModel.cpp.
|
private |
Handles the scroll events.
| e | The key press event. |
Definition at line 75 of file DisassemblyModel.cpp.
|
private |
Updates the list pointers to a new value. Val is multipled by 4 - for example, if val is 1, memoryIndex is incremented by 4, as this is the gap between memory registers.
| val | The value to increment by. |
Definition at line 364 of file DisassemblyModel.cpp.
|
private |
Converts a fixed width 32-bit integer to a hex string, padded with 0's to 8 characters, pre-fixed with "0x", and raised to all capitals.
| formatMe | The integer to be formatted. |
Definition at line 102 of file DisassemblyModel.cpp.
|
private |
Handle the toggling of a breakpoint within the DisassemblyView.
| row | The row which has had it's breakpoint toggled. Row id's are a direct index - the first row is 0, the last row is 11 - so we can combine the row ID with the memoryIndex variable to identify what address the breakpoint should be set at. |
Definition at line 41 of file DisassemblyModel.cpp.
|
private |
Parses the DEFB ARM mnemonic - since a single ARM command is broken into a vector by the spaces between strings, the string that the DEFB command defines will be split across several vector indexes. This function packs this string back into a single index of the vector.
| m | The vector of strings making up the current ARM command. |
Definition at line 209 of file DisassemblyModel.cpp.
|
private |
Parses labels from an ARM command. If the first index in the vector is not a recognised keyword, then it must be a label. This function defines an initial string that is only defined if the first index is a label. It then updates the vector such that upon returning, the first index is the keyword. It returns this parsed vector along with the new output text.
| m | The vector of strings making up the current ARM command. |
Definition at line 255 of file DisassemblyModel.cpp.
|
private |
Parses the SWI ARM mnemonic - the SWI command always takes 1 paramter, but means very different things depending on the parameter, meaning that a single entry in mnemonicsMap for the SWI command cannot work. This function packs the paramter of the SWI command in with the SWI key word for easier lookup in the map, if the first key word in the vector is SWI.
| m | The vector of strings making up the current ARM command. |
Definition at line 235 of file DisassemblyModel.cpp.
|
private |
Sanitizes any of the paramters used with an ARM mnemonic.
| param | The parameter to be sanitized. |
Definition at line 301 of file DisassemblyModel.cpp.
| void DisassemblyModel::setEnglishMnemonic | ( | const bool | val | ) |
Set the value of the englishMnemonic member variable.
| val | The value to set englishMnemonic to. |
Definition at line 488 of file DisassemblyModel.cpp.
| void DisassemblyModel::setPCValue | ( | const std::string | val | ) |
Updates the value of PCValue.
| val | The value to set PCValue to. |
Definition at line 481 of file DisassemblyModel.cpp.
|
private |
Converts a string to lower case.
| s | The string to convert to lower case. |
Definition at line 316 of file DisassemblyModel.cpp.
|
private |
Handles setting the CSS flags for each disassembly row, which determines which CSS class it uses and therefore how it looks.
| flag | The current CSS state of the memory row. |
| row | The current memory row. |
| address | The address of the current memory row. |
Definition at line 331 of file DisassemblyModel.cpp.
|
private |
The CSS state flags for a memory row that has keyboard focus.
Definition at line 67 of file DisassemblyModel.h.
|
private |
A map pairing ARM mnemonic commands with the English translation string associated with them for the screenreader. For ARM commands that take paramters, the English equivalent string has a paramter notation that is regexed away. This notation is: ?'paramter_number'?.
For example, in the command "ADD R1, R2, R3", R1 is paramter 1, R2 is paramter 2, R3 is paramter 3. So the associated English string "Add ?3? to ?2? and store in ?1?" swaps ?1? with R1, ?2? with R2, and ?3? with R3, to result in the string "Add R3 to R2 and store in R1."
Definition at line 90 of file DisassemblyModel.h.
|
private |
The CSS state flags for if the memory row is currently stored in the Program Counter.
Definition at line 61 of file DisassemblyModel.h.
|
private |
The CSS state flags for e memory row that has keyboard focus and is currently stored in the Program Counter.
Definition at line 74 of file DisassemblyModel.h.
1.8.11