MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / processAsm

Method processAsm

lib/compilers/lua.ts:126–162  ·  view source on GitHub ↗
(result: {asm: string})

Source from the content-addressed store, hash-verified

124 }
125
126 override async processAsm(result: {asm: string}) {
127 // luac listing format (Lua 5.x):
128 // "main <name:0,0> (N instructions at 0x...)"
129 // " 1 [3] VARARGPREP 0"
130 // The bracketed value is the source line for that bytecode instruction.
131 const instructionLineRe = /^\s*\d+\s+\[(\d+)\]/;
132 const functionHeaderRe = /<[^:>]*:(\d+),\d+>/;
133
134 const bytecodeLines = result.asm.split('\n');
135 const bytecodeResult: ParsedAsmResultLine[] = [];
136 let lastLineNo: number | null = null;
137 let sourceLoc: AsmResultSource | null = null;
138
139 for (const line of bytecodeLines) {
140 const insnMatch = line.match(instructionLineRe);
141 const fnMatch = line.match(functionHeaderRe);
142
143 if (insnMatch) {
144 const lineno = Number.parseInt(insnMatch[1], 10);
145 lastLineNo = lineno;
146 sourceLoc = {line: lineno, file: null};
147 } else if (fnMatch) {
148 const lineno = Number.parseInt(fnMatch[1], 10);
149 lastLineNo = lineno > 0 ? lineno : null;
150 sourceLoc = {line: lastLineNo, file: null};
151 } else if (line) {
152 sourceLoc = {line: lastLineNo, file: null};
153 } else {
154 lastLineNo = null;
155 sourceLoc = {line: null, file: null};
156 }
157
158 bytecodeResult.push({text: line, source: sourceLoc});
159 }
160
161 return {asm: bytecodeResult};
162 }
163
164 /** Arguments passed to the bytecode dumper. */
165 protected getDisassemblyArgs(_options: string[], inputFilename: string): string[] {

Callers

nothing calls this directly

Calls 2

matchMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected