aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers
diff options
context:
space:
mode:
Diffstat (limited to 'lib/compilers')
-rw-r--r--lib/compilers/clean.js45
1 files changed, 25 insertions, 20 deletions
diff --git a/lib/compilers/clean.js b/lib/compilers/clean.js
index ea4d06298..524fbf708 100644
--- a/lib/compilers/clean.js
+++ b/lib/compilers/clean.js
@@ -26,10 +26,10 @@ const
BaseCompiler = require('../base-compiler'),
fs = require('fs-extra'),
path = require('path'),
- logger = require('../logger').logger;
+ utils = require('../utils');
class CleanCompiler extends BaseCompiler {
- optionsForFilter(filters, outputFilename) {
+ optionsForFilter(filters) {
if (filters.binary) {
return [];
} else {
@@ -37,23 +37,26 @@ class CleanCompiler extends BaseCompiler {
}
}
- getOutputFilename(dirPath, outputFilebase) {
+ getOutputFilename(dirPath) {
return path.join(dirPath, "Clean System Files/example.s");
}
- objdump(outputFilename, result, maxSize, intelAsm, demangle) {
- logger.info(outputFilename);
- let args = ["-d", outputFilename, "-l", "--insn-width=16"];
- if (demangle) args = args.concat("-C");
- if (intelAsm) args = args.concat(["-M", "intel"]);
- return this.exec(this.compiler.objdumper, args, {maxOutput: maxSize})
- .then(objResult => {
- result.asm = objResult.stdout;
- if (objResult.code !== 0) {
- result.asm = `<No output: objdump returned ${objResult.code}>`;
+ preprocessOutput(output) {
+ const errorRegex = /^Error \[.*,(\d*),(.*)\]:\s(.*)/i;
+ const parseerrorRegex = /^Parse error \[.*,(\d*);(\d*),(.*)\]:\s(.*)/i;
+ return utils.splitLines(output).map(line => {
+ let matches = line.match(errorRegex);
+ if (matches) {
+ return "<source>:" + matches[1] + ",0: error: (" + matches[2] + ") " + matches[3];
+ } else {
+ matches = line.match(parseerrorRegex);
+ if (matches) {
+ return "<source>:" + matches[1] + "," + matches[2] + ": error: (" + matches[3] + ") " + matches[3];
+ } else {
+ return line;
}
- return result;
- });
+ }
+ }).join("\n");
}
runCompiler(compiler, options, inputFilename, execOptions) {
@@ -67,23 +70,25 @@ class CleanCompiler extends BaseCompiler {
options.pop();
options.push(moduleName);
return super.runCompiler(compiler, options, moduleName, execOptions).then(result => {
- return new Promise((resolve, reject) => {
+ return new Promise((resolve) => {
+ result.stdout = this.preprocessOutput(result.stdout);
+ result.stderr = this.preprocessOutput(result.stderr);
if (!options.includes("-S")) {
const aout = path.join(tmpDir, "a.out");
- fs.stat(aout).then(stats => {
+ fs.stat(aout).then(() => {
fs.copyFile(aout, this.getOutputFilename(tmpDir)).then(() => {
result.code = 0;
resolve(result);
});
- }).catch(err => {
+ }).catch(() => {
result.code = 1;
resolve(result);
});
} else {
- fs.stat(this.getOutputFilename(tmpDir)).then(stats => {
+ fs.stat(this.getOutputFilename(tmpDir)).then(() => {
result.code = 0;
resolve(result);
- }).catch(err => {
+ }).catch(() => {
resolve(result);
});
}