Apply automatic fixes

This commit is contained in:
Mats Larsen
2024-11-06 13:41:01 +09:00
parent 07b5d6763a
commit 12d08f39a1
338 changed files with 2671 additions and 3141 deletions
+26 -29
View File
@@ -22,11 +22,11 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import child_process from 'child_process';
import os from 'os';
import path from 'path';
import process from 'process';
import url from 'url';
import child_process from 'node:child_process';
import os from 'node:os';
import path from 'node:path';
import process from 'node:process';
import url from 'node:url';
import * as Sentry from '@sentry/node';
import bodyParser from 'body-parser';
@@ -64,7 +64,7 @@ import {RouteAPI, ShortLinkMetaData} from './lib/handlers/route-api.js';
import {loadSiteTemplates} from './lib/handlers/site-templates.js';
import {SourceHandler} from './lib/handlers/source.js';
import {languages as allLanguages} from './lib/languages.js';
import {logger, logToLoki, logToPapertrail, makeLogStream, suppressConsoleLog} from './lib/logger.js';
import {logToLoki, logToPapertrail, logger, makeLogStream, suppressConsoleLog} from './lib/logger.js';
import {setupMetricsServer} from './lib/metrics-server.js';
import {ClientOptionsHandler} from './lib/options-handler.js';
import * as props from './lib/properties.js';
@@ -258,13 +258,14 @@ const isDevMode = () => process.env.NODE_ENV !== 'production';
function getFaviconFilename() {
if (isDevMode()) {
return 'favicon-dev.ico';
} else if (opts.env && opts.env.includes('beta')) {
return 'favicon-beta.ico';
} else if (opts.env && opts.env.includes('staging')) {
return 'favicon-staging.ico';
} else {
return 'favicon.ico';
}
if (opts.env?.includes('beta')) {
return 'favicon-beta.ico';
}
if (opts.env?.includes('staging')) {
return 'favicon-staging.ico';
}
return 'favicon.ico';
}
const propHierarchy = [
@@ -304,9 +305,8 @@ const languages = (() => {
// Always keep cmake for IDE mode, just in case
filteredLangs[allLanguages.cmake.id] = allLanguages.cmake;
return filteredLangs;
} else {
return allLanguages;
}
return allLanguages;
})();
if (Object.keys(languages).length === 0) {
@@ -327,7 +327,7 @@ const staticRoot = urljoin(staticUrl || urljoin(httpRoot, 'static'), '/');
function staticHeaders(res: express.Response) {
if (staticMaxAgeSecs) {
res.setHeader('Cache-Control', 'public, max-age=' + staticMaxAgeSecs + ', must-revalidate');
res.setHeader('Cache-Control', `public, max-age=${staticMaxAgeSecs}, must-revalidate`);
}
}
@@ -425,10 +425,9 @@ async function setupStaticMiddleware(router: express.Router) {
pugRequireHandler = path => {
if (Object.prototype.hasOwnProperty.call(staticManifest, path)) {
return urljoin(staticRoot, staticManifest[path]);
} else {
logger.error(`failed to locate static asset '${path}' in manifest`);
return '';
}
logger.error(`failed to locate static asset '${path}' in manifest`);
return '';
};
}
@@ -470,7 +469,7 @@ function startListening(server: express.Express) {
if (ss) {
// ms (5 min default)
const idleTimeout = process.env.IDLE_TIMEOUT;
const timeout = (idleTimeout === undefined ? 300 : parseInt(idleTimeout)) * 1000;
const timeout = (idleTimeout === undefined ? 300 : Number.parseInt(idleTimeout)) * 1000;
if (idleTimeout) {
const exit = () => {
logger.info('Inactivity timeout reached, exiting.');
@@ -495,7 +494,7 @@ function startListening(server: express.Express) {
});
startupGauge.set(process.uptime());
const startupDurationMs = Math.floor(process.uptime() * 1000);
if (isNaN(parseInt(_port))) {
if (Number.isNaN(Number.parseInt(_port))) {
// unix socket, not a port number...
logger.info(` Listening on socket: //${_port}/`);
logger.info(` Startup duration: ${startupDurationMs}ms`);
@@ -521,8 +520,8 @@ const awsProps = props.propsFor('aws');
async function main() {
await aws.initConfig(awsProps);
// Initialise express and then sentry. Sentry as early as possible to catch errors during startup.
const webServer = express(),
router = express.Router();
const webServer = express();
const router = express.Router();
SetupSentry(aws.getConfig('sentryDsn'), ceProps, releaseBuildNumber, gitReleaseName, defArgs);
startWineInit();
@@ -570,9 +569,8 @@ async function main() {
if (initialFindResults.foundClash) {
// If we are forced to have no clashes, throw an error with some explanation
throw new Error('Clashing compilers in the current environment found!');
} else {
logger.info('No clashing ids found, continuing normally...');
}
logger.info('No clashing ids found, continuing normally...');
}
}
@@ -678,8 +676,7 @@ async function main() {
.use(Sentry.Handlers.errorHandler)
// eslint-disable-next-line no-unused-vars
.use((err: any, req: express.Request, res: express.Response, _next: express.NextFunction) => {
const status =
err.status || err.statusCode || err.status_code || (err.output && err.output.statusCode) || 500;
const status = err.status || err.statusCode || err.status_code || err.output?.statusCode || 500;
const message = err.message || 'Internal Server Error';
res.status(status);
res.render('error', renderConfig({error: {code: status, message: message}}));
@@ -688,7 +685,7 @@ async function main() {
}
});
const sponsorConfig = loadSponsorsFromString(fs.readFileSync(configDir + '/sponsors.yaml', 'utf8'));
const sponsorConfig = loadSponsorsFromString(fs.readFileSync(`${configDir}/sponsors.yaml`, 'utf8'));
loadSiteTemplates(configDir);
@@ -731,7 +728,7 @@ async function main() {
staticHeaders(res);
contentPolicyHeader(res);
const embedded = req.query.embedded === 'true' ? true : false;
const embedded = req.query.embedded === 'true';
res.render(
embedded ? 'embed' : 'index',
@@ -748,7 +745,7 @@ async function main() {
);
}
const embeddedHandler = function (req: express.Request, res: express.Response) {
const embeddedHandler = (req: express.Request, res: express.Response) => {
staticHeaders(res);
contentPolicyHeader(res);
res.render(
+2 -3
View File
@@ -109,10 +109,9 @@ class CompilerArgsApp {
getParser() {
if (compilerParsers[this.parserName as keyof typeof compilerParsers]) {
return compilerParsers[this.parserName as keyof typeof compilerParsers];
} else {
console.error('Unknown parser type');
process.exit(1);
}
console.error('Unknown parser type');
process.exit(1);
}
async doTheParsing() {
+1 -1
View File
@@ -44,7 +44,7 @@ describe('Individual pane testing', () => {
});
function addPaneOpenTest(paneData) {
it(paneData.name + ' pane', () => {
it(`${paneData.name} pane`, () => {
cy.get(`[data-cy="new-${paneData.selector}-btn"]:visible`).click();
// Not the most consistent way, but the easiest one!
cy.get('span.lm_title:visible').contains(paneData.name);
+1 -1
View File
@@ -2,7 +2,7 @@ import '../../static/global';
export function runFrontendTest(name: string) {
it(name, () => {
return cy.window().then(win => {
return cy.window().then(win => {
return win.compilerExplorerFrontendTesting.run(name);
});
});
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -56,10 +56,10 @@ export async function addArtifactToResult(
}
export async function addHeaptrackResults(result: CompilationResult, dirPath?: string): Promise<void> {
let dirPathToUse: string = '';
let dirPathToUse = '';
if (dirPath) {
dirPathToUse = dirPath;
} else if (result.buildResult && result.buildResult.dirPath) {
} else if (result.buildResult?.dirPath) {
dirPathToUse = result.buildResult.dirPath;
}
+7 -10
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import * as fs from 'fs';
import path from 'path';
import * as fs from 'node:fs';
import path from 'node:path';
import {isString} from '../shared/common-utils.js';
import {parse} from '../shared/stacktrace.js';
@@ -33,9 +33,8 @@ const filePrefix = 'file://';
function removeFileProtocol(path: string) {
if (path.startsWith(filePrefix)) {
return path.slice(filePrefix.length);
} else {
return path;
}
return path;
}
function check_path(parent: URL, directory: string) {
@@ -43,9 +42,8 @@ function check_path(parent: URL, directory: string) {
const relative = path.relative(parent.pathname, directory);
if (relative && !relative.startsWith('..') && !path.isAbsolute(relative)) {
return relative;
} else {
return false;
}
return false;
}
function get_diagnostic() {
@@ -83,16 +81,15 @@ function fail(fail_message: string, user_message: string | undefined, args: any[
}
if (args.length > 0) {
try {
assert_line += ', ' + JSON.stringify(args);
assert_line += `, ${JSON.stringify(args)}`;
} catch (e) {}
}
const diagnostic = get_diagnostic();
if (diagnostic) {
throw new Error(assert_line + `, at ${diagnostic.file}:${diagnostic.line} \`${diagnostic.src}\``);
} else {
throw new Error(assert_line);
throw new Error(`${assert_line}, at ${diagnostic.file}:${diagnostic.line} \`${diagnostic.src}\``);
}
throw new Error(assert_line);
}
// Using `unknown` instead of generic implementation due to:
+1 -1
View File
@@ -100,7 +100,7 @@ async function loadAwsConfig(properties: PropertyGetter) {
const ssm = new SSM({region: region, credentials: awsCredentials()});
const path = '/compiler-explorer/';
try {
const response = await ssm.getParameters({Names: [path + 'sentryDsn']});
const response = await ssm.getParameters({Names: [`${path}sentryDsn`]});
const map: Record<string, string | undefined> = {};
for (const param of unwrap(response.Parameters)) {
map[unwrap(param.Name).substring(path.length)] = param.Value;
+103 -117
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import os from 'os';
import path from 'path';
import os from 'node:os';
import path from 'node:path';
import fs from 'fs-extra';
import * as PromClient from 'prom-client';
@@ -39,8 +39,6 @@ import {
BuildResult,
BuildStep,
BypassCache,
bypassCompilationCache,
bypassExecutionCache,
CacheKey,
CmakeCacheKey,
CompilationCacheKey,
@@ -52,6 +50,8 @@ import {
FiledataPair,
GccDumpOptions,
LibsAndOptions,
bypassCompilationCache,
bypassExecutionCache,
} from '../types/compilation/compilation.interfaces.js';
import {
CompilerOverrideOption,
@@ -88,8 +88,8 @@ import {CompilerArguments} from './compiler-arguments.js';
import {
BaseParser,
ClangCParser,
ClangirParser,
ClangParser,
ClangirParser,
GCCCParser,
GCCParser,
ICCParser,
@@ -208,7 +208,7 @@ export class BaseCompiler implements ICompiler {
protected packager: Packager;
protected executionType: string;
protected sandboxType: string;
protected defaultRpathFlag: string = '-Wl,-rpath,';
protected defaultRpathFlag = '-Wl,-rpath,';
private static objdumpAndParseCounter = new PromClient.Counter({
name: 'ce_objdumpandparsetime_total',
help: 'Time spent on objdump and parsing of objdumps',
@@ -318,12 +318,11 @@ export class BaseCompiler implements ICompiler {
id: match[1],
version: match[2],
};
} else {
return {
id: lib,
version: false,
};
}
return {
id: lib,
version: false,
};
});
const filterLibIds = new Set();
@@ -369,13 +368,13 @@ export class BaseCompiler implements ICompiler {
env.CXX = this.compiler.exe;
if (this.compiler.exe.endsWith('clang++.exe')) {
env.CC = this.compiler.exe.substring(0, this.compiler.exe.length - 6) + '.exe';
env.CC = `${this.compiler.exe.substring(0, this.compiler.exe.length - 6)}.exe`;
} else if (this.compiler.exe.endsWith('g++.exe')) {
env.CC = this.compiler.exe.substring(0, this.compiler.exe.length - 6) + 'cc.exe';
env.CC = `${this.compiler.exe.substring(0, this.compiler.exe.length - 6)}cc.exe`;
} else if (this.compiler.exe.endsWith('clang++')) {
env.CC = this.compiler.exe.substring(0, this.compiler.exe.length - 2);
} else if (this.compiler.exe.endsWith('g++')) {
env.CC = this.compiler.exe.substring(0, this.compiler.exe.length - 2) + 'cc';
env.CC = `${this.compiler.exe.substring(0, this.compiler.exe.length - 2)}cc`;
}
} else if (this.lang.id === 'fortran') {
env.FC = this.compiler.exe;
@@ -558,9 +557,8 @@ export class BaseCompiler implements ICompiler {
if (this.compiler.instructionSet) {
return this.compiler.instructionSet;
} else {
return 'amd64';
}
return 'amd64';
}
async runCompiler(
@@ -632,7 +630,7 @@ export class BaseCompiler implements ICompiler {
outputFilename = this.getObjdumpOutputFilename(outputFilename);
if (!(await utils.fileExists(outputFilename))) {
result.asm = '<No output file ' + outputFilename + '>';
result.asm = `<No output file ${outputFilename}>`;
return result;
}
@@ -649,7 +647,7 @@ export class BaseCompiler implements ICompiler {
if (this.externalparser) {
const objResult = await this.externalparser.objdumpAndParseAssembly(result.dirPath, args, filters);
if (objResult.parsingTime !== undefined) {
objResult.objdumpTime = parseInt(result.execTime) - parseInt(result.parsingTime);
objResult.objdumpTime = Number.parseInt(result.execTime) - Number.parseInt(result.parsingTime);
delete objResult.execTime;
}
@@ -739,20 +737,20 @@ export class BaseCompiler implements ICompiler {
// files outside of the tempdir created on the fly.
if (this.compiler.removeEmptyGccDump) {
if (gccDumpOptions.treeDump !== false) {
addOpts.push('-fdump-tree-all' + flags);
addOpts.push(`-fdump-tree-all${flags}`);
}
if (gccDumpOptions.rtlDump !== false) {
addOpts.push('-fdump-rtl-all' + flags);
addOpts.push(`-fdump-rtl-all${flags}`);
}
if (gccDumpOptions.ipaDump !== false) {
addOpts.push('-fdump-ipa-all' + flags);
addOpts.push(`-fdump-ipa-all${flags}`);
}
} else {
// If not dumping everything, create a specific command like
// -fdump-tree-fixup_cfg1-some-flags=somefilename
if (gccDumpOptions.pass) {
const dumpFile = this.getGccDumpFileName(outputFilename);
const dumpCmd = gccDumpOptions.pass.command_prefix + flags + `=${dumpFile}`;
const dumpCmd = `${gccDumpOptions.pass.command_prefix + flags}=${dumpFile}`;
addOpts.push(dumpCmd);
}
}
@@ -765,7 +763,7 @@ export class BaseCompiler implements ICompiler {
optionsForBackend(backendOptions: Record<string, any>, outputFilename: string): string[] {
let addOpts: string[] = [];
if (backendOptions.produceGccDump && backendOptions.produceGccDump.opened && this.compiler.supportsGccDump) {
if (backendOptions.produceGccDump?.opened && this.compiler.supportsGccDump) {
addOpts = addOpts.concat(this.getGccDumpOptions(backendOptions.produceGccDump, outputFilename));
}
@@ -800,7 +798,7 @@ export class BaseCompiler implements ICompiler {
foundLib.versions,
(o: VersionInfo, versionId: string): boolean => {
if (versionId === selectedLib.version) return true;
return !!(o.alias && o.alias.includes(selectedLib.version));
return !!o.alias?.includes(selectedLib.version);
},
);
@@ -816,11 +814,7 @@ export class BaseCompiler implements ICompiler {
findAutodetectStaticLibLink(linkname: string): SelectedLibraryVersion | false {
const foundLib = _.findKey(this.supportedLibraries!, lib => {
return (
lib.versions.autodetect &&
lib.versions.autodetect.staticliblink &&
lib.versions.autodetect.staticliblink.includes(linkname)
);
return lib.versions.autodetect?.staticliblink?.includes(linkname);
});
if (!foundLib) return false;
@@ -842,9 +836,8 @@ export class BaseCompiler implements ICompiler {
if (lib) {
dictionary[lib] = foundVersion;
return [lib, foundVersion.dependencies];
} else {
return false;
}
return false;
});
})
.flat(3),
@@ -867,14 +860,14 @@ export class BaseCompiler implements ICompiler {
) {
idxToInsert = idx;
break;
} else if (libToInsertObj && libToInsertObj.dependencies.includes(libCompareName)) {
}
if (libToInsertObj?.dependencies.includes(libCompareName)) {
idxToInsert = idx;
break;
} else if (libCompareObj && libCompareObj.dependencies.includes(libToInsertName)) {
continue;
}
if (libCompareObj?.dependencies.includes(libToInsertName)) {
} else if (
libToInsertObj &&
libToInsertObj.staticliblink.includes(libToInsertName) &&
libToInsertObj?.staticliblink.includes(libToInsertName) &&
libToInsertObj.staticliblink.includes(libCompareName)
) {
if (
@@ -882,13 +875,11 @@ export class BaseCompiler implements ICompiler {
libToInsertObj.staticliblink.indexOf(libCompareName)
) {
continue;
} else {
idxToInsert = idx;
}
idxToInsert = idx;
break;
} else if (
libCompareObj &&
libCompareObj.staticliblink.includes(libToInsertName) &&
libCompareObj?.staticliblink.includes(libToInsertName) &&
libCompareObj.staticliblink.includes(libCompareName)
) {
if (
@@ -896,9 +887,8 @@ export class BaseCompiler implements ICompiler {
libCompareObj.staticliblink.indexOf(libCompareName)
) {
continue;
} else {
idxToInsert = idx;
}
idxToInsert = idx;
break;
}
}
@@ -933,9 +923,8 @@ export class BaseCompiler implements ICompiler {
return foundVersion.liblink.map(lib => {
if (lib) {
return linkFlag + lib;
} else {
return false;
}
return false;
});
})
.filter(Boolean) as string[];
@@ -1329,12 +1318,12 @@ export class BaseCompiler implements ICompiler {
try {
const [stdout, stderr] = await this.env.formatHandler.internalFormat('clangformat', 'LLVM', output);
if (stderr) {
return stdout + '\n/* clang-format stderr:\n' + stderr.trim() + '\n*/';
return `${stdout}\n/* clang-format stderr:\n${stderr.trim()}\n*/`;
}
return stdout;
} catch (err) {
logger.error('Internal formatter error', {err});
return '/* <Error while running clang-format> */\n\n' + output;
return `/* <Error while running clang-format> */\n\n${output}`;
}
}
@@ -1509,13 +1498,12 @@ export class BaseCompiler implements ICompiler {
compileTime: compileEnd - compileStart,
parseTime: parseEnd - parseStart,
};
} else {
return {
results: optPipeline,
compileTime: compileEnd - compileStart,
parseTime: parseEnd - parseStart,
};
}
return {
results: optPipeline,
compileTime: compileEnd - compileStart,
parseTime: parseEnd - parseStart,
};
} catch (e: any) {
return {
error: e.toString(),
@@ -1643,7 +1631,7 @@ export class BaseCompiler implements ICompiler {
getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string {
let filename;
if (key && key.backendOptions && key.backendOptions.customOutputFilename) {
if (key?.backendOptions?.customOutputFilename) {
filename = key.backendOptions.customOutputFilename;
} else {
filename = `${outputFilebase}.s`;
@@ -1651,9 +1639,8 @@ export class BaseCompiler implements ICompiler {
if (dirPath) {
return path.join(dirPath, filename);
} else {
return filename;
}
return filename;
}
getExecutableFilename(dirPath: string, outputFilebase: string, key?: CacheKey | CompilationCacheKey) {
@@ -1742,15 +1729,15 @@ export class BaseCompiler implements ICompiler {
fromInternalGccDumpName(internalDumpName: string, selectedPasses: string[]) {
if (!selectedPasses) selectedPasses = ['ipa', 'tree', 'rtl'];
const internalNameRe = new RegExp('^\\s*(' + selectedPasses.join('|') + ')-([\\w_-]+).*ON$');
const internalNameRe = new RegExp(`^\\s*(${selectedPasses.join('|')})-([\\w_-]+).*ON$`);
const match = internalDumpName.match(internalNameRe);
if (match)
return {
filename_suffix: `${match[1][0]}.${match[2]}`,
name: match[2] + ' (' + match[1] + ')',
name: `${match[2]} (${match[1]})`,
command_prefix: `-fdump-${match[1]}-${match[2]}`,
};
else return null;
return null;
}
async checkOutputFileAndDoPostProcess(
@@ -1817,9 +1804,8 @@ export class BaseCompiler implements ICompiler {
if (this.buildenvsetup) {
const libraryDetails = await this.getRequiredLibraryVersions(key.libraries);
return this.buildenvsetup.setup(key, dirPath, libraryDetails, binary);
} else {
return [];
}
return [];
}
protected async writeMultipleFiles(files: FiledataPair[], dirPath: string) {
@@ -2138,17 +2124,16 @@ export class BaseCompiler implements ICompiler {
didExecute: true,
buildResult: buildResult,
});
} else {
return {
code: -1,
didExecute: false,
buildResult,
stderr: [{text: `No execution available for ${execTriple.toString()}`}],
stdout: [],
execTime: 0,
timedOut: false,
};
}
return {
code: -1,
didExecute: false,
buildResult,
stderr: [{text: `No execution available for ${execTriple.toString()}`}],
stdout: [],
execTime: 0,
timedOut: false,
};
}
const result = await this.runExecutable(
@@ -2264,9 +2249,8 @@ export class BaseCompiler implements ICompiler {
libsAndOptions.libraries = _.union(libsAndOptions.libraries, detectedLibs);
return true;
} else {
return false;
}
return false;
}
sanitizeCompilerOverrides(overrides: ConfiguredOverrides): ConfiguredOverrides {
@@ -2343,8 +2327,7 @@ export class BaseCompiler implements ICompiler {
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;
const makeGccDump = backendOptions.produceGccDump?.opened && this.compiler.supportsGccDump;
const [
asmResult,
@@ -2365,7 +2348,7 @@ export class BaseCompiler implements ICompiler {
inputFilename,
options,
backendOptions.produceIr,
backendOptions.produceCfg && backendOptions.produceCfg.ir,
backendOptions.produceCfg?.ir,
filters,
)
: undefined,
@@ -2475,13 +2458,14 @@ export class BaseCompiler implements ICompiler {
getCompilerEnvironmentVariables(compilerflags: string) {
if (this.lang.id === 'c++') {
return {...this.cmakeBaseEnv, CXXFLAGS: compilerflags};
} else if (this.lang.id === 'fortran') {
return {...this.cmakeBaseEnv, FFLAGS: compilerflags};
} else if (this.lang.id === 'cuda') {
return {...this.cmakeBaseEnv, CUDAFLAGS: compilerflags};
} else {
return {...this.cmakeBaseEnv, CFLAGS: compilerflags};
}
if (this.lang.id === 'fortran') {
return {...this.cmakeBaseEnv, FFLAGS: compilerflags};
}
if (this.lang.id === 'cuda') {
return {...this.cmakeBaseEnv, CUDAFLAGS: compilerflags};
}
return {...this.cmakeBaseEnv, CFLAGS: compilerflags};
}
async doBuildstep(command: string, args: string[], execParams: ExecutionOptions) {
@@ -2591,13 +2575,14 @@ export class BaseCompiler implements ICompiler {
getUsedEnvironmentVariableFlags(makeExecParams: ExecutionOptionsWithEnv) {
if (this.lang.id === 'c++') {
return utils.splitArguments(makeExecParams.env.CXXFLAGS);
} else if (this.lang.id === 'fortran') {
return utils.splitArguments(makeExecParams.env.FFLAGS);
} else if (this.lang.id === 'cuda') {
return utils.splitArguments(makeExecParams.env.CUDAFLAGS);
} else {
return utils.splitArguments(makeExecParams.env.CFLAGS);
}
if (this.lang.id === 'fortran') {
return utils.splitArguments(makeExecParams.env.FFLAGS);
}
if (this.lang.id === 'cuda') {
return utils.splitArguments(makeExecParams.env.CUDAFLAGS);
}
return utils.splitArguments(makeExecParams.env.CFLAGS);
}
async cmake(
@@ -2762,7 +2747,7 @@ export class BaseCompiler implements ICompiler {
fullResult.code = 0;
if (fullResult.buildsteps) {
_.each(fullResult.buildsteps, function (step) {
_.each(fullResult.buildsteps, step => {
fullResult.code += step.code;
});
}
@@ -2931,7 +2916,7 @@ export class BaseCompiler implements ICompiler {
{abandonIfStale: true},
);
if (result.execResult && result.execResult.buildResult) {
if (result.execResult?.buildResult) {
this.doTempfolderCleanup(result.execResult.buildResult);
}
}
@@ -2948,7 +2933,7 @@ export class BaseCompiler implements ICompiler {
if (backendOptions.executorRequest) {
const execResult = await this.handleExecution(key, executeOptions, bypassCache);
if (execResult && execResult.buildResult) {
if (execResult?.buildResult) {
this.doTempfolderCleanup(execResult.buildResult);
}
return execResult;
@@ -3050,7 +3035,8 @@ export class BaseCompiler implements ICompiler {
result.filteredCount = res.filteredCount;
if (res.languageId) result.languageId = res.languageId;
if (result.objdumpTime) {
const dumpAndParseTime = parseInt(result.objdumpTime) + parseInt(result.parsingTime);
const dumpAndParseTime =
Number.parseInt(result.objdumpTime) + Number.parseInt(result.parsingTime);
BaseCompiler.objdumpAndParseCounter.inc(dumpAndParseTime);
}
} else {
@@ -3062,7 +3048,7 @@ export class BaseCompiler implements ICompiler {
if (this.compiler.supportsCfg && backendOptions.produceCfg && backendOptions.produceCfg.asm) {
const isLlvmIr =
this.compiler.instructionSet === 'llvm' ||
(options && options.includes('-emit-llvm')) ||
options?.includes('-emit-llvm') ||
this.llvmIr.isLlvmIr(result.asm);
result.cfg = cfg.generateStructure(this.compiler, result.asm, isLlvmIr);
}
@@ -3113,7 +3099,7 @@ export class BaseCompiler implements ICompiler {
}
async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) {
if ((options && options.includes('-emit-llvm')) || this.llvmIr.isLlvmIr(result.asm)) {
if (options?.includes('-emit-llvm') || this.llvmIr.isLlvmIr(result.asm)) {
return await this.llvmIr.processFromFilters(result.asm, filters);
}
@@ -3177,7 +3163,7 @@ export class BaseCompiler implements ICompiler {
const versionMatch = versionRegex.exec(version);
if (versionMatch) {
const versionNum = parseFloat(versionMatch[1]);
const versionNum = Number.parseFloat(versionMatch[1]);
return version.toLowerCase().includes('clang') && versionNum >= 3.3;
}
@@ -3355,18 +3341,15 @@ but nothing was dumped. Possible causes are:
return result;
}
if (result.asmSize >= maxSize) {
result.asm =
'<No output: generated assembly was too large' +
` (${result.asmSize} > ${maxSize} bytes)>`;
result.asm = `<No output: generated assembly was too large (${result.asmSize} > ${maxSize} bytes)>`;
return result;
}
if (postProcess.length > 0) {
return await this.execPostProcess(result, postProcess, outputFilename, maxSize);
} else {
const contents = await fs.readFile(outputFilename);
result.asm = contents.toString();
return result;
}
const contents = await fs.readFile(outputFilename);
result.asm = contents.toString();
return result;
})();
return Promise.all([asmPromise, optPromise, stackUsagePromise]);
}
@@ -3407,16 +3390,21 @@ but nothing was dumped. Possible causes are:
const exeFilename = path.basename(exe);
if (exeFilename.includes('icc')) {
return ICCParser;
} else if (exe.includes('clangir')) {
}
if (exe.includes('clangir')) {
return ClangirParser;
} else if (exeFilename.includes('clang++') || exeFilename.includes('icpx')) {
}
if (exeFilename.includes('clang++') || exeFilename.includes('icpx')) {
// check this first as "clang++" matches "g++"
return ClangParser;
} else if (exeFilename.includes('clang') || exeFilename.includes('icx')) {
}
if (exeFilename.includes('clang') || exeFilename.includes('icx')) {
return ClangCParser;
} else if (exeFilename.includes('gcc')) {
}
if (exeFilename.includes('gcc')) {
return GCCCParser;
} else if (exeFilename.includes('g++')) {
}
if (exeFilename.includes('g++')) {
return GCCParser;
}
//there is a lot of code around that makes this assumption.
@@ -3462,9 +3450,8 @@ but nothing was dumped. Possible causes are:
value: target,
};
});
} else {
return [];
}
return [];
}
async getPossibleStdversAsOverrideValues(): Promise<CompilerOverrideOption[]> {
@@ -3542,7 +3529,7 @@ but nothing was dumped. Possible causes are:
name: CompilerOverrideType.toolchain,
display_title: 'Toolchain',
description: c_default_toolchain_description,
flags: [flag + '<value>'],
flags: [`${flag}<value>`],
values: possibleToolchains,
});
}
@@ -3649,15 +3636,14 @@ but nothing was dumped. Possible causes are:
delete this.compiler.cachedPossibleArguments;
}
return this;
} else {
const initResult = await this.getArgumentParserClass().parse(this);
await this.populatePossibleOverrides();
await this.populatePossibleRuntimeTools();
logger.info(`${compiler} ${version} is ready`);
return initResult;
}
const initResult = await this.getArgumentParserClass().parse(this);
await this.populatePossibleOverrides();
await this.populatePossibleRuntimeTools();
logger.info(`${compiler} ${version} is ready`);
return initResult;
}
getModificationTime(): number | undefined {
+10 -10
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import os from 'os';
import os from 'node:os';
import {InstructionSet} from '../../types/instructionsets.js';
import {executeDirect} from '../exec.js';
@@ -85,8 +85,8 @@ export class BinaryInfoLinux {
}
static removeComments(value: string): string {
let filtered: string = '';
let inComment: boolean = false;
let filtered = '';
let inComment = false;
for (const c of value) {
if (!inComment && c === '(') {
inComment = true;
@@ -106,16 +106,17 @@ export class BinaryInfoLinux {
if (isElf) {
return {
os: OSType.linux,
instructionSet: this.getInstructionSetForArchText(csv[1]),
instructionSet: BinaryInfoLinux.getInstructionSetForArchText(csv[1]),
};
} else if (isPE) {
const filteredLine = this.removeComments(csv[0]);
}
if (isPE) {
const filteredLine = BinaryInfoLinux.removeComments(csv[0]);
const lastWordPos = filteredLine.lastIndexOf(' ');
const lastWord = filteredLine.substring(lastWordPos + 1);
return {
os: OSType.windows,
instructionSet: this.getInstructionSetForArchText(lastWord),
instructionSet: BinaryInfoLinux.getInstructionSetForArchText(lastWord),
};
}
@@ -128,10 +129,9 @@ export class BinaryInfoLinux {
os: OSType.windows,
instructionSet: 'amd64',
};
} else {
const info = await executeDirect('/usr/bin/file', ['-b', filepath], {});
if (info.code === 0) return this.parseFileInfo(info.stdout);
}
const info = await executeDirect('/usr/bin/file', ['-b', filepath], {});
if (info.code === 0) return BinaryInfoLinux.parseFileInfo(info.stdout);
return undefined;
}
}
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import * as fs from 'fs-extra';
@@ -73,11 +73,11 @@ export class WinUtils {
if (this.skippable.includes(dll_name.toLowerCase())) continue;
if (this.alreadyDone.includes(dll_name)) continue;
logger.debug('looking for ' + dll_name);
logger.debug(`looking for ${dll_name}`);
const dll_path = await this.find_first_file_in_dirs(paths, dll_name);
if (dll_path) {
logger.debug('found at ' + dll_path);
logger.debug(`found at ${dll_path}`);
dlls_used.push(dll_path);
this.alreadyDone.push(dll_name);
+24 -27
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import _ from 'underscore';
@@ -78,9 +78,11 @@ export class BuildEnvSetupBase {
let searchFor = arch as string;
if (this.compiler.exe.includes('icpx')) {
return arch === 'x86' || arch === 'x86_64';
} else if (this.compiler.exe.includes('circle')) {
}
if (this.compiler.exe.includes('circle')) {
return arch === 'x86' || arch === 'x86_64';
} else if (this.compiler.group === 'icc') {
}
if (this.compiler.group === 'icc') {
result = await execCompilerCached(this.compiler.exe, ['--help']);
if (arch === 'x86') {
searchFor = '-m32';
@@ -90,9 +92,8 @@ export class BuildEnvSetupBase {
} else if (this.compilerTypeOrGCC === 'gcc') {
if (this.compiler.exe.includes('/icpx')) {
return arch === 'x86' || arch === 'x86_64';
} else {
result = await execCompilerCached(this.compiler.exe, ['--target-help']);
}
result = await execCompilerCached(this.compiler.exe, ['--target-help']);
} else if (this.compilerTypeOrGCC === 'clang') {
const binpath = path.dirname(this.compiler.exe);
const llc = path.join(binpath, 'llc');
@@ -142,13 +143,11 @@ export class BuildEnvSetupBase {
if (target && arch) {
if (arch.length < target.length) {
return arch;
} else {
return target;
}
} else {
if (target) return target;
if (arch) return arch;
return target;
}
if (target) return target;
if (arch) return arch;
return false;
}
@@ -157,17 +156,16 @@ export class BuildEnvSetupBase {
const match = this.compiler.options.match(/-stdlib=(\S*)/i);
if (match) {
return match[1];
} else {
const stdlibOption: string | undefined = _.find(key.options, option => {
return option.startsWith('-stdlib=');
});
if (stdlibOption) {
return stdlibOption.substring(8);
}
return this.defaultLibCxx;
}
const stdlibOption: string | undefined = _.find(key.options, option => {
return option.startsWith('-stdlib=');
});
if (stdlibOption) {
return stdlibOption.substring(8);
}
return this.defaultLibCxx;
}
getTarget(key: CacheKey): string {
@@ -176,14 +174,13 @@ export class BuildEnvSetupBase {
if (key.options.includes('-m32')) {
return 'x86';
} else {
const target: string | undefined = _.find(key.options, option => {
return option.startsWith('-target=') || option.startsWith('--target=');
});
}
const target: string | undefined = _.find(key.options, option => {
return option.startsWith('-target=') || option.startsWith('--target=');
});
if (target) {
return target.substring(target.indexOf('=') + 1);
}
if (target) {
return target.substring(target.indexOf('=') + 1);
}
return 'x86_64';
+1 -1
View File
@@ -45,7 +45,7 @@ export class BuildEnvSetupCeConanCircleDirect extends BuildEnvSetupCeConanDirect
override async getConanBuildProperties(key: CacheKey): Promise<ConanBuildProperties> {
const props = await super.getConanBuildProperties(key);
props['compiler'] = this.linkedCompilerType;
props.compiler = this.linkedCompilerType;
props['compiler.version'] = this.linkedCompilerId;
return props;
}
+10 -13
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import _ from 'underscore';
@@ -61,16 +61,14 @@ export class BuildEnvSetupCeConanRustDirect extends BuildEnvSetupCeConanDirect {
}
getArchFromTriple(triple: string) {
if (triple && triple.split) {
if (triple?.split) {
const arr = triple.split('-');
if (arr && arr[0]) {
if (arr?.[0]) {
return arr[0];
} else {
return triple;
}
} else {
return '';
return triple;
}
return '';
}
override getTarget(key: CacheKey) {
@@ -84,12 +82,11 @@ export class BuildEnvSetupCeConanRustDirect extends BuildEnvSetupCeConanDirect {
if (target) {
const triple = target.substring(target.indexOf('=') + 1);
return this.getArchFromTriple(triple);
} else {
const idx = key.options.indexOf('--target');
if (idx !== -1) {
const triple = key.options[idx + 1];
return this.getArchFromTriple(triple);
}
}
const idx = key.options.indexOf('--target');
if (idx !== -1) {
const triple = key.options[idx + 1];
return this.getArchFromTriple(triple);
}
return 'x86_64';
+7 -8
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import zlib from 'zlib';
import path from 'node:path';
import zlib from 'node:zlib';
import fs, {mkdirp} from 'fs-extra';
import request from 'request';
@@ -126,9 +126,8 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase {
if (this.extractAllToRoot) {
const filename = path.basename(zippedPath);
return path.join(downloadPath, filename);
} else {
return path.join(downloadPath, libId, zippedPath);
}
return path.join(downloadPath, libId, zippedPath);
}
async downloadAndExtractPackage(
@@ -245,11 +244,11 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase {
return _.all(buildProperties, (val, key) => {
if ((key === 'compiler' || key === 'compiler.version') && elem.settings[key] === 'cshared') {
return true;
} else if (key === 'compiler.libcxx' && elem.settings['compiler'] === 'cshared') {
return true;
} else {
return val === elem.settings[key];
}
if (key === 'compiler.libcxx' && elem.settings.compiler === 'cshared') {
return true;
}
return val === elem.settings[key];
});
});
}
+2 -2
View File
@@ -32,8 +32,8 @@ import {OnDiskCache} from './on-disk.js';
import {S3Cache} from './s3.js';
function paramInt(config: string, param: string): number {
const result = parseInt(param);
if (isNaN(result)) throw new Error(`Bad params: ${config}`);
const result = Number.parseInt(param);
if (Number.isNaN(result)) throw new Error(`Bad params: ${config}`);
return result;
}
+3 -3
View File
@@ -23,8 +23,8 @@
// POSSIBILITY OF SUCH DAMAGE.
import {Buffer} from 'buffer';
import crypto from 'crypto';
import path from 'path';
import crypto from 'node:crypto';
import path from 'node:path';
import fs from 'fs-extra';
import {LRUCache} from 'lru-cache';
@@ -121,7 +121,7 @@ export class OnDiskCache extends BaseCache {
size: value.length,
};
// Write to a temp file and then rename
const tempFile = info.path + `.tmp.${crypto.randomUUID()}`;
const tempFile = `${info.path}.tmp.${crypto.randomUUID()}`;
await fs.writeFile(tempFile, value);
await fs.rename(tempFile, info.path);
this.cache.set(key, info);
+27 -25
View File
@@ -74,7 +74,7 @@ export class BaseCFGParser {
public filterData(assembly: AssemblyLine[]) {
const jmpLabelRegex = /\.L\d+:/;
const isCode = (x: AssemblyLine) =>
x && x.text && (x.source !== null || jmpLabelRegex.test(x.text) || this.isFunctionName(x));
x?.text && (x.source !== null || jmpLabelRegex.test(x.text) || this.isFunctionName(x));
return this.filterTextSection(assembly).map(_.clone).filter(isCode);
}
@@ -108,9 +108,12 @@ export class BaseCFGParser {
let rangeBb: BBRange = {nameId: functionName, start: first, end: 0, actionPos: []};
const result: BBRange[] = [];
const newRangeWith = function (oldRange: BBRange, nameId: string, start: number) {
return {nameId: nameId, start: start, actionPos: [], end: oldRange.end};
};
const newRangeWith = (oldRange: BBRange, nameId: string, start: number) => ({
nameId: nameId,
start: start,
actionPos: [],
end: oldRange.end,
});
while (first < last) {
const inst = asmArr[first].text;
@@ -176,7 +179,7 @@ export class BaseCFGParser {
}
protected extractNodeName(inst: string) {
return inst.match(/\.L\d+/) + ':';
return `${inst.match(/\.L\d+/)}:`;
}
protected splitToCanonicalBasicBlock(basicBlock: BBRange): CanonicalBB[] {
@@ -194,31 +197,30 @@ export class BaseCFGParser {
end: basicBlock.end,
},
];
else if (actPosSz === 1)
if (actPosSz === 1)
return [
{nameId: basicBlock.nameId, start: basicBlock.start, end: actionPos[0] + 1},
{nameId: basicBlock.nameId + '@' + (actionPos[0] + 1), start: actionPos[0] + 1, end: basicBlock.end},
{nameId: `${basicBlock.nameId}@${actionPos[0] + 1}`, start: actionPos[0] + 1, end: basicBlock.end},
];
else {
let first = 0;
const last = actPosSz;
const blockName = basicBlock.nameId;
let tmp: CanonicalBB = {nameId: blockName, start: basicBlock.start, end: actionPos[first] + 1};
const result: CanonicalBB[] = [];
result.push(_.clone(tmp));
while (first !== last - 1) {
tmp.nameId = blockName + '@' + (actionPos[first] + 1);
tmp.start = actionPos[first] + 1;
++first;
tmp.end = actionPos[first] + 1;
result.push(_.clone(tmp));
}
tmp = {nameId: blockName + '@' + (actionPos[first] + 1), start: actionPos[first] + 1, end: basicBlock.end};
let first = 0;
const last = actPosSz;
const blockName = basicBlock.nameId;
let tmp: CanonicalBB = {nameId: blockName, start: basicBlock.start, end: actionPos[first] + 1};
const result: CanonicalBB[] = [];
result.push(_.clone(tmp));
while (first !== last - 1) {
tmp.nameId = `${blockName}@${actionPos[first] + 1}`;
tmp.start = actionPos[first] + 1;
++first;
tmp.end = actionPos[first] + 1;
result.push(_.clone(tmp));
return result;
}
tmp = {nameId: `${blockName}@${actionPos[first] + 1}`, start: actionPos[first] + 1, end: basicBlock.end};
result.push(_.clone(tmp));
return result;
}
protected concatInstructions(asmArr: AssemblyLine[], first: number, last: number) {
@@ -250,7 +252,7 @@ export class BaseCFGParser {
return asm ? this.isBasicBlockEnd(asm.text, '') : false;
};
const generateName = function (name: string, suffix: number) {
const generateName = (name: string, suffix: number) => {
const pos = name.indexOf('@');
if (pos === -1) return `${name}@${suffix}`;
+2 -2
View File
@@ -36,7 +36,7 @@ export class ClangCFGParser extends BaseCFGParser {
override filterData(assembly: ResultLine[]) {
const jmpLabelRegex = /\.LBB\d+_\d+:/;
const isCode = (x: ResultLine) =>
x && x.text && (x.source !== null || jmpLabelRegex.test(x.text) || this.isFunctionName(x));
x?.text && (x.source !== null || jmpLabelRegex.test(x.text) || this.isFunctionName(x));
const removeComments = (x: ResultLine) => {
const pos_x86 = x.text.indexOf('# ');
@@ -50,6 +50,6 @@ export class ClangCFGParser extends BaseCFGParser {
}
override extractNodeName(inst: string) {
return inst.match(/\.LBB\d+_\d+/) + ':';
return `${inst.match(/\.LBB\d+_\d+/)}:`;
}
}
+2 -2
View File
@@ -36,11 +36,11 @@ export class GccCFGParser extends BaseCFGParser {
override filterData(assembly: ResultLine[]) {
const jmpLabelRegex = /\.L\d+:/;
const isCode = (x: AssemblyLine) =>
x && x.text && (x.source !== null || jmpLabelRegex.test(x.text) || this.isFunctionName(x));
x?.text && (x.source !== null || jmpLabelRegex.test(x.text) || this.isFunctionName(x));
return this.filterTextSection(assembly).map(_.clone).filter(isCode);
}
override extractNodeName(inst: string) {
return inst.match(/\.L\d+/) + ':';
return `${inst.match(/\.L\d+/)}:`;
}
}
+9 -7
View File
@@ -83,8 +83,8 @@ export class LlvmIrCfgParser extends BaseCFGParser {
const result: BBRange[] = [];
let i = fn.start + 1;
let bbStart = i;
let currentName: string = '';
let namePrefix: string = fnName + '\n\n';
let currentName = '';
let namePrefix = `${fnName}\n\n`;
while (i < fn.end) {
const match = code[i].text.match(this.labelRe);
if (match) {
@@ -159,7 +159,8 @@ export class LlvmIrCfgParser extends BaseCFGParser {
lastInst--;
}
return this.concatInstructions(asmArr, lastInst, end + 1);
} else if (
}
if (
lastInst >= 1 &&
asmArr[lastInst].text.includes('unwind label') &&
asmArr[lastInst - 1].text.trim().includes('invoke ')
@@ -168,7 +169,8 @@ export class LlvmIrCfgParser extends BaseCFGParser {
// invoke void @__cxa_throw(ptr nonnull %exception, ptr nonnull @typeinfo for int, ptr null) #3
// to label %unreachable unwind label %lpad
return this.concatInstructions(asmArr, lastInst - 1, lastInst + 1);
} else if (
}
if (
lastInst >= 1 &&
asmArr[lastInst - 1].text.includes('landingpad') &&
asmArr[lastInst].text.includes('catch')
@@ -177,7 +179,8 @@ export class LlvmIrCfgParser extends BaseCFGParser {
// %0 = landingpad { ptr, i32 }
// catch ptr null
return this.concatInstructions(asmArr, lastInst - 1, lastInst + 1);
} else if (
}
if (
lastInst >= 1 &&
asmArr[lastInst - 1].text.includes('callbr') &&
asmArr[lastInst].text.trim().startsWith('to label')
@@ -186,9 +189,8 @@ export class LlvmIrCfgParser extends BaseCFGParser {
// %2 = callbr i32 asm "mov ${1:l}, $0", "=r,!i,~{dirflag},~{fpsr},~{flags}"() #2
// to label %asm.fallthrough1 [label %err.split2]
return this.concatInstructions(asmArr, lastInst - 1, lastInst + 1);
} else {
return asmArr[lastInst].text;
}
return asmArr[lastInst].text;
})();
let terminator;
if (terminatingInstruction.includes('invoke ')) {
+29 -32
View File
@@ -28,7 +28,7 @@ import {EdgeColor} from '../../../types/compilation/cfg.interfaces.js';
import {logger} from '../../logger.js';
import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js';
import {AssemblyLine, BaseCFGParser, BBRange, CanonicalBB, Edge, Range} from './base.js';
import {AssemblyLine, BBRange, BaseCFGParser, CanonicalBB, Edge, Range} from './base.js';
// This currently only covers the default arm64 output. To support dex2oat's
// other ISAs, we just need to make sure the correct isJmpInstruction() is being
@@ -124,7 +124,7 @@ export class OatCFGParser extends BaseCFGParser {
// '0x00004168' -> '0x4168'
shortenHex(pc: string) {
const match = pc.match(this.hexRegex);
if (match) return '0x' + match[1];
if (match) return `0x${match[1]}`;
return pc;
}
@@ -153,14 +153,12 @@ export class OatCFGParser extends BaseCFGParser {
actionPos: [],
};
const newRangeWith = function (oldRange: BBRange, nameId: string, start: number) {
return {
nameId: nameId,
start: start,
actionPos: [],
end: oldRange.end,
};
};
const newRangeWith = (oldRange: BBRange, nameId: string, start: number) => ({
nameId: nameId,
start: start,
actionPos: [],
end: oldRange.end,
});
const result: BBRange[] = [];
while (first < last) {
@@ -212,7 +210,7 @@ export class OatCFGParser extends BaseCFGParser {
end: basicBlock.end,
},
];
else if (actPosSz === 1)
if (actPosSz === 1)
return [
{nameId: basicBlock.nameId, start: basicBlock.start, end: actionPos[0] + 1},
{
@@ -221,30 +219,29 @@ export class OatCFGParser extends BaseCFGParser {
end: basicBlock.end,
},
];
else {
let first = 0;
const last = actPosSz;
const blockName = basicBlock.nameId;
let tmp: CanonicalBB = {nameId: blockName, start: basicBlock.start, end: actionPos[first] + 1};
const result: CanonicalBB[] = [];
result.push(_.clone(tmp));
while (first !== last - 1) {
tmp.nameId = this.extractNodeName(this.code[actionPos[first] + 1].text);
tmp.start = actionPos[first] + 1;
++first;
tmp.end = actionPos[first] + 1;
result.push(_.clone(tmp));
}
tmp = {
nameId: this.extractNodeName(this.code[actionPos[first] + 1].text),
start: actionPos[first] + 1,
end: basicBlock.end,
};
let first = 0;
const last = actPosSz;
const blockName = basicBlock.nameId;
let tmp: CanonicalBB = {nameId: blockName, start: basicBlock.start, end: actionPos[first] + 1};
const result: CanonicalBB[] = [];
result.push(_.clone(tmp));
while (first !== last - 1) {
tmp.nameId = this.extractNodeName(this.code[actionPos[first] + 1].text);
tmp.start = actionPos[first] + 1;
++first;
tmp.end = actionPos[first] + 1;
result.push(_.clone(tmp));
return result;
}
tmp = {
nameId: this.extractNodeName(this.code[actionPos[first] + 1].text),
start: actionPos[first] + 1,
end: basicBlock.end,
};
result.push(_.clone(tmp));
return result;
}
override makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) {
+4 -5
View File
@@ -24,7 +24,7 @@
import type {CompilerInfo} from '../../types/compiler.interfaces.js';
import {AssemblyLine, Edge, getParserByKey, Node} from './cfg-parsers/index.js';
import {AssemblyLine, Edge, Node, getParserByKey} from './cfg-parsers/index.js';
import {OatCFGParser} from './cfg-parsers/oat.js';
import {getInstructionSetByKey} from './instruction-sets/index.js';
@@ -60,10 +60,9 @@ export function generateStructure(compilerInfo: CompilerInfo, asmArr: AssemblyLi
// dex2oat is a special case because it can output different instruction
// sets. Create an OAT parser instead of searching by ISA.
const parser =
compilerGroup && compilerGroup.includes('dex2oat')
? new OatCFGParser(instructionSet)
: new (getParserByKey(compilerGroup))(instructionSet);
const parser = compilerGroup?.includes('dex2oat')
? new OatCFGParser(instructionSet)
: new (getParserByKey(compilerGroup))(instructionSet);
const code = parser.filterData(asmArr);
const functions = parser.splitToFunctions(code);
+16 -25
View File
@@ -58,29 +58,21 @@ export class ArmInstructionSetInfo extends BaseInstructionSetInfo {
// blxcc reg
// movcc pc, reg
static conditionalJumps = new RegExp(
'\\b(?:' +
[
`b\\.?${ArmInstructionSetInfo.conditions}(?:\\.w)?`,
`bx${ArmInstructionSetInfo.conditions}`,
`bxj${ArmInstructionSetInfo.conditions}`,
`cbz`,
`cbnz`,
`tbz`,
`tbnz`,
]
.map(re => `(?:${re})`)
.join('|') +
')\\b',
);
static unconditionalJumps = new RegExp(
'\\b(?:' + [`b(?:\\.w)?`, `bx`, `bxj`].map(re => `(?:${re})`).join('|') + ')\\b',
`\\b(?:${[
`b\\.?${ArmInstructionSetInfo.conditions}(?:\\.w)?`,
`bx${ArmInstructionSetInfo.conditions}`,
`bxj${ArmInstructionSetInfo.conditions}`,
'cbz',
'cbnz',
'tbz',
'tbnz',
]
.map(re => `(?:${re})`)
.join('|')})\\b`,
);
static unconditionalJumps = new RegExp(`\\b(?:${['b(?:\\.w)?', 'bx', 'bxj'].map(re => `(?:${re})`).join('|')})\\b`);
static returnInstruction = new RegExp(
'(?:' +
[`bx`, `ret`].map(re => `(?:${re})`).join('|') +
')\\b.*' +
`|pop\\s*\\{(?:r(?:\\d{2,}|[4-9]),\\s*)*pc\\}.*` +
`|mov\\s*pc\\s*,.*`,
`(?:${['bx', 'ret'].map(re => `(?:${re})`).join('|')})\\b.*|pop\\s*\\{(?:r(?:\\d{2,}|[4-9]),\\s*)*pc\\}.*|mov\\s*pc\\s*,.*`,
);
static override get key(): InstructionSet[] {
@@ -97,11 +89,10 @@ export class ArmInstructionSetInfo extends BaseInstructionSetInfo {
override getInstructionType(instruction: string) {
const opcode = instruction.trim().split(' ')[0].toLowerCase();
if (ArmInstructionSetInfo.conditionalJumps.test(opcode)) return InstructionType.conditionalJmpInst;
else if (ArmInstructionSetInfo.unconditionalJumps.test(opcode)) return InstructionType.jmp;
else if (ArmInstructionSetInfo.returnInstruction.test(instruction.trim().toLocaleLowerCase())) {
if (ArmInstructionSetInfo.unconditionalJumps.test(opcode)) return InstructionType.jmp;
if (ArmInstructionSetInfo.returnInstruction.test(instruction.trim().toLocaleLowerCase())) {
return InstructionType.retInst;
} else {
return InstructionType.notRetInst;
}
return InstructionType.notRetInst;
}
}
+7 -8
View File
@@ -25,10 +25,10 @@
import {InstructionSet} from '../../../types/instructionsets.js';
export enum InstructionType {
jmp,
conditionalJmpInst,
notRetInst,
retInst,
jmp = 0,
conditionalJmpInst = 1,
notRetInst = 2,
retInst = 3,
}
export class BaseInstructionSetInfo {
@@ -46,11 +46,10 @@ export class BaseInstructionSetInfo {
getInstructionType(inst: string) {
if (inst.includes('jmp') || inst.includes(' b ')) return InstructionType.jmp;
else if (this.isJmpInstruction(inst)) return InstructionType.conditionalJmpInst;
else if (inst.includes(' ret')) {
if (this.isJmpInstruction(inst)) return InstructionType.conditionalJmpInst;
if (inst.includes(' ret')) {
return InstructionType.retInst;
} else {
return InstructionType.notRetInst;
}
return InstructionType.notRetInst;
}
}
+5 -7
View File
@@ -377,9 +377,8 @@ class GoldenLayoutComponents {
filename: session.filename,
},
};
} else {
return editor;
}
return editor;
}
createTreeComponent(tree: ClientStateTree, customTreeId?: number): GoldenLayoutComponentStruct {
@@ -884,12 +883,11 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
createSourceContentArray(state: ClientState, leftSession: number, rightSession: number): BasicGoldenLayoutStruct[] {
if (leftSession === rightSession) {
return [this.createPresentationModeComponents(state.sessions[leftSession], 1, 100)];
} else {
return [
this.createPresentationModeComponents(state.sessions[leftSession], 1),
this.createPresentationModeComponents(state.sessions[rightSession], 2),
];
}
return [
this.createPresentationModeComponents(state.sessions[leftSession], 1),
this.createPresentationModeComponents(state.sessions[rightSession], 2),
];
}
getPresentationModeEmptyLayout() {
+1 -1
View File
@@ -121,7 +121,7 @@ export class ClientStateCompiler {
export class ClientStateExecutor {
compilerVisible = false;
compilerOutputVisible = false;
arguments: string = '';
arguments = '';
argumentsVisible = false;
stdin = '';
stdinVisible = false;
+7 -7
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import child_process from 'child_process';
import child_process from 'node:child_process';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -39,7 +39,7 @@ import {FormattingHandler} from './handlers/formatting.js';
import {logger} from './logger.js';
import type {PropertyGetter} from './properties.interfaces.js';
import {CompilerProps, PropFunc} from './properties.js';
import {createStatsNoter, IStatsNoter} from './stats.js';
import {IStatsNoter, createStatsNoter} from './stats.js';
export class CompilationEnvironment {
ceProps: PropertyGetter;
@@ -116,9 +116,9 @@ export class CompilationEnvironment {
getEnv(needsMulti: boolean) {
const env = {...this.baseEnv};
if (needsMulti && this.multiarch) {
env.LIBRARY_PATH = '/usr/lib/' + this.multiarch;
env.C_INCLUDE_PATH = '/usr/include/' + this.multiarch;
env.CPLUS_INCLUDE_PATH = '/usr/include/' + this.multiarch;
env.LIBRARY_PATH = `/usr/lib/${this.multiarch}`;
env.C_INCLUDE_PATH = `/usr/include/${this.multiarch}`;
env.CPLUS_INCLUDE_PATH = `/usr/include/${this.multiarch}`;
}
return env;
}
@@ -164,13 +164,13 @@ export class CompilationEnvironment {
}
getExecutableHash(object: CacheableValue): string {
return BaseCache.hash(object) + '_exec';
return `${BaseCache.hash(object)}_exec`;
}
async executableGet(key: string, destinationFolder: string): Promise<string | null> {
const result = await this.executableCache.get(key);
if (!result.hit) return null;
const filepath = destinationFolder + '/' + key;
const filepath = `${destinationFolder}/${key}`;
await fs.writeFile(filepath, unwrap(result.data));
return filepath;
}
+2 -2
View File
@@ -23,7 +23,7 @@
// POSSIBILITY OF SUCH DAMAGE.
// eslint-disable-next-line n/no-unsupported-features/node-builtins
import {executionAsyncId} from 'async_hooks';
import {executionAsyncId} from 'node:async_hooks';
import {default as Queue} from 'p-queue';
import PromClient from 'prom-client';
@@ -90,7 +90,7 @@ export class CompilationQueue {
() => {
const dequeuedAt = Date.now();
queueDequeued.inc();
if (options && options.abandonIfStale && dequeuedAt > enqueuedAt + this._staleAfterMs) {
if (options?.abandonIfStale && dequeuedAt > enqueuedAt + this._staleAfterMs) {
queueCompleted.inc();
queueStale.inc();
const queueTimeSecs = (dequeuedAt - enqueuedAt) / 1000;
+13 -8
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -53,7 +53,7 @@ export class CompilerArguments implements ICompilerArguments {
localfolder = resolvePathFromAppRoot(localfolder);
}
const filepath = path.join(localfolder, this.compilerId + '.json');
const filepath = path.join(localfolder, `${this.compilerId}.json`);
if (await fileExists(filepath)) {
const contents = await fs.readFile(filepath);
const stats = JSON.parse(contents.toString());
@@ -80,7 +80,7 @@ export class CompilerArguments implements ICompilerArguments {
if (region && bucket && prefix && this.compilerId) {
const s3 = new S3Bucket(bucket, region);
const result = await s3.get(this.compilerId + '.json', prefix);
const result = await s3.get(`${this.compilerId}.json`, prefix);
if (result.hit) {
const stats = JSON.parse(unwrap(result.data).toString());
_.each(stats, (times, arg) => {
@@ -124,15 +124,20 @@ export class CompilerArguments implements ICompilerArguments {
// prefer optimization flags or standard if statistics are not available
if (a[1].description.includes('optimization')) {
return -1;
} else if (b[1].description.includes('optimization')) {
}
if (b[1].description.includes('optimization')) {
return 1;
} else if (a[1].description.includes('optimize')) {
}
if (a[1].description.includes('optimize')) {
return -1;
} else if (b[1].description.includes('optimize')) {
}
if (b[1].description.includes('optimize')) {
return 1;
} else if (a[1].description.includes('std')) {
}
if (a[1].description.includes('std')) {
return -1;
} else if (b[1].description.includes('std')) {
}
if (b[1].description.includes('std')) {
return 1;
}
}
+12 -16
View File
@@ -22,10 +22,10 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import http from 'http';
import https from 'https';
import path from 'path';
import {promisify} from 'util';
import http from 'node:http';
import https from 'node:https';
import path from 'node:path';
import {promisify} from 'node:util';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -119,14 +119,11 @@ export class CompilerFinder {
if (statusCode !== 200) {
error = new Error(
'Failed fetching remote compilers from ' +
`${uriSchema}://${host}:${port}${apiPath}\n` +
`Status Code: ${statusCode}`,
`Failed fetching remote compilers from ${uriSchema}://${host}:${port}${apiPath}\nStatus Code: ${statusCode}`,
);
} else if (!contentType || !/^application\/json/.test(contentType)) {
error = new Error(
'Invalid content-type.\n' +
`Expected application/json but received ${contentType}`,
`Invalid content-type.\nExpected application/json but received ${contentType}`,
);
}
if (error) {
@@ -147,7 +144,7 @@ export class CompilerFinder {
// e.g. https://www.godbolt.ms
// (see https://github.com/compiler-explorer/compiler-explorer/issues/1768)
if (!compiler.alias) compiler.alias = [];
if (typeof compiler.alias == 'string') compiler.alias = [compiler.alias];
if (typeof compiler.alias === 'string') compiler.alias = [compiler.alias];
// End fixup
compiler.exe = '/dev/null';
compiler.remote = {
@@ -184,7 +181,7 @@ export class CompilerFinder {
const instances = await this.awsInstances();
const mapped = await Promise.all(
instances.map(instance => {
logger.info('Checking instance ' + instance.InstanceId);
logger.info(`Checking instance ${instance.InstanceId}`);
const address = this.awsProps('externalTestMode', false)
? instance.PublicDnsName
: instance.PrivateDnsName;
@@ -353,8 +350,7 @@ export class CompilerFinder {
if (props('demanglerClassFile') !== undefined) {
logger.error(
`Error in compiler.${compilerId}: ` +
'demanglerClassFile is no longer supported, please use demanglerType',
`Error in compiler.${compilerId}: demanglerClassFile is no longer supported, please use demanglerType`,
);
return null;
}
@@ -379,7 +375,7 @@ export class CompilerFinder {
const bits = compilerName.split('@');
const host = bits[0];
const pathParts = bits[1].split('/');
const port = parseInt(unwrap(pathParts.shift()));
const port = Number.parseInt(unwrap(pathParts.shift()));
const path = pathParts.join('/');
return (await this.fetchRemote(host, port, path, this.ceProps, langId)) || [];
}
@@ -598,13 +594,13 @@ export class CompilerFinder {
if (compiler.buildenvsetup) {
compiler.buildenvsetup.props = (propName, def) => {
return this.compilerProps(langId, 'buildenvsetup.' + propName, def);
return this.compilerProps(langId, `buildenvsetup.${propName}`, def);
};
}
if (compiler.externalparser) {
compiler.externalparser.props = (propName: string, def: any) => {
return this.compilerProps(langId, 'externalparser.' + propName, def);
return this.compilerProps(langId, `externalparser.${propName}`, def);
};
}
+12 -9
View File
@@ -23,7 +23,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -72,13 +72,13 @@ export class AdaCompiler extends BaseCompiler {
// - "foo.o" may be used by intermediary file, so "-o foo.o" will not
// work if building an executable.
if (key && key.filters && key.filters.binary) {
if (key?.filters?.binary) {
return path.join(dirPath, 'example');
} else if (key && key.filters && key.filters.binaryObject) {
return path.join(dirPath, 'example.o');
} else {
return path.join(dirPath, 'example.s');
}
if (key?.filters?.binaryObject) {
return path.join(dirPath, 'example.o');
}
return path.join(dirPath, 'example.s');
}
override prepareArguments(
@@ -174,13 +174,16 @@ export class AdaCompiler extends BaseCompiler {
if (a === '-cargs') {
part = 1;
continue;
} else if (a === '-largs') {
}
if (a === '-largs') {
part = 2;
continue;
} else if (a === '-bargs') {
}
if (a === '-bargs') {
part = 3;
continue;
} else if (a === '-margs') {
}
if (a === '-margs') {
part = 0;
continue;
}
+173 -159
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import process from 'process';
import path from 'node:path';
import process from 'node:process';
import * as Sentry from '@sentry/node';
import fs from 'fs-extra';
@@ -58,7 +58,7 @@ export class BaseParser {
}
static getExampleFilepath(): string {
let filename = path.join(this.getExamplesRoot(), this.getDefaultExampleFilename());
let filename = path.join(BaseParser.getExamplesRoot(), BaseParser.getDefaultExampleFilename());
if (!path.isAbsolute(filename)) filename = path.join(process.cwd(), filename);
return filename;
@@ -70,18 +70,19 @@ export class BaseParser {
utils.eachLine(stdout, line => {
const match1 = line.match(optionWithDescRegex);
if (match1 && match1[1] && match1[2]) {
if (match1?.[1] && match1[2]) {
previousOption = match1[1].trim();
if (previousOption) {
options[previousOption] = {
description: this.spaceCompress(match1[2].trim()),
description: BaseParser.spaceCompress(match1[2].trim()),
timesused: 0,
};
}
return;
} else if (optionWithoutDescRegex) {
}
if (optionWithoutDescRegex) {
const match2 = line.match(optionWithoutDescRegex);
if (match2 && match2[1]) {
if (match2?.[1]) {
previousOption = match2[1].trim();
if (previousOption) {
@@ -99,14 +100,14 @@ export class BaseParser {
options[previousOption].description += line.trim();
else {
if (options[previousOption].description.length > 0) {
const combined = options[previousOption].description + ' ' + line.trim();
const combined = `${options[previousOption].description} ${line.trim()}`;
options[previousOption].description = combined;
} else {
options[previousOption].description = line.trim();
}
}
options[previousOption].description = this.spaceCompress(options[previousOption].description);
options[previousOption].description = BaseParser.spaceCompress(options[previousOption].description);
} else {
previousOption = false;
}
@@ -133,11 +134,11 @@ export class BaseParser {
}
static async getOptions(compiler: BaseCompiler, helpArg: string) {
const optionFinder1 = /^ *(--?[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*) +(.*)/i;
const optionFinder1 = /^ *(--?[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*) {2,}(.*)/i;
const optionFinder2 = /^ *(--?[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, [helpArg]);
const options =
result.code === 0 ? this.parseLines(result.stdout + result.stderr, optionFinder1, optionFinder2) : {};
result.code === 0 ? BaseParser.parseLines(result.stdout + result.stderr, optionFinder1, optionFinder2) : {};
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -165,18 +166,18 @@ export class GCCParser extends BaseParser {
static override async setCompilerSettingsFromOptions(compiler: BaseCompiler, options: Record<string, Argument>) {
const keys = _.keys(options);
logger.debug(`gcc-like compiler options: ${keys.join(' ')}`);
if (this.hasSupport(options, '-masm=')) {
await this.checkAndSetMasmIntelIfSupported(compiler);
if (GCCParser.hasSupport(options, '-masm=')) {
await GCCParser.checkAndSetMasmIntelIfSupported(compiler);
}
if (this.hasSupport(options, '-fstack-usage')) {
if (GCCParser.hasSupport(options, '-fstack-usage')) {
compiler.compiler.stackUsageArg = '-fstack-usage';
compiler.compiler.supportsStackUsageOutput = true;
}
if (this.hasSupport(options, '-fdiagnostics-color')) {
if (GCCParser.hasSupport(options, '-fdiagnostics-color')) {
if (compiler.compiler.options) compiler.compiler.options += ' ';
compiler.compiler.options += '-fdiagnostics-color=always';
}
if (this.hasSupport(options, '-fverbose-asm')) {
if (GCCParser.hasSupport(options, '-fverbose-asm')) {
compiler.compiler.supportsVerboseAsm = true;
}
// This check is not infallible, but takes care of Rust and Swift being picked up :)
@@ -188,22 +189,22 @@ export class GCCParser extends BaseParser {
// not produce anything.
compiler.compiler.removeEmptyGccDump = true;
}
if (this.hasSupportStartsWith(options, '-march=')) compiler.compiler.supportsMarch = true;
if (this.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (this.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
if (GCCParser.hasSupportStartsWith(options, '-march=')) compiler.compiler.supportsMarch = true;
if (GCCParser.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (GCCParser.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
}
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([
this.getOptions(compiler, '-fsyntax-only --help'),
this.getOptions(compiler, '-fsyntax-only --target-help'),
this.getOptions(compiler, '-fsyntax-only --help=common'),
this.getOptions(compiler, '-fsyntax-only --help=warnings'),
this.getOptions(compiler, '-fsyntax-only --help=optimizers'),
this.getOptions(compiler, '-fsyntax-only --help=target'),
GCCParser.getOptions(compiler, '-fsyntax-only --help'),
GCCParser.getOptions(compiler, '-fsyntax-only --target-help'),
GCCParser.getOptions(compiler, '-fsyntax-only --help=common'),
GCCParser.getOptions(compiler, '-fsyntax-only --help=warnings'),
GCCParser.getOptions(compiler, '-fsyntax-only --help=optimizers'),
GCCParser.getOptions(compiler, '-fsyntax-only --help=target'),
]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await GCCParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
@@ -213,9 +214,8 @@ export class GCCParser extends BaseParser {
const match = result.stdout.match(re);
if (match) {
return match[1].split(' ');
} else {
return [];
}
return [];
}
static getLanguageSpecificHelpFlags(): string[] {
@@ -224,12 +224,12 @@ export class GCCParser extends BaseParser {
static override async getPossibleStdvers(compiler: BaseCompiler): Promise<CompilerOverrideOptions> {
const possible: CompilerOverrideOptions = [];
const options = await this.getOptionsStrict(compiler, this.getLanguageSpecificHelpFlags());
const options = await GCCParser.getOptionsStrict(compiler, GCCParser.getLanguageSpecificHelpFlags());
for (const opt in options) {
if (opt.startsWith('-std=') && !options[opt].description?.startsWith('Deprecated')) {
const stdver = opt.substring(5);
possible.push({
name: stdver + ': ' + options[opt].description,
name: `${stdver}: ${options[opt].description}`,
value: stdver,
});
}
@@ -238,11 +238,11 @@ export class GCCParser extends BaseParser {
}
static override async getOptions(compiler: BaseCompiler, helpArg: string) {
const optionFinder1 = /^ *(--?[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*) +(.*)/i;
const optionFinder1 = /^ *(--?[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*) {2,}(.*)/i;
const optionFinder2 = /^ *(--?[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' '));
const options =
result.code === 0 ? this.parseLines(result.stdout + result.stderr, optionFinder1, optionFinder2) : {};
result.code === 0 ? GCCParser.parseLines(result.stdout + result.stderr, optionFinder1, optionFinder2) : {};
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -250,7 +250,7 @@ export class GCCParser extends BaseParser {
static async getOptionsStrict(compiler: BaseCompiler, helpArgs: string[]) {
const optionFinder = /^ {2}(--?[\d+,<=>[\]a-z|-]*) *(.*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArgs);
return result.code === 0 ? this.parseLines(result.stdout + result.stderr, optionFinder) : {};
return result.code === 0 ? GCCParser.parseLines(result.stdout + result.stderr, optionFinder) : {};
}
}
@@ -265,51 +265,52 @@ export class ClangParser extends BaseParser {
logger.error(`compiler options appear empty for ${compiler.compiler.id}`);
}
if (this.hasSupport(options, '-fsave-optimization-record')) {
if (ClangParser.hasSupport(options, '-fsave-optimization-record')) {
compiler.compiler.optArg = '-fsave-optimization-record';
compiler.compiler.supportsOptOutput = true;
}
if (this.hasSupport(options, '-fstack-usage')) {
if (ClangParser.hasSupport(options, '-fstack-usage')) {
compiler.compiler.stackUsageArg = '-fstack-usage';
compiler.compiler.supportsStackUsageOutput = true;
}
if (this.hasSupport(options, '-fverbose-asm')) {
if (ClangParser.hasSupport(options, '-fverbose-asm')) {
compiler.compiler.supportsVerboseAsm = true;
}
if (this.hasSupport(options, '-emit-llvm')) {
if (ClangParser.hasSupport(options, '-emit-llvm')) {
compiler.compiler.supportsIrView = true;
compiler.compiler.irArg = ['-Xclang', '-emit-llvm', '-fsyntax-only'];
compiler.compiler.minIrArgs = ['-emit-llvm'];
}
if (this.hasSupport(options, '-emit-cir')) {
if (ClangParser.hasSupport(options, '-emit-cir')) {
compiler.compiler.supportsClangirView = true;
}
if (
this.hasSupport(options, '-mllvm') &&
this.mllvmOptions.has('--print-before-all') &&
this.mllvmOptions.has('--print-after-all')
ClangParser.hasSupport(options, '-mllvm') &&
ClangParser.mllvmOptions.has('--print-before-all') &&
ClangParser.mllvmOptions.has('--print-after-all')
) {
compiler.compiler.optPipeline = {
arg: ['-mllvm', '--print-before-all', '-mllvm', '--print-after-all'],
moduleScopeArg: [],
noDiscardValueNamesArg: [],
};
if (this.mllvmOptions.has('--print-module-scope')) {
if (ClangParser.mllvmOptions.has('--print-module-scope')) {
compiler.compiler.optPipeline.moduleScopeArg = ['-mllvm', '-print-module-scope'];
}
if (this.hasSupport(options, '-fno-discard-value-names')) {
if (ClangParser.hasSupport(options, '-fno-discard-value-names')) {
compiler.compiler.optPipeline.noDiscardValueNamesArg = ['-fno-discard-value-names'];
}
}
if (this.hasSupport(options, '-fcolor-diagnostics')) compiler.compiler.options += ' -fcolor-diagnostics';
if (this.hasSupport(options, '-fno-crash-diagnostics')) compiler.compiler.options += ' -fno-crash-diagnostics';
if (ClangParser.hasSupport(options, '-fcolor-diagnostics')) compiler.compiler.options += ' -fcolor-diagnostics';
if (ClangParser.hasSupport(options, '-fno-crash-diagnostics'))
compiler.compiler.options += ' -fno-crash-diagnostics';
if (this.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (this.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
if (ClangParser.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (ClangParser.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
}
static getMainHelpOptions(): string[] {
@@ -330,14 +331,21 @@ export class ClangParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
try {
const options = await this.getOptions(compiler, this.getMainHelpOptions().join(' '));
const options = await ClangParser.getOptions(compiler, ClangParser.getMainHelpOptions().join(' '));
const filename = this.getExampleFilepath();
const filename = ClangParser.getExampleFilepath();
this.mllvmOptions = new Set(
_.keys(await this.getOptions(compiler, this.getHiddenHelpOptions(filename).join(' '), false, true)),
ClangParser.mllvmOptions = new Set(
_.keys(
await ClangParser.getOptions(
compiler,
ClangParser.getHiddenHelpOptions(filename).join(' '),
false,
true,
),
),
);
this.setCompilerSettingsFromOptions(compiler, options);
ClangParser.setCompilerSettingsFromOptions(compiler, options);
} catch (error) {
const err = `Error while trying to generate llvm backend arguments for ${compiler.compiler.id}: ${error}`;
logger.error(err);
@@ -356,7 +364,7 @@ export class ClangParser extends BaseParser {
if (!match[i]) return [];
arr.push({
name: match[i] + ': ' + match[maxToMatch],
name: `${match[i]}: ${match[maxToMatch]}`,
value: match[i],
});
}
@@ -372,22 +380,22 @@ export class ClangParser extends BaseParser {
const re4 = /note: use '([\w+:]*)', '([\w+:]*)', '([\w+:]*)', or '([\w+:]*)' for '(.*)' standard/;
for (const line of lines) {
let match = line.match(re1);
let stdvers = this.getRegexMatchesAsStdver(match, 2);
let stdvers = ClangParser.getRegexMatchesAsStdver(match, 2);
possible.push(...stdvers);
if (stdvers.length > 0) continue;
match = line.match(re2);
stdvers = this.getRegexMatchesAsStdver(match, 3);
stdvers = ClangParser.getRegexMatchesAsStdver(match, 3);
possible.push(...stdvers);
if (stdvers.length > 0) continue;
match = line.match(re3);
stdvers = this.getRegexMatchesAsStdver(match, 4);
stdvers = ClangParser.getRegexMatchesAsStdver(match, 4);
possible.push(...stdvers);
if (stdvers.length > 0) continue;
match = line.match(re4);
stdvers = this.getRegexMatchesAsStdver(match, 5);
stdvers = ClangParser.getRegexMatchesAsStdver(match, 5);
possible.push(...stdvers);
}
return possible;
@@ -397,16 +405,20 @@ export class ClangParser extends BaseParser {
let possible: CompilerOverrideOptions = [];
// clang doesn't have a --help option to get the std versions, we'll have to compile with a fictional stdversion to coax a response
const filename = this.getExampleFilepath();
const filename = ClangParser.getExampleFilepath();
const result = await compiler.execCompilerCached(compiler.compiler.exe, this.getStdVersHelpOptions(filename), {
...compiler.getDefaultExecOptions(),
createAndUseTempDir: true,
});
const result = await compiler.execCompilerCached(
compiler.compiler.exe,
ClangParser.getStdVersHelpOptions(filename),
{
...compiler.getDefaultExecOptions(),
createAndUseTempDir: true,
},
);
if (result.stderr) {
const lines = utils.splitLines(result.stderr);
possible = this.extractPossibleStdvers(lines);
possible = ClangParser.extractPossibleStdvers(lines);
possible.sort((a, b) => {
return a.value === b.value ? 0 : a.value > b.value ? 1 : -1;
});
@@ -422,16 +434,15 @@ export class ClangParser extends BaseParser {
const match = line.match(re);
if (match) {
return match[1];
} else {
return false;
}
return false;
})
.filter(Boolean) as string[];
}
static override async getPossibleTargets(compiler: BaseCompiler): Promise<string[]> {
const result = await compiler.execCompilerCached(compiler.compiler.exe, this.getTargetsHelpOptions());
return this.extractPossibleTargets(utils.splitLines(result.stdout));
const result = await compiler.execCompilerCached(compiler.compiler.exe, ClangParser.getTargetsHelpOptions());
return ClangParser.extractPossibleTargets(utils.splitLines(result.stdout));
}
static override async getOptions(compiler: BaseCompiler, helpArg: string, populate = true, isolate = false) {
@@ -442,7 +453,7 @@ export class ClangParser extends BaseParser {
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' '), execOptions);
const options =
result.code === 0
? this.parseLines(result.stdout + result.stderr, optionFinderWithDesc, optionFinderWithoutDesc)
? ClangParser.parseLines(result.stdout + result.stderr, optionFinderWithDesc, optionFinderWithoutDesc)
: {};
if (populate) compiler.possibleArguments.populateOptions(options);
return options;
@@ -491,10 +502,10 @@ export class ClangCParser extends ClangParser {
export class CircleParser extends ClangParser {
static override async getOptions(compiler: BaseCompiler, helpArg: string) {
const optionFinder1 = /^ +(--?[\w#,.<=>[\]|-]*) +- (.*)/i;
const optionFinder1 = /^ +(--?[\w#,.<=>[\]|-]*) {2,}- (.*)/i;
const optionFinder2 = /^ +(--?[\w#,.<=>[\]|-]*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' '));
const options = result.code === 0 ? this.parseLines(result.stdout, optionFinder1, optionFinder2) : {};
const options = result.code === 0 ? CircleParser.parseLines(result.stdout, optionFinder1, optionFinder2) : {};
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -508,7 +519,8 @@ export class CircleParser extends ClangParser {
if (!isInStdVerSection && line.startsWith(' --std=')) {
isInStdVerSection = true;
continue;
} else if (isInStdVerSection && line.startsWith(' --')) {
}
if (isInStdVerSection && line.startsWith(' --')) {
break;
}
@@ -519,7 +531,7 @@ export class CircleParser extends ClangParser {
const stdver = match[1];
const desc = match[2];
possible.push({
name: stdver + ': ' + desc,
name: `${stdver}: ${desc}`,
value: stdver,
});
}
@@ -530,44 +542,44 @@ export class CircleParser extends ClangParser {
export class LDCParser extends BaseParser {
static override async setCompilerSettingsFromOptions(compiler: BaseCompiler, options: Record<string, Argument>) {
if (this.hasSupport(options, '--fsave-optimization-record')) {
if (LDCParser.hasSupport(options, '--fsave-optimization-record')) {
compiler.compiler.optArg = '--fsave-optimization-record';
compiler.compiler.supportsOptOutput = true;
}
if (this.hasSupport(options, '-fverbose-asm')) {
if (LDCParser.hasSupport(options, '-fverbose-asm')) {
compiler.compiler.supportsVerboseAsm = true;
}
if (this.hasSupport(options, '--print-before-all') && this.hasSupport(options, '--print-after-all')) {
if (LDCParser.hasSupport(options, '--print-before-all') && LDCParser.hasSupport(options, '--print-after-all')) {
compiler.compiler.optPipeline = {
arg: ['--print-before-all', '--print-after-all'],
moduleScopeArg: [],
noDiscardValueNamesArg: [],
};
if (this.hasSupport(options, '--print-module-scope')) {
if (LDCParser.hasSupport(options, '--print-module-scope')) {
compiler.compiler.optPipeline.moduleScopeArg = ['--print-module-scope'];
}
if (this.hasSupport(options, '--fno-discard-value-names')) {
if (LDCParser.hasSupport(options, '--fno-discard-value-names')) {
compiler.compiler.optPipeline.noDiscardValueNamesArg = ['--fno-discard-value-names'];
}
}
if (this.hasSupport(options, '--enable-color')) {
if (LDCParser.hasSupport(options, '--enable-color')) {
compiler.compiler.options += ' --enable-color';
}
}
static override async parse(compiler: BaseCompiler) {
const options = await this.getOptions(compiler, '--help-hidden');
this.setCompilerSettingsFromOptions(compiler, options);
const options = await LDCParser.getOptions(compiler, '--help-hidden');
LDCParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
static override async getOptions(compiler: BaseCompiler, helpArg: string, populate = true) {
const optionFinder = /^\s*(--?[\d+,<=>[\]a-z|-]*)\s*(.*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' '));
const options = result.code === 0 ? this.parseLines(result.stdout + result.stderr, optionFinder) : {};
const options = result.code === 0 ? LDCParser.parseLines(result.stdout + result.stderr, optionFinder) : {};
if (populate) {
compiler.possibleArguments.populateOptions(options);
}
@@ -577,21 +589,21 @@ export class LDCParser extends BaseParser {
export class ElixirParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '--help');
await ElixirParser.getOptions(compiler, '--help');
return compiler;
}
}
export class ErlangParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await ErlangParser.getOptions(compiler, '-help');
return compiler;
}
}
export class PascalParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await PascalParser.getOptions(compiler, '-help');
return compiler;
}
}
@@ -599,11 +611,11 @@ export class PascalParser extends BaseParser {
export class ICCParser extends GCCParser {
static override async setCompilerSettingsFromOptions(compiler: BaseCompiler, options: Record<string, Argument>) {
const keys = _.keys(options);
if (this.hasSupport(options, '-masm=')) {
if (ICCParser.hasSupport(options, '-masm=')) {
compiler.compiler.intelAsm = '-masm=intel';
compiler.compiler.supportsIntel = true;
}
if (this.hasSupport(options, '-fdiagnostics-color')) {
if (ICCParser.hasSupport(options, '-fdiagnostics-color')) {
if (compiler.compiler.options) compiler.compiler.options += ' ';
compiler.compiler.options += '-fdiagnostics-color=always';
}
@@ -611,9 +623,9 @@ export class ICCParser extends GCCParser {
compiler.compiler.supportsGccDump = true;
compiler.compiler.removeEmptyGccDump = true;
}
if (this.hasSupportStartsWith(options, '-march=')) compiler.compiler.supportsMarch = true;
if (this.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (this.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
if (ICCParser.hasSupportStartsWith(options, '-march=')) compiler.compiler.supportsMarch = true;
if (ICCParser.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (ICCParser.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
}
static extractPossibleStdvers(lines: string[]): CompilerOverrideOptions {
@@ -632,7 +644,7 @@ export class ICCParser extends GCCParser {
const descMatch = line.match(descRe);
if (descMatch) {
possible.push({
name: descMatch[1] + ': ' + descMatch[2],
name: `${descMatch[1]}: ${descMatch[2]}`,
value: descMatch[1],
});
} else {
@@ -653,35 +665,35 @@ export class ICCParser extends GCCParser {
const result = await compiler.execCompilerCached(compiler.compiler.exe, ['--help']);
const lines = utils.splitLines(result.stdout);
return this.extractPossibleStdvers(lines);
return ICCParser.extractPossibleStdvers(lines);
}
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([this.getOptions(compiler, '-fsyntax-only --help')]);
const results = await Promise.all([ICCParser.getOptions(compiler, '-fsyntax-only --help')]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await ICCParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
}
export class ISPCParser extends BaseParser {
static override async setCompilerSettingsFromOptions(compiler: BaseCompiler, options: Record<string, Argument>) {
if (this.hasSupport(options, '--x86-asm-syntax')) {
if (ISPCParser.hasSupport(options, '--x86-asm-syntax')) {
compiler.compiler.intelAsm = '--x86-asm-syntax=intel';
compiler.compiler.supportsIntel = true;
}
}
static override async parse(compiler: BaseCompiler) {
const options = await this.getOptions(compiler, '--help');
await this.setCompilerSettingsFromOptions(compiler, options);
const options = await ISPCParser.getOptions(compiler, '--help');
await ISPCParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
static override async getOptions(compiler: BaseCompiler, helpArg: string) {
const result = await compiler.execCompilerCached(compiler.compiler.exe, [helpArg]);
const optionFinder = /^\s*\[(--?[\d\s()+,/<=>a-z{|}-]*)]\s*(.*)/i;
const options = result.code === 0 ? this.parseLines(result.stdout + result.stderr, optionFinder) : {};
const options = result.code === 0 ? ISPCParser.parseLines(result.stdout + result.stderr, optionFinder) : {};
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -689,28 +701,28 @@ export class ISPCParser extends BaseParser {
export class JavaParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await JavaParser.getOptions(compiler, '-help');
return compiler;
}
}
export class KotlinParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await KotlinParser.getOptions(compiler, '-help');
return compiler;
}
}
export class ScalaParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await ScalaParser.getOptions(compiler, '-help');
return compiler;
}
}
export class VCParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '/help');
await VCParser.getOptions(compiler, '/help');
return compiler;
}
@@ -725,10 +737,10 @@ export class VCParser extends BaseParser {
if (!match) {
if (previousOption && line.trim().length > 0) {
if (options[previousOption].description.endsWith(':'))
options[previousOption].description += ' ' + line.trim();
options[previousOption].description += ` ${line.trim()}`;
else {
if (options[previousOption].description.length > 0)
options[previousOption].description += ', ' + line.trim();
options[previousOption].description += `, ${line.trim()}`;
else options[previousOption].description = line.trim();
}
} else {
@@ -784,7 +796,7 @@ export class VCParser extends BaseParser {
if (descMatch) {
if (stdverValues.includes(descMatch[1])) {
possible.push({
name: descMatch[1] + ': ' + descMatch[2],
name: `${descMatch[1]}: ${descMatch[2]}`,
value: descMatch[1],
});
} else {
@@ -802,13 +814,13 @@ export class VCParser extends BaseParser {
const result = await compiler.execCompilerCached(compiler.compiler.exe, ['/help']);
const lines = utils.splitLines(result.stdout);
return this.extractPossibleStdvers(lines);
return VCParser.extractPossibleStdvers(lines);
}
static override async getOptions(compiler: BaseCompiler, helpArg: string) {
const result = await compiler.execCompilerCached(compiler.compiler.exe, [helpArg]);
const optionFinder = /^\s*(\/[\w#+,.:<=>[\]{|}-]*)\s*(.*)/i;
const options = result.code === 0 ? this.parseLines(result.stdout, optionFinder) : {};
const options = result.code === 0 ? VCParser.parseLines(result.stdout, optionFinder) : {};
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -816,22 +828,22 @@ export class VCParser extends BaseParser {
export class RustParser extends BaseParser {
static override async setCompilerSettingsFromOptions(compiler: BaseCompiler, options: Record<string, Argument>) {
if (this.hasSupport(options, '--color')) {
if (RustParser.hasSupport(options, '--color')) {
if (compiler.compiler.options) compiler.compiler.options += ' ';
compiler.compiler.options += '--color=always';
}
if (this.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (this.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
if (RustParser.hasSupportStartsWith(options, '--target=')) compiler.compiler.supportsTargetIs = true;
if (RustParser.hasSupportStartsWith(options, '--target ')) compiler.compiler.supportsTarget = true;
}
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([
this.getOptions(compiler, '--help'),
this.getOptions(compiler, '-C help'),
this.getOptions(compiler, '--help -v'),
RustParser.getOptions(compiler, '--help'),
RustParser.getOptions(compiler, '-C help'),
RustParser.getOptions(compiler, '--help -v'),
]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await RustParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
@@ -840,7 +852,7 @@ export class RustParser extends BaseParser {
const re = /--edition ([\d|]*)/;
const match = result.stdout.match(re);
if (match && match[1]) {
if (match?.[1]) {
return match[1].split('|');
}
@@ -872,24 +884,23 @@ export class RustParser extends BaseParser {
options[previousOption].description += line.trim();
else {
if (options[previousOption].description.length > 0)
options[previousOption].description += ' ' + line.trim();
options[previousOption].description += ` ${line.trim()}`;
else options[previousOption].description = line.trim();
}
} else {
previousOption = false;
}
return;
} else {
if (match1) {
previousOption = match1[1].trim();
if (match1[2]) description = match1[2].trim();
} else if (match2) {
previousOption = match2[1].trim();
if (match2[2]) description = match2[2].trim();
} else if (match3) {
previousOption = match3[1].trim();
if (match3[2]) description = match3[2].trim();
}
}
if (match1) {
previousOption = match1[1].trim();
if (match1[2]) description = match1[2].trim();
} else if (match2) {
previousOption = match2[1].trim();
if (match2[2]) description = match2[2].trim();
} else if (match3) {
previousOption = match3[1].trim();
if (match3[2]) description = match3[2].trim();
}
if (previousOption) {
@@ -910,9 +921,9 @@ export class RustParser extends BaseParser {
if (helpArg === '-C help') {
const optionFinder = /^\s*(-c\s*[\d=a-z-]*)\s--\s(.*)/i;
options = this.parseLines(result.stdout + result.stderr, optionFinder);
options = RustParser.parseLines(result.stdout + result.stderr, optionFinder);
} else {
options = this.parseRustHelpLines(result.stdout + result.stderr);
options = RustParser.parseRustHelpLines(result.stdout + result.stderr);
}
}
compiler.possibleArguments.populateOptions(options);
@@ -922,29 +933,29 @@ export class RustParser extends BaseParser {
export class ZksolcParser extends RustParser {
static override async parse(compiler: BaseCompiler) {
const options = await this.getOptions(compiler, '--help');
await this.setCompilerSettingsFromOptions(compiler, options);
const options = await ZksolcParser.getOptions(compiler, '--help');
await ZksolcParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
}
export class MrustcParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '--help');
await MrustcParser.getOptions(compiler, '--help');
return compiler;
}
}
export class NimParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await NimParser.getOptions(compiler, '-help');
return compiler;
}
}
export class CrystalParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, 'build');
await CrystalParser.getOptions(compiler, 'build');
return compiler;
}
}
@@ -952,7 +963,7 @@ export class CrystalParser extends BaseParser {
export class TableGenParser extends BaseParser {
static async getPossibleActions(compiler: BaseCompiler): Promise<CompilerOverrideOptions> {
const result = await compiler.execCompilerCached(compiler.compiler.exe, ['--help']);
return this.extractPossibleActions(utils.splitLines(result.stdout));
return TableGenParser.extractPossibleActions(utils.splitLines(result.stdout));
}
static extractPossibleActions(lines: string[]): CompilerOverrideOptions {
@@ -974,7 +985,7 @@ export class TableGenParser extends BaseParser {
}
actions.push({
name: action_match[1].substring(2) + ': ' + action_match[2],
name: `${action_match[1].substring(2)}: ${action_match[2]}`,
value: action_match[1],
});
}
@@ -986,21 +997,21 @@ export class TableGenParser extends BaseParser {
export class TypeScriptNativeParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '--help');
await TypeScriptNativeParser.getOptions(compiler, '--help');
return compiler;
}
}
export class TurboCParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '');
await TurboCParser.getOptions(compiler, '');
return compiler;
}
}
export class ToitParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '-help');
await ToitParser.getOptions(compiler, '-help');
return compiler;
}
}
@@ -1013,13 +1024,13 @@ export class JuliaParser extends BaseParser {
compiler.compilerWrapperPath,
helpArg,
]);
const options = result.code === 0 ? this.parseLines(result.stdout + result.stderr, optionFinder) : {};
const options = result.code === 0 ? JuliaParser.parseLines(result.stdout + result.stderr, optionFinder) : {};
compiler.possibleArguments.populateOptions(options);
return options;
}
static override async parse(compiler: JuliaCompiler) {
await this.getOptions(compiler, '--help');
await JuliaParser.getOptions(compiler, '--help');
return compiler;
}
}
@@ -1040,7 +1051,7 @@ export class Z88dkParser extends BaseParser {
export class WasmtimeParser extends BaseParser {
static override async parse(compiler: BaseCompiler) {
await this.getOptions(compiler, '--help');
await WasmtimeParser.getOptions(compiler, '--help');
return compiler;
}
}
@@ -1079,12 +1090,12 @@ export class FlangParser extends ClangParser {
}
static override async setCompilerSettingsFromOptions(compiler: BaseCompiler, options: Record<string, Argument>) {
super.setCompilerSettingsFromOptions(compiler, options);
ClangParser.setCompilerSettingsFromOptions(compiler, options);
// flang does not allow -emit-llvm to be used as it is with clang
// as -Xflang -emit-llvm. Instead you just give -emit-llvm to flang
// directly.
if (this.hasSupport(options, '-emit-llvm')) {
if (FlangParser.hasSupport(options, '-emit-llvm')) {
compiler.compiler.supportsIrView = true;
compiler.compiler.irArg = ['-emit-llvm'];
compiler.compiler.minIrArgs = ['-emit-llvm'];
@@ -1106,7 +1117,7 @@ export class FlangParser extends ClangParser {
const re1 = /error: Only -std=([\w+]*) is allowed currently./;
for (const line of lines) {
const match = line.match(re1);
if (match && match[1]) {
if (match?.[1]) {
possible.push({
name: match[1],
value: match[1],
@@ -1119,9 +1130,9 @@ export class FlangParser extends ClangParser {
export class GHCParser extends GCCParser {
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([this.getOptions(compiler, '--help')]);
const results = await Promise.all([GHCParser.getOptions(compiler, '--help')]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await GHCParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
@@ -1129,7 +1140,7 @@ export class GHCParser extends GCCParser {
const optionFinder1 = /^ {4}(-[\w[\]]+)\s+(.*)/i;
const optionFinder2 = /^ {4}(-[\w[\]]+)/;
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' '));
const options = result.code === 0 ? this.parseLines(result.stdout, optionFinder1, optionFinder2) : {};
const options = result.code === 0 ? GHCParser.parseLines(result.stdout, optionFinder1, optionFinder2) : {};
compiler.possibleArguments.populateOptions(options);
return options;
@@ -1138,9 +1149,9 @@ export class GHCParser extends GCCParser {
export class SwiftParser extends ClangParser {
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([this.getOptions(compiler, '--help')]);
const results = await Promise.all([SwiftParser.getOptions(compiler, '--help')]);
const options = Object.assign({}, ...results);
this.setCompilerSettingsFromOptions(compiler, options);
SwiftParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
@@ -1155,16 +1166,16 @@ export class SwiftParser extends ClangParser {
export class TendraParser extends GCCParser {
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([this.getOptions(compiler, '--help')]);
const results = await Promise.all([TendraParser.getOptions(compiler, '--help')]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await TendraParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
static override async getOptions(compiler: BaseCompiler, helpArg: string) {
const optionFinder = /^ *(-[\d#+,<=>[\]a-z|-]* ?[\d+,<=>[\]a-z|-]*) : +(.*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, helpArg.split(' '));
const options = this.parseLines(result.stdout + result.stderr, optionFinder);
const options = TendraParser.parseLines(result.stdout + result.stderr, optionFinder);
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -1185,10 +1196,13 @@ export class GolangParser extends GCCParser {
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([
this.getOptions(compiler, 'build -o ./output.s "-gcflags=-S --help" ' + this.getExampleFilepath()),
GolangParser.getOptions(
compiler,
`build -o ./output.s "-gcflags=-S --help" ${GolangParser.getExampleFilepath()}`,
),
]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await GolangParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
@@ -1199,7 +1213,7 @@ export class GolangParser extends GCCParser {
...compiler.getDefaultExecOptions(),
createAndUseTempDir: true,
});
const options = this.parseLines(result.stdout + result.stderr, optionFinder1, optionFinder2);
const options = GolangParser.parseLines(result.stdout + result.stderr, optionFinder1, optionFinder2);
compiler.possibleArguments.populateOptions(options);
return options;
}
@@ -1212,7 +1226,7 @@ export class GnuCobolParser extends GCCParser {
static override async getPossibleStdvers(compiler: BaseCompiler): Promise<CompilerOverrideOptions> {
const possible: CompilerOverrideOptions = [];
const options = await this.getOptionsStrict(compiler, this.getLanguageSpecificHelpFlags());
const options = await GnuCobolParser.getOptionsStrict(compiler, GnuCobolParser.getLanguageSpecificHelpFlags());
for (const opt in options) {
if (opt.startsWith('-std=')) {
const vers = options[opt].description
@@ -1235,16 +1249,16 @@ export class GnuCobolParser extends GCCParser {
export class MadpascalParser extends GCCParser {
static override async parse(compiler: BaseCompiler) {
const results = await Promise.all([this.getOptions(compiler, '')]);
const results = await Promise.all([MadpascalParser.getOptions(compiler, '')]);
const options = Object.assign({}, ...results);
await this.setCompilerSettingsFromOptions(compiler, options);
await MadpascalParser.setCompilerSettingsFromOptions(compiler, options);
return compiler;
}
static override async getOptions(compiler: BaseCompiler, helpArg: string) {
const optionFinder = /^(-[\w:<>]*) *(.*)/i;
const result = await compiler.execCompilerCached(compiler.compiler.exe, []);
const options = this.parseLines(result.stdout + result.stderr, optionFinder);
const options = MadpascalParser.parseLines(result.stdout + result.stderr, optionFinder);
compiler.possibleArguments.populateOptions(options);
return options;
}
+6 -4
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import _ from 'underscore';
@@ -101,9 +101,11 @@ export class AssemblyCompiler extends BaseCompiler {
const output = result.stdout.map(line => line.text).join('\n');
if (output.includes('ELF32') && output.includes('80386')) {
return 'x86';
} else if (output.includes('ELF64') && output.includes('X86-64')) {
}
if (output.includes('ELF64') && output.includes('X86-64')) {
return 'x86_64';
} else if (output.includes('Mach-O 64-bit x86-64')) {
}
if (output.includes('Mach-O 64-bit x86-64')) {
// note: this is to support readelf=objdump on Mac
return 'x86_64';
}
+3 -4
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -50,7 +50,7 @@ export class AvrGcc6502Compiler extends BaseCompiler {
public override getOutputFilename(dirPath: string, outputFilebase: string, key?: any) {
let filename;
if (key && key.backendOptions && key.backendOptions.customOutputFilename) {
if (key?.backendOptions?.customOutputFilename) {
filename = key.backendOptions.customOutputFilename;
} else {
filename = `${outputFilebase}.6502.asm`;
@@ -58,9 +58,8 @@ export class AvrGcc6502Compiler extends BaseCompiler {
if (dirPath) {
return path.join(dirPath, filename);
} else {
return filename;
}
return filename;
}
protected override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string): string[] {
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
+2 -2
View File
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -21,6 +21,6 @@ export class C3Compiler extends BaseCompiler {
}
override getIrOutputFilename(inputFilename: string): string {
return this.filename(path.dirname(inputFilename) + '/output.ll');
return this.filename(`${path.dirname(inputFilename)}/output.ll`);
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ export class CarbonCompiler extends BaseCompiler {
// Hook to parse out the "result: 123" line at the end of the interpreted execution run.
const re = /^result: (\d+)$/;
const match = re.exec(this.lastLine(result.asm as ResultLine[]));
const code = match ? parseInt(match[1]) : -1;
const code = match ? Number.parseInt(match[1]) : -1;
result.execResult = {
stdout: result.stdout,
stderr: [],
+4 -5
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -67,13 +67,12 @@ export class Cc65Compiler extends BaseCompiler {
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
if (filters.binary) {
return ['-g', '-o', this.filename(outputFilename)];
} else {
return ['-g', '-S', '-c', '-o', this.filename(outputFilename)];
}
return ['-g', '-S', '-c', '-o', this.filename(outputFilename)];
}
override getCompilerEnvironmentVariables(compilerflags: string) {
const allOptions = (this.compiler.options + ' ' + compilerflags).trim();
const allOptions = `${this.compiler.options} ${compilerflags}`.trim();
return {...this.cmakeBaseEnv, CFLAGS: allOptions};
}
@@ -132,7 +131,7 @@ export class Cc65Compiler extends BaseCompiler {
res,
outputFilename,
ArtifactType.c64prg,
path.basename(outputFilename) + '.prg',
`${path.basename(outputFilename)}.prg`,
);
}
}
+10 -11
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {BypassCache, CacheKey, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
@@ -66,7 +66,7 @@ export class CerberusCompiler extends BaseCompiler {
override async objdump(outputFilename: string, result: any, maxSize: number) {
if (!(await utils.fileExists(outputFilename))) {
result.asm = '<No output file ' + outputFilename + '>';
result.asm = `<No output file ${outputFilename}>`;
return result;
}
@@ -106,16 +106,15 @@ export class CerberusCompiler extends BaseCompiler {
didExecute: true,
buildResult: compileResult,
};
} else {
return {
stdout: compileResult.stdout,
stderr: compileResult.stderr,
code: compileResult.code,
didExecute: false,
buildResult: compileResult,
timedOut: false,
};
}
return {
stdout: compileResult.stdout,
stderr: compileResult.stderr,
code: compileResult.code,
didExecute: false,
buildResult: compileResult,
timedOut: false,
};
}
override async processAsm(result): Promise<ParsedAsmResult> {
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import {BaseCompiler} from '../base-compiler.js';
+7 -10
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import fs from 'fs';
import path from 'path';
import fs from 'node:fs';
import path from 'node:path';
import _ from 'underscore';
@@ -99,8 +99,7 @@ export class ClangCompiler extends BaseCompiler {
async addTimeTraceToResult(result: CompilationResult, dirPath: string, outputFilename: string) {
const timeTraceJson = utils.changeExtension(outputFilename, '.json');
const alternativeFilename =
outputFilename + '-' + utils.changeExtension(path.basename(result.inputFilename || 'example.cpp'), '.json');
const alternativeFilename = `${outputFilename}-${utils.changeExtension(path.basename(result.inputFilename || 'example.cpp'), '.json')}`;
const mainFilepath = path.join(dirPath, timeTraceJson);
const alternativeJsonFilepath = path.join(dirPath, alternativeFilename);
@@ -176,8 +175,7 @@ export class ClangCompiler extends BaseCompiler {
return option === '-stdlib=libc++';
})
) {
const addedIncludePath =
'-I' + path.join(path.dirname(this.compiler.exe), '../include/x86_64-unknown-linux-gnu/c++/v1/');
const addedIncludePath = `-I${path.join(path.dirname(this.compiler.exe), '../include/x86_64-unknown-linux-gnu/c++/v1/')}`;
if (
!_.any(userOptions, option => {
return option === addedIncludePath;
@@ -271,7 +269,7 @@ export class ClangCompiler extends BaseCompiler {
}
async extractBitcodeFromBundle(bundlefile: string, devicename: string): Promise<string> {
const bcfile = path.join(path.dirname(bundlefile), devicename + '.bc');
const bcfile = path.join(path.dirname(bundlefile), `${devicename}.bc`);
const env = this.getDefaultExecOptions();
env.customCwd = path.dirname(bundlefile);
@@ -290,7 +288,7 @@ export class ClangCompiler extends BaseCompiler {
}
if (this.llvmDisassemblerPath) {
const llvmirFile = path.join(path.dirname(bundlefile), devicename + '.ll');
const llvmirFile = path.join(path.dirname(bundlefile), `${devicename}.ll`);
const disassembleResult: UnprocessedExecResult = await this.exec(this.llvmDisassemblerPath, [bcfile], env);
if (disassembleResult.code !== 0) {
@@ -298,9 +296,8 @@ export class ClangCompiler extends BaseCompiler {
}
return fs.readFileSync(llvmirFile, 'utf8');
} else {
return '<error: no llvm-dis found to disassemble bitcode>';
}
return '<error: no llvm-dis found to disassemble bitcode>';
}
async processDeviceAssembly(deviceName: string, deviceAsm: string, filters, compilationInfo: CompilationInfo) {
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -76,7 +76,7 @@ export class ClangCLCompiler extends Win32Compiler {
}
override getIrOutputFilename(inputFilename: string): string {
return this.filename(path.dirname(inputFilename) + '/output.s.obj');
return this.filename(`${path.dirname(inputFilename)}/output.s.obj`);
}
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
+8 -12
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -39,9 +39,8 @@ export class CleanCompiler extends BaseCompiler {
override optionsForFilter(filters: ParseFiltersAndOutputOptions) {
if (filters.binary) {
return [];
} else {
return ['-S'];
}
return ['-S'];
}
override getOutputFilename(dirPath: string) {
@@ -68,23 +67,20 @@ export class CleanCompiler extends BaseCompiler {
if (!matches) matches = line.match(typeeerrorRegex);
if (matches) {
return '<source>:' + matches[1] + ',0: error: (' + matches[2] + ') ' + matches[3];
return `<source>:${matches[1]},0: error: (${matches[2]}) ${matches[3]}`;
}
matches = line.match(errorLineRegex);
if (matches) {
return '<source>:' + matches[1] + ',0: error: ' + matches[2];
return `<source>:${matches[1]},0: error: ${matches[2]}`;
}
matches = line.match(parseerrorRegex);
if (matches) {
if (matches[3] === '') {
return '<source>:' + matches[1] + ',' + matches[2] + ': error: ' + matches[4];
} else {
return (
'<source>:' + matches[1] + ',' + matches[2] + ': error: (' + matches[3] + ') ' + matches[4]
);
return `<source>:${matches[1]},${matches[2]}: error: ${matches[4]}`;
}
return `<source>:${matches[1]},${matches[2]}: error: (${matches[3]}) ${matches[4]}`;
}
return line;
@@ -110,8 +106,8 @@ export class CleanCompiler extends BaseCompiler {
execOptions.env.CLEANLIB = path.join(compilerPath, '../lib/exe');
}
execOptions.env.CLEANPATH = this.compiler.libPath.join(':');
execOptions.env.CLEANABCPATH = tmpDir + '/Clean System Files';
execOptions.env.CLEANOPATH = tmpDir + '/obj';
execOptions.env.CLEANABCPATH = `${tmpDir}/Clean System Files`;
execOptions.env.CLEANOPATH = `${tmpDir}/obj`;
options.pop();
options.push(moduleName);
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {BaseCompiler} from '../base-compiler.js';
@@ -36,7 +36,7 @@ export class CprocCompiler extends BaseCompiler {
// needed for finding the qbe program
const toolRoot = path.resolve(path.dirname(this.compiler.exe));
execOptions.env.PATH = execOptions.env.PATH + ':' + toolRoot;
execOptions.env.PATH = `${execOptions.env.PATH}:${toolRoot}`;
return execOptions;
}
}
+3 -5
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import semverParser from 'semver';
import _ from 'underscore';
@@ -80,17 +80,15 @@ export class CrystalCompiler extends BaseCompiler {
override getIrOutputFilename(inputFilename: string, filters: ParseFiltersAndOutputOptions): string {
if (this.usesNewEmitFilenames()) {
return this.getOutputFilename(path.dirname(inputFilename), this.outputFilebase).replace('.s', '.ll');
} else {
return super.getIrOutputFilename(inputFilename, filters);
}
return super.getIrOutputFilename(inputFilename, filters);
}
override getOutputFilename(dirPath: string, outputFilebase: string) {
if (this.usesNewEmitFilenames()) {
return path.join(dirPath, `${outputFilebase}.s`);
} else {
return path.join(dirPath, `${path.basename(this.compileFilename, this.lang.extensions[0])}.s`);
}
return path.join(dirPath, `${path.basename(this.compileFilename, this.lang.extensions[0])}.s`);
}
override getExecutableFilename(dirPath: string, outputFilebase: string) {
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -199,7 +199,7 @@ export class D8Compiler extends BaseCompiler implements SimpleOutputFilenameComp
const smaliFiles = files.filter(f => f.endsWith('.smali'));
let objResult = '';
for (const smaliFile of smaliFiles) {
objResult = objResult.concat(fs.readFileSync(path.join(dirPath, smaliFile), 'utf8') + '\n\n');
objResult = objResult.concat(`${fs.readFileSync(path.join(dirPath, smaliFile), 'utf8')}\n\n`);
}
const asmResult: ParsedAsmResult = {
+2 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import Semver from 'semver';
@@ -79,9 +79,8 @@ export class DartCompiler extends BaseCompiler {
const dartCompileIntroduction = '2.10.0';
if (Semver.lt(utils.asSafeVer(this.compiler.semver), dartCompileIntroduction, true)) {
return ['-k', 'aot', '-o', this.filename(outputFilename)];
} else {
return ['compile', 'aot-snapshot', '-o', this.filename(outputFilename)];
}
return ['compile', 'aot-snapshot', '-o', this.filename(outputFilename)];
}
override getArgumentParserClass() {
+19 -21
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -225,7 +225,7 @@ export class Dex2OatCompiler extends BaseCompiler {
let match;
if (this.versionPrefixRegex.test(this.compiler.id)) {
match = this.compiler.id.match(this.versionPrefixRegex);
versionPrefix = parseInt(match![2]);
versionPrefix = Number.parseInt(match![2]);
} else if (this.latestVersionRegex.test(this.compiler.id)) {
isLatest = true;
}
@@ -238,7 +238,7 @@ export class Dex2OatCompiler extends BaseCompiler {
'--copy-dex-files=always',
...(versionPrefix >= 34 || isLatest ? ['--runtime-arg', '-Xgc:CMC'] : []),
'--runtime-arg',
'-Xbootclasspath:' + bootclassjars.map(f => path.join(this.artArtifactDir, f)).join(':'),
`-Xbootclasspath:${bootclassjars.map(f => path.join(this.artArtifactDir, f)).join(':')}`,
'--runtime-arg',
'-Xbootclasspath-locations:/apex/com.android.art/javalib/core-oj.jar' +
':/apex/com.android.art/javalib/core-libart.jar' +
@@ -352,17 +352,17 @@ export class Dex2OatCompiler extends BaseCompiler {
// dex2oat doesn't have --version, but artArtifactDir contains a file with
// the build number.
override async getVersion() {
const versionFile = this.artArtifactDir + '/snapshot-creation-build-number.txt';
const versionFile = `${this.artArtifactDir}/snapshot-creation-build-number.txt`;
const version = fs.readFileSync(versionFile, {encoding: 'utf8'});
return {
stdout: 'Android Build ' + version,
stdout: `Android Build ${version}`,
stderr: '',
code: 0,
};
}
override async processAsm(result) {
let asm: string = '';
let asm = '';
if (typeof result.asm === 'string') {
const asmLines = utils.splitLines(result.asm);
@@ -370,15 +370,13 @@ export class Dex2OatCompiler extends BaseCompiler {
return {
asm: [{text: asmLines[0], source: null}],
};
} else {
return {
asm: [{text: JSON.stringify(asmLines), source: null}],
};
}
} else {
// result.asm is an array, but we only expect it to have one value.
asm = result.asm[0].text;
return {
asm: [{text: JSON.stringify(asmLines), source: null}],
};
}
// result.asm is an array, but we only expect it to have one value.
asm = result.asm[0].text;
const segments: ParsedAsmResultLine[] = [];
if (this.fullOutput) {
@@ -389,15 +387,15 @@ export class Dex2OatCompiler extends BaseCompiler {
segments.push(
{
text: 'Instruction set: ' + compileData.insnSet,
text: `Instruction set: ${compileData.insnSet}`,
source: null,
},
{
text: 'Instruction set features: ' + compileData.insnSetFeatures,
text: `Instruction set features: ${compileData.insnSetFeatures}`,
source: null,
},
{
text: 'Compiler filter: ' + compileData.compilerFilter,
text: `Compiler filter: ${compileData.compilerFilter}`,
source: null,
},
{text: '', source: null},
@@ -407,12 +405,12 @@ export class Dex2OatCompiler extends BaseCompiler {
for (const className of classNames) {
for (const method of classToMethods[className]) {
segments.push({
text: method + ' [' + methodsToSizes[method] + ' bytes]',
text: `${method} [${methodsToSizes[method]} bytes]`,
source: null,
});
for (const instruction of methodsToInstructions[method]) {
segments.push({
text: ' ' + instruction,
text: ` ${instruction}`,
source: null,
});
}
@@ -470,10 +468,10 @@ export class Dex2OatCompiler extends BaseCompiler {
inCode = true;
} else if (inCode && this.insnRegex.test(l)) {
match = l.match(this.insnRegex);
methodsToInstructions[currentMethod].push(match![1] + ' ' + match![2]);
methodsToInstructions[currentMethod].push(`${match![1]} ${match![2]}`);
} else if (inCode && this.stackMapRegex.test(l)) {
match = l.match(this.stackMapRegex);
methodsToInstructions[currentMethod].push(' ' + match![1] + ' ' + match![2]);
methodsToInstructions[currentMethod].push(` ${match![1]} ${match![2]}`);
}
}
@@ -495,7 +493,7 @@ export class Dex2OatCompiler extends BaseCompiler {
const compileEnd = performance.now();
try {
const classesCfg = dirPath + '/classes.cfg';
const classesCfg = `${dirPath}/classes.cfg`;
const rawText = fs.readFileSync(classesCfg, {encoding: 'utf8'});
const parseStart = performance.now();
const optPipeline = this.passDumpParser.process(rawText);
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -47,7 +47,7 @@ export class DMDCompiler extends BaseCompiler {
}
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
const options = ['-g', '-of' + this.filename(outputFilename)];
const options = ['-g', `-of${this.filename(outputFilename)}`];
if (filters.binaryObject) options.push('-c');
return options;
}
+3 -4
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -121,7 +121,7 @@ export class DosboxCompiler extends BaseCompiler {
result = await (this.env.enqueue(async () =>
this.exec(compiler, args, options),
) as Promise<UnprocessedExecResult>);
if (result && result.okToCache) {
if (result?.okToCache) {
this.env
.compilerCachePut(key as any, result, undefined)
.then(() => {
@@ -170,9 +170,8 @@ export class DosboxCompiler extends BaseCompiler {
options.map(option => {
if (option === inputFilename) {
return path.basename(option);
} else {
return option;
}
return option;
}),
inputFilename,
execOptions,
+23 -13
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -788,9 +788,8 @@ do()
if (fs.existsSync(versionFilePath)) {
const versionString = await fs.readFile(versionFilePath);
return versionString.toString();
} else {
return '<unknown version>';
}
return '<unknown version>';
}
async runCorerunForDisasm(
@@ -859,11 +858,16 @@ do()
) {
// prettier-ignore
const crossgen2Options = [
'-r', path.join(bclPath, '/'),
'-r', this.disassemblyLoaderPath,
'-r',
path.join(bclPath, '/'),
'-r',
this.disassemblyLoaderPath,
dllPath,
'-o', `${AssemblyName}.r2r.dll`,
].concat(toolOptions).concat(toolSwitches);
'-o',
`${AssemblyName}.r2r.dll`,
]
.concat(toolOptions)
.concat(toolSwitches);
if (sdkMajorVersion >= 9) {
crossgen2Options.push('--inputbubble', '--compilebubblegenerics');
@@ -872,7 +876,7 @@ do()
if (await fs.exists(this.crossgen2Path)) {
compiler = this.crossgen2Path;
} else {
crossgen2Options.unshift(this.crossgen2Path + '.dll');
crossgen2Options.unshift(`${this.crossgen2Path}.dll`);
}
const compilerExecResult = await this.exec(compiler, crossgen2Options, execOptions);
@@ -900,10 +904,14 @@ do()
// prettier-ignore
const ilcOptions = [
dllPath,
'-o', `${AssemblyName}.obj`,
'-r', this.disassemblyLoaderPath,
'-r', path.join(this.clrBuildDir, 'aotsdk', '*.dll'),
'-r', path.join(this.clrBuildDir, '*.dll'),
'-o',
`${AssemblyName}.obj`,
'-r',
this.disassemblyLoaderPath,
'-r',
path.join(this.clrBuildDir, 'aotsdk', '*.dll'),
'-r',
path.join(this.clrBuildDir, '*.dll'),
'--initassembly:System.Private.CoreLib',
'--initassembly:System.Private.StackTraceMetadata',
'--initassembly:System.Private.TypeLoader',
@@ -920,7 +928,9 @@ do()
'--generateunmanagedentrypoints:System.Private.CoreLib',
'--notrimwarn',
'--noaotwarn',
].concat(toolOptions).concat(toolSwitches);
]
.concat(toolOptions)
.concat(toolSwitches);
if (!buildToBinary) {
ilcOptions.push('--nativelib', '--root:CompilerExplorer');
+2 -5
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import {BaseCompiler} from '../base-compiler.js';
@@ -37,10 +37,7 @@ export class ElixirCompiler extends BaseCompiler {
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string): string[] {
return [
'--eval',
'[input] = Code.required_files();' +
'code = Code.compile_file(input)' +
'|> Enum.map(fn {_,code} -> :beam_disasm.file(code) end);' +
`:ok = File.write("${outputFilename}", inspect(code, pretty: true));`,
`[input] = Code.required_files();code = Code.compile_file(input)|> Enum.map(fn {_,code} -> :beam_disasm.file(code) end);:ok = File.write("${outputFilename}", inspect(code, pretty: true));`,
];
}
+2 -7
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import {BaseCompiler} from '../base-compiler.js';
@@ -38,12 +38,7 @@ export class ErlangCompiler extends BaseCompiler {
return [
'-noshell',
'-eval',
'{ok, Input} = init:get_argument(input),' +
"{ok, _, Output} = compile:file(Input, ['S', binary, no_line_info, report])," +
`{ok,Fd} = file:open("${outputFilename}", [write]),` +
'beam_listing:module(Fd, Output),' +
'file:close(Fd),' +
'halt().',
`{ok, Input} = init:get_argument(input),{ok, _, Output} = compile:file(Input, ['S', binary, no_line_info, report]),{ok,Fd} = file:open("${outputFilename}", [write]),beam_listing:module(Fd, Output),file:close(Fd),halt().`,
];
}
+2 -11
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import {BaseCompiler} from '../base-compiler.js';
@@ -38,16 +38,7 @@ export class ErlangAsmCompiler extends BaseCompiler {
return [
'-noshell',
'-eval',
'{ok, Input} = init:get_argument(input),' +
"{ok, _, _} = compile:file(Input, ['S', binary, no_line_info, report])," +
`Output = "${outputFilename}",` +
'{ok,File}=epp:parse_file(Input,[]),' +
'{ok,Module,Binary}=compile:forms(File),' +
'erts_debug:set_internal_state(available_internal_state, true),' +
'erts_debug:set_internal_state(jit_asm_dump, true),' +
'load_module(Module,Binary),' +
'file:copy(atom_to_list(Module) ++ ".asm", Output),' +
'halt().',
`{ok, Input} = init:get_argument(input),{ok, _, _} = compile:file(Input, ['S', binary, no_line_info, report]),Output = "${outputFilename}",{ok,File}=epp:parse_file(Input,[]),{ok,Module,Binary}=compile:forms(File),erts_debug:set_internal_state(available_internal_state, true),erts_debug:set_internal_state(jit_asm_dump, true),load_module(Module,Binary),file:copy(atom_to_list(Module) ++ ".asm", Output),halt().`,
];
}
+1 -1
View File
@@ -43,6 +43,6 @@ export class EWARMCompiler extends BaseCompiler {
return [];
}
return ['-lB', this.filename(outputFilename), '-o', this.filename(outputFilename + '.obj')];
return ['-lB', this.filename(outputFilename), '-o', this.filename(`${outputFilename}.obj`)];
}
}
+1 -1
View File
@@ -45,6 +45,6 @@ export class EWAVRCompiler extends BaseCompiler {
return [];
}
return ['-lB', this.filename(outputFilename), '-o', this.filename(outputFilename + '.obj')];
return ['-lB', this.filename(outputFilename), '-o', this.filename(`${outputFilename}.obj`)];
}
}
+4 -4
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import * as fs from 'fs';
import path from 'path';
import * as fs from 'node:fs';
import path from 'node:path';
import type {CompilationResult, ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import {SelectedLibraryVersion} from '../../types/libraries/libraries.interfaces.js';
@@ -46,7 +46,7 @@ export class FortranCompiler extends BaseCompiler {
}
getExactStaticLibNameAndPath(lib: string, libPaths: string[]): string {
const libFilename = 'lib' + lib + '.a';
const libFilename = `lib${lib}.a`;
// note: fortran doesn't use -llibname,
// you have to add the full filename to the commandline instead
@@ -97,7 +97,7 @@ export class FortranCompiler extends BaseCompiler {
execOptions.customCwd = path.dirname(inputFilename);
const result = await this.exec(compiler, options, execOptions);
const baseFilename = './' + path.basename(inputFilename);
const baseFilename = `./${path.basename(inputFilename)}`;
return {
...result,
stdout: utils.parseOutput(result.stdout, baseFilename),
+1 -1
View File
@@ -21,7 +21,7 @@
// 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.
import path from 'path';
import path from 'node:path';
import {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import {BaseCompiler} from '../base-compiler.js';
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+3 -4
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -101,7 +101,7 @@ export class GnuCobolCompiler extends BaseCompiler {
override getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string {
let filename;
if (key && key.backendOptions && key.backendOptions.customOutputFilename) {
if (key?.backendOptions?.customOutputFilename) {
filename = key.backendOptions.customOutputFilename;
} else if (key.filters.binary) {
// note: interesting fact about gnucobol, if you name the outputfile output.s it will always output assembly
@@ -114,9 +114,8 @@ export class GnuCobolCompiler extends BaseCompiler {
if (dirPath) {
return path.join(dirPath, filename);
} else {
return filename;
}
return filename;
}
override getExecutableFilename(dirPath: string, outputFilebase: string) {
+4 -5
View File
@@ -203,7 +203,7 @@ export class GolangCompiler extends BaseCompiler {
if (collisions > 0) {
label += `_${collisions}`;
}
usedLabels[label + ':'] = true; // record label use for later filtering
usedLabels[`${label}:`] = true; // record label use for later filtering
return `${match[1]}${label}${match[3]}`;
}
@@ -242,11 +242,10 @@ export class GolangCompiler extends BaseCompiler {
}
if (filters.binary) {
return ['build', '-o', outputFilename, '-gcflags=' + unwrap(userOptions).join(' ')];
} else {
// Add userOptions to -gcflags to preserve previous behavior.
return ['build', '-o', outputFilename, '-gcflags=-S ' + unwrap(userOptions).join(' ')];
return ['build', '-o', outputFilename, `-gcflags=${unwrap(userOptions).join(' ')}`];
}
// Add userOptions to -gcflags to preserve previous behavior.
return ['build', '-o', outputFilename, `-gcflags=-S ${unwrap(userOptions).join(' ')}`];
}
override filterUserOptions(userOptions: string[]) {
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -75,7 +75,7 @@ export class HaskellCompiler extends BaseCompiler {
override getSharedLibraryPathsAsArguments(libraries: SelectedLibraryVersion[]) {
const libPathFlag = this.compiler.libpathFlag || '-L';
return [libPathFlag + '.', ...this.getSharedLibraryPaths(libraries).map(path => libPathFlag + path)];
return [`${libPathFlag}.`, ...this.getSharedLibraryPaths(libraries).map(path => libPathFlag + path)];
}
override getArgumentParserClass(): any {
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {
CacheKey,
@@ -96,7 +96,7 @@ export class HookCompiler extends BaseCompiler {
}
const match = text.match(instructionRegex);
if (match) {
const lineNo = parseInt(match[1]);
const lineNo = Number.parseInt(match[1]);
item.source = {line: lineNo, file: null};
lastLineNo = lineNo;
continue;
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+10 -12
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import Semver from 'semver';
@@ -160,16 +160,15 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo
didExecute: true,
buildResult: compileResult,
};
} else {
return {
stdout: compileResult.stdout,
stderr: compileResult.stderr,
code: compileResult.code,
didExecute: false,
buildResult: compileResult,
timedOut: false,
};
}
return {
stdout: compileResult.stdout,
stderr: compileResult.stderr,
code: compileResult.code,
didExecute: false,
buildResult: compileResult,
timedOut: false,
};
}
async getMainClassName(dirPath: string) {
@@ -409,9 +408,8 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo
firstSourceLine: methods.reduce((prev, method) => {
if (method.startLine) {
return prev === -1 ? method.startLine : Math.min(prev, method.startLine);
} else {
return prev;
}
return prev;
}, -1),
methods: methods,
textsBeforeMethod,
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {CompilationResult, ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
+7 -7
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import semverParser from 'semver';
@@ -70,13 +70,13 @@ export class LDCCompiler extends BaseCompiler {
}
override getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string {
if (key && key.filters && key.filters.binary) {
if (key?.filters?.binary) {
return path.join(dirPath, 'output');
} else if (key && key.filters && key.filters.binaryObject) {
return path.join(dirPath, 'output.o');
} else {
return path.join(dirPath, 'output.s');
}
if (key?.filters?.binaryObject) {
return path.join(dirPath, 'output.o');
}
return path.join(dirPath, 'output.s');
}
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
@@ -102,7 +102,7 @@ export class LDCCompiler extends BaseCompiler {
override couldSupportASTDump(version: string) {
const versionRegex = /\((\d\.\d+)\.\d+/;
const versionMatch = versionRegex.exec(version);
return versionMatch ? semverParser.compare(versionMatch[1] + '.0', '1.4.0', true) >= 0 : false;
return versionMatch ? semverParser.compare(`${versionMatch[1]}.0`, '1.4.0', true) >= 0 : false;
}
override async generateAST(inputFilename: string, options: string[]): Promise<ResultLine[]> {
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {CompilationResult, FiledataPair} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -68,8 +68,8 @@ export class LLVMMOSCompiler extends ClangCompiler {
dynamicReloc: boolean,
filters: ParseFiltersAndOutputOptions,
) {
if (!outputFilename.endsWith('.elf') && (await utils.fileExists(outputFilename + '.elf'))) {
outputFilename = outputFilename + '.elf';
if (!outputFilename.endsWith('.elf') && (await utils.fileExists(`${outputFilename}.elf`))) {
outputFilename = `${outputFilename}.elf`;
}
intelAsm = false;
+5 -8
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -57,27 +57,24 @@ export class MadPascalCompiler extends BaseCompiler {
const filename = `${outputFilebase}.a65`;
if (dirPath) {
return path.join(dirPath, filename);
} else {
return filename;
}
return filename;
}
getAssemblerOutputFilename(dirPath: string, outputFilebase: string) {
const filename = `${outputFilebase}.obx`;
if (dirPath) {
return path.join(dirPath, filename);
} else {
return filename;
}
return filename;
}
getListingFilename(dirPath: string, outputFilebase: string) {
const filename = `${outputFilebase}.lst`;
if (dirPath) {
return path.join(dirPath, filename);
} else {
return filename;
}
return filename;
}
override getOutputFilename(dirPath: string, outputFilebase: string, key?: any): string {
@@ -173,7 +170,7 @@ export class MadPascalCompiler extends BaseCompiler {
const listingFilename = this.getListingFilename(tmpDir, this.outputFilebase);
if (!(await utils.fileExists(listingFilename))) {
result.asm = '<No output file ' + listingFilename + '>';
result.asm = `<No output file ${listingFilename}>`;
return result;
}
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
+11 -11
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -48,15 +48,15 @@ export class NimCompiler extends BaseCompiler {
}
cacheDir(outputFilename: string) {
return outputFilename + '.cache';
return `${outputFilename}.cache`;
}
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
return [
'--debugger:native', // debugging info
'-o:' + outputFilename, //output file, only for js mode
`-o:${outputFilename}`, //output file, only for js mode
'--nolinking', //disable linking, only compile to nimcache
'--nimcache:' + this.cacheDir(outputFilename), //output folder for the nimcache
`--nimcache:${this.cacheDir(outputFilename)}`, //output folder for the nimcache
];
}
@@ -70,14 +70,14 @@ export class NimCompiler extends BaseCompiler {
}
expectedExtensionFromCommand(command: string) {
const isC = ['compile', 'compileToC', 'c'],
isCpp = ['compileToCpp', 'cpp', 'cc'],
isObjC = ['compileToOC', 'objc'];
const isC = ['compile', 'compileToC', 'c'];
const isCpp = ['compileToCpp', 'cpp', 'cc'];
const isObjC = ['compileToOC', 'objc'];
if (isC.includes(command)) return '.c.o';
else if (isCpp.includes(command)) return '.cpp.o';
else if (isObjC.includes(command)) return '.m.o';
else return null;
if (isCpp.includes(command)) return '.cpp.o';
if (isObjC.includes(command)) return '.m.o';
return null;
}
getCacheFile(options: string[], inputFilename: string, cacheDir: string) {
@@ -87,7 +87,7 @@ export class NimCompiler extends BaseCompiler {
const extension = this.expectedExtensionFromCommand(command);
if (!extension) return null;
const moduleName = path.basename(inputFilename);
const resultName = '@m' + moduleName + extension;
const resultName = `@m${moduleName}${extension}`;
return path.join(cacheDir, resultName);
}
+6 -9
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import * as fs from 'fs/promises';
import Path from 'path';
import * as fs from 'node:fs/promises';
import Path from 'node:path';
import Semver from 'semver';
import _ from 'underscore';
@@ -114,18 +114,15 @@ export class NvccCompiler extends BaseCompiler {
return result;
}
if (result.asmSize >= maxSize) {
result.asm =
'<No output: generated assembly was too large' +
` (${result.asmSize} > ${maxSize} bytes)>`;
result.asm = `<No output: generated assembly was too large (${result.asmSize} > ${maxSize} bytes)>`;
return result;
}
if (postProcess.length > 0) {
return await this.execPostProcess(result, postProcess, outputFilename, maxSize);
} else {
const contents = await fs.readFile(outputFilename, {encoding: 'utf8'});
result.asm = contents.toString();
return result;
}
const contents = await fs.readFile(outputFilename, {encoding: 'utf8'});
result.asm = contents.toString();
return result;
})()
).then(asm => {
result.asm = typeof asm === 'string' ? asm : asm.asm;
+3 -6
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import * as fs from 'fs/promises';
import path from 'path';
import * as fs from 'node:fs/promises';
import path from 'node:path';
import {CompilationInfo, CompilationResult} from '../../types/compilation/compilation.interfaces.js';
import {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -44,10 +44,7 @@ export class NvcppCompiler extends BaseCompiler {
constructor(info: PreliminaryCompilerInfo, env: CompilationEnvironment) {
super(info, env);
this.cuobjdump = this.compilerProps<string | undefined>(
'compiler.' + this.compiler.id + '.cuobjdump',
undefined,
);
this.cuobjdump = this.compilerProps<string | undefined>(`compiler.${this.compiler.id}.cuobjdump`, undefined);
this.deviceAsmParser = new SassAsmParser(this.compilerProps);
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import Path from 'path';
import Path from 'node:path';
import Semver from 'semver';
+6 -10
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -85,10 +85,9 @@ export class PascalWinCompiler extends BaseCompiler {
override filename(fn: string) {
if (process.platform === 'linux' || process.platform === 'darwin') {
return 'Z:' + fn;
} else {
return super.filename(fn);
return `Z:${fn}`;
}
return super.filename(fn);
}
override async objdump(outputFilename: string, result, maxSize: number, intelAsm: boolean) {
@@ -106,7 +105,7 @@ export class PascalWinCompiler extends BaseCompiler {
if (objResult.code === 0) {
result.asm = objResult.stdout;
} else {
result.asm = '<No output: objdump returned ' + objResult.code + '>';
result.asm = `<No output: objdump returned ${objResult.code}>`;
}
return result;
@@ -117,10 +116,7 @@ export class PascalWinCompiler extends BaseCompiler {
await fs.writeFile(
filename,
// prettier-ignore
'program prog;\n' +
'uses ' + unitName + ' in \'' + unitPath + '\';\n' +
'begin\n' +
'end.\n',
`program prog;\nuses ${unitName} in \'${unitPath}\';\nbegin\nend.\n`,
);
}
@@ -131,7 +127,7 @@ export class PascalWinCompiler extends BaseCompiler {
} else {
const unitName = this.pasUtils.getUnitname(source);
if (unitName) {
inputFilename = path.join(dirPath, unitName + '.pas');
inputFilename = path.join(dirPath, `${unitName}.pas`);
} else {
inputFilename = path.join(dirPath, this.compileFilename);
}
+16 -22
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -72,7 +72,7 @@ export class FPCCompiler extends BaseCompiler {
override async postProcess(result, outputFilename: string, filters: ParseFiltersAndOutputOptions) {
const userSourceFilename = result.inputFilename;
const pasFilepath = path.join(result.dirPath, userSourceFilename);
const asmDumpFilepath = pasFilepath.substring(0, pasFilepath.length - 3) + 's';
const asmDumpFilepath = `${pasFilepath.substring(0, pasFilepath.length - 3)}s`;
return super.postProcess(result, asmDumpFilepath, filters);
}
@@ -92,8 +92,7 @@ export class FPCCompiler extends BaseCompiler {
for (let j = 0; j < result.asm.length; ++j) {
result.asm[j].text = this.demangler.demangleIfNeeded(result.asm[j].text);
if (
result.asm[j].source &&
result.asm[j].source.file &&
result.asm[j].source?.file &&
!result.asm[j].source.mainsource &&
this.isTheSameFileProbably(result.inputFilename, result.asm[j].source.file)
) {
@@ -176,11 +175,10 @@ export class FPCCompiler extends BaseCompiler {
if (furtherLookback === -1) break;
if (endOfProc === -1) {
newSource = newSource + input.substring(furtherLookback) + '\n';
newSource = `${newSource + input.substring(furtherLookback)}\n`;
break;
} else {
newSource = newSource + input.substring(furtherLookback, endOfProc + 3) + '\n';
}
newSource = `${newSource + input.substring(furtherLookback, endOfProc + 3)}\n`;
foundSourceAt = input.indexOf('/app/', endOfProc + 3);
}
@@ -196,21 +194,18 @@ export class FPCCompiler extends BaseCompiler {
await fs.writeFile(
filename,
// prettier-ignore
'program prog;\n' +
'uses ' + unitName + ' in \'' + unitPath + '\';\n' +
'begin\n' +
'end.\n',
`program prog;\nuses ${unitName} in \'${unitPath}\';\nbegin\nend.\n`,
);
}
getMainSourceFilename(source: string) {
let inputFilename;
if (this.pasUtils.isProgram(source)) {
inputFilename = this.pasUtils.getProgName(source) + '.dpr';
inputFilename = `${this.pasUtils.getProgName(source)}.dpr`;
} else {
const unitName = this.pasUtils.getUnitname(source);
if (unitName) {
inputFilename = unitName + '.pas';
inputFilename = `${unitName}.pas`;
} else {
inputFilename = this.compileFilename;
}
@@ -256,7 +251,7 @@ export class FPCCompiler extends BaseCompiler {
execOptions.customCwd = dirPath;
if (this.nasmPath) {
execOptions.env = _.clone(process.env) as Record<string, string>;
execOptions.env.PATH = execOptions.env.PATH + ':' + this.nasmPath;
execOptions.env.PATH = `${execOptions.env.PATH}:${this.nasmPath}`;
}
if (!alreadyHasDPR) {
@@ -266,7 +261,7 @@ export class FPCCompiler extends BaseCompiler {
}
options.pop();
options.push('-FE' + dirPath, '-B', projectFile);
options.push(`-FE${dirPath}`, '-B', projectFile);
return this.parseOutput(await this.exec(compiler, options, execOptions), inputFilename, dirPath);
}
@@ -298,14 +293,13 @@ export class FPCCompiler extends BaseCompiler {
if (Number.isNaN(Number(valueInBrackets))) {
return ` .file ${currentFileId} "${valueInBrackets}"`;
} else {
return ` .loc ${currentFileId} ${valueInBrackets} 0`;
}
} else if (asm.startsWith('.Le')) {
return ' .cfi_endproc';
} else {
return false;
return ` .loc ${currentFileId} ${valueInBrackets} 0`;
}
if (asm.startsWith('.Le')) {
return ' .cfi_endproc';
}
return false;
}
tryGetFilenumber(asm: string, files: Record<string, number>) {
@@ -324,7 +318,7 @@ export class FPCCompiler extends BaseCompiler {
if (Number.isNaN(Number(valueInBrackets))) {
if (!files[valueInBrackets]) {
let maxFileId = _.max(files);
if (maxFileId === -Infinity) {
if (maxFileId === Number.NEGATIVE_INFINITY) {
maxFileId = 0;
}
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {CompilationResult, ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import {LLVMIrBackendOptions} from '../../types/compilation/ir.interfaces.js';
+8 -8
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {CompilationResult, ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -49,14 +49,14 @@ export class PtxAssembler extends BaseCompiler {
parsePtxOutput(lines: string, inputFilename: string, pathPrefix: string) {
const re = /^ptxas\s*<source>, line (\d+);(.*)/;
const result: ResultLine[] = [];
utils.eachLine(lines, function (line) {
utils.eachLine(lines, line => {
if (pathPrefix) line = line.replace(pathPrefix, '');
if (inputFilename) {
line = line.split(inputFilename).join('<source>');
if (inputFilename.indexOf('./') === 0) {
line = line.split('/home/ubuntu/' + inputFilename.substring(2)).join('<source>');
line = line.split('/home/ce/' + inputFilename.substring(2)).join('<source>');
line = line.split(`/home/ubuntu/${inputFilename.substring(2)}`).join('<source>');
line = line.split(`/home/ce/${inputFilename.substring(2)}`).join('<source>');
}
}
if (line !== null) {
@@ -66,7 +66,7 @@ export class PtxAssembler extends BaseCompiler {
lineObj.text = `<source>:${match[1]} ${match[2].trim()}`;
lineObj.tag = {
severity: 0,
line: parseInt(match[1]),
line: Number.parseInt(match[1]),
column: 0,
text: match[2].trim(),
};
@@ -107,8 +107,8 @@ export class PtxAssembler extends BaseCompiler {
return {
...result,
inputFilename,
stdout: this.parsePtxOutput(result.stdout, './' + this.compileFilename, 'no idea what to put here'),
stderr: this.parsePtxOutput(result.stderr, './' + this.compileFilename, 'no idea what to put here'),
stdout: this.parsePtxOutput(result.stdout, `./${this.compileFilename}`, 'no idea what to put here'),
stderr: this.parsePtxOutput(result.stderr, `./${this.compileFilename}`, 'no idea what to put here'),
};
}
@@ -132,7 +132,7 @@ export class PtxAssembler extends BaseCompiler {
if (objResult.code === 0) {
result.objdumpTime = objResult.execTime;
} else {
result.asm = '<No output: objdump returned ' + objResult.code + '>';
result.asm = `<No output: objdump returned ${objResult.code}>`;
}
return result;
}
+1 -1
View File
@@ -60,7 +60,7 @@ export class PythonCompiler extends BaseCompiler {
const match = line.match(lineRe);
if (match) {
const lineno = parseInt(match[1]);
const lineno = Number.parseInt(match[1]);
sourceLoc = {line: lineno, file: null};
lastLineNo = lineno;
} else if (line) {
+4 -4
View File
@@ -1,4 +1,4 @@
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -33,7 +33,7 @@ export class PythranCompiler extends BaseCompiler {
const execOptions = super.getDefaultExecOptions();
if (this.cpp_compiler_root) {
execOptions.env.PATH = execOptions.env.PATH + ':' + path.join(this.cpp_compiler_root, 'bin');
execOptions.env.PATH = `${execOptions.env.PATH}:${path.join(this.cpp_compiler_root, 'bin')}`;
}
return execOptions;
@@ -50,7 +50,7 @@ export class PythranCompiler extends BaseCompiler {
}
override getCompilerResultLanguageId(filters?: ParseFiltersAndOutputOptions): string | undefined {
if (filters !== undefined && filters.binary) return 'asm';
else return 'cppp';
if (filters?.binary) return 'asm';
return 'cppp';
}
}
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
import _ from 'underscore';
@@ -167,9 +167,9 @@ export class R8Compiler extends D8Compiler implements SimpleOutputFilenameCompil
if (this.lang.id === 'android-kotlin') {
libArgs.push(
'--lib',
this.kotlinLibPath + '/kotlin-stdlib.jar',
`${this.kotlinLibPath}/kotlin-stdlib.jar`,
'--lib',
this.kotlinLibPath + '/annotations-13.0.jar',
`${this.kotlinLibPath}/annotations-13.0.jar`,
);
}
return libArgs;
+4 -4
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -199,9 +199,9 @@ export class RacketCompiler extends BaseCompiler {
execOptions.maxOutput = 1024 * 1024 * 1024;
// Dump various optimisation passes during compilation
execOptions.env['PLT_LINKLET_SHOW_CP0'] = '1';
execOptions.env['PLT_LINKLET_SHOW_PASSES'] = 'all';
execOptions.env['PLT_LINKLET_SHOW_ASSEMBLY'] = '1';
execOptions.env.PLT_LINKLET_SHOW_CP0 = '1';
execOptions.env.PLT_LINKLET_SHOW_PASSES = 'all';
execOptions.env.PLT_LINKLET_SHOW_ASSEMBLY = '1';
const compileStart = performance.now();
const output = await this.runCompiler(this.compiler.exe, options, pipelineFile, execOptions);
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import fs from 'fs-extra';
@@ -203,7 +203,7 @@ Please supply an ASIC from the following options:`,
const files = await fs.readdir(outputDir, {encoding: 'utf8'});
for (const file of files) {
if (file.startsWith((asicSelection.asic as string) + '_output')) {
if (file.startsWith(`${asicSelection.asic as string}_output`)) {
await fs.rename(path.join(outputDir, file), outputFile);
registerAnalysisFile = path.join(outputDir, file.replace('output', 'livereg').replace('.s', '.txt'));
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -64,12 +64,12 @@ export class RubyCompiler extends BaseCompiler {
const match = line.match(lineRe);
if (match) {
lastLineNo = parseInt(match[1]);
lastLineNo = Number.parseInt(match[1]);
} else if (line) {
const fileMatch = line.match(fileRe);
if (fileMatch) {
lastFile = fileMatch[1];
lastLineNo = parseInt(fileMatch[2]);
lastLineNo = Number.parseInt(fileMatch[2]);
}
} else {
lastFile = null;
+2 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {SemVer} from 'semver';
import _ from 'underscore';
@@ -182,9 +182,8 @@ export class RustCompiler extends BaseCompiler {
if (this.buildenvsetup) {
const libraryDetails = await this.getRequiredLibraryVersions(key.libraries);
return this.buildenvsetup.setup(key, dirPath, libraryDetails);
} else {
return [];
}
return [];
}
override fixIncompatibleOptions(
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -60,7 +60,7 @@ export class RustcCgGCCCompiler extends RustCompiler {
}
override getGccDumpOptions(gccDumpOptions, outputFilename: string) {
return ['-C', 'llvm-args=' + super.getGccDumpOptions(gccDumpOptions, outputFilename).join(' ')];
return ['-C', `llvm-args=${super.getGccDumpOptions(gccDumpOptions, outputFilename).join(' ')}`];
}
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string, userOptions?: string[]) {
@@ -70,7 +70,7 @@ export class RustcCgGCCCompiler extends RustCompiler {
let options = [
'-Z',
'codegen-backend=' + path.join(toolroot, 'lib', 'librustc_codegen_gcc.so'),
`codegen-backend=${path.join(toolroot, 'lib', 'librustc_codegen_gcc.so')}`,
'--sysroot',
path.join(toolroot, 'sysroot'),
];
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {BaseCompiler} from '../base-compiler.js';
@@ -62,7 +62,7 @@ export class SolidityZKsyncCompiler extends BaseCompiler {
const combinedJson = JSON.parse(result.asm);
const asm: any[] = [];
for (const build of Object.values(combinedJson.contracts) as JSON[]) {
asm.push({text: build['asm']});
asm.push({text: build.asm});
}
return {asm};
}
+17 -21
View File
@@ -22,8 +22,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import * as fs from 'fs';
import path from 'path';
import * as fs from 'node:fs';
import path from 'node:path';
import Semver from 'semver';
@@ -115,20 +115,18 @@ export class SolidityCompiler extends BaseCompiler {
return node.name === 'FunctionDefinition';
})
.map(node => {
const [begin, length] = node.src.split(':').map(x => parseInt(x));
const [begin, length] = node.src.split(':').map(x => Number.parseInt(x));
let name = node.attributes.isConstructor ? 'constructor' : node.attributes.name;
// encode the args into the name so we can
// differentiate between overloads
if (node.children[0].children.length > 0) {
name +=
'_' +
node.children[0].children
.map(paramNode => {
return paramNode.attributes.type;
})
.join('_');
name += `_${node.children[0].children
.map(paramNode => {
return paramNode.attributes.type;
})
.join('_')}`;
}
return {
@@ -147,20 +145,18 @@ export class SolidityCompiler extends BaseCompiler {
return node.nodeType === 'FunctionDefinition';
})
.map(node => {
const [begin, length] = node.src.split(':').map(x => parseInt(x));
const [begin, length] = node.src.split(':').map(x => Number.parseInt(x));
let name = node.kind === 'constructor' ? 'constructor' : node.name;
// encode the args into the name so we can
// differentiate between overloads
if (node.parameters.parameters.length > 0) {
name +=
'_' +
node.parameters.parameters
.map(paramNode => {
return paramNode.typeName.name;
})
.join('_');
name += `_${node.parameters.parameters
.map(paramNode => {
return paramNode.typeName.name;
})
.join('_')}`;
}
return {
@@ -179,7 +175,7 @@ export class SolidityCompiler extends BaseCompiler {
const generatedSources = {};
for (const generatedSource of generatedSourcesData) {
generatedSources[generatedSource.id] = generatedSource.ast.statements.map(statement => {
const [begin, length] = statement.src.split(':').map(x => parseInt(x));
const [begin, length] = statement.src.split(':').map(x => Number.parseInt(x));
return {
name: statement.name,
begin: begin,
@@ -272,11 +268,11 @@ export class SolidityCompiler extends BaseCompiler {
(Object.entries(data.asm['.data']) as [string, any][]).map(([id, {'.code': code}]) => {
// some .data sections do not contain embedded .code
if (code === undefined) return [];
else return [{text: `\t${id}:`}, processOpcodes(code, '\t', generatedSourcesRuntime)];
return [{text: `\t${id}:`}, processOpcodes(code, '\t', generatedSourcesRuntime)];
}),
];
})
.flat(Infinity),
.flat(Number.POSITIVE_INFINITY),
};
}
}
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import Semver from 'semver';
import _ from 'underscore';
@@ -116,7 +116,7 @@ export class SpiceCompiler extends BaseCompiler {
override getIrOutputFilename(inputFilename: string): string {
const dirPath = path.dirname(inputFilename);
return path.join(dirPath, 'example-ir-code' + this.optLevelSuffix + '.ll');
return path.join(dirPath, `example-ir-code${this.optLevelSuffix}.ll`);
}
override getObjdumpOutputFilename(inputFilename: string): string {
+2 -2
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
@@ -161,7 +161,7 @@ export class SPIRVToolsCompiler extends BaseCompiler {
return result;
}
const spvasmFilename = path.join(sourceDir, this.outputFilebase + '.spvasm');
const spvasmFilename = path.join(sourceDir, `${this.outputFilebase}.spvasm`);
const disassemblerFlags = [spvBinFilename, '-o', spvasmFilename];
// Will likely never fail
+6 -6
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import type {ExecutionOptionsWithEnv} from '../../types/compilation/compilation.interfaces.js';
import type {ConfiguredOverrides} from '../../types/compilation/compiler-overrides.interfaces.js';
@@ -107,7 +107,7 @@ export class SPIRVCompiler extends BaseCompiler {
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
const sourceDir = path.dirname(outputFilename);
const bitcodeFilename = path.join(sourceDir, this.outputFilebase + '.bc');
const bitcodeFilename = path.join(sourceDir, `${this.outputFilebase}.bc`);
return ['-cc1', '-debug-info-kind=limited', '-dwarf-version=5', '-debugger-tuning=gdb', '-o', bitcodeFilename];
}
@@ -126,7 +126,7 @@ export class SPIRVCompiler extends BaseCompiler {
execOptions: ExecutionOptionsWithEnv,
) {
const sourceDir = path.dirname(inputFilename);
const bitcodeFilename = path.join(sourceDir, this.outputFilebase + '.bc');
const bitcodeFilename = path.join(sourceDir, `${this.outputFilebase}.bc`);
if (!execOptions) {
execOptions = this.getDefaultExecOptions();
@@ -142,7 +142,7 @@ export class SPIRVCompiler extends BaseCompiler {
return result;
}
const spvBinFilename = path.join(sourceDir, this.outputFilebase + '.spv');
const spvBinFilename = path.join(sourceDir, `${this.outputFilebase}.spv`);
const translatorFlags = ['-spirv-debug', bitcodeFilename, '-o', spvBinFilename];
const spvBin = await this.exec(this.translatorPath, translatorFlags, execOptions);
@@ -153,7 +153,7 @@ export class SPIRVCompiler extends BaseCompiler {
return result;
}
const spvasmFilename = path.join(sourceDir, this.outputFilebase + '.spvasm');
const spvasmFilename = path.join(sourceDir, `${this.outputFilebase}.spvasm`);
const disassemblerFlags = [spvBinFilename, '-o', spvasmFilename];
const spvasmOutput = await this.exec(this.disassemblerPath, disassemblerFlags, execOptions);
@@ -180,7 +180,7 @@ export class SPIRVCompiler extends BaseCompiler {
execOptions.customCwd = path.dirname(inputFilename);
const sourceDir = path.dirname(inputFilename);
const outputFile = path.join(sourceDir, this.outputFilebase + '.bc');
const outputFile = path.join(sourceDir, `${this.outputFilebase}.bc`);
const newOptions = options;
newOptions.concat('-S');
+3 -3
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
@@ -42,7 +42,7 @@ export class TIC2000 extends BaseCompiler {
}
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) {
const options = ['-g', '-c', '-n', '--output_file=' + outputFilename];
const options = ['-g', '-c', '-n', `--output_file=${outputFilename}`];
filters.preProcessLines = this.preProcessLines.bind(this);
@@ -63,7 +63,7 @@ export class TIC2000 extends BaseCompiler {
if (match) {
// Add two lines stating the file and location to allow parsing the source location by the standard
// parser
asmLines.splice(i, 0, ' .file 1 ' + match[1], ' .loc 1 ' + match[2] + ' ' + match[3]);
asmLines.splice(i, 0, ` .file 1 ${match[1]}`, ` .loc 1 ${match[2]} ${match[3]}`);
i += 2;
}
}
+4 -5
View File
@@ -36,12 +36,11 @@ export class TinyCCompiler extends BaseCompiler {
override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string, userOptions?: string[]) {
if (_.some(unwrap(userOptions), opt => opt === '--help' || opt === '-h' || opt === '-hh')) {
return [];
} else {
if (!_.some(unwrap(userOptions), opt => opt === '-E')) {
filters.binary = true;
}
return ['-g', '-o', this.filename(outputFilename)];
}
if (!_.some(unwrap(userOptions), opt => opt === '-E')) {
filters.binary = true;
}
return ['-g', '-o', this.filename(outputFilename)];
}
override filterUserOptions(userOptions: string[]) {
+1 -1
View File
@@ -41,7 +41,7 @@ export class ToitCompiler extends BaseCompiler {
}
cacheDir(outputFilename: string) {
return outputFilename + '.cache';
return `${outputFilename}.cache`;
}
override optionsForFilter(
+1 -1
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import {SelectedLibraryVersion} from '../../types/libraries/libraries.interfaces.js';
import {logger} from '../logger.js';
+4 -4
View File
@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
import path from 'path';
import path from 'node:path';
import Semver from 'semver';
@@ -82,7 +82,7 @@ export class TypeScriptNativeCompiler extends BaseCompiler {
}
if (this.tscNewOutput) {
addOpts.push('-o=' + this.filename(outputFilename));
addOpts.push(`-o=${this.filename(outputFilename)}`);
}
return addOpts;
@@ -106,7 +106,7 @@ export class TypeScriptNativeCompiler extends BaseCompiler {
) {
const newOptions = options.filter(e => !e.startsWith('--emit=') && !e.startsWith('-o='));
if (this.tscNewOutput) {
newOptions.push('-o=' + this.getIrOutputFilename(inputFilename, filters));
newOptions.push(`-o=${this.getIrOutputFilename(inputFilename, filters)}`);
}
return await super.generateIR(inputFilename, newOptions, irOptions, produceCfg, filters);
@@ -127,7 +127,7 @@ export class TypeScriptNativeCompiler extends BaseCompiler {
override async handleInterpreting(key: CacheKey, executeParameters: ExecutableExecutionOptions) {
executeParameters.args = [
'--emit=jit',
this.tscSharedLib ? '--shared-libs=' + this.tscSharedLib : '-nogc',
this.tscSharedLib ? `--shared-libs=${this.tscSharedLib}` : '-nogc',
...executeParameters.args,
];

Some files were not shown because too many files have changed in this diff Show More