Skip to content

Commit

Permalink
fix #169: fix issues related to propagation of errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hlorenzi committed Jul 2, 2023
1 parent f3247a0 commit bbdbef9
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "customasm"
version = "0.13.1"
version = "0.13.2"
edition = "2021"
authors = ["hlorenzi <https://hlorenzi.com>"]
description = "An assembler for custom, user-defined instruction sets!"
Expand Down
4 changes: 4 additions & 0 deletions src/asm/resolver/eval_asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ pub fn eval_asm(
&encodings[0].1,
(size, 0));
}
else if !ctx.can_guess()
{
return Err(());
}
}

else
Expand Down
5 changes: 5 additions & 0 deletions src/asm/resolver/instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,11 @@ fn resolve_instruction_match_inner(
ctx,
arg_eval_ctx)?;

if arg_value.should_propagate()
{
return Ok(arg_value);
}

let param = &rule.parameters[index];

eval_ctx.set_local(
Expand Down
2 changes: 1 addition & 1 deletion tests/expr_asm/err_multiple_matches.asm
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
test {x} => asm { emit {x} }
}

test 0x12 ; error: failed / note:_:5: within / error:_:5: multiple / note:_:3: match / note:_:4: match / error: did not converge
test 0x12 ; error: failed / note:_:5: within / error:_:5: multiple / note:_:3: match / note:_:4: match
16 changes: 16 additions & 0 deletions tests/issue169/err1.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#subruledef subtest
{
{x: s32} =>
{
assert(x > 0)
assert(x < 10)
x
}
}
#ruledef test
{
test {s: s32} => s
testasm {a: subtest} => asm{test {a}}
}

testasm 121 ; error: failed / note:_:13: within / note:_:3: within / error:_:6: assertion
24 changes: 24 additions & 0 deletions tests/issue169/err2.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#subruledef cpu6502_reladdr
{
{addr: u16} =>
{
reladdr = addr - $ - 2
assert(reladdr <= 0x7f)
assert(reladdr >= !0x7f)
reladdr`8
}
}

#ruledef cpu6502
{
bcc {addr: cpu6502_reladdr} => 0x90 @ addr
}

#ruledef cpu6502_macro
{
bccmacro {addr: cpu6502_reladdr} => asm{bcc {addr}}
}

bcc 120
bccmacro 16384 ; error: failed / note:_:19: within / note:_:3: within / error:_:6: assertion
bcc 120

0 comments on commit bbdbef9

Please sign in to comment.