aboutsummaryrefslogtreecommitdiff
path: root/lib/compilers/pascal.js
diff options
context:
space:
mode:
authorRubén Rincón Blanco <ruben@rinconblanco.es>2020-08-04 22:39:02 +0200
committerGitHub <noreply@github.com>2020-08-04 16:39:02 -0400
commitccff4b9ee5a37c13f0973b52e8f90a8be8359fea (patch)
tree0022c9364824c5b4e4f5818c4abbf654aa99f2e8 /lib/compilers/pascal.js
parent7126b39a6bdeabffc312c8a117ec7af072ef6a1c (diff)
downloadcompiler-explorer-ccff4b9ee5a37c13f0973b52e8f90a8be8359fea.tar.gz
compiler-explorer-ccff4b9ee5a37c13f0973b52e8f90a8be8359fea.zip
Add new eslint rules (#2121)
The largest changes here are: - enforcing single quotes for strings - enforcing trailing commas where possible In addition to those we have enabled several eslint plugins: - plugin:requirejs/recommended, to enforce some conventions in require statements - plugin:node/recommended, to enforce correct usage of various node.js APIs - plugin:unicorn/recommended, which contains a pretty mixed bag of useful rules This PR attempts to not change code behavior when possible. In cases where fixing existing code would change semantics, a linting exclusion has been placed in the code base to silence the error. You can find these by searching for `eslint-disable-next-line`. Co-authored-by: Austin Morton <austinpmorton@gmail.com>
Diffstat (limited to 'lib/compilers/pascal.js')
-rw-r--r--lib/compilers/pascal.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/lib/compilers/pascal.js b/lib/compilers/pascal.js
index 8f82fb824..424a6381f 100644
--- a/lib/compilers/pascal.js
+++ b/lib/compilers/pascal.js
@@ -21,14 +21,14 @@
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
-"use strict";
+'use strict';
const BaseCompiler = require('../base-compiler'),
utils = require('../utils'),
_ = require('underscore'),
- fs = require("fs-extra"),
- path = require("path"),
- argumentParsers = require("./argument-parsers");
+ fs = require('fs-extra'),
+ path = require('path'),
+ argumentParsers = require('./argument-parsers');
class FPCCompiler extends BaseCompiler {
constructor(info, env) {
@@ -66,7 +66,7 @@ class FPCCompiler extends BaseCompiler {
let options = ['-g', '-al'];
if (this.compiler.intelAsm && filters.intel && !filters.binary) {
- options = options.concat(this.compiler.intelAsm.split(" "));
+ options = options.concat(this.compiler.intelAsm.split(' '));
}
filters.preProcessLines = _.bind(this.preProcessLines, this);
@@ -79,20 +79,20 @@ class FPCCompiler extends BaseCompiler {
}
getExecutableFilename(dirPath) {
- return path.join(dirPath, "prog");
+ return path.join(dirPath, 'prog');
}
static preProcessBinaryAsm(input) {
- const relevantAsmStartsAt = input.indexOf("<OUTPUT");
+ const relevantAsmStartsAt = input.indexOf('<OUTPUT');
if (relevantAsmStartsAt !== -1) {
- const lastLinefeedBeforeStart = input.lastIndexOf("\n", relevantAsmStartsAt);
+ const lastLinefeedBeforeStart = input.lastIndexOf('\n', relevantAsmStartsAt);
if (lastLinefeedBeforeStart !== -1) {
input =
- input.substr(0, input.indexOf("00000000004")) + "\n" +
+ input.substr(0, input.indexOf('00000000004')) + '\n' +
input.substr(lastLinefeedBeforeStart + 1);
} else {
input =
- input.substr(0, input.indexOf("00000000004")) + "\n" +
+ input.substr(0, input.indexOf('00000000004')) + '\n' +
input.substr(relevantAsmStartsAt);
}
}
@@ -102,13 +102,13 @@ class FPCCompiler extends BaseCompiler {
async objdump(outputFilename, result, maxSize, intelAsm, demangle) {
const dirPath = path.dirname(outputFilename);
outputFilename = this.getExecutableFilename(dirPath);
- let args = ["-d", outputFilename, "-l", "--insn-width=16"];
- if (demangle) args = args.concat(["-C"]);
- if (intelAsm) args = args.concat(["-M", "intel"]);
+ let args = ['-d', outputFilename, '-l', '--insn-width=16'];
+ if (demangle) args = args.concat(['-C']);
+ if (intelAsm) args = args.concat(['-M', 'intel']);
const objResult = await this.exec(
this.compiler.objdumper, args, {maxOutput: maxSize, customCwd: dirPath});
if (objResult.code !== 0) {
- result.asm = "<No output: objdump returned " + objResult.code + ">";
+ result.asm = '<No output: objdump returned ' + objResult.code + '>';
} else {
result.asm = FPCCompiler.preProcessBinaryAsm(objResult.stdout);
}
@@ -119,10 +119,10 @@ class FPCCompiler extends BaseCompiler {
const unitName = path.basename(this.compileFilename, this.lang.extensions[0]);
await fs.writeFile(filename,
- "program prog; " +
- "uses " + unitName + " in '" + this.compileFilename + "'; " +
- "begin " +
- "end.");
+ 'program prog; ' +
+ 'uses ' + unitName + " in '" + this.compileFilename + "'; " +
+ 'begin ' +
+ 'end.');
}
async runCompiler(compiler, options, inputFilename, execOptions) {
@@ -131,7 +131,7 @@ class FPCCompiler extends BaseCompiler {
}
const dirPath = path.dirname(inputFilename);
- const projectFile = path.join(dirPath, "prog.dpr");
+ const projectFile = path.join(dirPath, 'prog.dpr');
execOptions.customCwd = dirPath;
await this.saveDummyProjectFile(projectFile);
@@ -163,23 +163,23 @@ class FPCCompiler extends BaseCompiler {
}
getExtraAsmHint(asm) {
- if (asm.startsWith("# [")) {
- const bracketEndPos = asm.indexOf("]", 3);
+ if (asm.startsWith('# [')) {
+ const bracketEndPos = asm.indexOf(']', 3);
let valueInBrackets = asm.substr(3, bracketEndPos - 3);
- const colonPos = valueInBrackets.indexOf(":");
+ const colonPos = valueInBrackets.indexOf(':');
if (colonPos !== -1) {
valueInBrackets = valueInBrackets.substr(0, colonPos - 1);
}
if (!isNaN(valueInBrackets)) {
- return " .loc 1 " + valueInBrackets + " 0";
+ return ' .loc 1 ' + valueInBrackets + ' 0';
} else if (valueInBrackets.includes(this.compileFilename)) {
- return " .file 1 \"<stdin>\"";
+ return ' .file 1 "<stdin>"';
} else {
return false;
}
- } else if (asm.startsWith(".Le")) {
- return " .cfi_endproc";
+ } else if (asm.startsWith('.Le')) {
+ return ' .cfi_endproc';
} else {
return false;
}