MCPcopy
hub / github.com/compiler-explorer/compiler-explorer / x86to6502Tool

Class x86to6502Tool

lib/tooling/x86to6502-tool.ts:32–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30import {BaseTool} from './base-tool.js';
31
32export 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}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected