| 30 | import {BaseTool} from './base-tool.js'; |
| 31 | |
| 32 | export class x86to6502Tool extends BaseTool { |
| 33 | static get key() { |
| 34 | return 'x86to6502-tool'; |
| 35 | } |
| 36 | |
| 37 | override async runTool(compilationInfo: CompilationInfo, _inputFilepath?: string, args?: string[]) { |
| 38 | if (compilationInfo.filters.intel) { |
| 39 | return new Promise<ToolResult>(resolve => { |
| 40 | resolve(this.createErrorResponse('<need AT&T notation assembly>')); |
| 41 | }); |
| 42 | } |
| 43 | |
| 44 | if (compilationInfo.filters.binary) { |
| 45 | return new Promise<ToolResult>(resolve => { |
| 46 | resolve(this.createErrorResponse('<cannot run x86to6502 on binary>')); |
| 47 | }); |
| 48 | } |
| 49 | |
| 50 | if (!compilationInfo.asm) { |
| 51 | return this.createErrorResponse('<no assembly output available>'); |
| 52 | } |
| 53 | |
| 54 | const parser = new AsmParser(); |
| 55 | const filters = Object.assign({}, compilationInfo.filters); |
| 56 | |
| 57 | const asmString = utils.normalizeAsmToString(compilationInfo.asm); |
| 58 | const result = parser.process(asmString, filters); |
| 59 | |
| 60 | const asm = result.asm |
| 61 | .map(obj => { |
| 62 | if (typeof obj.text !== 'string' || obj.text.trim() === '') { |
| 63 | return ''; |
| 64 | } |
| 65 | if (/.*:/.test(obj.text)) { |
| 66 | return obj.text.replace(/^\s*/, ''); |
| 67 | } |
| 68 | return obj.text.replace(/^\s*/, '\t'); |
| 69 | }) |
| 70 | .join('\n'); |
| 71 | |
| 72 | return super.runTool(compilationInfo, undefined, args, asm); |
| 73 | } |
| 74 | } |
nothing calls this directly
no outgoing calls
no test coverage detected