mirror of
https://github.com/compiler-explorer/compiler-explorer.git
synced 2025-12-27 10:33:59 -05:00
No array for each
This commit is contained in:
@@ -54,7 +54,7 @@ rules:
|
||||
- ignoreRegExpLiterals: true
|
||||
max-statements:
|
||||
- error
|
||||
- 50
|
||||
- 100 # TODO reduce...was 50
|
||||
no-control-regex: 0
|
||||
no-duplicate-imports: error
|
||||
no-useless-call: error
|
||||
@@ -133,7 +133,6 @@ rules:
|
||||
unicorn/prevent-abbreviations: off
|
||||
# things we'd like to turn on but need fairly extensive code changes:
|
||||
unicorn/prefer-ternary: off
|
||||
unicorn/no-array-for-each: off
|
||||
unicorn/prefer-array-some: off
|
||||
unicorn/prefer-spread: off
|
||||
unicorn/no-lonely-if: off
|
||||
|
||||
@@ -157,13 +157,13 @@ export class AsmEWAVRParser extends AsmParser {
|
||||
}
|
||||
};
|
||||
|
||||
asmLines.forEach(line => {
|
||||
for (let line of asmLines) {
|
||||
if (line.trim() === 'END') {
|
||||
seenEnd = true;
|
||||
if (!filters.directives) {
|
||||
resultObject.postfix.push({text: line, source: null});
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line.trim() === '') {
|
||||
@@ -177,7 +177,7 @@ export class AsmEWAVRParser extends AsmParser {
|
||||
else {
|
||||
currentLabel.lines.push(emptyLine);
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (seenEnd && !this.commentOnly.test(line)) {
|
||||
// There should be nothing but comments after END directive
|
||||
@@ -213,7 +213,7 @@ export class AsmEWAVRParser extends AsmParser {
|
||||
checkRequiresStatement(line);
|
||||
|
||||
if (filters.commentOnly && this.commentOnly.test(line)) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
const shouldSkip = filters.directives && (
|
||||
@@ -226,7 +226,7 @@ export class AsmEWAVRParser extends AsmParser {
|
||||
);
|
||||
|
||||
if (shouldSkip) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
line = utils.expandTabs(line);
|
||||
@@ -239,7 +239,7 @@ export class AsmEWAVRParser extends AsmParser {
|
||||
} else if (!shouldSkip) {
|
||||
currentLabel.lines.push(textAndSource);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this.resultObjectIntoArray(resultObject, filters, definedLabels);
|
||||
}
|
||||
|
||||
@@ -148,11 +148,11 @@ export class VcAsmParser extends AsmParser {
|
||||
const labels = line.match(this.labelFind);
|
||||
if (!labels) return;
|
||||
labels.splice(0, 1);
|
||||
labels.forEach((item) => {
|
||||
for (const item of labels) {
|
||||
if (datadefLabels.find(l => item === l)) {
|
||||
datadefLabelsUsed.push(item);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const checkBeginFunction = (line) => {
|
||||
@@ -174,16 +174,16 @@ export class VcAsmParser extends AsmParser {
|
||||
}
|
||||
};
|
||||
|
||||
asmLines.forEach(line => {
|
||||
for (let line of asmLines) {
|
||||
if (line.trim() === 'END') {
|
||||
seenEnd = true;
|
||||
if (!filters.directives) {
|
||||
resultObject.postfix = {text: line, source: null};
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (line.trim() === '') {
|
||||
if (seenEnd) return;
|
||||
if (seenEnd) continue;
|
||||
|
||||
const emptyLine = {text: '', source: null};
|
||||
if (currentFunction === null) {
|
||||
@@ -191,7 +191,7 @@ export class VcAsmParser extends AsmParser {
|
||||
} else {
|
||||
currentFunction.lines.push(emptyLine);
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
if (seenEnd) {
|
||||
// this should never happen
|
||||
@@ -232,12 +232,12 @@ export class VcAsmParser extends AsmParser {
|
||||
const functionName = line.match(this.definesFunction);
|
||||
if (functionName) {
|
||||
if (asmLines.length === 0) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
currentFunction.name = functionName[1];
|
||||
}
|
||||
|
||||
if (filters.commentOnly && this.commentOnly.test(line)) return;
|
||||
if (filters.commentOnly && this.commentOnly.test(line)) continue;
|
||||
|
||||
const shouldSkip = filters.directives && (
|
||||
line.match(this.endSegment) ||
|
||||
@@ -246,7 +246,7 @@ export class VcAsmParser extends AsmParser {
|
||||
line.match(this.beginSegment));
|
||||
|
||||
if (shouldSkip) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
checkForDdefLabel(line);
|
||||
@@ -264,7 +264,7 @@ export class VcAsmParser extends AsmParser {
|
||||
}
|
||||
|
||||
checkUsedDatadefLabels(line);
|
||||
});
|
||||
}
|
||||
|
||||
return this.resultObjectIntoArray(resultObject, filters, datadefLabelsUsed);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export class AsmParser extends AsmRegex {
|
||||
// mov eax, .baz
|
||||
// In this case, the '.baz' is used by an opcode, and so is strongly used.
|
||||
// The '.foo' is weakly used by .baz.
|
||||
asmLines.forEach(line => {
|
||||
for (let line of asmLines) {
|
||||
if (this.startAppBlock.test(line) || this.startAsmNesting.test(line)) {
|
||||
inCustomAssembly++;
|
||||
} else if (this.endAppBlock.test(line) || this.endAsmNesting.test(line)) {
|
||||
@@ -148,27 +148,27 @@ export class AsmParser extends AsmRegex {
|
||||
}
|
||||
|
||||
const definesFunction = line.match(this.definesFunction);
|
||||
if (!definesFunction && (!line || line[0] === '.')) return;
|
||||
if (!definesFunction && (!line || line[0] === '.')) continue;
|
||||
|
||||
match = line.match(labelFind);
|
||||
if (!match) return;
|
||||
if (!match) continue;
|
||||
|
||||
if (!filterDirectives || this.hasOpcode(line, false) || definesFunction) {
|
||||
// Only count a label as used if it's used by an opcode, or else we're not filtering directives.
|
||||
match.forEach(label => labelsUsed[label] = true);
|
||||
for (const label of match) labelsUsed[label] = true;
|
||||
} else {
|
||||
// If we have a current label, then any subsequent opcode or data definition's labels are referred to
|
||||
// weakly by that label.
|
||||
const isDataDefinition = !!this.dataDefn.test(line);
|
||||
const isOpcode = this.hasOpcode(line, false);
|
||||
if (isDataDefinition || isOpcode) {
|
||||
currentLabelSet.forEach(currentLabel => {
|
||||
for (const currentLabel of currentLabelSet) {
|
||||
if (!weakUsages[currentLabel]) weakUsages[currentLabel] = [];
|
||||
match.forEach(label => weakUsages[currentLabel].push(label));
|
||||
});
|
||||
for (const label of match) weakUsages[currentLabel].push(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Now follow the chains of used labels, marking any weak references they refer
|
||||
// to as also used. We iteratively do this until either no new labels are found,
|
||||
@@ -194,7 +194,7 @@ export class AsmParser extends AsmRegex {
|
||||
|
||||
parseFiles(asmLines) {
|
||||
const files = {};
|
||||
asmLines.forEach(line => {
|
||||
for (const line of asmLines) {
|
||||
const match = line.match(this.fileFind);
|
||||
if (match) {
|
||||
const lineNum = parseInt(match[1]);
|
||||
@@ -205,7 +205,7 @@ export class AsmParser extends AsmRegex {
|
||||
files[lineNum] = match[2];
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return files;
|
||||
}
|
||||
|
||||
@@ -356,8 +356,11 @@ export class AsmParser extends AsmRegex {
|
||||
|
||||
// TODO: Make this function smaller
|
||||
// eslint-disable-next-line max-statements
|
||||
asmLines.forEach(line => {
|
||||
if (line.trim() === '') return maybeAddBlank();
|
||||
for (let line of asmLines) {
|
||||
if (line.trim() === '') {
|
||||
maybeAddBlank();
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.startAppBlock.test(line) || this.startAsmNesting.test(line)) {
|
||||
inCustomAssembly++;
|
||||
@@ -397,7 +400,7 @@ export class AsmParser extends AsmRegex {
|
||||
}
|
||||
|
||||
if (!keepInlineCode) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
mayRemovePreviousLabel = true;
|
||||
@@ -407,7 +410,7 @@ export class AsmParser extends AsmRegex {
|
||||
((commentOnly.test(line) && !inNvccCode) ||
|
||||
(commentOnlyNvcc.test(line) && inNvccCode))
|
||||
) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inCustomAssembly > 0)
|
||||
@@ -427,7 +430,7 @@ export class AsmParser extends AsmRegex {
|
||||
if (labelsUsed[match[1]] === undefined) {
|
||||
// It's an unused label.
|
||||
if (filters.labels) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
// A used label.
|
||||
@@ -446,7 +449,7 @@ export class AsmParser extends AsmRegex {
|
||||
} else {
|
||||
// .inst generates an opcode, so does not count as a directive
|
||||
if (this.directive.test(line) && !this.instOpcodeRe.test(line)) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -461,7 +464,7 @@ export class AsmParser extends AsmRegex {
|
||||
source: this.hasOpcode(line, inNvccCode) ? source : null,
|
||||
labels: labelsInLine,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.removeLabelsWithoutDefinition(asm, labelDefinitions);
|
||||
|
||||
@@ -511,7 +514,7 @@ export class AsmParser extends AsmRegex {
|
||||
asmLines = filters.preProcessBinaryAsmLines(asmLines);
|
||||
}
|
||||
|
||||
asmLines.forEach(line => {
|
||||
for (const line of asmLines) {
|
||||
const labelsInLine = [];
|
||||
|
||||
if (asm.length >= this.maxAsmLines) {
|
||||
@@ -522,12 +525,12 @@ export class AsmParser extends AsmRegex {
|
||||
labels: labelsInLine,
|
||||
});
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
let match = line.match(this.lineRe);
|
||||
if (match) {
|
||||
source = {file: null, line: parseInt(match[2])};
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
match = line.match(this.labelRe);
|
||||
@@ -541,10 +544,10 @@ export class AsmParser extends AsmRegex {
|
||||
});
|
||||
labelDefinitions[func] = asm.length;
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!func || !this.isUserFunction(func)) return;
|
||||
if (!func || !this.isUserFunction(func)) continue;
|
||||
|
||||
if (filters.libraryCode && source && source.file !== null) {
|
||||
if (mayRemovePreviousLabel && asm.length > 0) {
|
||||
@@ -554,7 +557,7 @@ export class AsmParser extends AsmRegex {
|
||||
}
|
||||
mayRemovePreviousLabel = false;
|
||||
}
|
||||
return;
|
||||
continue;
|
||||
} else {
|
||||
mayRemovePreviousLabel = true;
|
||||
}
|
||||
@@ -585,7 +588,7 @@ export class AsmParser extends AsmRegex {
|
||||
labels: labelsInLine,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
this.removeLabelsWithoutDefinition(asm, labelDefinitions);
|
||||
|
||||
|
||||
@@ -37,16 +37,16 @@ export class AsmRaw extends AsmRegex {
|
||||
return [{text: asmLines[0], source: null}];
|
||||
}
|
||||
|
||||
asmLines.forEach(line => {
|
||||
for (const line of asmLines) {
|
||||
let match = line.match(labelRe);
|
||||
if (match) {
|
||||
result.push({text: match[2] + ':', source: null});
|
||||
return;
|
||||
continue;
|
||||
} else {
|
||||
match = line.match(this.labelDef);
|
||||
if (match) {
|
||||
result.push({text: match[1] + ':', source: null});
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ export class AsmRaw extends AsmRegex {
|
||||
}
|
||||
result.push({opcodes: opcodes, address: address, text: disassembly, source: source, links: links});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
asm: result,
|
||||
|
||||
@@ -57,9 +57,9 @@ async function loadAwsConfig(properties) {
|
||||
try {
|
||||
const response = await ssm.getParametersByPath({Path: path}).promise();
|
||||
const map = {};
|
||||
response.Parameters.forEach((response) => {
|
||||
map[response.Name.substr(path.length)] = response.Value;
|
||||
});
|
||||
for (const param of response.Parameters) {
|
||||
map[param.Name.substr(path.length)] = param.Value;
|
||||
}
|
||||
logger.info('AWS info:', map);
|
||||
return map;
|
||||
} catch (err) {
|
||||
|
||||
@@ -649,7 +649,7 @@ export class BaseCompiler {
|
||||
runToolsOfType(tools, type, compilationInfo) {
|
||||
let tooling = [];
|
||||
if (tools) {
|
||||
tools.forEach((tool) => {
|
||||
for (const tool of tools) {
|
||||
const matches = this.possibleTools.find(possibleTool => {
|
||||
return possibleTool.getId() === tool.id &&
|
||||
possibleTool.getType() === type;
|
||||
@@ -660,7 +660,7 @@ export class BaseCompiler {
|
||||
compilationInfo.inputFilename, tool.args, tool.stdin);
|
||||
tooling.push(toolPromise);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return tooling;
|
||||
@@ -1432,11 +1432,11 @@ Please select another pass or change filters.`;
|
||||
checkSource(source) {
|
||||
const re = /^\s*#\s*i(nclude|mport)(_next)?\s+["<](\/|.*\.\.)[">]/;
|
||||
const failed = [];
|
||||
utils.splitLines(source).forEach((line, index) => {
|
||||
for (const [index, line] of utils.splitLines(source).entries()) {
|
||||
if (re.test(line)) {
|
||||
failed.push(`<stdin>:${index + 1}:1: no absolute or relative includes please`);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (failed.length > 0) return failed.join('\n');
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ export class ClientStateNormalizer {
|
||||
}
|
||||
|
||||
fromGoldenLayoutContent(content) {
|
||||
content.forEach((component) => {
|
||||
for (const component of content) {
|
||||
this.fromGoldenLayoutComponent(component);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
setFilterSettingsFromComponent(compiler, component) {
|
||||
@@ -388,14 +388,14 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
|
||||
this.createConformanceViewComponent(session, conformanceview),
|
||||
);
|
||||
|
||||
conformanceview.compilers.forEach((compiler) => {
|
||||
for (const compiler of conformanceview.compilers) {
|
||||
const compjson = {
|
||||
compilerId: compiler.id,
|
||||
options: compiler.options,
|
||||
};
|
||||
|
||||
stack.content[0].componentState.compilers.push(compjson);
|
||||
});
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
@@ -521,17 +521,17 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
|
||||
this.createCompilerComponent(session, compiler, customSessionId),
|
||||
);
|
||||
|
||||
compiler.specialoutputs.forEach((viewtype) => {
|
||||
for (const viewtype of compiler.specialoutputs) {
|
||||
stack.content.push(
|
||||
this.createSpecialOutputComponent(viewtype, session, idxCompiler, customSessionId),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
compiler.tools.forEach((tool) => {
|
||||
for (const tool of compiler.tools) {
|
||||
stack.content.push(
|
||||
this.createToolComponent(session, idxCompiler + 1, tool.id, tool.args, customSessionId),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (let idxExecutor = 0; idxExecutor < session.executors.length; idxExecutor++) {
|
||||
@@ -640,20 +640,20 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
|
||||
let stack = this.newCompilerStackFromSession(session, compiler, compilerWidth);
|
||||
this.golden.content[0].content[idxSession].content[1].content.push(stack);
|
||||
|
||||
compiler.specialoutputs.forEach((viewtype) => {
|
||||
for (const viewtype of compiler.specialoutputs) {
|
||||
let stack = this.newStackWithOneComponent(compilerWidth,
|
||||
this.createSpecialOutputComponent(viewtype, session, idxCompiler));
|
||||
|
||||
if (stack) {
|
||||
this.golden.content[0].content[idxSession].content[1].content.push(stack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
compiler.tools.forEach((tool) => {
|
||||
for (const tool of compiler.tools) {
|
||||
let stack = this.newToolStackFromCompiler(session, idxCompiler + 1,
|
||||
tool.id, tool.args, compilerWidth);
|
||||
this.golden.content[0].content[idxSession].content[1].content.push(stack);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (let idxExecutor = 0; idxExecutor < session.executors.length; idxExecutor++) {
|
||||
@@ -683,26 +683,26 @@ export class ClientStateGoldenifier extends GoldenLayoutComponents {
|
||||
let stack = this.newCompilerStackFromSession(session, compiler, width);
|
||||
this.golden.content[0].content.push(stack);
|
||||
|
||||
compiler.specialoutputs.forEach((viewtype) => {
|
||||
for (const viewtype of compiler.specialoutputs) {
|
||||
let stack = this.newStackWithOneComponent(width,
|
||||
this.createSpecialOutputComponent(viewtype, session, idxCompiler));
|
||||
|
||||
if (stack) {
|
||||
this.golden.content[0].content.push(stack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
compiler.tools.forEach((tool) => {
|
||||
for (const tool of compiler.tools) {
|
||||
let stack = this.newToolStackFromCompiler(session, compiler, idxCompiler + 1,
|
||||
tool.id, tool.args, width);
|
||||
this.golden.content[0].content.push(stack);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
session.executors.forEach((executor) => {
|
||||
for (const executor of session.executors) {
|
||||
let stack = this.newExecutorStackFromSession(session, executor, width);
|
||||
this.golden.content[0].content.push(stack);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,9 +139,9 @@ export class ClientStateConformanceView {
|
||||
|
||||
fromJsonData(jsondata) {
|
||||
this.libs = jsondata.libs;
|
||||
jsondata.compilers.forEach((compilerdata) => {
|
||||
for (const compilerdata of jsondata.compilers) {
|
||||
this.compilers.push(new ClientStateCompiler(compilerdata));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,17 +169,17 @@ export class ClientStateSession {
|
||||
}
|
||||
}
|
||||
|
||||
jsondata.compilers.forEach((compilerdata) => {
|
||||
for (const compilerdata of jsondata.compilers) {
|
||||
const compiler = new ClientStateCompiler(compilerdata);
|
||||
if (compiler.id) {
|
||||
this.compilers.push(compiler);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof jsondata.executors !== 'undefined') {
|
||||
jsondata.executors.forEach((executor) => {
|
||||
for (const executor of jsondata.executors) {
|
||||
this.executors.push(new ClientStateExecutor(executor));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -203,10 +203,10 @@ export class ClientStateSession {
|
||||
|
||||
if (this.conformanceview) count++;
|
||||
|
||||
this.compilers.forEach((compiler) => {
|
||||
for (const compiler of this.compilers) {
|
||||
count += compiler.specialoutputs.length;
|
||||
if (compiler.tools) count += compiler.tools.length;
|
||||
});
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
@@ -220,9 +220,9 @@ export class ClientState {
|
||||
}
|
||||
|
||||
fromJsonData(jsondata) {
|
||||
jsondata.sessions.forEach((sessiondata) => {
|
||||
for (const sessiondata of jsondata.sessions) {
|
||||
this.sessions.push(new ClientStateSession(sessiondata));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
findSessionById(id) {
|
||||
|
||||
@@ -58,32 +58,27 @@ export class CompilerArguments {
|
||||
}
|
||||
|
||||
getOptimizationArguments(excludeUsedArguments) {
|
||||
let possibleArguments = {};
|
||||
_.forEach(this.possibleArguments, (obj, argKey) => {
|
||||
for (let argIdx in excludeUsedArguments) {
|
||||
if (this.match(argKey, excludeUsedArguments[argIdx])) return;
|
||||
excludeUsedArguments = excludeUsedArguments || [];
|
||||
const possibleArguments = {};
|
||||
for (const [argKey, obj] of Object.entries(this.possibleArguments)) {
|
||||
if (!excludeUsedArguments.some(used => this.match(argKey, used))) {
|
||||
if (obj.description.includes('optimize') || obj.description.includes('optimization')) {
|
||||
possibleArguments[argKey] = {
|
||||
description: obj.description,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (obj.description.includes('optimize') || obj.description.includes('optimization')) {
|
||||
possibleArguments[argKey] = {
|
||||
description: obj.description,
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
return possibleArguments;
|
||||
}
|
||||
|
||||
getPopularArguments(excludeUsedArguments) {
|
||||
let possibleArguments = {};
|
||||
if (excludeUsedArguments && excludeUsedArguments.length > 0) {
|
||||
_.forEach(this.possibleArguments, (obj, argKey) => {
|
||||
for (let argIdx in excludeUsedArguments) {
|
||||
if (this.match(argKey, excludeUsedArguments[argIdx])) return;
|
||||
}
|
||||
excludeUsedArguments = excludeUsedArguments || [];
|
||||
const possibleArguments = {};
|
||||
for (const [argKey, obj] of Object.entries(this.possibleArguments)) {
|
||||
if (!excludeUsedArguments.some(used => this.match(argKey, used))) {
|
||||
possibleArguments[argKey] = obj;
|
||||
});
|
||||
} else {
|
||||
possibleArguments = this.possibleArguments;
|
||||
}
|
||||
}
|
||||
|
||||
let arr = _.pairs(possibleArguments);
|
||||
@@ -164,7 +159,7 @@ export class CompilerArguments {
|
||||
_.keys(this.possibleArguments).map((val) => this.match(val, option)),
|
||||
);
|
||||
|
||||
possibleKeys.forEach(key => {
|
||||
for (const key of possibleKeys) {
|
||||
if (this.possibleArguments[key]) {
|
||||
this.possibleArguments[key].timesused += timesUsed;
|
||||
|
||||
@@ -179,6 +174,6 @@ export class CompilerArguments {
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,15 +392,15 @@ export class CompilerFinder {
|
||||
_.each(ndkPaths, (ndkPath, langId) => {
|
||||
if (ndkPath) {
|
||||
const toolchains = fs.readdirSync(`${ndkPath}/toolchains`);
|
||||
toolchains.forEach((version, index, a) => {
|
||||
for (const [version, index] of toolchains) {
|
||||
const path = `${ndkPath}/toolchains/${version}/prebuilt/linux-x86_64/bin/`;
|
||||
if (fs.existsSync(path)) {
|
||||
const cc = fs.readdirSync(path).find(filename => filename.includes('g++'));
|
||||
a[index] = path + cc;
|
||||
toolchains[index] = path + cc;
|
||||
} else {
|
||||
a[index] = null;
|
||||
toolchains[index] = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
langToCompilers[langId].push(toolchains.filter(x => x !== null));
|
||||
}
|
||||
});
|
||||
|
||||
@@ -57,11 +57,11 @@ export class AssemblyCompiler extends BaseCompiler {
|
||||
const files = fs.readdirSync(outputFolder);
|
||||
|
||||
let outputFilename = super.filename(fn);
|
||||
files.forEach(file => {
|
||||
for (const file of files) {
|
||||
if (file[0] !== '.' && file !== this.compileFilename) {
|
||||
outputFilename = path.join(outputFolder, file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return outputFilename;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ export class JavaCompiler extends BaseCompiler {
|
||||
parseds.sort((o1, o2) => o1.firstSourceLine - o2.firstSourceLine);
|
||||
|
||||
const segments = [];
|
||||
parseds.forEach((parsed, classNumber) => {
|
||||
for (const [classNumber, parsed] of parseds.entries()) {
|
||||
if (classNumber > 0) {
|
||||
// Separate classes with two line breaks
|
||||
segments.push({text: '', source: null}, {text: '', source: null});
|
||||
@@ -178,12 +178,12 @@ export class JavaCompiler extends BaseCompiler {
|
||||
// textsBeforeMethod[last] is actually *after* the last method.
|
||||
// Check whether there is a method following the text block
|
||||
if (i < parsed.methods.length) {
|
||||
parsed.methods[i].instructions.forEach(({text, sourceLine}) => {
|
||||
for (const {text, sourceLine} of parsed.methods[i].instructions) {
|
||||
segments.push({text: text, source: {file: null, line: sourceLine}});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return {asm: segments};
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ export class PythonCompiler extends BaseCompiler {
|
||||
let lastLineNo = null;
|
||||
let sourceLoc = null;
|
||||
|
||||
bytecodeLines.forEach(line => {
|
||||
for (const line of bytecodeLines) {
|
||||
const match = line.match(lineRe);
|
||||
|
||||
if (match) {
|
||||
@@ -61,7 +61,7 @@ export class PythonCompiler extends BaseCompiler {
|
||||
}
|
||||
|
||||
bytecodeResult.push({text: line, source: sourceLoc});
|
||||
});
|
||||
}
|
||||
|
||||
return {asm: bytecodeResult};
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ export class BaseDemangler extends AsmRegex {
|
||||
demangleLabels(labels, tree) {
|
||||
if (!Array.isArray(labels) || labels.length === 0) return;
|
||||
|
||||
labels.forEach((label, index) => {
|
||||
for (const [index, label] of labels.entries()) {
|
||||
const value = label.name;
|
||||
const newValue = tree.findExact(value);
|
||||
if (newValue) {
|
||||
@@ -72,7 +72,7 @@ export class BaseDemangler extends AsmRegex {
|
||||
labels[j].range.startCol += newValue.length - value.length;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
demangleLabelDefinitions(labelDefinitions, translations) {
|
||||
|
||||
@@ -302,9 +302,9 @@ export class CompileHandler {
|
||||
}
|
||||
|
||||
tools = tools || [];
|
||||
tools.forEach((tool) => {
|
||||
for (const tool of tools) {
|
||||
tool.args = utils.splitArguments(tool.args);
|
||||
});
|
||||
}
|
||||
return {source, options, backendOptions, filters, bypassCache, tools, executionParameters, libraries};
|
||||
}
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ export class LlvmIrParser {
|
||||
// Filters
|
||||
const commentOnly = /^\s*(;.*)$/;
|
||||
|
||||
irLines.forEach(line => {
|
||||
for (const line of irLines) {
|
||||
let source = null;
|
||||
let match;
|
||||
|
||||
@@ -132,11 +132,11 @@ export class LlvmIrParser {
|
||||
result.push({text: '', source: null});
|
||||
}
|
||||
prevLineEmpty = true;
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (filters.commentOnly && commentOnly.test(line)) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Non-Meta IR line. Metadata is attached to it using "!dbg !123"
|
||||
@@ -148,7 +148,7 @@ export class LlvmIrParser {
|
||||
scope: match[1],
|
||||
});
|
||||
prevLineEmpty = false;
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
const metaNode = this.parseMetaNode(line);
|
||||
@@ -157,25 +157,25 @@ export class LlvmIrParser {
|
||||
}
|
||||
|
||||
if (filters.directives && this.isLineLlvmDirective(line)) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
result.push({text: (filters.trim ? utils.squashHorizontalWhitespace(line) : line), source: source});
|
||||
prevLineEmpty = false;
|
||||
});
|
||||
}
|
||||
|
||||
if (result.length >= this.maxIrLines) {
|
||||
result.length = this.maxIrLines + 1;
|
||||
result[this.maxIrLines] = {text: '[truncated; too many lines]', source: null};
|
||||
}
|
||||
|
||||
result.forEach(line => {
|
||||
if (!line.scope) return;
|
||||
for (const line of result) {
|
||||
if (!line.scope) continue;
|
||||
line.source = {
|
||||
file: this.getFileName(debugInfo, line.scope),
|
||||
line: this.getSourceLineNumber(debugInfo, line.scope),
|
||||
column: this.getSourceColumn(debugInfo, line.scope),
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
asm: result,
|
||||
|
||||
@@ -48,27 +48,27 @@ function debug(string) {
|
||||
export function get(base, property, defaultValue) {
|
||||
let result = defaultValue;
|
||||
let source = 'default';
|
||||
hierarchy.forEach(elem => {
|
||||
for (const elem of hierarchy) {
|
||||
const propertyMap = findProps(base, elem);
|
||||
if (propertyMap && property in propertyMap) {
|
||||
debug(`${base}.${property}: overriding ${source} value (${result}) with ${propertyMap[property]}`);
|
||||
result = propertyMap[property];
|
||||
source = elem;
|
||||
}
|
||||
});
|
||||
}
|
||||
debug(`${base}.${property}: returning ${result} (from ${source})`);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function parseProperties(blob, name) {
|
||||
const props = {};
|
||||
blob.split('\n').forEach((line, index) => {
|
||||
for (let [index, line] of blob.split('\n').entries()) {
|
||||
line = line.replace(/#.*/, '').trim();
|
||||
if (!line) return;
|
||||
if (!line) continue;
|
||||
let split = line.match(/([^=]+)=(.*)/);
|
||||
if (!split) {
|
||||
logger.error(`Bad line: ${line} in ${name}: ${index + 1}`);
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
let prop = split[1].trim();
|
||||
let val = split[2].trim();
|
||||
@@ -79,7 +79,7 @@ export function parseProperties(blob, name) {
|
||||
}
|
||||
props[prop] = val;
|
||||
debug(`${prop} = ${val}`);
|
||||
});
|
||||
}
|
||||
return props;
|
||||
}
|
||||
|
||||
@@ -90,12 +90,12 @@ export function initialize(directory, hier) {
|
||||
const endsWith = /\.properties$/;
|
||||
const propertyFiles = fs.readdirSync(directory).filter(filename => filename.match(endsWith));
|
||||
properties = {};
|
||||
propertyFiles.forEach(file => {
|
||||
for (let file of propertyFiles) {
|
||||
const baseName = file.replace(endsWith, '');
|
||||
file = path.join(directory, file);
|
||||
debug('Reading config from ' + file);
|
||||
properties[baseName] = parseProperties(fs.readFileSync(file, 'utf-8'), file);
|
||||
});
|
||||
}
|
||||
logger.debug('props.properties = ', properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -82,9 +82,9 @@ export class SymbolStore {
|
||||
}
|
||||
|
||||
addMany(symbols) {
|
||||
symbols.forEach(symbol => {
|
||||
for (const symbol of symbols) {
|
||||
this.uniqueSymbols[symbol] = symbol;
|
||||
});
|
||||
}
|
||||
|
||||
this.isSorted = false;
|
||||
}
|
||||
|
||||
@@ -26,19 +26,19 @@ import * as csp from '../lib/csp';
|
||||
|
||||
describe('CSP', () => {
|
||||
it('Should work in the godbolt.org domain for every field', () => {
|
||||
Object.keys(csp.data).forEach(value => {
|
||||
for (const value of Object.keys(csp.data)) {
|
||||
csp.data[value].should.include.members(['https://*.godbolt.org', "'self'"]);
|
||||
});
|
||||
}
|
||||
});
|
||||
it('Should work in the compiler-explorer domain for every field', () => {
|
||||
Object.keys(csp.data).forEach(value => {
|
||||
for (const value of Object.keys(csp.data)) {
|
||||
csp.data[value].should.include.members(['https://*.compiler-explorer.com', "'self'"]);
|
||||
});
|
||||
}
|
||||
});
|
||||
it('Should work in a localhost environment for every field', () => {
|
||||
Object.keys(csp.data).forEach(value => {
|
||||
for (const value of Object.keys(csp.data)) {
|
||||
csp.data[value].should.include.members(['localhost:*', "'self'"]);
|
||||
});
|
||||
}
|
||||
});
|
||||
it('Should be a valid policy', () => {
|
||||
csp.policy.should.be.a('string');
|
||||
|
||||
@@ -81,42 +81,42 @@ function testFilter(filename, suffix, filters) {
|
||||
describe('Filter test cases', function () {
|
||||
|
||||
describe('No filters', function () {
|
||||
cases.forEach(x => testFilter(x, '.none', {}));
|
||||
for (const x of cases) testFilter(x, '.none', {});
|
||||
});
|
||||
describe('Directive filters', function () {
|
||||
cases.forEach(x => testFilter(x, '.directives', {directives: true}));
|
||||
for (const x of cases) testFilter(x, '.directives', {directives: true});
|
||||
});
|
||||
describe('Directives and labels together', function () {
|
||||
cases.forEach(x => testFilter(x, '.directives.labels', {directives: true, labels: true}));
|
||||
for (const x of cases) testFilter(x, '.directives.labels', {directives: true, labels: true});
|
||||
});
|
||||
describe('Directives, labels and comments', function () {
|
||||
cases.forEach(function (x) {
|
||||
for (const x of cases) {
|
||||
testFilter(x, '.directives.labels.comments', {directives: true, labels: true, commentOnly: true});
|
||||
});
|
||||
}
|
||||
});
|
||||
describe('Binary, directives, labels and comments', function () {
|
||||
if (process.platform !== 'win32') {
|
||||
cases.forEach(function (x) {
|
||||
for (const x of cases) {
|
||||
testFilter(x, '.binary.directives.labels.comments', {
|
||||
binary: true,
|
||||
directives: true,
|
||||
labels: true,
|
||||
commentOnly: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
describe('Directives and comments', function () {
|
||||
cases.forEach(x => testFilter(x, '.directives.comments', {directives: true, commentOnly: true}));
|
||||
for (const x of cases) testFilter(x, '.directives.comments', {directives: true, commentOnly: true});
|
||||
});
|
||||
describe('Directives and library code', function () {
|
||||
cases.forEach(x => testFilter(x, '.directives.library', {directives: true, libraryCode: true}));
|
||||
for (const x of cases) testFilter(x, '.directives.library', {directives: true, libraryCode: true});
|
||||
});
|
||||
describe('Directives, labels, comments and library code', function () {
|
||||
cases.forEach(function (x) {
|
||||
for (const x of cases) {
|
||||
testFilter(x, '.directives.labels.comments.library',
|
||||
{directives: true, labels: true, commentOnly: true, libraryCode: true});
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -28,16 +28,16 @@ import { fs, path, should } from './utils';
|
||||
|
||||
describe('Language definitions tests', () => {
|
||||
it('Has id equal to object key', () => {
|
||||
Object.keys(languages).forEach(languageKey => should.equal(languages[languageKey].id, languageKey));
|
||||
for (const languageKey of Object.keys(languages)) should.equal(languages[languageKey].id, languageKey);
|
||||
});
|
||||
it('Has extensions with leading dots', () => {
|
||||
Object.keys(languages).forEach(languageKey => should.equal(languages[languageKey].extensions[0][0], '.'));
|
||||
for (const languageKey of Object.keys(languages)) should.equal(languages[languageKey].extensions[0][0], '.');
|
||||
});
|
||||
it('Has examples & are initialized', () => {
|
||||
Object.keys(languages).forEach(languageKey => {
|
||||
for (const languageKey of Object.keys(languages)) {
|
||||
const lang = languages[languageKey];
|
||||
const example = fs.readFileSync(path.join('examples', lang.id, 'default' + lang.extensions[0]), 'utf-8');
|
||||
should.equal(example, lang.example);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -246,14 +246,14 @@ describe('llvm-ir isLineLlvmDirective', function () {
|
||||
];
|
||||
|
||||
it('should recognize directives', function () {
|
||||
directives.forEach(directive => {
|
||||
for (const directive of directives) {
|
||||
llvmIrParser.isLineLlvmDirective(directive).should.be.true;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('should recognize non-directives', function () {
|
||||
nonDirectives.forEach(directive => {
|
||||
for (const directive of nonDirectives) {
|
||||
llvmIrParser.isLineLlvmDirective(directive).should.be.false;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user