Tsification binge #7 (#6974)

This commit is contained in:
Ofek
2024-10-25 12:19:04 +03:00
committed by GitHub
parent 02b574b4a9
commit c1985d64a1
87 changed files with 331 additions and 202 deletions

View File

@@ -2342,7 +2342,7 @@ export class BaseCompiler implements ICompiler {
!!this.compiler.removeEmptyGccDump, !!this.compiler.removeEmptyGccDump,
outputFilename, outputFilename,
) )
: ''; : null;
const rustMirResult = makeRustMir ? await this.processRustMirOutput(outputFilename, asmResult) : undefined; const rustMirResult = makeRustMir ? await this.processRustMirOutput(outputFilename, asmResult) : undefined;
const haskellCoreResult = makeHaskellCore const haskellCoreResult = makeHaskellCore
@@ -3078,7 +3078,12 @@ export class BaseCompiler implements ICompiler {
); );
} }
async processGccDumpOutput(opts: GccDumpOptions, result, removeEmptyPasses: boolean, outputFilename: string) { async processGccDumpOutput(
opts: GccDumpOptions,
result,
removeEmptyPasses: boolean | undefined,
outputFilename: string,
) {
const rootDir = path.dirname(result.inputFilename); const rootDir = path.dirname(result.inputFilename);
if (opts.treeDump === false && opts.rtlDump === false && opts.ipaDump === false) { if (opts.treeDump === false && opts.rtlDump === false && opts.ipaDump === false) {
@@ -3092,7 +3097,7 @@ export class BaseCompiler implements ICompiler {
const output = { const output = {
all: [] as any[], all: [] as any[],
selectedPass: opts.pass, selectedPass: opts.pass ?? null,
currentPassOutput: '<No pass selected>', currentPassOutput: '<No pass selected>',
syntaxHighlight: false, syntaxHighlight: false,
}; };
@@ -3194,7 +3199,7 @@ but nothing was dumped. Possible causes are:
return result; return result;
} }
async execPostProcess(result, postProcesses, outputFilename: string, maxSize: number) { async execPostProcess(result, postProcesses: string[], outputFilename: string, maxSize: number) {
const postCommand = `cat "${outputFilename}" | ${postProcesses.join(' | ')}`; const postCommand = `cat "${outputFilename}" | ${postProcesses.join(' | ')}`;
return this.handlePostProcessResult(result, await this.exec('bash', ['-c', postCommand], {maxOutput: maxSize})); return this.handlePostProcessResult(result, await this.exec('bash', ['-c', postCommand], {maxOutput: maxSize}));
} }

View File

@@ -32,6 +32,7 @@ import _ from 'underscore';
import {CacheKey} from '../../types/compilation/compilation.interfaces.js'; import {CacheKey} from '../../types/compilation/compilation.interfaces.js';
import {CompilerInfo} from '../../types/compiler.interfaces.js'; import {CompilerInfo} from '../../types/compiler.interfaces.js';
import {CompilationEnvironment} from '../compilation-env.js';
import {logger} from '../logger.js'; import {logger} from '../logger.js';
import {VersionInfo} from '../options-handler.js'; import {VersionInfo} from '../options-handler.js';
@@ -67,14 +68,12 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase {
return 'ceconan'; return 'ceconan';
} }
constructor(compilerInfo: CompilerInfo, env) { constructor(compilerInfo: CompilerInfo, env: CompilationEnvironment) {
super(compilerInfo, env); super(compilerInfo, env);
this.host = compilerInfo.buildenvsetup!.props('host', ''); this.host = compilerInfo.buildenvsetup!.props('host', '');
this.onlyonstaticliblink = compilerInfo.buildenvsetup!.props('onlyonstaticliblink', ''); this.onlyonstaticliblink = compilerInfo.buildenvsetup!.props('onlyonstaticliblink', '');
this.extractAllToRoot = false; this.extractAllToRoot = false;
if (env.debug) request.debug = true;
} }
async getAllPossibleBuilds(libid: string, version: string) { async getAllPossibleBuilds(libid: string, version: string) {

View File

@@ -24,6 +24,7 @@
import _ from 'underscore'; import _ from 'underscore';
import {EdgeColor} from '../../../types/compilation/cfg.interfaces.js';
import type {ResultLineSource} from '../../../types/resultline/resultline.interfaces.js'; import type {ResultLineSource} from '../../../types/resultline/resultline.interfaces.js';
import {logger} from '../../logger.js'; import {logger} from '../../logger.js';
import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js'; import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js';
@@ -55,7 +56,7 @@ export type Edge = {
from: string; from: string;
to: string; to: string;
arrows: string; arrows: string;
color: string; color: EdgeColor;
}; };
export type AssemblyLine = { export type AssemblyLine = {
@@ -237,7 +238,7 @@ export class BaseCFGParser {
protected makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) { protected makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) {
const edges: Edge[] = []; const edges: Edge[] = [];
const setEdge = (sourceNode: string, targetNode: string, color: string) => ({ const setEdge = (sourceNode: string, targetNode: string, color: EdgeColor) => ({
from: sourceNode, from: sourceNode,
to: targetNode, to: targetNode,
arrows: 'to', arrows: 'to',

View File

@@ -24,6 +24,7 @@
import _ from 'underscore'; import _ from 'underscore';
import {EdgeColor} from '../../../types/compilation/cfg.interfaces.js';
import {logger} from '../../logger.js'; import {logger} from '../../logger.js';
import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js'; import {BaseInstructionSetInfo, InstructionType} from '../instruction-sets/base.js';
@@ -249,7 +250,7 @@ export class OatCFGParser extends BaseCFGParser {
override makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) { override makeEdges(asmArr: AssemblyLine[], arrOfCanonicalBasicBlock: CanonicalBB[]) {
const edges: Edge[] = []; const edges: Edge[] = [];
const setEdge = (sourceNode: string, targetNode: string, color: string) => ({ const setEdge = (sourceNode: string, targetNode: string, color: EdgeColor) => ({
from: sourceNode, from: sourceNode,
to: targetNode, to: targetNode,
arrows: 'to', arrows: 'to',

View File

@@ -24,6 +24,7 @@
import path from 'path'; import path from 'path';
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {BypassCache, CacheKey, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js'; import {BypassCache, CacheKey, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js';
import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js'; import {ExecutableExecutionOptions} from '../../types/execution/execution.interfaces.js';
@@ -114,10 +115,10 @@ export class CerberusCompiler extends BaseCompiler {
} }
} }
override async processAsm(result) { override async processAsm(result): Promise<ParsedAsmResult> {
// Handle "error" documents. // Handle "error" documents.
if (!result.asm.includes('\n') && result.asm[0] === '<') { if (!result.asm.includes('\n') && result.asm[0] === '<') {
return [{text: result.asm, source: null}]; return {asm: [{text: result.asm, source: null}]};
} }
const lines = result.asm.split('\n'); const lines = result.asm.split('\n');

View File

@@ -220,9 +220,9 @@ export class D8Compiler extends BaseCompiler implements SimpleOutputFilenameComp
} }
// Map line numbers to lines. // Map line numbers to lines.
override async processAsm(result) { override async processAsm(result): Promise<ParsedAsmResult> {
if (result.code !== 0) { if (result.code !== 0) {
return [{text: result.asm, source: null}]; return {asm: [{text: result.asm, source: null}]};
} }
const segments: ParsedAsmResultLine[] = []; const segments: ParsedAsmResultLine[] = [];
const asm = result.asm[0].text; const asm = result.asm[0].text;

View File

@@ -86,12 +86,12 @@ export class HookCompiler extends BaseCompiler {
const commentRegex = /^\s*;(.*)/; const commentRegex = /^\s*;(.*)/;
const instructionRegex = /^\s{2}(\d+)(.*)/; const instructionRegex = /^\s{2}(\d+)(.*)/;
const asm = _result.asm; const asm = _result.asm;
let lastLineNo: number | undefined; let lastLineNo: number | null = null;
for (const item of asm) { for (const item of asm) {
const text = item.text; const text = item.text;
if (commentRegex.test(text)) { if (commentRegex.test(text)) {
item.source = {line: undefined, file: null}; item.source = {line: null, file: null};
lastLineNo = undefined; lastLineNo = null;
continue; continue;
} }
const match = text.match(instructionRegex); const match = text.match(instructionRegex);
@@ -105,8 +105,8 @@ export class HookCompiler extends BaseCompiler {
item.source = {line: lastLineNo, file: null}; item.source = {line: lastLineNo, file: null};
continue; continue;
} }
item.source = {line: undefined, file: null}; item.source = {line: null, file: null};
lastLineNo = undefined; lastLineNo = null;
} }
_result.asm = asm; _result.asm = asm;
return _result; return _result;

View File

@@ -248,10 +248,10 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo
return this.filterUserOptionsWithArg(userOptions, oneArgForbiddenList); return this.filterUserOptionsWithArg(userOptions, oneArgForbiddenList);
} }
override async processAsm(result) { override async processAsm(result): Promise<ParsedAsmResult> {
// Handle "error" documents. // Handle "error" documents.
if (!result.asm.includes('\n') && result.asm[0] === '<') { if (!result.asm.includes('\n') && result.asm[0] === '<') {
return [{text: result.asm, source: null}]; return {asm: [{text: result.asm, source: null}]};
} }
// result.asm is an array of javap stdouts // result.asm is an array of javap stdouts

View File

@@ -23,7 +23,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import {isString} from '../shared/common-utils.js'; import {isString} from '../shared/common-utils.js';
import type {IRResultLine} from '../types/asmresult/asmresult.interfaces.js'; import type {IRResultLine, ParsedAsmResult} from '../types/asmresult/asmresult.interfaces.js';
import {LLVMIrBackendOptions} from '../types/compilation/ir.interfaces.js'; import {LLVMIrBackendOptions} from '../types/compilation/ir.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../types/features/filters.interfaces.js'; import {ParseFiltersAndOutputOptions} from '../types/features/filters.interfaces.js';
@@ -264,7 +264,7 @@ export class LlvmIrParser {
} }
} }
async processFromFilters(ir: string, filters: ParseFiltersAndOutputOptions) { async processFromFilters(ir: string, filters: ParseFiltersAndOutputOptions): Promise<ParsedAsmResult> {
if (isString(ir)) { if (isString(ir)) {
return await this.processIr(ir, { return await this.processIr(ir, {
filterDebugInfo: !!filters.debugCalls, filterDebugInfo: !!filters.debugCalls,

View File

@@ -56,6 +56,7 @@ export type VersionInfo = {
options: string[]; options: string[];
hidden: boolean; hidden: boolean;
packagedheaders?: boolean; packagedheaders?: boolean;
$order?: number;
}; };
export type OptionsHandlerLibrary = { export type OptionsHandlerLibrary = {
name: string; name: string;
@@ -439,7 +440,7 @@ export class ClientOptionsHandler {
'isSemVer', 'isSemVer',
]); ]);
const copiedCompilers = JSON.parse(JSON.stringify(compilers)) as CompilerInfo[]; const copiedCompilers = JSON.parse(JSON.stringify(compilers)) as CompilerInfo[];
const semverGroups: Record<string, any> = {}; const semverGroups: Record<string, Partial<CompilerInfo>[]> = {};
// Reset the supportsExecute flag in case critical compilers change // Reset the supportsExecute flag in case critical compilers change
for (const key of Object.keys(this.options.languages)) { for (const key of Object.keys(this.options.languages)) {
@@ -462,7 +463,7 @@ export class ClientOptionsHandler {
for (const propKey of Object.keys(compiler)) { for (const propKey of Object.keys(compiler)) {
if (forbiddenKeys.has(propKey)) { if (forbiddenKeys.has(propKey)) {
delete copiedCompilers[compilersKey][propKey]; delete copiedCompilers[compilersKey][propKey as keyof CompilerInfo];
} }
} }
} }

View File

@@ -22,6 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import * as utils from '../utils.js'; import * as utils from '../utils.js';
@@ -33,7 +34,7 @@ type Source = {file: string | null; line: number};
const lineRe = /^\s*#line\s+(?<line>\d+)\s+"(?<file>[^"]+)"/; const lineRe = /^\s*#line\s+(?<line>\d+)\s+"(?<file>[^"]+)"/;
export class AsmParserCpp implements IAsmParser { export class AsmParserCpp implements IAsmParser {
process(asmResult: string, filters: ParseFiltersAndOutputOptions) { process(asmResult: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult {
const startTime = process.hrtime.bigint(); const startTime = process.hrtime.bigint();
const asm: { const asm: {
@@ -69,7 +70,7 @@ export class AsmParserCpp implements IAsmParser {
const endTime = process.hrtime.bigint(); const endTime = process.hrtime.bigint();
return { return {
asm: asm, asm: asm,
labelDefinitions: [], labelDefinitions: {},
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(), parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
filteredCount: 0, filteredCount: 0,
}; };

View File

@@ -23,6 +23,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import {AsmResultLabel, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js'; import {AsmResultLabel, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import * as utils from '../utils.js'; import * as utils from '../utils.js';
import {AsmParser} from './asm-parser.js'; import {AsmParser} from './asm-parser.js';
@@ -84,7 +85,7 @@ export class SPIRVAsmParser extends AsmParser {
return labelsInLine; return labelsInLine;
} }
override processAsm(asmResult, filters) { override processAsm(asmResult, filters: ParseFiltersAndOutputOptions) {
const startTime = process.hrtime.bigint(); const startTime = process.hrtime.bigint();
const asm: ParsedAsmResultLine[] = []; const asm: ParsedAsmResultLine[] = [];

View File

@@ -1,5 +1,6 @@
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
export interface IAsmParser { export interface IAsmParser {
process(asm: string, filters: ParseFiltersAndOutputOptions); process(asm: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult;
} }

8
package-lock.json generated
View File

@@ -81,6 +81,7 @@
"@smithy/util-stream": "^3.1.9", "@smithy/util-stream": "^3.1.9",
"@types/body-parser": "^1.19.5", "@types/body-parser": "^1.19.5",
"@types/bootstrap": "^5.2.10", "@types/bootstrap": "^5.2.10",
"@types/chai": "^5.0.0",
"@types/compression": "^1.7.5", "@types/compression": "^1.7.5",
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/file-saver": "^2.0.7", "@types/file-saver": "^2.0.7",
@@ -4100,6 +4101,13 @@
"integrity": "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==", "integrity": "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==",
"dev": true "dev": true
}, },
"node_modules/@types/chai": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.0.0.tgz",
"integrity": "sha512-+DwhEHAaFPPdJ2ral3kNHFQXnTfscEEFsUxzD+d7nlcLrFK23JtNjH71RGasTcHb88b4vVi4mTyfpf8u2L8bdA==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/compression": { "node_modules/@types/compression": {
"version": "1.7.5", "version": "1.7.5",
"resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.5.tgz", "resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.5.tgz",

View File

@@ -90,6 +90,7 @@
"@smithy/util-stream": "^3.1.9", "@smithy/util-stream": "^3.1.9",
"@types/body-parser": "^1.19.5", "@types/body-parser": "^1.19.5",
"@types/bootstrap": "^5.2.10", "@types/bootstrap": "^5.2.10",
"@types/chai": "^5.0.0",
"@types/compression": "^1.7.5", "@types/compression": "^1.7.5",
"@types/express": "^4.17.21", "@types/express": "^4.17.21",
"@types/file-saver": "^2.0.7", "@types/file-saver": "^2.0.7",

View File

@@ -323,7 +323,7 @@ function tokenize(text: string, options: AnsiToHtmlOptions, callback: TokenizeCa
return ''; return '';
} }
function rgb(m) { function rgb(m: string) {
callback('rgb', m); callback('rgb', m);
return ''; return '';
} }

View File

@@ -67,7 +67,7 @@ function fail(fail_message: string, user_message: string | undefined, args: any[
} }
} }
export function assert<C>(c: C, message?: string, ...extra_info: any[]): asserts c { export function assert(c: unknown, message?: string, ...extra_info: any[]): asserts c {
if (!c) { if (!c) {
fail('Assertion failed', message, extra_info); fail('Assertion failed', message, extra_info);
} }

View File

@@ -38,6 +38,7 @@ import {CompilationResult, FiledataPair} from '../types/compilation/compilation.
import {CompilationStatus} from './compiler-service.interfaces.js'; import {CompilationStatus} from './compiler-service.interfaces.js';
import {IncludeDownloads, SourceAndFiles} from './download-service.js'; import {IncludeDownloads, SourceAndFiles} from './download-service.js';
import {SentryCapture} from './sentry.js'; import {SentryCapture} from './sentry.js';
import {SiteSettings} from './settings.js';
const ASCII_COLORS_RE = new RegExp(/\x1B\[[\d;]*m(.\[K)?/g); const ASCII_COLORS_RE = new RegExp(/\x1B\[[\d;]*m(.\[K)?/g);
@@ -61,7 +62,10 @@ export class CompilerService {
this.compilersByLang[compiler.lang][compiler.id] = compiler; this.compilersByLang[compiler.lang][compiler.id] = compiler;
} }
eventHub.on('settingsChange', newSettings => (this.allowStoreCodeDebug = newSettings.allowStoreCodeDebug)); eventHub.on(
'settingsChange',
(newSettings: SiteSettings) => (this.allowStoreCodeDebug = newSettings.allowStoreCodeDebug),
);
} }
private getDefaultCompilerForLang(langId: string) { private getDefaultCompilerForLang(langId: string) {

View File

@@ -28,7 +28,7 @@ import type {CompilerState} from './panes/compiler.interfaces.js';
import type {ExecutorState} from './panes/executor.interfaces.js'; import type {ExecutorState} from './panes/executor.interfaces.js';
export interface ICompilerShared { export interface ICompilerShared {
updateState(state: CompilerState | ExecutorState); updateState(state: CompilerState | ExecutorState): void;
getOverrides(): ConfiguredOverrides | undefined; getOverrides(): ConfiguredOverrides | undefined;
getRuntimeTools(): ConfiguredRuntimeTools | undefined; getRuntimeTools(): ConfiguredRuntimeTools | undefined;
} }

View File

@@ -186,8 +186,8 @@ export function getExecutorWith(
editorId: number, editorId: number,
lang: string, lang: string,
compilerId: string, compilerId: string,
libraries: unknown, libraries: {name: string; ver: string}[],
compilerArgs, compilerArgs: string | undefined,
treeId: number, treeId: number,
overrides?: ConfiguredOverrides, overrides?: ConfiguredOverrides,
runtimeTools?: ConfiguredRuntimeTools, runtimeTools?: ConfiguredRuntimeTools,

View File

@@ -40,7 +40,7 @@ export class IncludeDownloads {
private toDownload: FileToDownload[] = []; private toDownload: FileToDownload[] = [];
private downloadPromises: Promise<FileToDownload>[] = []; private downloadPromises: Promise<FileToDownload>[] = [];
private async doDownload(download): Promise<FileToDownload> { private async doDownload(download: FileToDownload): Promise<FileToDownload> {
try { try {
const response = await fetch(download.url); const response = await fetch(download.url);
if (response.status >= 400) { if (response.status >= 400) {
@@ -55,7 +55,7 @@ export class IncludeDownloads {
return download; return download;
} }
private async startDownload(download) { private async startDownload(download: FileToDownload) {
this.downloadPromises.push(this.doDownload(download)); this.downloadPromises.push(this.doDownload(download));
} }

View File

@@ -156,10 +156,10 @@ export type EventMap = {
// TODO: There are no emitters for this event // TODO: There are no emitters for this event
selectLine: (editorId: number, lineNumber: number) => void; selectLine: (editorId: number, lineNumber: number) => void;
settingsChange: (newSettings: SiteSettings) => void; settingsChange: (newSettings: SiteSettings) => void;
setToolInput: (compilerId: number, toolId: string, string: string) => void; setToolInput: (compilerId: number, toolId: string, value: string) => void;
shown: () => void; shown: () => void;
themeChange: (newTheme: Theme | null) => void; themeChange: (newTheme: Theme | null) => void;
toolClosed: (compilerId: number, toolState: unknown) => void; toolClosed: (compilerId: number, toolState: ToolState) => void;
toolInputChange: (compilerId: number, toolId: string, input: string) => void; toolInputChange: (compilerId: number, toolId: string, input: string) => void;
toolInputViewClosed: (compilerId: number, toolId: string, input: string) => void; toolInputViewClosed: (compilerId: number, toolId: string, input: string) => void;
toolInputViewCloseRequest: (compilerId: number, toolId: string) => void; toolInputViewCloseRequest: (compilerId: number, toolId: string) => void;

View File

@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import {AnnotatedCfgDescriptor, AnnotatedNodeDescriptor} from '../types/compilation/cfg.interfaces.js'; import {AnnotatedCfgDescriptor, AnnotatedNodeDescriptor, EdgeColor} from '../types/compilation/cfg.interfaces.js';
import IntervalTree from '@flatten-js/interval-tree'; import IntervalTree from '@flatten-js/interval-tree';
@@ -70,7 +70,7 @@ type EdgeSegment = {
}; };
type Edge = { type Edge = {
color: string; color: EdgeColor;
dest: number; dest: number;
mainColumn: number; mainColumn: number;
path: EdgeSegment[]; path: EdgeSegment[];
@@ -214,7 +214,7 @@ export class GraphLayoutCore {
return order.reverse(); return order.reverse();
} }
assignRows(topologicalOrder) { assignRows(topologicalOrder: number[]) {
for (const i of topologicalOrder) { for (const i of topologicalOrder) {
const block = this.blocks[i]; const block = this.blocks[i];
//console.log(block); //console.log(block);
@@ -225,7 +225,7 @@ export class GraphLayoutCore {
} }
} }
computeTree(topologicalOrder) { computeTree(topologicalOrder: number[]) {
// DAG is reduced to a tree based on what's vertically adjacent // DAG is reduced to a tree based on what's vertically adjacent
// //
// For something like // For something like
@@ -317,7 +317,7 @@ export class GraphLayoutCore {
} }
} }
assignColumns(topologicalOrder) { assignColumns(topologicalOrder: number[]) {
// Note: Currently not taking shape into account like Cutter does. // Note: Currently not taking shape into account like Cutter does.
// Post DFS order means we compute all children before their parents // Post DFS order means we compute all children before their parents
for (const i of topologicalOrder.slice().reverse()) { for (const i of topologicalOrder.slice().reverse()) {

View File

@@ -23,6 +23,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import GoldenLayout, {ContentItem} from 'golden-layout'; import GoldenLayout, {ContentItem} from 'golden-layout';
type GLC = GoldenLayout.Container;
import {CompilerService} from './compiler-service.js'; import {CompilerService} from './compiler-service.js';
import { import {
@@ -87,6 +88,7 @@ import {GnatDebugTree as GnatDebugTreeView} from './panes/gnatdebugtree-view.js'
import {RustMacroExp as RustMacroExpView} from './panes/rustmacroexp-view.js'; import {RustMacroExp as RustMacroExpView} from './panes/rustmacroexp-view.js';
import {IdentifierSet} from './identifier-set.js'; import {IdentifierSet} from './identifier-set.js';
import {EventMap} from './event-map.js'; import {EventMap} from './event-map.js';
import {LanguageKey} from './languages.interfaces.js';
type EventDescriptorMap = { type EventDescriptorMap = {
[E in keyof EventMap]: [E, ...Parameters<EventMap[E]>]; [E in keyof EventMap]: [E, ...Parameters<EventMap[E]>];
@@ -107,50 +109,60 @@ export class Hub {
public deferred = true; public deferred = true;
public deferredEmissions: EventDescriptor[] = []; public deferredEmissions: EventDescriptor[] = [];
public lastOpenedLangId: string | null; public lastOpenedLangId: LanguageKey | null;
public subdomainLangId: string | undefined; public subdomainLangId: string | undefined;
public defaultLangId: string; public defaultLangId: LanguageKey;
public constructor( public constructor(
public readonly layout: GoldenLayout, public readonly layout: GoldenLayout,
subLangId: string | undefined, subLangId: string | undefined,
defaultLangId: string, defaultLangId: LanguageKey,
) { ) {
this.lastOpenedLangId = null; this.lastOpenedLangId = null;
this.subdomainLangId = subLangId; this.subdomainLangId = subLangId;
this.defaultLangId = defaultLangId; this.defaultLangId = defaultLangId;
this.compilerService = new CompilerService(this.layout.eventHub); this.compilerService = new CompilerService(this.layout.eventHub);
layout.registerComponent(EDITOR_COMPONENT_NAME, (c, s) => this.codeEditorFactory(c, s)); layout.registerComponent(EDITOR_COMPONENT_NAME, (c: GLC, s: any) => this.codeEditorFactory(c, s));
layout.registerComponent(COMPILER_COMPONENT_NAME, (c, s) => this.compilerFactory(c, s)); layout.registerComponent(COMPILER_COMPONENT_NAME, (c: GLC, s: any) => this.compilerFactory(c, s));
layout.registerComponent(TREE_COMPONENT_NAME, (c, s) => this.treeFactory(c, s)); layout.registerComponent(TREE_COMPONENT_NAME, (c: GLC, s: any) => this.treeFactory(c, s));
layout.registerComponent(EXECUTOR_COMPONENT_NAME, (c, s) => this.executorFactory(c, s)); layout.registerComponent(EXECUTOR_COMPONENT_NAME, (c: GLC, s: any) => this.executorFactory(c, s));
layout.registerComponent(OUTPUT_COMPONENT_NAME, (c, s) => this.outputFactory(c, s)); layout.registerComponent(OUTPUT_COMPONENT_NAME, (c: GLC, s: any) => this.outputFactory(c, s));
layout.registerComponent(TOOL_COMPONENT_NAME, (c, s) => this.toolFactory(c, s)); layout.registerComponent(TOOL_COMPONENT_NAME, (c: GLC, s: any) => this.toolFactory(c, s));
layout.registerComponent(TOOL_INPUT_VIEW_COMPONENT_NAME, (c, s) => this.toolInputViewFactory(c, s)); layout.registerComponent(TOOL_INPUT_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.toolInputViewFactory(c, s));
layout.registerComponent(DIFF_VIEW_COMPONENT_NAME, (c, s) => this.diffFactory(c, s)); layout.registerComponent(DIFF_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.diffFactory(c, s));
layout.registerComponent(OPT_VIEW_COMPONENT_NAME, (c, s) => this.optViewFactory(c, s)); layout.registerComponent(OPT_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.optViewFactory(c, s));
layout.registerComponent(STACK_USAGE_VIEW_COMPONENT_NAME, (c, s) => this.stackUsageViewFactory(c, s)); layout.registerComponent(STACK_USAGE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.stackUsageViewFactory(c, s));
layout.registerComponent(FLAGS_VIEW_COMPONENT_NAME, (c, s) => this.flagsViewFactory(c, s)); layout.registerComponent(FLAGS_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.flagsViewFactory(c, s));
layout.registerComponent(PP_VIEW_COMPONENT_NAME, (c, s) => this.ppViewFactory(c, s)); layout.registerComponent(PP_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.ppViewFactory(c, s));
layout.registerComponent(AST_VIEW_COMPONENT_NAME, (c, s) => this.astViewFactory(c, s)); layout.registerComponent(AST_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.astViewFactory(c, s));
layout.registerComponent(IR_VIEW_COMPONENT_NAME, (c, s) => this.irViewFactory(c, s)); layout.registerComponent(IR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.irViewFactory(c, s));
layout.registerComponent(CLANGIR_VIEW_COMPONENT_NAME, (c, s) => this.clangirViewFactory(c, s)); layout.registerComponent(CLANGIR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.clangirViewFactory(c, s));
layout.registerComponent(OPT_PIPELINE_VIEW_COMPONENT_NAME, (c, s) => this.optPipelineFactory(c, s)); layout.registerComponent(OPT_PIPELINE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.optPipelineFactory(c, s));
// Historical LLVM-specific name preserved to keep old links working // Historical LLVM-specific name preserved to keep old links working
layout.registerComponent(LLVM_OPT_PIPELINE_VIEW_COMPONENT_NAME, (c, s) => this.optPipelineFactory(c, s)); layout.registerComponent(LLVM_OPT_PIPELINE_VIEW_COMPONENT_NAME, (c: GLC, s: any) =>
layout.registerComponent(DEVICE_VIEW_COMPONENT_NAME, (c, s) => this.deviceViewFactory(c, s)); this.optPipelineFactory(c, s),
layout.registerComponent(RUST_MIR_VIEW_COMPONENT_NAME, (c, s) => this.rustMirViewFactory(c, s)); );
layout.registerComponent(HASKELL_CORE_VIEW_COMPONENT_NAME, (c, s) => this.haskellCoreViewFactory(c, s)); layout.registerComponent(DEVICE_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.deviceViewFactory(c, s));
layout.registerComponent(HASKELL_STG_VIEW_COMPONENT_NAME, (c, s) => this.haskellStgViewFactory(c, s)); layout.registerComponent(RUST_MIR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.rustMirViewFactory(c, s));
layout.registerComponent(HASKELL_CMM_VIEW_COMPONENT_NAME, (c, s) => this.haskellCmmViewFactory(c, s)); layout.registerComponent(HASKELL_CORE_VIEW_COMPONENT_NAME, (c: GLC, s: any) =>
layout.registerComponent(GNAT_DEBUG_TREE_VIEW_COMPONENT_NAME, (c, s) => this.gnatDebugTreeViewFactory(c, s)); this.haskellCoreViewFactory(c, s),
layout.registerComponent(GNAT_DEBUG_VIEW_COMPONENT_NAME, (c, s) => this.gnatDebugViewFactory(c, s)); );
layout.registerComponent(RUST_MACRO_EXP_VIEW_COMPONENT_NAME, (c, s) => this.rustMacroExpViewFactory(c, s)); layout.registerComponent(HASKELL_STG_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.haskellStgViewFactory(c, s));
layout.registerComponent(RUST_HIR_VIEW_COMPONENT_NAME, (c, s) => this.rustHirViewFactory(c, s)); layout.registerComponent(HASKELL_CMM_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.haskellCmmViewFactory(c, s));
layout.registerComponent(GCC_DUMP_VIEW_COMPONENT_NAME, (c, s) => this.gccDumpViewFactory(c, s)); layout.registerComponent(GNAT_DEBUG_TREE_VIEW_COMPONENT_NAME, (c: GLC, s: any) =>
layout.registerComponent(CFG_VIEW_COMPONENT_NAME, (c, s) => this.cfgViewFactory(c, s)); this.gnatDebugTreeViewFactory(c, s),
layout.registerComponent(CONFORMANCE_VIEW_COMPONENT_NAME, (c, s) => this.conformanceViewFactory(c, s)); );
layout.registerComponent(GNAT_DEBUG_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.gnatDebugViewFactory(c, s));
layout.registerComponent(RUST_MACRO_EXP_VIEW_COMPONENT_NAME, (c: GLC, s: any) =>
this.rustMacroExpViewFactory(c, s),
);
layout.registerComponent(RUST_HIR_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.rustHirViewFactory(c, s));
layout.registerComponent(GCC_DUMP_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.gccDumpViewFactory(c, s));
layout.registerComponent(CFG_VIEW_COMPONENT_NAME, (c: GLC, s: any) => this.cfgViewFactory(c, s));
layout.registerComponent(CONFORMANCE_VIEW_COMPONENT_NAME, (c: GLC, s: any) =>
this.conformanceViewFactory(c, s),
);
layout.eventHub.on( layout.eventHub.on(
'editorOpen', 'editorOpen',
@@ -210,7 +222,7 @@ export class Hub {
); );
layout.eventHub.on( layout.eventHub.on(
'languageChange', 'languageChange',
function (this: Hub, editorId: number, langId: string) { function (this: Hub, editorId: number, langId: LanguageKey) {
this.lastOpenedLangId = langId; this.lastOpenedLangId = langId;
}, },
this, this,
@@ -385,7 +397,7 @@ export class Hub {
} }
} }
public activateTabForContainer(container?: GoldenLayout.Container) { public activateTabForContainer(container?: GLC) {
if (container && (container.tab as typeof container.tab | null)) { if (container && (container.tab as typeof container.tab | null)) {
container.tab.header.parent.setActiveContentItem(container.tab.contentItem); container.tab.header.parent.setActiveContentItem(container.tab.contentItem);
} }

View File

@@ -24,6 +24,7 @@
import {options} from './options.js'; import {options} from './options.js';
import {LanguageLibs, Library} from './options.interfaces.js'; import {LanguageLibs, Library} from './options.interfaces.js';
import {Remote} from './compiler.interfaces.js';
const LIB_MATCH_RE = /([\w-]*)\.([\w-]*)/i; const LIB_MATCH_RE = /([\w-]*)\.([\w-]*)/i;
@@ -68,7 +69,7 @@ function copyAndFilterLibraries(allLibraries: LanguageLibs, filter: string[]) {
export function getSupportedLibraries( export function getSupportedLibraries(
supportedLibrariesArr: string[] | undefined, supportedLibrariesArr: string[] | undefined,
langId: string, langId: string,
remote, remote?: Remote,
): LanguageLibs { ): LanguageLibs {
if (!remote) { if (!remote) {
const allLibs = options.libs[langId]; const allLibs = options.libs[langId];

View File

@@ -24,6 +24,7 @@
import _ from 'underscore'; import _ from 'underscore';
import {MultifileService} from './multifile-service.js'; import {MultifileService} from './multifile-service.js';
import {ResultLine} from './resultline/resultline.interfaces.js';
interface ColouredSourcelineInfo { interface ColouredSourcelineInfo {
sourceLine: number; sourceLine: number;
@@ -50,7 +51,7 @@ export class LineColouring {
this.linesAndColourByEditor = {}; this.linesAndColourByEditor = {};
} }
public addFromAssembly(compilerId, asm) { public addFromAssembly(compilerId: number, asm: ResultLine[]) {
let asmLineIdx = 0; let asmLineIdx = 0;
for (const asmLine of asm) { for (const asmLine of asm) {
if (asmLine.source && asmLine.source.line > 0) { if (asmLine.source && asmLine.source.line > 0) {

View File

@@ -31,7 +31,7 @@ export interface Storage {
set(key: string, value: string): boolean; set(key: string, value: string): boolean;
remove(key: string); remove(key: string): void;
} }
class LocalOnlyStorage implements Storage { class LocalOnlyStorage implements Storage {

View File

@@ -23,6 +23,8 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
function definition(): monaco.languages.IMonarchLanguage { function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
import * as cppp from './cppp-mode.js'; import * as cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
import * as cppp from './cppp-mode.js'; import * as cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
import * as cppp from './cppp-mode.js'; import * as cppp from './cppp-mode.js';
@@ -52,7 +54,7 @@ function definition(): monaco.languages.IMonarchLanguage {
// Generic parsers. // Generic parsers.
function parseCpp2Balanced(delimiters, delimiter, opener, closer) { function parseCpp2Balanced(delimiters: string, delimiter: string, opener: RegExp, closer: RegExp) {
return (cppfront.tokenizer['parse_cpp2_balanced_' + delimiters] = [ return (cppfront.tokenizer['parse_cpp2_balanced_' + delimiters] = [
{include: '@whitespace'}, {include: '@whitespace'},
[opener, 'delimiter.' + delimiter, '$S2.$S3.$S4'], [opener, 'delimiter.' + delimiter, '$S2.$S3.$S4'],
@@ -91,7 +93,14 @@ function definition(): monaco.languages.IMonarchLanguage {
} }
function setupLiteralParsers() { function setupLiteralParsers() {
cppfront.at_cpp2_interpolation = /\([^"]+\)\$/; function balancedParenthesesRegex(max_nesting: number) {
const front = String.raw`\((?:[^\\()]*|`;
const back = String.raw`)*\)`;
return front.repeat(max_nesting + 1) + back.repeat(max_nesting + 1);
}
cppfront.at_cpp2_balanced_parentheses = balancedParenthesesRegex(5);
cppfront.at_cpp2_interpolation = /@at_cpp2_balanced_parentheses\$/;
cppfront.tokenizer.parse_cpp2_interpolation = [ cppfront.tokenizer.parse_cpp2_interpolation = [
[/(\()(.)/, ['delimiter.parenthesis', {token: '@rematch', next: 'parse_cpp2_expression'}]], [/(\()(.)/, ['delimiter.parenthesis', {token: '@rematch', next: 'parse_cpp2_expression'}]],
[/:[^)]*/, 'string'], [/:[^)]*/, 'string'],
@@ -107,7 +116,7 @@ function definition(): monaco.languages.IMonarchLanguage {
[/@encoding?"/, {token: 'string', switchTo: '@string..cpp2'}], [/@encoding?"/, {token: 'string', switchTo: '@string..cpp2'}],
]; ];
function parseCpp2Interpolation(state, prefix_token_regex, token_class) { function parseCpp2Interpolation(state: string, prefix_token_regex: RegExp, token_class: string) {
cppfront.tokenizer[state].unshift([ cppfront.tokenizer[state].unshift([
prefix_token_regex.source + /(@at_cpp2_interpolation)/.source, prefix_token_regex.source + /(@at_cpp2_interpolation)/.source,
{ {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
// We need to create a new definition for cpp so we can remove invalid keywords // We need to create a new definition for cpp so we can remove invalid keywords

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
import * as cppp from './cppp-mode.js'; import * as cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
import * as cppp from './cppp-mode.js'; import * as cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
function definition(): monaco.languages.IMonarchLanguage { function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
function definition(): monaco.languages.IMonarchLanguage { function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -23,6 +23,8 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as swift from 'monaco-editor/esm/vs/basic-languages/swift/swift'; import * as swift from 'monaco-editor/esm/vs/basic-languages/swift/swift';
function definition(): monaco.languages.IMonarchLanguage { function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
function definition(): monaco.languages.IMonarchLanguage { function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
// We need to ensure we use proper keywords for the Monaco Editor matcher. Note how // We need to ensure we use proper keywords for the Monaco Editor matcher. Note how

View File

@@ -25,6 +25,8 @@
import $ from 'jquery'; import $ from 'jquery';
import * as monaco from 'monaco-editor'; import * as monaco from 'monaco-editor';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp'; import * as cpp from 'monaco-editor/esm/vs/basic-languages/cpp/cpp';
import * as nc from './nc-mode.js'; import * as nc from './nc-mode.js';

View File

@@ -332,7 +332,7 @@ export class MultifileService {
}); });
} }
public getEditorIdByFilename(filename: string): number | null { public getEditorIdByFilename(filename: string | null): number | null {
const file = this.files.find((file: MultifileFile) => { const file = this.files.find((file: MultifileFile) => {
return file.isIncluded && file.filename === filename; return file.isIncluded && file.filename === filename;
}); });

View File

@@ -64,7 +64,7 @@ export type Options = {
release?: string; release?: string;
sentryEnvironment?: string; sentryEnvironment?: string;
compileOptions: Record<LanguageKey, string>; compileOptions: Record<LanguageKey, string>;
tools: Partial<Record<LanguageKey, Record<string, Tool>>>; tools: Record<LanguageKey, Record<string, Tool>>;
slides?: any[]; slides?: any[];
cookieDomainRe: string; cookieDomainRe: string;
motdUrl: string; motdUrl: string;

View File

@@ -35,7 +35,7 @@ window.staticRoot = unwrap(configElement.getAttribute('staticRoot'));
const extraOptions: object = JSON.parse(decodeURIComponent(configElement.getAttribute('extraOptions') ?? '"%7B%7D"')); // Encoded {} const extraOptions: object = JSON.parse(decodeURIComponent(configElement.getAttribute('extraOptions') ?? '"%7B%7D"')); // Encoded {}
for (const key in extraOptions) { for (const key in extraOptions) {
window.compilerExplorerOptions[key] = extraOptions[key]; window.compilerExplorerOptions[key] = extraOptions[key as keyof typeof extraOptions];
} }
declare let __webpack_public_path__: string; declare let __webpack_public_path__: string;

View File

@@ -36,6 +36,7 @@ import * as monacoConfig from '../monaco-config.js';
import {Hub} from '../hub.js'; import {Hub} from '../hub.js';
import {unwrap} from '../assert.js'; import {unwrap} from '../assert.js';
import {CompilerInfo} from '../compiler.interfaces.js'; import {CompilerInfo} from '../compiler.interfaces.js';
import {CompilationResult} from '../compilation/compilation.interfaces.js';
type DecorationEntry = { type DecorationEntry = {
linkedCode: any[]; linkedCode: any[];
@@ -168,7 +169,7 @@ export class Ast extends MonacoPane<monaco.editor.IStandaloneCodeEditor, AstStat
return this.editor.getModel()?.getLanguageId(); return this.editor.getModel()?.getLanguageId();
} }
override onCompileResult(id: number, compiler, result) { override onCompileResult(id: number, compiler: CompilerInfo, result: CompilationResult) {
if (this.compilerInfo.compilerId !== id) return; if (this.compilerInfo.compilerId !== id) return;
if (result.astOutput) { if (result.astOutput) {
@@ -229,7 +230,7 @@ export class Ast extends MonacoPane<monaco.editor.IStandaloneCodeEditor, AstStat
tryApplyAstColours(): void { tryApplyAstColours(): void {
if (!this.srcColours || !this.colourScheme || !this.astCode || this.astCode.length === 0) return; if (!this.srcColours || !this.colourScheme || !this.astCode || this.astCode.length === 0) return;
const astColours = {}; const astColours: Record<number, number> = {};
for (const [index, code] of this.astCode.entries()) { for (const [index, code] of this.astCode.entries()) {
if ( if (
code.source && code.source &&

View File

@@ -176,7 +176,7 @@ export class Cfg extends Pane<CfgState> {
dropdownParent: 'body', dropdownParent: 'body',
plugins: ['dropdown_input'], plugins: ['dropdown_input'],
sortField: 'title', sortField: 'title',
onChange: e => this.selectFunction(e as unknown as string), onChange: (e: string) => this.selectFunction(e),
}); });
this.functionSelector.on('dropdown_close', () => { this.functionSelector.on('dropdown_close', () => {
// scroll back to the selection on the next open // scroll back to the selection on the next open

View File

@@ -69,7 +69,10 @@ export class Clangir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Cla
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('clangirViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('clangirViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -2692,8 +2692,8 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
if (!this.compiler) return; if (!this.compiler) return;
const addTool = (toolName: string, title: string, toolIcon?, toolIconDark?) => { const addTool = (toolName: string, title: string, toolIcon?: string, toolIconDark?: string) => {
const btn = $("<button class='dropdown-item btn btn-light btn-sm new-pane-button'>"); const btn = $("<button class='dropdown-item btn btn-light btn-sm'>");
btn.addClass('view-' + toolName); btn.addClass('view-' + toolName);
btn.data('toolname', toolName); btn.data('toolname', toolName);
if (toolIcon) { if (toolIcon) {
@@ -2753,7 +2753,10 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
const filters = this.getEffectiveFilters(); const filters = this.getEffectiveFilters();
// We can support intel output if the compiler supports it, or if we're compiling // We can support intel output if the compiler supports it, or if we're compiling
// to binary (as we can disassemble it however we like). // to binary (as we can disassemble it however we like).
const formatFilterTitle = (button, title) => { const formatFilterTitle = (
button: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>,
title: JQuery<HTMLElement>,
) => {
button.prop( button.prop(
'title', 'title',
'[' + '[' +

View File

@@ -362,7 +362,7 @@ export class DeviceAsm extends MonacoPane<monaco.editor.IStandaloneCodeEditor, D
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (id === this.compilerInfo.compilerId && this.deviceCode) { if (id === this.compilerInfo.compilerId && this.deviceCode) {
const irColours = {}; const irColours: Record<number, number> = {};
this.deviceCode.forEach((x: ResultLine, index: number) => { this.deviceCode.forEach((x: ResultLine, index: number) => {
if (x.source && x.source.file == null && x.source.line > 0 && colours[x.source.line - 1]) { if (x.source && x.source.file == null && x.source.line > 0 && colours[x.source.line - 1]) {
irColours[index] = colours[x.source.line - 1]; irColours[index] = colours[x.source.line - 1];

View File

@@ -90,9 +90,9 @@ class DiffStateObject {
this.extraoption = extraoption; this.extraoption = extraoption;
} }
update(id: number | string, compiler, result: CompilationResult) { update(id: number | string, compiler: CompilerInfo, result: CompilationResult) {
if (this.id !== id) return false; if (this.id !== id) return false;
this.compiler = compiler; this.compiler!.compiler = compiler;
this.result = result; this.result = result;
this.refresh(); this.refresh();
@@ -320,7 +320,7 @@ export class Diff extends MonacoPane<monaco.editor.IStandaloneDiffEditor, DiffSt
this.updateCompilers(); this.updateCompilers();
} }
getDiffableOptions(picker?, extraoptions?: DiffOption[]): any[] { getDiffableOptions(picker?: HTMLSelectElement | TomSelect, extraoptions?: DiffOption[]): any[] {
const options: DiffOption[] = [ const options: DiffOption[] = [
{id: DiffType.ASM.toString(), name: 'Assembly'}, {id: DiffType.ASM.toString(), name: 'Assembly'},
{id: DiffType.CompilerStdOut.toString(), name: 'Compiler stdout'}, {id: DiffType.CompilerStdOut.toString(), name: 'Compiler stdout'},

View File

@@ -22,7 +22,7 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
import {Language} from '../../types/languages.interfaces.js'; import {Language, LanguageKey} from '../../types/languages.interfaces.js';
export type EditorState = { export type EditorState = {
filename?: string; filename?: string;
@@ -30,7 +30,7 @@ export type EditorState = {
readOnly?: boolean; readOnly?: boolean;
}; };
source?: string; source?: string;
lang: string; lang: LanguageKey;
}; };
export type LanguageSelectData = Language & { export type LanguageSelectData = Language & {

View File

@@ -81,7 +81,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
private filename: string | false; private filename: string | false;
private awaitingInitialResults: boolean; private awaitingInitialResults: boolean;
private revealJumpStack: editor.ICodeEditorViewState[]; private revealJumpStack: editor.ICodeEditorViewState[];
private langKeys: string[]; private langKeys: LanguageKey[];
private legacyReadOnly?: boolean; private legacyReadOnly?: boolean;
private selectize?: TomSelect; private selectize?: TomSelect;
private lastChangeEmitted: string | null; private lastChangeEmitted: string | null;
@@ -316,13 +316,13 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
this.waitingForLanguage = Boolean(state.source && !state.lang); this.waitingForLanguage = Boolean(state.source && !state.lang);
if (this.settings.defaultLanguage && this.settings.defaultLanguage in languages) { if (this.settings.defaultLanguage && this.settings.defaultLanguage in languages) {
newLanguage = languages[this.settings.defaultLanguage]; newLanguage = languages[this.settings.defaultLanguage];
} else if (this.hub.defaultLangId && this.hub.defaultLangId in languages) { } else if (this.hub.defaultLangId in languages) {
// the first time the user visits the site (or particular domain), this.settings might not be set yet // the first time the user visits the site (or particular domain), this.settings might not be set yet
// use the hub's default lang if possible // use the hub's default lang if possible
newLanguage = languages[this.hub.defaultLangId]; newLanguage = languages[this.hub.defaultLangId];
} }
if (state.lang && state.lang in languages) { if (state.lang in languages) {
newLanguage = languages[state.lang]; newLanguage = languages[state.lang];
} else if ( } else if (
this.settings.newEditorLastLang && this.settings.newEditorLastLang &&
@@ -498,7 +498,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
super.initializeGlobalDependentProperties(); super.initializeGlobalDependentProperties();
this.httpRoot = window.httpRoot; this.httpRoot = window.httpRoot;
this.langKeys = Object.keys(languages); this.langKeys = Object.keys(languages) as LanguageKey[];
} }
override initializeStateDependentProperties(state: MonacoPaneState & EditorState): void { override initializeStateDependentProperties(state: MonacoPaneState & EditorState): void {
@@ -598,7 +598,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
return Components.getEditor(this.settings.defaultLanguage as any); return Components.getEditor(this.settings.defaultLanguage as any);
}; };
const addPaneOpener = (dragSource, dragConfig) => { const addPaneOpener = (dragSource: JQuery<HTMLElement>, dragConfig) => {
this.container.layoutManager this.container.layoutManager
.createDragSource(dragSource, dragConfig) .createDragSource(dragSource, dragConfig)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
@@ -1523,7 +1523,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
if (obj.tag.link) { if (obj.tag.link) {
link = { link = {
value: obj.tag.link.text, value: obj.tag.link.text,
target: obj.tag.link.url, target: obj.tag.link.url as unknown as monaco.Uri,
}; };
} }

View File

@@ -882,7 +882,7 @@ export class Executor extends Pane<ExecutorState> {
LibUtils.getSupportedLibraries( LibUtils.getSupportedLibraries(
this.compiler ? this.compiler.libsArr : [], this.compiler ? this.compiler.libsArr : [],
this.currentLangId, this.currentLangId,
this.compiler?.remote ?? null, this.compiler?.remote ?? undefined,
), ),
); );
} }
@@ -1248,7 +1248,7 @@ export class Executor extends Pane<ExecutorState> {
filteredLibraries = LibUtils.getSupportedLibraries( filteredLibraries = LibUtils.getSupportedLibraries(
this.compiler.libsArr, this.compiler.libsArr,
this.currentLangId || '', this.currentLangId || '',
this.compiler.remote ?? null, this.compiler.remote ?? undefined,
); );
} }

View File

@@ -157,7 +157,7 @@ export class Flags extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Flags
return state as MonacoPaneState; return state as MonacoPaneState;
} }
maybeEmitChange(force) { maybeEmitChange(force: boolean) {
const options = this.getOptions(); const options = this.getOptions();
if (!force && options === this.lastChangeEmitted) return; if (!force && options === this.lastChangeEmitted) return;

View File

@@ -97,8 +97,8 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
if (match) { if (match) {
const selectedPassO: GccDumpViewSelectedPass = { const selectedPassO: GccDumpViewSelectedPass = {
filename_suffix: match[1] + '.' + match[2], filename_suffix: match[1] + '.' + match[2],
name: match[2] + ' (' + passType[match[1]] + ')', name: match[2] + ' (' + passType[match[1] as keyof typeof passType] + ')',
command_prefix: '-fdump-' + passType[match[1]] + '-' + match[2], command_prefix: '-fdump-' + passType[match[1] as keyof typeof passType] + '-' + match[2],
// FIXME(dkm): maybe this could be avoided by better typing. // FIXME(dkm): maybe this could be avoided by better typing.
selectedPass: null, selectedPass: null,
@@ -256,7 +256,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
} }
updateButtons() { updateButtons() {
const formatButtonTitle = (button, title) => const formatButtonTitle = (button: JQuery<HTMLElement>, title: string) =>
button.prop('title', '[' + (button.hasClass('active') ? 'ON' : 'OFF') + '] ' + title); button.prop('title', '[' + (button.hasClass('active') ? 'ON' : 'OFF') + '] ' + title);
formatButtonTitle(this.dumpTreesButton, this.dumpTreesTitle); formatButtonTitle(this.dumpTreesButton, this.dumpTreesTitle);
formatButtonTitle(this.dumpRtlButton, this.dumpRtlTitle); formatButtonTitle(this.dumpRtlButton, this.dumpRtlTitle);
@@ -310,7 +310,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
// Called after result from new compilation received // Called after result from new compilation received
// if gccDumpOutput is false, cleans the select menu // if gccDumpOutput is false, cleans the select menu
updatePass(filters, selectize, gccDumpOutput) { updatePass(filters: Toggles, selectize: TomSelect, gccDumpOutput) {
const passes = gccDumpOutput ? gccDumpOutput.all : []; const passes = gccDumpOutput ? gccDumpOutput.all : [];
// we are changing selectize but don't want any callback to // we are changing selectize but don't want any callback to
@@ -323,10 +323,10 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
selectize.addOption(p); selectize.addOption(p);
} }
if (gccDumpOutput.selectedPass) selectize.addItem(gccDumpOutput.selectedPass.name, true); if (gccDumpOutput && gccDumpOutput.selectedPass) {
else selectize.clear(true); selectize.addItem(gccDumpOutput.selectedPass.name, true);
this.eventHub.emit('gccDumpPassSelected', this.compilerInfo.compilerId, gccDumpOutput.selectedPass, false);
this.eventHub.emit('gccDumpPassSelected', this.compilerInfo.compilerId, gccDumpOutput.selectedPass, false); } else selectize.clear(true);
this.inhibitPassSelect = false; this.inhibitPassSelect = false;
} }
@@ -362,7 +362,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
} else { } else {
this.selectize.clear(true); this.selectize.clear(true);
this.selectedPass = null; this.selectedPass = null;
this.updatePass(this.filters, this.selectize, false); this.updatePass(this.filters, this.selectize, null);
this.uiIsReady = false; this.uiIsReady = false;
this.onUiNotReady(); this.onUiNotReady();
if (!compiler.supportsGccDump) { if (!compiler.supportsGccDump) {
@@ -374,7 +374,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
this.updateState(); this.updateState();
} }
showGccDumpResults(results) { showGccDumpResults(results: string) {
this.editor.setValue(results); this.editor.setValue(results);
if (!this.isAwaitingInitialResults) { if (!this.isAwaitingInitialResults) {
@@ -386,7 +386,13 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
} }
} }
override onCompiler(compilerId: number, compiler, options: unknown, editorId: number, treeId: number) { override onCompiler(
compilerId: number,
compiler: CompilerInfo | null,
options: unknown,
editorId: number,
treeId: number,
) {
if (compilerId === this.compilerInfo.compilerId) { if (compilerId === this.compilerInfo.compilerId) {
this.compilerInfo.compilerName = compiler ? compiler.name : ''; this.compilerInfo.compilerName = compiler ? compiler.name : '';
this.compilerInfo.editorId = editorId; this.compilerInfo.editorId = editorId;
@@ -397,12 +403,12 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
} }
} }
override onCompilerClose(id) { override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) { if (id === this.compilerInfo.compilerId) {
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
// the hierarchy. We can't modify while it's being iterated over. // the hierarchy. We can't modify while it's being iterated over.
this.close(); this.close();
_.defer(function (self) { _.defer(function (self: GccDump) {
self.container.close(); self.container.close();
}, this); }, this);
} }

View File

@@ -70,7 +70,10 @@ export class GnatDebug extends MonacoPane<monaco.editor.IStandaloneCodeEditor, G
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('gnatDebugViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('gnatDebugViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -70,7 +70,10 @@ export class GnatDebugTree extends MonacoPane<monaco.editor.IStandaloneCodeEdito
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('gnatDebugTreeViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('gnatDebugTreeViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class HaskellCmm extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('haskellCmmViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('haskellCmmViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class HaskellCore extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('haskellCoreViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('haskellCoreViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class HaskellStg extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('haskellStgViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('haskellStgViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -312,8 +312,9 @@ export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState>
}; };
let changed = false; let changed = false;
for (const k in newOptions) { for (const k in newOptions) {
if (newOptions[k] !== this.lastOptions[k]) { if (newOptions[k as keyof LLVMIrBackendOptions] !== this.lastOptions[k as keyof LLVMIrBackendOptions]) {
changed = true; changed = true;
break;
} }
} }
this.lastOptions = newOptions; this.lastOptions = newOptions;

View File

@@ -120,7 +120,7 @@ export class OptPipeline extends MonacoPane<monaco.editor.IStandaloneDiffEditor,
plugins: ['input_autogrow'], plugins: ['input_autogrow'],
sortField: 'title', sortField: 'title',
maxOptions: 1000, maxOptions: 1000,
onChange: e => this.selectGroup(e as string), onChange: (e: string) => this.selectGroup(e),
}); });
this.groupSelector.on('dropdown_close', () => { this.groupSelector.on('dropdown_close', () => {
// scroll back to the selection on the next open // scroll back to the selection on the next open
@@ -289,7 +289,8 @@ export class OptPipeline extends MonacoPane<monaco.editor.IStandaloneDiffEditor,
}; };
let changed = false; let changed = false;
for (const k in newOptions) { for (const k in newOptions) {
if (newOptions[k] !== this.lastOptions[k]) { const key = k as keyof OptPipelineBackendOptions;
if (newOptions[key] !== this.lastOptions[key]) {
changed = true; changed = true;
} }
} }

View File

@@ -37,7 +37,7 @@ import {CompilationResult} from '../../types/compilation/compilation.interfaces.
import {CompilerInfo} from '../../types/compiler.interfaces.js'; import {CompilerInfo} from '../../types/compiler.interfaces.js';
import {escapeHTML} from '../../shared/common-utils.js'; import {escapeHTML} from '../../shared/common-utils.js';
function makeAnsiToHtml(color?) { function makeAnsiToHtml(color?: string) {
return new AnsiToHtml.Filter({ return new AnsiToHtml.Filter({
fg: color ? color : '#333', fg: color ? color : '#333',
bg: '#f5f5f5', bg: '#f5f5f5',
@@ -251,7 +251,7 @@ export class Output extends Pane<OutputState> {
if (color) elem.css('color', color); if (color) elem.css('color', color);
} }
getEditorIdByFilename(filename) { getEditorIdByFilename(filename: string) {
if (this.compilerInfo.treeId) { if (this.compilerInfo.treeId) {
const tree = this.hub.getTreeById(this.compilerInfo.treeId); const tree = this.hub.getTreeById(this.compilerInfo.treeId);
if (tree) { if (tree) {
@@ -261,7 +261,7 @@ export class Output extends Pane<OutputState> {
} }
} }
emitEditorLinkLine(lineNum, column, filename, goto) { emitEditorLinkLine(lineNum: number, column: number, filename: string, goto: boolean) {
if (this.compilerInfo.editorId) { if (this.compilerInfo.editorId) {
this.eventHub.emit('editorLinkLine', this.compilerInfo.editorId, lineNum, column, column + 1, goto); this.eventHub.emit('editorLinkLine', this.compilerInfo.editorId, lineNum, column, column + 1, goto);
} else if (filename) { } else if (filename) {
@@ -274,7 +274,7 @@ export class Output extends Pane<OutputState> {
add(msg: string, lineNum?: number, column?: number, filename?: string) { add(msg: string, lineNum?: number, column?: number, filename?: string) {
const elem = $('<div/>').appendTo(this.contentRoot); const elem = $('<div/>').appendTo(this.contentRoot);
if (lineNum) { if (lineNum && column && filename) {
elem.empty(); elem.empty();
$('<span class="linked-compiler-output-line"></span>') $('<span class="linked-compiler-output-line"></span>')
.html(msg) .html(msg)
@@ -302,7 +302,7 @@ export class Output extends Pane<OutputState> {
return `(Compiler #${this.compilerInfo.compilerId})`; return `(Compiler #${this.compilerInfo.compilerId})`;
} }
override onCompilerClose(id) { override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) { if (id === this.compilerInfo.compilerId) {
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
// the hierarchy. We can't modify while it's being iterated over. // the hierarchy. We can't modify while it's being iterated over.
@@ -320,7 +320,7 @@ export class Output extends Pane<OutputState> {
$(document).off('keydown', this.keydownCallback); $(document).off('keydown', this.keydownCallback);
} }
setCompileStatus(isCompiling) { setCompileStatus(isCompiling: boolean) {
this.contentRoot.toggleClass('compiling', isCompiling); this.contentRoot.toggleClass('compiling', isCompiling);
} }

View File

@@ -33,7 +33,7 @@ import {Container} from 'golden-layout';
import {MonacoPaneState} from './pane.interfaces.js'; import {MonacoPaneState} from './pane.interfaces.js';
import {Hub} from '../hub.js'; import {Hub} from '../hub.js';
import {unwrap} from '../assert.js'; import {unwrap} from '../assert.js';
import {CompilationResult} from '../compilation/compilation.interfaces.js'; import {CompilationResult, PPOutput} from '../compilation/compilation.interfaces.js';
import {CompilerInfo} from '../compiler.interfaces.js'; import {CompilerInfo} from '../compiler.interfaces.js';
export class PP extends MonacoPane<monaco.editor.IStandaloneCodeEditor, PPViewState> { export class PP extends MonacoPane<monaco.editor.IStandaloneCodeEditor, PPViewState> {
@@ -129,7 +129,7 @@ export class PP extends MonacoPane<monaco.editor.IStandaloneCodeEditor, PPViewSt
return this.editor.getModel()?.getLanguageId(); return this.editor.getModel()?.getLanguageId();
} }
showPpResults(results) { showPpResults(results: PPOutput | string) {
if (typeof results === 'object') { if (typeof results === 'object') {
if (results.numberOfLinesFiltered > 0) { if (results.numberOfLinesFiltered > 0) {
this.editor.setValue( this.editor.setValue(
@@ -180,12 +180,12 @@ export class PP extends MonacoPane<monaco.editor.IStandaloneCodeEditor, PPViewSt
return state; return state;
} }
override onCompilerClose(id) { override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) { if (id === this.compilerInfo.compilerId) {
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
// the hierarchy. We can't modify while it's being iterated over. // the hierarchy. We can't modify while it's being iterated over.
this.close(); this.close();
_.defer(function (self) { _.defer(function (self: PP) {
self.container.close(); self.container.close();
}, this); }, this);
} }

View File

@@ -69,7 +69,10 @@ export class RustHir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Rus
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('rustHirViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('rustHirViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class RustMacroExp extends MonacoPane<monaco.editor.IStandaloneCodeEditor
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('rustMacroExpViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('rustMacroExpViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class RustMir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Rus
} }
override registerCallbacks(): void { override registerCallbacks(): void {
const throttleFunction = _.throttle(event => this.onDidChangeCursorSelection(event), 500); const throttleFunction = _.throttle(
(event: monaco.editor.ICursorSelectionChangedEvent) => this.onDidChangeCursorSelection(event),
500,
);
this.editor.onDidChangeCursorSelection(event => throttleFunction(event)); this.editor.onDidChangeCursorSelection(event => throttleFunction(event));
this.eventHub.emit('rustMirViewOpened', this.compilerInfo.compilerId); this.eventHub.emit('rustMirViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings'); this.eventHub.emit('requestSettings');

View File

@@ -179,7 +179,7 @@ export class StackUsage extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
this.editorDecorations.set(suDecorations); this.editorDecorations.set(suDecorations);
} }
override onCompiler(id: number, compiler) { override onCompiler(id: number, compiler: CompilerInfo | null) {
if (id === this.compilerInfo.compilerId) { if (id === this.compilerInfo.compilerId) {
this.compilerInfo.compilerName = compiler ? compiler.name : ''; this.compilerInfo.compilerName = compiler ? compiler.name : '';
this.updateTitle(); this.updateTitle();

View File

@@ -33,6 +33,7 @@ import {Hub} from '../hub.js';
import {ToolInputViewState} from './tool-input-view.interfaces.js'; import {ToolInputViewState} from './tool-input-view.interfaces.js';
import {CompilationResult} from '../compilation/compilation.interfaces.js'; import {CompilationResult} from '../compilation/compilation.interfaces.js';
import {CompilerInfo} from '../compiler.interfaces.js'; import {CompilerInfo} from '../compiler.interfaces.js';
import {SiteSettings} from '../settings.js';
export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEditor, ToolInputViewState> { export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEditor, ToolInputViewState> {
_toolId: string; _toolId: string;
@@ -131,45 +132,45 @@ export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEdito
this.editor.dispose(); this.editor.dispose();
} }
onToolClose(compilerId, toolSettings) { onToolClose(compilerId: number, toolSettings: ToolState) {
if (this.compilerInfo.compilerId === compilerId && this._toolId === toolSettings.toolId) { if (this.compilerInfo.compilerId === compilerId && this._toolId === toolSettings.toolId) {
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
// the hierarchy. We can't modify while it's being iterated over. // the hierarchy. We can't modify while it's being iterated over.
this.close(); this.close();
_.defer(function (self) { _.defer(function (self: ToolInputView) {
self.container.close(); self.container.close();
}, this); }, this);
} }
} }
onToolInputViewCloseRequest(compilerId, toolId) { onToolInputViewCloseRequest(compilerId: number, toolId: string) {
if (this.compilerInfo.compilerId === compilerId && this._toolId === toolId) { if (this.compilerInfo.compilerId === compilerId && this._toolId === toolId) {
this.close(); this.close();
_.defer(function (self) { _.defer(function (self: ToolInputView) {
self.container.close(); self.container.close();
}, this); }, this);
} }
} }
override onCompilerClose(id) { override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) { if (id === this.compilerInfo.compilerId) {
// We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over // We can't immediately close as an outer loop somewhere in GoldenLayout is iterating over
// the hierarchy. We can't modify while it's being iterated over. // the hierarchy. We can't modify while it's being iterated over.
this.close(); this.close();
_.defer(function (self) { _.defer(function (self: ToolInputView) {
self.container.close(); self.container.close();
}, this); }, this);
} }
} }
override onSettingsChange(newSettings) { override onSettingsChange(newSettings: SiteSettings) {
super.onSettingsChange(newSettings); super.onSettingsChange(newSettings);
this.debouncedEmitChange = _.debounce(() => { this.debouncedEmitChange = _.debounce(() => {
this.maybeEmitChange(false); this.maybeEmitChange(false);
}, newSettings.delayAfterChange); }, newSettings.delayAfterChange);
} }
override onDidChangeCursorSelection(e) { override onDidChangeCursorSelection(e: monaco.editor.ICursorSelectionChangedEvent) {
// On initialization this callback fires with the default selection // On initialization this callback fires with the default selection
// overwriting any selection from state. If we are awaiting initial // overwriting any selection from state. If we are awaiting initial
// selection setting then don't update our selection. // selection setting then don't update our selection.
@@ -179,7 +180,7 @@ export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEdito
} }
} }
onSetToolInput(compilerId, toolId, value) { onSetToolInput(compilerId: number, toolId: string, value: string) {
if (this.compilerInfo.compilerId === compilerId && this._toolId === toolId) { if (this.compilerInfo.compilerId === compilerId && this._toolId === toolId) {
const ret = this.editor.getModel()?.setValue(value); const ret = this.editor.getModel()?.setValue(value);
if (this.shouldSetSelectionInitially && this.selection) { if (this.shouldSetSelectionInitially && this.selection) {
@@ -198,7 +199,7 @@ export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEdito
return this.editor.getModel()?.getValue() ?? ''; return this.editor.getModel()?.getValue() ?? '';
} }
maybeEmitChange(force) { maybeEmitChange(force: boolean) {
const input = this.getInput(); const input = this.getInput();
if (!force && input === this.lastChangeEmitted) return; if (!force && input === this.lastChangeEmitted) return;

View File

@@ -183,7 +183,7 @@ export class Tool extends MonacoPane<monaco.editor.IStandaloneCodeEditor, ToolSt
onLanguageChange(editorId: number | boolean, newLangId: LanguageKey) { onLanguageChange(editorId: number | boolean, newLangId: LanguageKey) {
if (this.compilerInfo.editorId && this.compilerInfo.editorId === editorId) { if (this.compilerInfo.editorId && this.compilerInfo.editorId === editorId) {
const tools = ceoptions.tools[newLangId]; const tools = ceoptions.tools[newLangId];
this.toggleUsable(!!tools && !!tools[this.toolId]); this.toggleUsable(!!tools[this.toolId]);
} }
} }
@@ -368,7 +368,7 @@ export class Tool extends MonacoPane<monaco.editor.IStandaloneCodeEditor, ToolSt
monacoEditorHasBeenAutoOpened: this.monacoEditorHasBeenAutoOpened, monacoEditorHasBeenAutoOpened: this.monacoEditorHasBeenAutoOpened,
argsPanelShown: !this.panelArgs.hasClass('d-none'), argsPanelShown: !this.panelArgs.hasClass('d-none'),
}; };
return state as MonacoPaneState; return state;
} }
setLanguage(languageId: false | string) { setLanguage(languageId: false | string) {

View File

@@ -41,6 +41,7 @@ import _ from 'underscore';
import {assert, unwrap, unwrapString} from '../assert.js'; import {assert, unwrap, unwrapString} from '../assert.js';
import {escapeHTML} from '../../shared/common-utils.js'; import {escapeHTML} from '../../shared/common-utils.js';
import {LanguageKey} from '../languages.interfaces.js'; import {LanguageKey} from '../languages.interfaces.js';
import {ResultLine} from '../resultline/resultline.interfaces.js';
const languages = options.languages; const languages = options.languages;
@@ -69,7 +70,7 @@ export class Tree {
private lineColouring: LineColouring; private lineColouring: LineColouring;
private readonly ourCompilers: Record<number, boolean>; private readonly ourCompilers: Record<number, boolean>;
private readonly busyCompilers: Record<number, boolean>; private readonly busyCompilers: Record<number, boolean>;
private readonly asmByCompiler: Record<number, any>; private readonly asmByCompiler: Record<number, ResultLine[]>;
private selectize: TomSelect; private selectize: TomSelect;
private languageBtn: JQuery; private languageBtn: JQuery;
private toggleCMakeButton: Toggles; private toggleCMakeButton: Toggles;
@@ -650,9 +651,7 @@ export class Tree {
this.lineColouring.clear(); this.lineColouring.clear();
for (const [compilerId, asm] of Object.entries(this.asmByCompiler)) { for (const [compilerId, asm] of Object.entries(this.asmByCompiler)) {
if (asm) { this.lineColouring.addFromAssembly(parseInt(compilerId), asm);
this.lineColouring.addFromAssembly(parseInt(compilerId), asm);
}
} }
this.lineColouring.calculate(); this.lineColouring.calculate();

View File

@@ -60,7 +60,7 @@ export class Printerinator {
.slice(css.indexOf('.mtk1')) .slice(css.indexOf('.mtk1'))
.trim() .trim()
.split('\n') .split('\n')
.map(line => '#printview ' + line) .map((line: string) => '#printview ' + line)
.join('\n'); .join('\n');
this.themer.setTheme(unwrap(theme)); this.themer.setTheme(unwrap(theme));
} }

View File

@@ -148,7 +148,7 @@ class Encoders {
if (id_ok.test(x)) return x; if (id_ok.test(x)) return x;
x = x.replace(/(['!])/g, function (a, b) { x = x.replace(/(['!])/g, function (a, b) {
if (string_table[b]) return '!' + b; if (string_table[b as keyof typeof string_table]) return '!' + b;
return b; return b;
}); });
return "'" + x + "'"; return "'" + x + "'";
@@ -293,7 +293,7 @@ class Parser {
const s = this.string; const s = this.string;
const c = s.charAt(this.index++); const c = s.charAt(this.index++);
if (!c) return this.error('"!" at end of input'); if (!c) return this.error('"!" at end of input');
const x = Parser.bangs[c]; const x = Parser.bangs[c as keyof typeof Parser.bangs];
if (typeof x == 'function') { if (typeof x == 'function') {
// eslint-disable-next-line no-useless-call // eslint-disable-next-line no-useless-call
return x.call(null, this); return x.call(null, this);
@@ -368,7 +368,7 @@ class Parser {
permittedSigns = ''; permittedSigns = '';
continue; continue;
} }
state = transitions[state + '+' + c.toLowerCase()]; state = transitions[(state + '+' + c.toLowerCase()) as keyof typeof transitions];
if (state === 'exp') permittedSigns = '-'; if (state === 'exp') permittedSigns = '-';
} while (state); } while (state);
this.index = --i; this.index = --i;

View File

@@ -30,13 +30,14 @@ import * as Sentry from '@sentry/browser';
import GoldenLayout from 'golden-layout'; import GoldenLayout from 'golden-layout';
import {serialiseState} from './url.js'; import {serialiseState} from './url.js';
import {SiteSettings} from './settings.js';
let layout: GoldenLayout; let layout: GoldenLayout;
let allowSendCode: boolean; let allowSendCode: boolean;
export function setSentryLayout(l: GoldenLayout) { export function setSentryLayout(l: GoldenLayout) {
layout = l; layout = l;
layout.eventHub.on('settingsChange', newSettings => { layout.eventHub.on('settingsChange', (newSettings: SiteSettings) => {
allowSendCode = newSettings.allowStoreCodeDebug; allowSendCode = newSettings.allowStoreCodeDebug;
}); });

View File

@@ -138,11 +138,11 @@ interface SliderSettings {
max: number; max: number;
step: number; step: number;
display: JQuery; display: JQuery;
formatter: (number) => string; formatter: (arg: number) => string;
} }
class Slider extends BaseSetting { class Slider extends BaseSetting {
private readonly formatter: (number) => string; private readonly formatter: (arg: number) => string;
private display: JQuery; private display: JQuery;
private max: number; private max: number;
private min: number; private min: number;

View File

@@ -48,7 +48,7 @@ const shareServices = {
embedValid: false, embedValid: false,
logoClass: 'fab fa-twitter', logoClass: 'fab fa-twitter',
cssClass: 'share-twitter', cssClass: 'share-twitter',
getLink: (title, url) => { getLink: (title: string, url: string) => {
return ( return (
'https://twitter.com/intent/tweet' + 'https://twitter.com/intent/tweet' +
`?text=${encodeURIComponent(title)}` + `?text=${encodeURIComponent(title)}` +
@@ -62,7 +62,7 @@ const shareServices = {
embedValid: false, embedValid: false,
logoClass: 'fab fa-reddit', logoClass: 'fab fa-reddit',
cssClass: 'share-reddit', cssClass: 'share-reddit',
getLink: (title, url) => { getLink: (title: string, url: string) => {
return ( return (
'http://www.reddit.com/submit' + 'http://www.reddit.com/submit' +
`?url=${encodeURIComponent(url)}` + `?url=${encodeURIComponent(url)}` +
@@ -344,7 +344,7 @@ export class Sharing {
done(null, window.location.origin + root + '#' + url.serialiseState(config), false); done(null, window.location.origin + root + '#' + url.serialiseState(config), false);
return; return;
case LinkType.Embed: { case LinkType.Embed: {
const options = {}; const options: Record<string, boolean> = {};
$('#sharelinkdialog input:checked').each((i, element) => { $('#sharelinkdialog input:checked').each((i, element) => {
options[$(element).prop('class')] = true; options[$(element).prop('class')] = true;
}); });
@@ -380,7 +380,12 @@ export class Sharing {
}); });
} }
private static getEmbeddedHtml(config, root, isReadOnly, extraOptions): string { private static getEmbeddedHtml(
config: any,
root: string,
isReadOnly: boolean,
extraOptions: Record<string, boolean>,
): string {
const embedUrl = Sharing.getEmbeddedUrl(config, root, isReadOnly, extraOptions); const embedUrl = Sharing.getEmbeddedUrl(config, root, isReadOnly, extraOptions);
// The attributes must be double quoted, the full url's rison contains single quotes // The attributes must be double quoted, the full url's rison contains single quotes
return `<iframe width="800px" height="200px" src="${embedUrl}"></iframe>`; return `<iframe width="800px" height="200px" src="${embedUrl}"></iframe>`;

View File

@@ -28,7 +28,7 @@ export interface ITestable {
} }
export interface IFrontendTesting { export interface IFrontendTesting {
add(test: ITestable); add(test: ITestable): void;
getAllTestNames(): string[]; getAllTestNames(): string[];
run(testToRun: string): Promise<void>; run(testToRun: string): Promise<void>;
} }

View File

@@ -26,16 +26,19 @@ import {assert} from 'chai';
import {isValidAd} from '../motd.js'; import {isValidAd} from '../motd.js';
import {ITestable} from './frontend-testing.interfaces.js'; import {ITestable} from './frontend-testing.interfaces.js';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore "Could not find a declaration file"
import * as sinon from '../../node_modules/sinon/pkg/sinon-esm.js'; import * as sinon from '../../node_modules/sinon/pkg/sinon-esm.js';
import {Ad} from '../motd.interfaces.js';
class MotdTests implements ITestable { class MotdTests implements ITestable {
public readonly description: string = 'motd'; public readonly description: string = 'motd';
private static assertAd(ad, subLang, expected, message) { private static assertAd(ad: Ad, subLang, expected: boolean, message: string) {
assert.equal(isValidAd(ad, subLang), expected, message); assert.equal(isValidAd(ad, subLang), expected, message);
} }
private static assertAdWithDateNow(dateNow, ad, subLang, expected, message) { private static assertAdWithDateNow(dateNow: number, ad: Ad, subLang, expected: boolean, message: string) {
const dateNowStub = sinon.stub(Date, 'now'); const dateNowStub = sinon.stub(Date, 'now');
dateNowStub.returns(dateNow); dateNowStub.returns(dateNow);
MotdTests.assertAd(ad, subLang, expected, message); MotdTests.assertAd(ad, subLang, expected, message);

View File

@@ -41,7 +41,7 @@ export function updateAndCalcTopBarHeight(domRoot: JQuery, topBar: JQuery, hidea
} }
export function formatDateTimeWithSpaces(d: Date) { export function formatDateTimeWithSpaces(d: Date) {
const t = x => x.slice(-2); const t = (x: string) => x.slice(-2);
// Hopefully some day we can use the temporal api to make this less of a pain // Hopefully some day we can use the temporal api to make this less of a pain
return ( return (
`${d.getFullYear()} ${t('0' + (d.getMonth() + 1))} ${t('0' + d.getDate())}` + `${d.getFullYear()} ${t('0' + (d.getMonth() + 1))} ${t('0' + d.getDate())}` +
@@ -92,8 +92,8 @@ function parseNumericValue(value: string): bigInt.BigInteger | null {
} }
export function getNumericToolTip(value: string, digitSeparator?: string): string | null { export function getNumericToolTip(value: string, digitSeparator?: string): string | null {
const formatNumber = (number, base, chunkSize) => { const formatNumber = (num: bigInt.BigInteger, base: number, chunkSize: number) => {
const numberString = number.toString(base).toUpperCase(); const numberString = num.toString(base).toUpperCase();
if (digitSeparator !== undefined) { if (digitSeparator !== undefined) {
return addDigitSeparator(numberString, digitSeparator, chunkSize); return addDigitSeparator(numberString, digitSeparator, chunkSize);
} else { } else {

View File

@@ -74,5 +74,5 @@ export interface AlertNotifyOptions {
/** /**
* onLoadHandler(element) * onLoadHandler(element)
*/ */
onBeforeShow?: (any) => void; onBeforeShow?: (arg: any) => void;
} }

View File

@@ -45,11 +45,11 @@ export class CompilerPicker {
eventHub: EventHub; eventHub: EventHub;
id: number; id: number;
compilerService: CompilerService; compilerService: CompilerService;
onCompilerChange: (x: string) => any; onCompilerChange: (x: string) => void;
tomSelect: TomSelect | null; tomSelect: TomSelect | null;
lastLangId: string; lastLangId: string;
lastCompilerId: string; lastCompilerId: string;
compilerIsVisible: (any) => any; // TODO => bool probably compilerIsVisible: (ci: CompilerInfo) => boolean;
popup: CompilerPickerPopup; popup: CompilerPickerPopup;
toolbarPopoutButton: JQuery<HTMLElement>; toolbarPopoutButton: JQuery<HTMLElement>;
popupTooltip: JQuery<HTMLElement>; popupTooltip: JQuery<HTMLElement>;
@@ -58,8 +58,8 @@ export class CompilerPicker {
hub: Hub, hub: Hub,
langId: string, langId: string,
compilerId: string, compilerId: string,
onCompilerChange: (x: string) => any, onCompilerChange: (x: string) => void,
compilerIsVisible?: (x: any) => any, compilerIsVisible?: (x: CompilerInfo) => boolean,
) { ) {
this.eventHub = hub.createEventHub(); this.eventHub = hub.createEventHub();
this.id = CompilerPicker.nextSelectorId++; this.id = CompilerPicker.nextSelectorId++;
@@ -116,12 +116,12 @@ export class CompilerPicker {
closeAfterSelect: true, closeAfterSelect: true,
plugins: ['dropdown_input'], plugins: ['dropdown_input'],
maxOptions: 1000, maxOptions: 1000,
onChange: val => { onChange: (val: string) => {
// TODO(jeremy-rifkin) I don't think this can be undefined. // TODO(jeremy-rifkin) I don't think this can be undefined.
// Typing here needs improvement later anyway. // Typing here needs improvement later anyway.
/* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */ /* eslint-disable-next-line @typescript-eslint/no-unnecessary-condition */
if (val) { if (val) {
const compilerId = val as string; const compilerId = val;
this.onCompilerChange(compilerId); this.onCompilerChange(compilerId);
this.lastCompilerId = compilerId; this.lastCompilerId = compilerId;
} }

View File

@@ -38,7 +38,7 @@ type PopulateItem = {name: string; load: () => void; delete?: () => void; overwr
export class LoadSave { export class LoadSave {
private modal: JQuery | null = null; private modal: JQuery | null = null;
private alertSystem: Alert; private alertSystem: Alert;
private onLoadCallback: (...any) => void = _.identity; private onLoadCallback: (...args: any) => void = _.identity;
private editorText = ''; private editorText = '';
private extension = '.txt'; private extension = '.txt';
private base: string; private base: string;

View File

@@ -66,7 +66,9 @@ export class Toggles extends EventEmitter {
// Inject the icon if applicable // Inject the icon if applicable
if (button.find('.state-icon').length === 0) { if (button.find('.state-icon').length === 0) {
button.prepend('<i class="state-icon ' + settings[button.data('state')].icon + '"></i> '); button.prepend(
'<i class="state-icon ' + settings[button.data('state') as keyof typeof settings].icon + '"></i> ',
);
} }
} }
} }
@@ -84,7 +86,7 @@ export class Toggles extends EventEmitter {
button button
.find('.state-icon') .find('.state-icon')
.removeClass() .removeClass()
.addClass(`state-icon ${settings[button.data('state')].icon}`); .addClass(`state-icon ${settings[button.data('state') as keyof typeof settings].icon}`);
// Update the button's color // Update the button's color
button.toggleClass('active', isChecked); button.toggleClass('active', isChecked);

View File

@@ -83,7 +83,7 @@ describe('Hook compiler', () => {
labels: [], labels: [],
source: { source: {
file: null, file: null,
line: undefined, line: null,
}, },
text: '; main in /app/example.hk at 0x56554a556550', text: '; main in /app/example.hk at 0x56554a556550',
}, },
@@ -91,7 +91,7 @@ describe('Hook compiler', () => {
labels: [], labels: [],
source: { source: {
file: null, file: null,
line: undefined, line: null,
}, },
text: '; 0 parameter(s), 0 non-local(s), 0 constant(s), 0 function(s)', text: '; 0 parameter(s), 0 non-local(s), 0 constant(s), 0 function(s)',
}, },
@@ -147,7 +147,7 @@ describe('Hook compiler', () => {
labels: [], labels: [],
source: { source: {
file: null, file: null,
line: undefined, line: null,
}, },
text: '; 6 instruction(s)', text: '; 6 instruction(s)',
}, },

View File

@@ -159,7 +159,9 @@ describe('javap parsing', () => {
asm: '<Compilation failed>', asm: '<Compilation failed>',
}; };
await expect(compiler.processAsm(result)).resolves.toEqual([{text: '<Compilation failed>', source: null}]); await expect(compiler.processAsm(result)).resolves.toEqual({
asm: [{text: '<Compilation failed>', source: null}],
});
}); });
it('Parses simple class with one method', () => { it('Parses simple class with one method', () => {

View File

@@ -24,11 +24,13 @@
// TODO(jeremy-rifkin): re-visit all the types here once the back-end is more typescripted // TODO(jeremy-rifkin): re-visit all the types here once the back-end is more typescripted
export type EdgeColor = 'red' | 'green' | 'blue' | 'grey';
export type EdgeDescriptor = { export type EdgeDescriptor = {
from: string; from: string;
to: string; to: string;
arrows: string; // <- useless arrows: string; // <- useless
color: string; color: EdgeColor;
}; };
export type NodeDescriptor = { export type NodeDescriptor = {

View File

@@ -145,6 +145,11 @@ export type CompilationRequest = {
bypassCache?: BypassCache; bypassCache?: BypassCache;
}; };
export type PPOutput = {
numberOfLinesFiltered: number;
output: string;
};
export type CompilationResult = { export type CompilationResult = {
code: number; code: number;
timedOut: boolean; timedOut: boolean;
@@ -167,14 +172,11 @@ export type CompilationResult = {
dirPath?: string; dirPath?: string;
compilationOptions?: string[]; compilationOptions?: string[];
downloads?: BuildEnvDownloadInfo[]; downloads?: BuildEnvDownloadInfo[];
gccDumpOutput?: any; gccDumpOutput?;
languageId?: string; languageId?: string;
result?: CompilationResult; // cmake inner result result?: CompilationResult; // cmake inner result
ppOutput?: { ppOutput?: PPOutput;
numberOfLinesFiltered: number;
output: string;
};
optOutput?: OptCodeEntry[]; optOutput?: OptCodeEntry[];
optPath?: string; optPath?: string;

View File

@@ -38,6 +38,12 @@ import {Language, LanguageKey} from './languages.interfaces.js';
import {Library} from './libraries/libraries.interfaces.js'; import {Library} from './libraries/libraries.interfaces.js';
import {Tool, ToolInfo} from './tool.interfaces.js'; import {Tool, ToolInfo} from './tool.interfaces.js';
export type Remote = {
target: string;
path: string;
cmakePath: string;
};
export type CompilerInfo = { export type CompilerInfo = {
id: string; id: string;
exe: string; exe: string;
@@ -130,11 +136,7 @@ export type CompilerInfo = {
preamble?: string; preamble?: string;
invasive?: boolean; invasive?: boolean;
}; };
remote?: { remote?: Remote;
target: string;
path: string;
cmakePath: string;
};
possibleOverrides?: AllCompilerOverrideOptions; possibleOverrides?: AllCompilerOverrideOptions;
possibleRuntimeTools?: PossibleRuntimeTools; possibleRuntimeTools?: PossibleRuntimeTools;
disabledFilters: string[]; disabledFilters: string[];