Skip to content

Commit

Permalink
Update executed line + hex editor line on continuous execution
Browse files Browse the repository at this point in the history
  • Loading branch information
cayb0rg committed Mar 27, 2024
1 parent 94a7eef commit a4a3519
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 0 additions & 1 deletion src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use swim::agent::datapath_reducer::DatapathReducer;
use swim::agent::EmulationCoreAgent;
use swim::emulation_core::mips::datapath::Stage;
use swim::parser::parser_assembler_main::parser;
use swim::parser::parser_structs_and_enums::LabelInstance;
use swim::parser::parser_structs_and_enums::ProgramInfo;
use swim::ui::footer::component::Footer;
use swim::ui::regview::component::Regview;
Expand Down
6 changes: 5 additions & 1 deletion src/ui/hex_editor/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ pub fn hex_editor(props: &HexEditorProps) -> Html {
}

let on_editor_created = {
let memory_curr_instr = props.memory_curr_instr.clone();
let datapath_state = props.datapath_state.clone();
memory_curr_instr.set(datapath_state.mips.registers.pc);

use_callback(
move |editor_link: CodeEditorLink,
(datapath_state, memory_text_model, memory_curr_instr)| {
Expand All @@ -156,7 +160,7 @@ pub fn hex_editor(props: &HexEditorProps) -> Html {
let raw_editor = editor.as_ref();
let cb_func = &cb.as_ref().unchecked_ref();

let coords = get_hex_coords(*memory_curr_instr);
let coords = get_hex_coords(**memory_curr_instr);
raw_editor.on_did_change_cursor_selection(cb_func);
raw_editor.reveal_line_in_center(coords.line_number, Some(ScrollType::Smooth));

Expand Down
6 changes: 6 additions & 0 deletions src/ui/swim_editor/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ use yew::prelude::*;
use yew::{html, Callback, Properties};
use yew_hooks::prelude::*;

use crate::agent::datapath_reducer::DatapathReducer;
use crate::emulation_core::mips::memory::Memory;
use crate::emulation_core::mips::stack::Stack;
use crate::ui::assembled_view::component::{StackFrameView, StackSegment};
Expand Down Expand Up @@ -105,8 +106,13 @@ pub fn SwimEditor(props: &SwimEditorProps) -> Html {

let on_editor_created = {
let curr_line = props.editor_curr_line.clone();
let program_info = props.program_info.clone();
let lines_content = Rc::clone(&props.lines_content);

let list_of_line_numbers = program_info.address_to_line_number;
let index = props.pc as usize / 4;
curr_line.set(*list_of_line_numbers.get(index).unwrap_or(&0) as f64 + 1.0); // add one to account for the editor's line numbers

use_callback(
move |editor_link: CodeEditorLink, curr_line| {
match editor_link.with_editor(|editor| {
Expand Down

0 comments on commit a4a3519

Please sign in to comment.