Compare commits
4 Commits
c67217a6b8
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b18922cc7 | |||
| a0b02cb955 | |||
| 240f0e553f | |||
| 25a59a6b19 |
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"label": "Run Emulator",
|
||||
"command": "cargo run --bin emulator",
|
||||
"use_new_terminal": true,
|
||||
},
|
||||
{
|
||||
"label": "Run Compiler",
|
||||
"command": "cargo run --bin compiler",
|
||||
"use_new_terminal": true,
|
||||
},
|
||||
{
|
||||
"label": "Run Assembler",
|
||||
"command": "cargo run --bin assembler",
|
||||
"use_new_terminal": true,
|
||||
},
|
||||
{
|
||||
"label": "Run Build System (dsx-build)",
|
||||
"command": "cargo run --bin dsx-build",
|
||||
"use_new_terminal": true,
|
||||
},
|
||||
{
|
||||
"label": "Build All (Release)",
|
||||
"command": "cargo build --release",
|
||||
"use_new_terminal": false,
|
||||
},
|
||||
{
|
||||
"label": "Run Tests",
|
||||
"command": "cargo test",
|
||||
"use_new_terminal": true,
|
||||
},
|
||||
{
|
||||
"label": "Profile Emulator with perf",
|
||||
"command": "cargo build --profile profiling; perf record -g -F 999 target/profiling/emulator; perf script -F +pid | save test.perf",
|
||||
"use_new_terminal": true,
|
||||
},
|
||||
]
|
||||
@@ -83,7 +83,7 @@ impl MemoryUnit for MainStore {
|
||||
|
||||
#[inline]
|
||||
fn read_word(&mut self, addr: u32) -> Result<u32, ProcessorError> {
|
||||
if addr % 4 != 0 {
|
||||
if !addr.is_multiple_of(4) {
|
||||
return Err(ProcessorError::BadMemoryAccess(addr));
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ impl MemoryUnit for MainStore {
|
||||
|
||||
#[inline]
|
||||
fn write_word(&mut self, addr: u32, value: u32) -> Result<(), ProcessorError> {
|
||||
if addr % 4 != 0 {
|
||||
if !addr.is_multiple_of(4) {
|
||||
return Err(ProcessorError::BadMemoryAccess(addr));
|
||||
}
|
||||
|
||||
|
||||
@@ -290,7 +290,6 @@ impl RegFile {
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn get(&self, reg: Register) -> Result<u32, ProcessorError> {
|
||||
Ok(match reg {
|
||||
Register::Rg0 => self.rg0,
|
||||
|
||||
@@ -21,10 +21,6 @@ pub struct Processor {
|
||||
pub cache: Cache,
|
||||
}
|
||||
|
||||
fn log(message: &str) {
|
||||
println!("\x1b[32mINFO:\x1b[0m {message}");
|
||||
}
|
||||
|
||||
impl Processor {
|
||||
#[must_use]
|
||||
pub fn new(memory: Box<dyn MemoryUnit>, io_devices: Vec<Arc<dyn IODevice>>) -> Self {
|
||||
|
||||
@@ -464,7 +464,7 @@ fn test_shift_left_with_shamt() {
|
||||
let shl_instr = Instruction::ShiftLeft(RTypeArgs::new(
|
||||
Some(Register::Rg1),
|
||||
Some(Register::Zero),
|
||||
None,
|
||||
Some(Register::Rg1),
|
||||
Some(2),
|
||||
));
|
||||
|
||||
@@ -485,7 +485,7 @@ fn test_shift_right_with_shamt() {
|
||||
let shr_instr = Instruction::ShiftRight(RTypeArgs::new(
|
||||
Some(Register::Rg1),
|
||||
Some(Register::Zero),
|
||||
None,
|
||||
Some(Register::Rg1),
|
||||
Some(2),
|
||||
));
|
||||
|
||||
|
||||
@@ -117,10 +117,7 @@ impl Editor {
|
||||
.file_name()
|
||||
.unwrap_or_else(|| OsStr::new("Unnamed!"))
|
||||
.to_str()
|
||||
.map_or_else(
|
||||
|| unreachable!("File name should be valid UTF-8."),
|
||||
|ext| ext,
|
||||
);
|
||||
.unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|
||||
}
|
||||
"Unnamed!"
|
||||
}
|
||||
@@ -129,12 +126,9 @@ impl Editor {
|
||||
if let Some(path) = &self.path {
|
||||
return path
|
||||
.extension()
|
||||
.map_or_else(|| OsStr::new("Unknown!"), |ext| ext)
|
||||
.unwrap_or_else(|| OsStr::new("Unknown!"))
|
||||
.to_str()
|
||||
.map_or_else(
|
||||
|| unreachable!("File name should be valid UTF-8."),
|
||||
|ext| ext,
|
||||
);
|
||||
.unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|
||||
}
|
||||
"Unknown!"
|
||||
}
|
||||
@@ -398,7 +392,7 @@ impl Editor {
|
||||
_ => Syntax::default(),
|
||||
};
|
||||
|
||||
let ed = CodeEditor::default()
|
||||
let mut editor = CodeEditor::default()
|
||||
.id_source("editor")
|
||||
.with_fontsize(12.0)
|
||||
.with_rows(0)
|
||||
@@ -407,8 +401,6 @@ impl Editor {
|
||||
.with_numlines(true)
|
||||
.desired_width(available_width - 500.0);
|
||||
|
||||
let mut editor = ed.clone();
|
||||
|
||||
editor.show(ui, &mut self.text);
|
||||
}
|
||||
|
||||
@@ -451,7 +443,7 @@ impl Editor {
|
||||
Some("dsc") => {
|
||||
let output_path = Path::new(path).with_extension("dsa");
|
||||
if let Err(e) = compiler::compile_file(path, &output_path) {
|
||||
self.error = Some(format!("Compiler error: {}", e));
|
||||
self.error = Some(format!("Compiler error: {e}"));
|
||||
}
|
||||
|
||||
let mut compiler = CompilerEngine::new();
|
||||
@@ -461,7 +453,7 @@ impl Editor {
|
||||
let instructions = match compiler.wait_for_result() {
|
||||
Ok(instructions) => instructions,
|
||||
Err(e) => {
|
||||
self.error = Some(format!("Assembler error: {}", e));
|
||||
self.error = Some(format!("Assembler error: {e}"));
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -79,10 +79,7 @@ impl Loader {
|
||||
.file_name()
|
||||
.unwrap_or_else(|| OsStr::new("Unnamed!"))
|
||||
.to_str()
|
||||
.map_or_else(
|
||||
|| unreachable!("File name should be valid UTF-8."),
|
||||
|ext| ext,
|
||||
);
|
||||
.unwrap_or_else(|| unreachable!("File name should be valid UTF-8."));
|
||||
}
|
||||
"Unnamed!"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user