diff options
author | Fábio de Souza Villaça Medeiros <fabiosvm@outlook.com> | 2023-01-20 07:29:07 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-20 11:29:07 +0100 |
commit | d9cd9e0301c9ace9642668b48dd43a1eadc7440b (patch) | |
tree | e6692d04892d5b41ca459c16c85dd6f29e7bd8d1 /lib/compilers/hook.ts | |
parent | 41db591c542665652da2eafff515ca8eb5387153 (diff) | |
download | compiler-explorer-d9cd9e0301c9ace9642668b48dd43a1eadc7440b.tar.gz compiler-explorer-d9cd9e0301c9ace9642668b48dd43a1eadc7440b.zip |
Ignore trim filter for Hook (#4604)gh-5901
Diffstat (limited to 'lib/compilers/hook.ts')
-rw-r--r-- | lib/compilers/hook.ts | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/compilers/hook.ts b/lib/compilers/hook.ts index 3e6c08773..26ebc42fe 100644 --- a/lib/compilers/hook.ts +++ b/lib/compilers/hook.ts @@ -24,7 +24,6 @@ import path from 'path'; -import {ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces'; import {CompilationResult, ExecutionOptions} from '../../types/compilation/compilation.interfaces'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces'; import {BaseCompiler} from '../base-compiler'; @@ -48,38 +47,44 @@ export class HookCompiler extends BaseCompiler { inputFilename: string, execOptions: ExecutionOptions, ): Promise<CompilationResult> { + const compilerPath = path.dirname(compiler); + execOptions.env.HOOK_HOME = path.join(compilerPath, '..'); const dirPath = path.dirname(inputFilename); const outputFilename = this.getOutputFilename(dirPath); options.push(outputFilename); return super.runCompiler(compiler, options, inputFilename, execOptions); } - override processAsm(result) { + override processAsm(result, filters, options) { + // Ignoring `trim` filter because it is not supported by Hook. + filters.trim = false; + const _result = super.processAsm(result, filters, options); const commentRegex = /^\s*;(.*)/; const instructionRegex = /^\s{2}(\d+)(.*)/; - const lines = result.asm.split('\n'); - const asm: ParsedAsmResultLine[] = []; + const asm = _result.asm; let lastLineNo: number | undefined; - for (const line of lines) { - if (commentRegex.test(line)) { - asm.push({text: line, source: {line: undefined, file: null}}); + for (const item of asm) { + const text = item.text; + if (commentRegex.test(text)) { + item.source = {line: undefined, file: null}; lastLineNo = undefined; continue; } - const match = line.match(instructionRegex); + const match = text.match(instructionRegex); if (match) { const lineNo = parseInt(match[1]); - asm.push({text: line, source: {line: lineNo, file: null}}); + item.source = {line: lineNo, file: null}; lastLineNo = lineNo; continue; } - if (line) { - asm.push({text: line, source: {line: lastLineNo, file: null}}); + if (text) { + item.source = {line: lastLineNo, file: null}; continue; } - asm.push({text: line, source: {line: undefined, file: null}}); + item.source = {line: undefined, file: null}; lastLineNo = undefined; } - return {asm: asm}; + _result.asm = asm; + return _result; } } |