diff options
Diffstat (limited to 'lib/base-compiler.js')
-rw-r--r-- | lib/base-compiler.js | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/lib/base-compiler.js b/lib/base-compiler.js index 5662e5609..e03619e08 100644 --- a/lib/base-compiler.js +++ b/lib/base-compiler.js @@ -889,10 +889,18 @@ export class BaseCompiler { return outputFilename.replace(path.extname(outputFilename), '.mir'); } + getHaskellCoreOutputFilename(inputFilename) { + return inputFilename.replace(path.extname(inputFilename), '.dump-simpl'); + } + getHaskellStgOutputFilename(inputFilename) { return inputFilename.replace(path.extname(inputFilename), '.dump-stg-final'); } + getHaskellCmmOutputFilename(inputFilename) { + return inputFilename.replace(path.extname(inputFilename), '.dump-cmm'); + } + // Currently called for getting macro expansion and HIR. // It returns the content of the output file created after using -Z unpretty=<unprettyOpt>. // The outputFriendlyName is a free form string used in case of error. @@ -940,22 +948,20 @@ export class BaseCompiler { return [{text: 'Internal error; unable to open output path'}]; } - async processHaskellStgOutput(inputFilename, output) { - const stgPath = this.getHaskellStgOutputFilename(inputFilename); + async processHaskellExtraOutput(outpath, output) { if (output.code !== 0) { - return [{text: 'Failed to run compiler to get Haskell STG'}]; + return [{text: 'Failed to run compiler to get Haskell Core'}]; } - if (await fs.exists(stgPath)) { - const content = await fs.readFile(stgPath, 'utf-8'); + if (await fs.exists(outpath)) { + const content = await fs.readFile(outpath, 'utf-8'); // output file starts with // - // ==================== Final STG: ==================== - // 2022-04-27 16:48:25.411966835 UTC + // ==================== <HEADER> ==================== // // we want to drop this to make the output nicer return content .split('\n') - .slice(4) + .slice(3) .map(line => ({ text: line, })); @@ -1447,7 +1453,9 @@ export class BaseCompiler { const makeRustMir = backendOptions.produceRustMir && this.compiler.supportsRustMirView; const makeRustMacroExp = backendOptions.produceRustMacroExp && this.compiler.supportsRustMacroExpView; const makeRustHir = backendOptions.produceRustHir && this.compiler.supportsRustHirView; + const makeHaskellCore = backendOptions.produceHaskellCore && this.compiler.supportsHaskellCoreView; const makeHaskellStg = backendOptions.produceHaskellStg && this.compiler.supportsHaskellStgView; + const makeHaskellCmm = backendOptions.produceHaskellCmm && this.compiler.supportsHaskellCmmView; const makeGccDump = backendOptions.produceGccDump && backendOptions.produceGccDump.opened && this.compiler.supportsGccDump; @@ -1488,7 +1496,15 @@ export class BaseCompiler { : ''; const rustMirResult = makeRustMir ? await this.processRustMirOutput(outputFilename, asmResult) : ''; - const haskellStgResult = makeHaskellStg ? await this.processHaskellStgOutput(inputFilename, asmResult) : ''; + const haskellCoreResult = makeHaskellCore + ? await this.processHaskellExtraOutput(this.getHaskellCoreOutputFilename(inputFilename), asmResult) + : ''; + const haskellStgResult = makeHaskellStg + ? await this.processHaskellExtraOutput(this.getHaskellStgOutputFilename(inputFilename), asmResult) + : ''; + const haskellCmmResult = makeHaskellCmm + ? await this.processHaskellExtraOutput(this.getHaskellCmmOutputFilename(inputFilename), asmResult) + : ''; asmResult.dirPath = dirPath; asmResult.compilationOptions = options; @@ -1554,10 +1570,18 @@ export class BaseCompiler { asmResult.hasRustHirOutput = true; asmResult.rustHirOutput = rustHirResult; } + if (haskellCoreResult) { + asmResult.hasHaskellCoreOutput = true; + asmResult.haskellCoreOutput = haskellCoreResult; + } if (haskellStgResult) { asmResult.hasHaskellStgOutput = true; asmResult.haskellStgOutput = haskellStgResult; } + if (haskellCmmResult) { + asmResult.hasHaskellCmmOutput = true; + asmResult.haskellCmmOutput = haskellCmmResult; + } return this.checkOutputFileAndDoPostProcess(asmResult, outputFilename, filters); } |