diff options
author | RabsRincon <ruben@rinconblanco.es> | 2020-01-08 13:49:23 +0100 |
---|---|---|
committer | RabsRincon <ruben@rinconblanco.es> | 2020-01-08 13:49:23 +0100 |
commit | 885aee1c63203f5868ac310e8592982f1519454c (patch) | |
tree | 25dc3bffd3a876f59f30e0e6bbcd9655a9da02e7 | |
parent | ea25a2a3dbd308f349e48ee2158c80de2fbb1535 (diff) | |
download | compiler-explorer-885aee1c63203f5868ac310e8592982f1519454c.tar.gz compiler-explorer-885aee1c63203f5868ac310e8592982f1519454c.zip |
Remove last remaining vars and fix formatting
-rw-r--r-- | lib/cfg.js | 13 | ||||
-rw-r--r-- | lib/compiler-arguments.js | 6 | ||||
-rw-r--r-- | lib/compilers/python.js | 8 | ||||
-rw-r--r-- | lib/map-file-delphi.js | 20 | ||||
-rw-r--r-- | lib/map-file-vs.js | 18 | ||||
-rw-r--r-- | lib/map-file.js | 125 |
6 files changed, 94 insertions, 96 deletions
diff --git a/lib/cfg.js b/lib/cfg.js index 5f803ff90..214ee9e9d 100644 --- a/lib/cfg.js +++ b/lib/cfg.js @@ -43,11 +43,11 @@ function getAsmDirective(txt) { } function filterTextSection(data) { - var useCurrentSection = true; - var result = []; - for (var i in data) { - var x = data[i]; - var directive = getAsmDirective(x.text); + let useCurrentSection = true; + const result = []; + for (let i in data) { + const x = data[i]; + const directive = getAsmDirective(x.text); if (directive != null) { if (directive === ".text" || directive === ".data") { useCurrentSection = directive === ".text"; @@ -166,8 +166,7 @@ function splitToBasicBlocks(asmArr, range, isEnd, isJmp) { result.push(_.clone(rangeBb)); //inst is expected to be .L*: where * in 1,2,... rangeBb = newRangeWith(rangeBb, inst, first + 1); - } - else if (isJmp(inst)) { + } else if (isJmp(inst)) { rangeBb.actionPos.push(first); } ++first; diff --git a/lib/compiler-arguments.js b/lib/compiler-arguments.js index 1458bb5f8..024f37a38 100644 --- a/lib/compiler-arguments.js +++ b/lib/compiler-arguments.js @@ -62,7 +62,7 @@ class CompilerArguments { getOptimizationArguments(excludeUsedArguments) { let possibleArguments = {}; _.forEach(this.possibleArguments, (obj, argKey) => { - for (var argIdx in excludeUsedArguments) { + for (let argIdx in excludeUsedArguments) { if (this.match(argKey, excludeUsedArguments[argIdx])) return; } @@ -79,7 +79,7 @@ class CompilerArguments { let possibleArguments = {}; if (excludeUsedArguments && excludeUsedArguments.length > 0) { _.forEach(this.possibleArguments, (obj, argKey) => { - for (var argIdx in excludeUsedArguments) { + for (let argIdx in excludeUsedArguments) { if (this.match(argKey, excludeUsedArguments[argIdx])) return; } possibleArguments[argKey] = obj; @@ -151,7 +151,7 @@ class CompilerArguments { return documentedOption; } } - + if (documentedOption.indexOf(givenOption) === 0) { return documentedOption; } diff --git a/lib/compilers/python.js b/lib/compilers/python.js index 15f42d0b8..ef362732a 100644 --- a/lib/compilers/python.js +++ b/lib/compilers/python.js @@ -40,12 +40,12 @@ class PythonCompiler extends BaseCompiler { const bytecodeLines = result.asm.split("\n"); - var bytecodeResult = []; - var lastLineNo = null; - var sourceLoc = null; + const bytecodeResult = []; + let lastLineNo = null; + let sourceLoc = null; bytecodeLines.forEach(line => { - var match = line.match(lineRe); + const match = line.match(lineRe); if (match) { const lineno = parseInt(match[1]); diff --git a/lib/map-file-delphi.js b/lib/map-file-delphi.js index 9d4d82c8a..b6f314fac 100644 --- a/lib/map-file-delphi.js +++ b/lib/map-file-delphi.js @@ -28,11 +28,11 @@ const MapFileReader = require("./map-file").MapFileReader; class MapFileReaderDelphi extends MapFileReader { /** * constructor - * @param {string} mapFilename + * @param {string} mapFilename */ constructor(mapFilename) { super(mapFilename); - + this.regexDelphiCodeSegmentOffset = /^\s([0-9a-f]*):([0-9a-f]*)\s*([0-9a-f]*)H\s*(\.[a-z$]*)\s*([a-z]*)$/i; this.regexDelphiCodeSegment = /^\s([0-9a-f]*):([0-9a-f]*)\s*([0-9a-f]*)\s*C=CODE\s*S=.text\s*G=.*M=([\w\d.]*)\s.*/i; this.regexDelphiICodeSegment = /^\s([0-9a-f]*):([0-9a-f]*)\s*([0-9a-f]*)\s*C=ICODE\s*S=.itext\s*G=.*M=([\w\d.]*)\s.*/i; @@ -49,7 +49,7 @@ class MapFileReaderDelphi extends MapFileReader { * 2. code segment delphi map * 3. icode segment delphi map * 4. code segment vs map - * @param {string} line + * @param {string} line */ tryReadingCodeSegmentInfo(line) { let codesegmentObject = false; @@ -88,7 +88,7 @@ class MapFileReaderDelphi extends MapFileReader { /** * Try to match information about the address where a symbol is - * @param {string} line + * @param {string} line */ tryReadingNamedAddress(line) { let symbolObject = false; @@ -105,21 +105,17 @@ class MapFileReaderDelphi extends MapFileReader { } /** - * - * @param {string} line + * + * @param {string} line */ isStartOfLineNumbers(line) { const matches = line.match(this.regexDelphiLineNumbersStart); - if (matches) { - return true; - } - - return false; + return !!matches; } /** * Retreives line number references from supplied Map line - * @param {string} line + * @param {string} line * @returns {boolean} */ tryReadingLineNumbers(line) { diff --git a/lib/map-file-vs.js b/lib/map-file-vs.js index 008622d45..6f0cb17d2 100644 --- a/lib/map-file-vs.js +++ b/lib/map-file-vs.js @@ -28,7 +28,7 @@ const MapFileReader = require("./map-file").MapFileReader; class MapFileReaderVS extends MapFileReader { /** * constructor - * @param {string} mapFilename + * @param {string} mapFilename */ constructor(mapFilename) { super(mapFilename); @@ -39,8 +39,8 @@ class MapFileReaderVS extends MapFileReader { } /** - * - * @param {string} line + * + * @param {string} line */ tryReadingPreferredAddress(line) { const matches = line.match(this.regexVSLoadAddress); @@ -56,10 +56,10 @@ class MapFileReaderVS extends MapFileReader { * 2. code segment delphi map * 3. icode segment delphi map * 4. code segment vs map - * @param {string} line + * @param {string} line */ tryReadingCodeSegmentInfo(line) { - var codesegmentObject = false; + let codesegmentObject = false; const matches = line.match(this.regexVsCodeSegment); if (matches) { @@ -74,14 +74,14 @@ class MapFileReaderVS extends MapFileReader { /** * Try to match information about the address where a symbol is - * @param {string} line + * @param {string} line */ tryReadingNamedAddress(line) { - var symbolObject = false; + let symbolObject = false; const matches = line.match(this.regexVsNames); if (matches && (matches.length >= 7) && (matches[4] !== "")) { - var addressWithOffset = parseInt(matches[4], 16); + const addressWithOffset = parseInt(matches[4], 16); symbolObject = { segment: matches[1], addressWithoutOffset: parseInt(matches[2], 16), @@ -95,7 +95,7 @@ class MapFileReaderVS extends MapFileReader { this.setSegmentOffset(symbolObject.segment, symbolObject.addressInt - symbolObject.addressWithoutOffset); - var segment = this.getSegmentInfoAddressWithoutOffsetIsIn( + const segment = this.getSegmentInfoAddressWithoutOffsetIsIn( symbolObject.segment, symbolObject.addressWithoutOffset); if (segment && !segment.unitName) { diff --git a/lib/map-file.js b/lib/map-file.js index 246d8de1c..e655b3795 100644 --- a/lib/map-file.js +++ b/lib/map-file.js @@ -23,7 +23,7 @@ // POSSIBILITY OF SUCH DAMAGE. "use strict"; -var fs = require("fs"), +const fs = require("fs"), utils = require("./utils"); class MapFileReader { @@ -32,7 +32,7 @@ class MapFileReader { * Note that this is a base class and should be overriden. (see for example map-file-vs.js) * Note that this base class retains and uses state, * so when you want to read a new file you need to instantiate a new object. - * @param {string} mapFilename + * @param {string} mapFilename */ constructor(mapFilename) { this.mapFilename = mapFilename; @@ -60,14 +60,14 @@ class MapFileReader { } /** - * - * @param {(string|boolean)} segment - * @param {number} address - * @returns {(Object|boolean)} + * + * @param {(string|boolean)} segment + * @param {number} address + * @returns {(Object|boolean)} */ getLineInfoByAddress(segment, address) { - for (var idx = 0; idx < this.lineNumbers.length; idx++) { - var lineInfo = this.lineNumbers[idx]; + for (let idx = 0; idx < this.lineNumbers.length; idx++) { + const lineInfo = this.lineNumbers[idx]; if (!segment && (lineInfo.addressInt === address)) { return lineInfo; } else if ((segment === lineInfo.segment) && (lineInfo.addressWithoutOffset === address)) { @@ -79,9 +79,9 @@ class MapFileReader { } /** - * - * @param {string} segment - * @returns {number} + * + * @param {string} segment + * @returns {number} */ getSegmentOffset(segment) { if (this.segmentOffsets.length > 0) { @@ -97,9 +97,9 @@ class MapFileReader { } /** - * - * @param {string} segment - * @param {number} address + * + * @param {string} segment + * @param {number} address */ setSegmentOffset(segment, address) { let info = false; @@ -133,9 +133,9 @@ class MapFileReader { } /** - * - * @param {string} unitName - * @returns {(Object|boolean)} + * + * @param {string} unitName + * @returns {(Object|boolean)} */ getSegmentInfoByUnitName(unitName) { for (let idx = 0; idx < this.segments.length; idx++) { @@ -149,9 +149,9 @@ class MapFileReader { } /** - * - * @param {string} unitName - * @returns {(Object|boolean)} + * + * @param {string} unitName + * @returns {(Object|boolean)} */ getICodeSegmentInfoByUnitName(unitName) { for (let idx = 0; idx < this.isegments.length; idx++) { @@ -165,9 +165,9 @@ class MapFileReader { } /** - * - * @param {string} unitName - * @returns {number} + * + * @param {string} unitName + * @returns {number} */ getSegmentIdByUnitName(unitName) { const info = this.getSegmentInfoByUnitName(unitName); @@ -182,7 +182,7 @@ class MapFileReader { * Get Segment info for exact address * @param {(string|boolean)} segment * @param {number} address - * @returns {(Object|boolean)} + * @returns {(Object|boolean)} */ getSegmentInfoByStartingAddress(segment, address) { for (let idx = 0; idx < this.segments.length; idx++) { @@ -199,9 +199,9 @@ class MapFileReader { /** * Get Segment info for the segment where the given address is in - * @param {(string|boolean)} segment - * @param {number} address - * @returns {(Object|boolean)} + * @param {(string|boolean)} segment + * @param {number} address + * @returns {(Object|boolean)} */ getSegmentInfoAddressIsIn(segment, address) { for (let idx = 0; idx < this.segments.length; idx++) { @@ -209,20 +209,20 @@ class MapFileReader { if (!segment && (address >= info.addressInt) && (address < (info.addressInt + info.segmentLength))) { return info; } else if ((segment === info.segment) && - (address >= info.addressWithoutOffset) && - (address < (info.addressWithoutOffset + info.segmentLength))) { + (address >= info.addressWithoutOffset) && + (address < (info.addressWithoutOffset + info.segmentLength))) { return info; } } return false; } - + /** * Get Segment info for the segment where the given address is in - * @param {string} segment - * @param {number} address - * @returns {(Object|boolean)} + * @param {string} segment + * @param {number} address + * @returns {(Object|boolean)} */ getSegmentInfoAddressWithoutOffsetIsIn(segment, address) { for (let idx = 0; idx < this.segments.length; idx++) { @@ -238,10 +238,10 @@ class MapFileReader { } /** - * - * @param {string} segment - * @param {number} address - * @returns {(Object|boolean)} + * + * @param {string} segment + * @param {number} address + * @returns {(Object|boolean)} */ getSymbolAt(segment, address) { for (let idx = 0; idx < this.namedAddresses.length; idx++) { @@ -257,7 +257,7 @@ class MapFileReader { } /** - * + * * @param {string} segment * @param {number} address * @returns {(Object|boolean)} @@ -283,8 +283,8 @@ class MapFileReader { /** * - * @param {string} name - * @returns {(Object|boolean)} + * @param {string} name + * @returns {(Object|boolean)} */ getSymbolInfoByName(name) { for (let idx = 0; idx < this.namedAddresses.length; idx++) { @@ -298,9 +298,9 @@ class MapFileReader { } /** - * - * @param {string} segment - * @param {string} address + * + * @param {string} segment + * @param {string} address */ addressToObject(segment, address) { const addressWithoutOffset = parseInt(address, 16); @@ -316,7 +316,7 @@ class MapFileReader { /** * Try to match information about the address where a symbol is - * @param {string} line + * @param {string} line */ tryReadingNamedAddress() { } @@ -324,14 +324,14 @@ class MapFileReader { /** * Tries to match the given line to code segment information. * Implementation specific, so this base function is empty - * @param {string} line + * @param {string} line */ tryReadingCodeSegmentInfo() { } /** - * - * @param {string} line + * + * @param {string} line */ tryReadingEntryPoint(line) { const matches = line.match(this.regexEntryPoint); @@ -344,26 +344,29 @@ class MapFileReader { } /** - * - * @param {string} line + * + * @param {string} line */ - tryReadingPreferredAddress() { + // eslint-disable-next-line no-unused-vars + tryReadingPreferredAddress(line) { } /** * Retreives line number references from supplied Map line - * @param {string} line + * @param {string} line * @returns {boolean} */ - tryReadingLineNumbers() { + // eslint-disable-next-line no-unused-vars + tryReadingLineNumbers(line) { return false; } /** - * - * @param {string} line + * + * @param {string} line */ - isStartOfLineNumbers() { + // eslint-disable-next-line no-unused-vars + isStartOfLineNumbers(line) { return false; } @@ -410,7 +413,7 @@ class MapFileReader { /** * Returns an array of objects with address range information for a given unit (filename) * [{startAddress: int, startAddressHex: string, endAddress: int, endAddressHex: string}] - * @param {string} unitName + * @param {string} unitName */ getReconstructedUnitAddressSpace(unitName) { let addressSpace = []; @@ -434,7 +437,7 @@ class MapFileReader { * Returns true if the address (and every address until address+size) is within * one of the given spaces. Spaces should be of format returned by getReconstructedUnitAddressSpace() * @param {array of objects} spaces - * @param {int} address + * @param {int} address * @param {int} size */ isWithinAddressSpace(spaces, address, size) { @@ -442,9 +445,9 @@ class MapFileReader { const spaceAddress = spaces[idxSpace]; if (((address >= spaceAddress.startAddress) && - (address < spaceAddress.endAddress)) || + (address < spaceAddress.endAddress)) || ((address < spaceAddress.startAddress) && - (address + size >= spaceAddress.startAddress))){ + (address + size >= spaceAddress.startAddress))) { return true; } } @@ -454,11 +457,11 @@ class MapFileReader { /** * Retreives information from Map file contents - * @param {string} contents + * @param {string} contents */ loadMapFromString(contents) { const mapLines = utils.splitLines(contents); - + let readLineNumbersMode = false; let lineIdx = 0; |