diff options
| -rw-r--r-- | lib/xixanta/src/object.rs | 13 | ||||
| -rwxr-xr-x | scripts/test-e2e.sh | 7 | ||||
| -rw-r--r-- | tests/expected/unused_macro_arg.nes | bin | 0 -> 27 bytes | |||
| -rw-r--r-- | tests/expected/unused_macro_arg.txt | 0 | ||||
| -rw-r--r-- | tests/unused_macro_arg.s | 27 |
5 files changed, 46 insertions, 1 deletions
diff --git a/lib/xixanta/src/object.rs b/lib/xixanta/src/object.rs index 36b15dc..08f94fd 100644 --- a/lib/xixanta/src/object.rs +++ b/lib/xixanta/src/object.rs @@ -343,7 +343,18 @@ impl Context { self.to_human() )); } - *sc = object.clone(); + + match object.object_type { + // For macro arguments, we still want to preserve the + // 'accessed' member, as arguments are re-created on each + // use and this information might get lost in the process. + ObjectType::Argument => { + let before = sc.accessed; + *sc = object.clone(); + sc.accessed = before; + } + _ => *sc = object.clone(), + } } None => { scope.insert(id.value.clone(), object.to_owned()); diff --git a/scripts/test-e2e.sh b/scripts/test-e2e.sh index 524c75e..9505274 100755 --- a/scripts/test-e2e.sh +++ b/scripts/test-e2e.sh @@ -119,6 +119,13 @@ echo "test: custom => unused_definition.nes" diff tests/out/unused_definition.txt tests/expected/unused_definition.txt exit_code=$((exit_code + $?)) +echo "test: custom => unused_macro_arg.nes" +./target/debug/nasm -c empty -Werror --asan tests/unused_macro_arg.s -o tests/out/unused_macro_arg.nes 2>tests/out/unused_macro_arg.txt +diff tests/out/unused_macro_arg.txt tests/expected/unused_macro_arg.txt +exit_code=$((exit_code + $?)) +diff tests/out/unused_macro_arg.nes tests/expected/unused_macro_arg.nes +exit_code=$((exit_code + $?)) + ## # code.nes diff --git a/tests/expected/unused_macro_arg.nes b/tests/expected/unused_macro_arg.nes Binary files differnew file mode 100644 index 0000000..4a14648 --- /dev/null +++ b/tests/expected/unused_macro_arg.nes diff --git a/tests/expected/unused_macro_arg.txt b/tests/expected/unused_macro_arg.txt new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/expected/unused_macro_arg.txt diff --git a/tests/unused_macro_arg.s b/tests/unused_macro_arg.s new file mode 100644 index 0000000..fe4d7f0 --- /dev/null +++ b/tests/unused_macro_arg.s @@ -0,0 +1,27 @@ +.segment "HEADER" + .byte 'N', 'E', 'S', $1A + .byte $02, $01 + .byte $00 + .byte $00 + +.segment "CODE" + +;;; asan:stack full + +.macro BCD_ADD ADDR + adc ADDR + bcc :+ + nop +: +.endmacro + +.proc add_to_player_y + BCD_ADD additions + + rts + +additions: + .byte $FF +.endproc + +jsr add_to_player_y |
