From 4c9ba99b2274c5c67a53e60f66cd52a4168d402d Mon Sep 17 00:00:00 2001 From: Jose Rodriguez Date: Mon, 27 Sep 2021 23:35:21 +0200 Subject: [PATCH] fix: fix line number in error msgs within asm contexts --- src/arch/z80/backend/generic.py | 4 ---- src/arch/z80/translator.py | 2 +- tests/functional/test_errmsg.txt | 2 ++ tests/functional/zx48k/tap_errline.bas | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 5 deletions(-) create mode 100644 tests/functional/zx48k/tap_errline.bas diff --git a/src/arch/z80/backend/generic.py b/src/arch/z80/backend/generic.py index 73a45b334..bef8ab6a8 100644 --- a/src/arch/z80/backend/generic.py +++ b/src/arch/z80/backend/generic.py @@ -540,10 +540,6 @@ def _inline(ins): i = 0 while i < len(tmp): - if not tmp[i]: # discard empty lines - tmp.pop(i) - continue - if not tmp[i] or tmp[i][0] == ";": # a comment i += 1 continue diff --git a/src/arch/z80/translator.py b/src/arch/z80/translator.py index a1b1f6cbc..58b8a52d7 100644 --- a/src/arch/z80/translator.py +++ b/src/arch/z80/translator.py @@ -916,7 +916,7 @@ def visit_ITALIC(self, node): # ----------------------------------------------------------------------------------------------------- def visit_ASM(self, node): EOL = "\n" - self.ic_inline(f'#line {node.lineno + 1} "{node.filename}"') + self.ic_inline(f'#line {node.lineno} "{node.filename}"') self.ic_inline(node.asm) self.ic_inline(f'#line {node.lineno + len(node.asm.split(EOL))} "{node.filename}"') diff --git a/tests/functional/test_errmsg.txt b/tests/functional/test_errmsg.txt index 6567b7e6e..f0ed0bb9f 100644 --- a/tests/functional/test_errmsg.txt +++ b/tests/functional/test_errmsg.txt @@ -225,6 +225,8 @@ line_number_after_macro.bas:11: error: Syntax Error. Unexpected token '+' >>> process_file('zx48k/tap_asm_error_line.bas', ['-S', '-q']) tap_asm_error_line.bas:3: error: Syntax error. Unexpected token '10' [INTEGER] tap_asm_error_line.bas:7: error: Syntax error. Unexpected token '10' [INTEGER] +>>> process_file('zx48k/tap_errline.bas') +tap_errline.bas:10: error: Syntax error. Unexpected token 'HL' [HL] # Test error file names >>> process_file('zx48k/bad_fname_err0.bas', ['-S', '-q']) diff --git a/tests/functional/zx48k/tap_errline.bas b/tests/functional/zx48k/tap_errline.bas new file mode 100644 index 000000000..900e8851b --- /dev/null +++ b/tests/functional/zx48k/tap_errline.bas @@ -0,0 +1,15 @@ + +asm + push hl + push de + push af + + ld hl,16384 + ld de,16385 + ld a,(hl) + ex hl,de + + pop af + pop de + pop hl +end asm