Skip to content

Commit

Permalink
feat: disallow eval br* ...
Browse files Browse the repository at this point in the history
use `jump` instead
  • Loading branch information
dxrcy committed Dec 18, 2024
1 parent 7db02df commit 499d26a
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/debugger/eval.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use miette::Result;

use crate::air::AsmLine;
use crate::air::{AirStmt, AsmLine};
use crate::runtime::RunState;
use crate::symbol::Span;
use crate::AsmParser;
use crate::{dprintln, AsmParser};

// TODO(feat): Warn on `eval br* ...` and suggest `jump ...`

Expand All @@ -23,6 +23,21 @@ pub fn eval(state: &mut RunState, line: String) {
fn eval_inner(state: &mut RunState, line: &'static str) -> Result<()> {
// Parse
let stmt = AsmParser::new_simple(line)?.parse_simple()?;
// Don't allow *condition* branch instructions
// Since CC is set to 0b000 at start, this could lead to confusion when `BR` instructions are
// not executed
match stmt {
AirStmt::Branch { .. } => {
dprintln!(
Always,
Error,
"Evaluation of `BR*` instructions is not supported."
);
dprintln!(Always, Error, "Consider using `jump` command instead.");
return Ok(());
}
_ => (),
}
// Check labels
let mut asm = AsmLine::new(0, stmt, Span::dummy());
asm.backpatch()?;
Expand Down

0 comments on commit 499d26a

Please sign in to comment.