From 68db4ca482f4809a24642dda9c85acdcf4c60815 Mon Sep 17 00:00:00 2001 From: narpfel Date: Tue, 12 Aug 2025 15:50:53 +0200 Subject: [PATCH] Remove unused method `AsmParser.labelFindFor` (#8022) `AsmParser.labelFindFor` was only called in tests. --- lib/parsers/asm-parser-ewavr.ts | 4 ---- lib/parsers/asm-parser-vc.ts | 4 ---- lib/parsers/asm-parser.ts | 4 ---- test/asm-parser-subclass-integration-tests.ts | 19 +------------------ test/ewavr-asm-parser-tests.ts | 5 ----- 5 files changed, 1 insertion(+), 35 deletions(-) diff --git a/lib/parsers/asm-parser-ewavr.ts b/lib/parsers/asm-parser-ewavr.ts index 9f401c0c9..6dfc663ed 100644 --- a/lib/parsers/asm-parser-ewavr.ts +++ b/lib/parsers/asm-parser-ewavr.ts @@ -92,10 +92,6 @@ export class AsmEWAVRParser extends AsmParser { return this.hasOpcodeRe.test(line); } - override labelFindFor() { - return this.labelDef; - } - override processAsm(asm: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult { // NOTE: EWAVR assembly seems to be closest to visual studio const getFilenameFromComment = (line: string) => { diff --git a/lib/parsers/asm-parser-vc.ts b/lib/parsers/asm-parser-vc.ts index e97f2f6c2..2dcf36ae1 100644 --- a/lib/parsers/asm-parser-vc.ts +++ b/lib/parsers/asm-parser-vc.ts @@ -100,10 +100,6 @@ export class VcAsmParser extends AsmParser { return this.hasOpcodeRe.test(line); } - override labelFindFor() { - return this.labelFind; - } - override processAsm(asm: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult { if (filters.binary || filters.binaryObject) { return this.asmBinaryParser.processAsm(asm, filters); diff --git a/lib/parsers/asm-parser.ts b/lib/parsers/asm-parser.ts index b729f604d..99fb96dc2 100644 --- a/lib/parsers/asm-parser.ts +++ b/lib/parsers/asm-parser.ts @@ -462,10 +462,6 @@ export class AsmParser extends AsmRegex implements IAsmParser { }; } - labelFindFor(asmLines: string[]) { - return this.labelProcessor.getLabelFind(asmLines, this.createLabelContext()); - } - findUsedLabels(asmLines: string[], filterDirectives?: boolean): Set { return this.labelProcessor.findUsedLabels(asmLines, filterDirectives || false, this.createLabelContext()); } diff --git a/test/asm-parser-subclass-integration-tests.ts b/test/asm-parser-subclass-integration-tests.ts index 1e8f7d0fa..47502254b 100644 --- a/test/asm-parser-subclass-integration-tests.ts +++ b/test/asm-parser-subclass-integration-tests.ts @@ -50,17 +50,7 @@ function processAsmWithParser( } describe('AsmParser subclass compatibility', () => { - describe('labelFindFor method behavior', () => { - it('should use VcAsmParser labelFindFor override to find specific VC labels', () => { - const asmLines = ['_start:', 'mov eax, OFFSET _data', 'call _function', 'jmp _start']; - const usedLabels = initializeParserAndFindLabels(VcAsmParser, [], asmLines); - - // VC-specific label detection should find these labels - expect(usedLabels.has('_data')).toBe(true); - expect(usedLabels.has('_function')).toBe(true); - expect(usedLabels.has('_start')).toBe(true); - }); - + describe('findUsedLabels method behavior', () => { it('should show EWAVR label finding now works correctly after refactoring', () => { const asmLines = [ '_data: .word 0x1234', @@ -78,10 +68,6 @@ describe('AsmParser subclass compatibility', () => { expect(usedLabels.has('_main')).toBe(true); expect(usedLabels.has('HIGH')).toBe(true); expect(usedLabels.has('LOW')).toBe(true); - // Verify that specific expected labels are found rather than checking exact count - - // The refactoring fixed the issue where EWAVR's labelFindFor returned definition regex - // Now it uses the base class identifierFindRe for finding label references }); it('should show base class finds all identifier-like tokens as potential labels', () => { @@ -96,9 +82,6 @@ describe('AsmParser subclass compatibility', () => { expect(usedLabels.has('value')).toBe(true); // Actual label reference expect(usedLabels.has('jmp')).toBe(true); // Instruction (not a label) expect(usedLabels.has('_start')).toBe(true); // Actual label reference - - // This over-matching is why subclasses override labelFindFor - // to be more specific about what constitutes a label in their syntax }); }); diff --git a/test/ewavr-asm-parser-tests.ts b/test/ewavr-asm-parser-tests.ts index 014ae1ca7..954356e08 100644 --- a/test/ewavr-asm-parser-tests.ts +++ b/test/ewavr-asm-parser-tests.ts @@ -163,11 +163,6 @@ describe('AsmEWAVRParser', () => { expect(usedLabels.has('HIGH')).toBe(true); // Ensure HIGH is included expect(usedLabels.has('LOW')).toBe(true); // Ensure LOW is included // Verify we found the expected labels rather than checking exact count - - // The labelFindFor regex is still for definitions (with colons) - const labelFindRegex = parser.labelFindFor(); - expect(labelFindRegex.test('_data:')).toBe(true); // Matches definitions - expect(labelFindRegex.test('_data')).toBe(false); // Doesn't match usage }); it('should handle EWAVR segment syntax and register operations', () => {