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,
outputFilename,
)
: '';
: null;
const rustMirResult = makeRustMir ? await this.processRustMirOutput(outputFilename, asmResult) : undefined;
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);
if (opts.treeDump === false && opts.rtlDump === false && opts.ipaDump === false) {
@@ -3092,7 +3097,7 @@ export class BaseCompiler implements ICompiler {
const output = {
all: [] as any[],
selectedPass: opts.pass,
selectedPass: opts.pass ?? null,
currentPassOutput: '<No pass selected>',
syntaxHighlight: false,
};
@@ -3194,7 +3199,7 @@ but nothing was dumped. Possible causes are:
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(' | ')}`;
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 {CompilerInfo} from '../../types/compiler.interfaces.js';
import {CompilationEnvironment} from '../compilation-env.js';
import {logger} from '../logger.js';
import {VersionInfo} from '../options-handler.js';
@@ -67,14 +68,12 @@ export class BuildEnvSetupCeConanDirect extends BuildEnvSetupBase {
return 'ceconan';
}
constructor(compilerInfo: CompilerInfo, env) {
constructor(compilerInfo: CompilerInfo, env: CompilationEnvironment) {
super(compilerInfo, env);
this.host = compilerInfo.buildenvsetup!.props('host', '');
this.onlyonstaticliblink = compilerInfo.buildenvsetup!.props('onlyonstaticliblink', '');
this.extractAllToRoot = false;
if (env.debug) request.debug = true;
}
async getAllPossibleBuilds(libid: string, version: string) {

View File

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

View File

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

View File

@@ -24,6 +24,7 @@
import path from 'path';
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {BypassCache, CacheKey, ExecutionOptions} from '../../types/compilation/compilation.interfaces.js';
import type {PreliminaryCompilerInfo} from '../../types/compiler.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.
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');

View File

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

View File

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

View File

@@ -248,10 +248,10 @@ export class JavaCompiler extends BaseCompiler implements SimpleOutputFilenameCo
return this.filterUserOptionsWithArg(userOptions, oneArgForbiddenList);
}
override async processAsm(result) {
override async processAsm(result): Promise<ParsedAsmResult> {
// Handle "error" documents.
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

View File

@@ -23,7 +23,7 @@
// POSSIBILITY OF SUCH DAMAGE.
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 {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)) {
return await this.processIr(ir, {
filterDebugInfo: !!filters.debugCalls,

View File

@@ -56,6 +56,7 @@ export type VersionInfo = {
options: string[];
hidden: boolean;
packagedheaders?: boolean;
$order?: number;
};
export type OptionsHandlerLibrary = {
name: string;
@@ -439,7 +440,7 @@ export class ClientOptionsHandler {
'isSemVer',
]);
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
for (const key of Object.keys(this.options.languages)) {
@@ -462,7 +463,7 @@ export class ClientOptionsHandler {
for (const propKey of Object.keys(compiler)) {
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
// POSSIBILITY OF SUCH DAMAGE.
import {ParsedAsmResult} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.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>[^"]+)"/;
export class AsmParserCpp implements IAsmParser {
process(asmResult: string, filters: ParseFiltersAndOutputOptions) {
process(asmResult: string, filters: ParseFiltersAndOutputOptions): ParsedAsmResult {
const startTime = process.hrtime.bigint();
const asm: {
@@ -69,7 +70,7 @@ export class AsmParserCpp implements IAsmParser {
const endTime = process.hrtime.bigint();
return {
asm: asm,
labelDefinitions: [],
labelDefinitions: {},
parsingTime: ((endTime - startTime) / BigInt(1000000)).toString(),
filteredCount: 0,
};

View File

@@ -23,6 +23,7 @@
// POSSIBILITY OF SUCH DAMAGE.
import {AsmResultLabel, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js';
import {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js';
import * as utils from '../utils.js';
import {AsmParser} from './asm-parser.js';
@@ -84,7 +85,7 @@ export class SPIRVAsmParser extends AsmParser {
return labelsInLine;
}
override processAsm(asmResult, filters) {
override processAsm(asmResult, filters: ParseFiltersAndOutputOptions) {
const startTime = process.hrtime.bigint();
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';
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",
"@types/body-parser": "^1.19.5",
"@types/bootstrap": "^5.2.10",
"@types/chai": "^5.0.0",
"@types/compression": "^1.7.5",
"@types/express": "^4.17.21",
"@types/file-saver": "^2.0.7",
@@ -4100,6 +4101,13 @@
"integrity": "sha512-hWtVTC2q7hc7xZ/RLbxapMvDMgUnDvKvMOpKal4DrMyfGBUfB1oKaZlIRr6mJL+If3bAP6sV/QneGzF6tJjZDg==",
"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": {
"version": "1.7.5",
"resolved": "https://registry.npmjs.org/@types/compression/-/compression-1.7.5.tgz",

View File

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

View File

@@ -323,7 +323,7 @@ function tokenize(text: string, options: AnsiToHtmlOptions, callback: TokenizeCa
return '';
}
function rgb(m) {
function rgb(m: string) {
callback('rgb', m);
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) {
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 {IncludeDownloads, SourceAndFiles} from './download-service.js';
import {SentryCapture} from './sentry.js';
import {SiteSettings} from './settings.js';
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;
}
eventHub.on('settingsChange', newSettings => (this.allowStoreCodeDebug = newSettings.allowStoreCodeDebug));
eventHub.on(
'settingsChange',
(newSettings: SiteSettings) => (this.allowStoreCodeDebug = newSettings.allowStoreCodeDebug),
);
}
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';
export interface ICompilerShared {
updateState(state: CompilerState | ExecutorState);
updateState(state: CompilerState | ExecutorState): void;
getOverrides(): ConfiguredOverrides | undefined;
getRuntimeTools(): ConfiguredRuntimeTools | undefined;
}

View File

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

View File

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

View File

@@ -156,10 +156,10 @@ export type EventMap = {
// TODO: There are no emitters for this event
selectLine: (editorId: number, lineNumber: number) => void;
settingsChange: (newSettings: SiteSettings) => void;
setToolInput: (compilerId: number, toolId: string, string: string) => void;
setToolInput: (compilerId: number, toolId: string, value: string) => void;
shown: () => 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;
toolInputViewClosed: (compilerId: number, toolId: string, input: 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
// 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';
@@ -70,7 +70,7 @@ type EdgeSegment = {
};
type Edge = {
color: string;
color: EdgeColor;
dest: number;
mainColumn: number;
path: EdgeSegment[];
@@ -214,7 +214,7 @@ export class GraphLayoutCore {
return order.reverse();
}
assignRows(topologicalOrder) {
assignRows(topologicalOrder: number[]) {
for (const i of topologicalOrder) {
const block = this.blocks[i];
//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
//
// 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.
// Post DFS order means we compute all children before their parents
for (const i of topologicalOrder.slice().reverse()) {

View File

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

View File

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

View File

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

View File

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

View File

@@ -23,6 +23,8 @@
// POSSIBILITY OF SUCH DAMAGE.
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';
function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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 cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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 cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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 cppp from './cppp-mode.js';
@@ -52,7 +54,7 @@ function definition(): monaco.languages.IMonarchLanguage {
// 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] = [
{include: '@whitespace'},
[opener, 'delimiter.' + delimiter, '$S2.$S3.$S4'],
@@ -91,7 +93,14 @@ function definition(): monaco.languages.IMonarchLanguage {
}
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 = [
[/(\()(.)/, ['delimiter.parenthesis', {token: '@rematch', next: 'parse_cpp2_expression'}]],
[/:[^)]*/, 'string'],
@@ -107,7 +116,7 @@ function definition(): monaco.languages.IMonarchLanguage {
[/@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([
prefix_token_regex.source + /(@at_cpp2_interpolation)/.source,
{

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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';
// 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 * 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 cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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 cppp from './cppp-mode.js';

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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';
function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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';
function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -23,6 +23,8 @@
// POSSIBILITY OF SUCH DAMAGE.
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';
function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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';
function definition(): monaco.languages.IMonarchLanguage {

View File

@@ -25,6 +25,8 @@
import $ from 'jquery';
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';
// 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 * 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 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) => {
return file.isIncluded && file.filename === filename;
});

View File

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

View File

@@ -36,6 +36,7 @@ import * as monacoConfig from '../monaco-config.js';
import {Hub} from '../hub.js';
import {unwrap} from '../assert.js';
import {CompilerInfo} from '../compiler.interfaces.js';
import {CompilationResult} from '../compilation/compilation.interfaces.js';
type DecorationEntry = {
linkedCode: any[];
@@ -168,7 +169,7 @@ export class Ast extends MonacoPane<monaco.editor.IStandaloneCodeEditor, AstStat
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 (result.astOutput) {
@@ -229,7 +230,7 @@ export class Ast extends MonacoPane<monaco.editor.IStandaloneCodeEditor, AstStat
tryApplyAstColours(): void {
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()) {
if (
code.source &&

View File

@@ -176,7 +176,7 @@ export class Cfg extends Pane<CfgState> {
dropdownParent: 'body',
plugins: ['dropdown_input'],
sortField: 'title',
onChange: e => this.selectFunction(e as unknown as string),
onChange: (e: string) => this.selectFunction(e),
});
this.functionSelector.on('dropdown_close', () => {
// 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 {
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.eventHub.emit('clangirViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -2692,8 +2692,8 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
if (!this.compiler) return;
const addTool = (toolName: string, title: string, toolIcon?, toolIconDark?) => {
const btn = $("<button class='dropdown-item btn btn-light btn-sm new-pane-button'>");
const addTool = (toolName: string, title: string, toolIcon?: string, toolIconDark?: string) => {
const btn = $("<button class='dropdown-item btn btn-light btn-sm'>");
btn.addClass('view-' + toolName);
btn.data('toolname', toolName);
if (toolIcon) {
@@ -2753,7 +2753,10 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
const filters = this.getEffectiveFilters();
// 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).
const formatFilterTitle = (button, title) => {
const formatFilterTitle = (
button: JQuery<HTMLElementTagNameMap[keyof HTMLElementTagNameMap]>,
title: JQuery<HTMLElement>,
) => {
button.prop(
'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
if (id === this.compilerInfo.compilerId && this.deviceCode) {
const irColours = {};
const irColours: Record<number, number> = {};
this.deviceCode.forEach((x: ResultLine, index: number) => {
if (x.source && x.source.file == null && x.source.line > 0 && colours[x.source.line - 1]) {
irColours[index] = colours[x.source.line - 1];

View File

@@ -90,9 +90,9 @@ class DiffStateObject {
this.extraoption = extraoption;
}
update(id: number | string, compiler, result: CompilationResult) {
update(id: number | string, compiler: CompilerInfo, result: CompilationResult) {
if (this.id !== id) return false;
this.compiler = compiler;
this.compiler!.compiler = compiler;
this.result = result;
this.refresh();
@@ -320,7 +320,7 @@ export class Diff extends MonacoPane<monaco.editor.IStandaloneDiffEditor, DiffSt
this.updateCompilers();
}
getDiffableOptions(picker?, extraoptions?: DiffOption[]): any[] {
getDiffableOptions(picker?: HTMLSelectElement | TomSelect, extraoptions?: DiffOption[]): any[] {
const options: DiffOption[] = [
{id: DiffType.ASM.toString(), name: 'Assembly'},
{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
// POSSIBILITY OF SUCH DAMAGE.
import {Language} from '../../types/languages.interfaces.js';
import {Language, LanguageKey} from '../../types/languages.interfaces.js';
export type EditorState = {
filename?: string;
@@ -30,7 +30,7 @@ export type EditorState = {
readOnly?: boolean;
};
source?: string;
lang: string;
lang: LanguageKey;
};
export type LanguageSelectData = Language & {

View File

@@ -81,7 +81,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
private filename: string | false;
private awaitingInitialResults: boolean;
private revealJumpStack: editor.ICodeEditorViewState[];
private langKeys: string[];
private langKeys: LanguageKey[];
private legacyReadOnly?: boolean;
private selectize?: TomSelect;
private lastChangeEmitted: string | null;
@@ -316,13 +316,13 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
this.waitingForLanguage = Boolean(state.source && !state.lang);
if (this.settings.defaultLanguage && this.settings.defaultLanguage in languages) {
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
// use the hub's default lang if possible
newLanguage = languages[this.hub.defaultLangId];
}
if (state.lang && state.lang in languages) {
if (state.lang in languages) {
newLanguage = languages[state.lang];
} else if (
this.settings.newEditorLastLang &&
@@ -498,7 +498,7 @@ export class Editor extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Edit
super.initializeGlobalDependentProperties();
this.httpRoot = window.httpRoot;
this.langKeys = Object.keys(languages);
this.langKeys = Object.keys(languages) as LanguageKey[];
}
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);
};
const addPaneOpener = (dragSource, dragConfig) => {
const addPaneOpener = (dragSource: JQuery<HTMLElement>, dragConfig) => {
this.container.layoutManager
.createDragSource(dragSource, dragConfig)
// 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) {
link = {
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(
this.compiler ? this.compiler.libsArr : [],
this.currentLangId,
this.compiler?.remote ?? null,
this.compiler?.remote ?? undefined,
),
);
}
@@ -1248,7 +1248,7 @@ export class Executor extends Pane<ExecutorState> {
filteredLibraries = LibUtils.getSupportedLibraries(
this.compiler.libsArr,
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;
}
maybeEmitChange(force) {
maybeEmitChange(force: boolean) {
const options = this.getOptions();
if (!force && options === this.lastChangeEmitted) return;

View File

@@ -97,8 +97,8 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
if (match) {
const selectedPassO: GccDumpViewSelectedPass = {
filename_suffix: match[1] + '.' + match[2],
name: match[2] + ' (' + passType[match[1]] + ')',
command_prefix: '-fdump-' + passType[match[1]] + '-' + match[2],
name: match[2] + ' (' + passType[match[1] as keyof typeof passType] + ')',
command_prefix: '-fdump-' + passType[match[1] as keyof typeof passType] + '-' + match[2],
// FIXME(dkm): maybe this could be avoided by better typing.
selectedPass: null,
@@ -256,7 +256,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
}
updateButtons() {
const formatButtonTitle = (button, title) =>
const formatButtonTitle = (button: JQuery<HTMLElement>, title: string) =>
button.prop('title', '[' + (button.hasClass('active') ? 'ON' : 'OFF') + '] ' + title);
formatButtonTitle(this.dumpTreesButton, this.dumpTreesTitle);
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
// if gccDumpOutput is false, cleans the select menu
updatePass(filters, selectize, gccDumpOutput) {
updatePass(filters: Toggles, selectize: TomSelect, gccDumpOutput) {
const passes = gccDumpOutput ? gccDumpOutput.all : [];
// 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);
}
if (gccDumpOutput.selectedPass) selectize.addItem(gccDumpOutput.selectedPass.name, true);
else selectize.clear(true);
if (gccDumpOutput && gccDumpOutput.selectedPass) {
selectize.addItem(gccDumpOutput.selectedPass.name, true);
this.eventHub.emit('gccDumpPassSelected', this.compilerInfo.compilerId, gccDumpOutput.selectedPass, false);
} else selectize.clear(true);
this.inhibitPassSelect = false;
}
@@ -362,7 +362,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
} else {
this.selectize.clear(true);
this.selectedPass = null;
this.updatePass(this.filters, this.selectize, false);
this.updatePass(this.filters, this.selectize, null);
this.uiIsReady = false;
this.onUiNotReady();
if (!compiler.supportsGccDump) {
@@ -374,7 +374,7 @@ export class GccDump extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Gcc
this.updateState();
}
showGccDumpResults(results) {
showGccDumpResults(results: string) {
this.editor.setValue(results);
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) {
this.compilerInfo.compilerName = compiler ? compiler.name : '';
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) {
// 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.
this.close();
_.defer(function (self) {
_.defer(function (self: GccDump) {
self.container.close();
}, this);
}

View File

@@ -70,7 +70,10 @@ export class GnatDebug extends MonacoPane<monaco.editor.IStandaloneCodeEditor, G
}
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.eventHub.emit('gnatDebugViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -70,7 +70,10 @@ export class GnatDebugTree extends MonacoPane<monaco.editor.IStandaloneCodeEdito
}
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.eventHub.emit('gnatDebugTreeViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class HaskellCmm extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
}
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.eventHub.emit('haskellCmmViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class HaskellCore extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
}
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.eventHub.emit('haskellCoreViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class HaskellStg extends MonacoPane<monaco.editor.IStandaloneCodeEditor,
}
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.eventHub.emit('haskellStgViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -312,8 +312,9 @@ export class Ir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, IrState>
};
let changed = false;
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;
break;
}
}
this.lastOptions = newOptions;

View File

@@ -120,7 +120,7 @@ export class OptPipeline extends MonacoPane<monaco.editor.IStandaloneDiffEditor,
plugins: ['input_autogrow'],
sortField: 'title',
maxOptions: 1000,
onChange: e => this.selectGroup(e as string),
onChange: (e: string) => this.selectGroup(e),
});
this.groupSelector.on('dropdown_close', () => {
// scroll back to the selection on the next open
@@ -289,7 +289,8 @@ export class OptPipeline extends MonacoPane<monaco.editor.IStandaloneDiffEditor,
};
let changed = false;
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;
}
}

View File

@@ -37,7 +37,7 @@ import {CompilationResult} from '../../types/compilation/compilation.interfaces.
import {CompilerInfo} from '../../types/compiler.interfaces.js';
import {escapeHTML} from '../../shared/common-utils.js';
function makeAnsiToHtml(color?) {
function makeAnsiToHtml(color?: string) {
return new AnsiToHtml.Filter({
fg: color ? color : '#333',
bg: '#f5f5f5',
@@ -251,7 +251,7 @@ export class Output extends Pane<OutputState> {
if (color) elem.css('color', color);
}
getEditorIdByFilename(filename) {
getEditorIdByFilename(filename: string) {
if (this.compilerInfo.treeId) {
const tree = this.hub.getTreeById(this.compilerInfo.treeId);
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) {
this.eventHub.emit('editorLinkLine', this.compilerInfo.editorId, lineNum, column, column + 1, goto);
} else if (filename) {
@@ -274,7 +274,7 @@ export class Output extends Pane<OutputState> {
add(msg: string, lineNum?: number, column?: number, filename?: string) {
const elem = $('<div/>').appendTo(this.contentRoot);
if (lineNum) {
if (lineNum && column && filename) {
elem.empty();
$('<span class="linked-compiler-output-line"></span>')
.html(msg)
@@ -302,7 +302,7 @@ export class Output extends Pane<OutputState> {
return `(Compiler #${this.compilerInfo.compilerId})`;
}
override onCompilerClose(id) {
override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) {
// 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.
@@ -320,7 +320,7 @@ export class Output extends Pane<OutputState> {
$(document).off('keydown', this.keydownCallback);
}
setCompileStatus(isCompiling) {
setCompileStatus(isCompiling: boolean) {
this.contentRoot.toggleClass('compiling', isCompiling);
}

View File

@@ -33,7 +33,7 @@ import {Container} from 'golden-layout';
import {MonacoPaneState} from './pane.interfaces.js';
import {Hub} from '../hub.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';
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();
}
showPpResults(results) {
showPpResults(results: PPOutput | string) {
if (typeof results === 'object') {
if (results.numberOfLinesFiltered > 0) {
this.editor.setValue(
@@ -180,12 +180,12 @@ export class PP extends MonacoPane<monaco.editor.IStandaloneCodeEditor, PPViewSt
return state;
}
override onCompilerClose(id) {
override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) {
// 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.
this.close();
_.defer(function (self) {
_.defer(function (self: PP) {
self.container.close();
}, this);
}

View File

@@ -69,7 +69,10 @@ export class RustHir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Rus
}
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.eventHub.emit('rustHirViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class RustMacroExp extends MonacoPane<monaco.editor.IStandaloneCodeEditor
}
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.eventHub.emit('rustMacroExpViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

@@ -69,7 +69,10 @@ export class RustMir extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Rus
}
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.eventHub.emit('rustMirViewOpened', this.compilerInfo.compilerId);
this.eventHub.emit('requestSettings');

View File

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

View File

@@ -33,6 +33,7 @@ import {Hub} from '../hub.js';
import {ToolInputViewState} from './tool-input-view.interfaces.js';
import {CompilationResult} from '../compilation/compilation.interfaces.js';
import {CompilerInfo} from '../compiler.interfaces.js';
import {SiteSettings} from '../settings.js';
export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEditor, ToolInputViewState> {
_toolId: string;
@@ -131,45 +132,45 @@ export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEdito
this.editor.dispose();
}
onToolClose(compilerId, toolSettings) {
onToolClose(compilerId: number, toolSettings: ToolState) {
if (this.compilerInfo.compilerId === compilerId && this._toolId === toolSettings.toolId) {
// 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.
this.close();
_.defer(function (self) {
_.defer(function (self: ToolInputView) {
self.container.close();
}, this);
}
}
onToolInputViewCloseRequest(compilerId, toolId) {
onToolInputViewCloseRequest(compilerId: number, toolId: string) {
if (this.compilerInfo.compilerId === compilerId && this._toolId === toolId) {
this.close();
_.defer(function (self) {
_.defer(function (self: ToolInputView) {
self.container.close();
}, this);
}
}
override onCompilerClose(id) {
override onCompilerClose(id: number) {
if (id === this.compilerInfo.compilerId) {
// 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.
this.close();
_.defer(function (self) {
_.defer(function (self: ToolInputView) {
self.container.close();
}, this);
}
}
override onSettingsChange(newSettings) {
override onSettingsChange(newSettings: SiteSettings) {
super.onSettingsChange(newSettings);
this.debouncedEmitChange = _.debounce(() => {
this.maybeEmitChange(false);
}, newSettings.delayAfterChange);
}
override onDidChangeCursorSelection(e) {
override onDidChangeCursorSelection(e: monaco.editor.ICursorSelectionChangedEvent) {
// On initialization this callback fires with the default selection
// overwriting any selection from state. If we are awaiting initial
// 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) {
const ret = this.editor.getModel()?.setValue(value);
if (this.shouldSetSelectionInitially && this.selection) {
@@ -198,7 +199,7 @@ export class ToolInputView extends MonacoPane<monaco.editor.IStandaloneCodeEdito
return this.editor.getModel()?.getValue() ?? '';
}
maybeEmitChange(force) {
maybeEmitChange(force: boolean) {
const input = this.getInput();
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) {
if (this.compilerInfo.editorId && this.compilerInfo.editorId === editorId) {
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,
argsPanelShown: !this.panelArgs.hasClass('d-none'),
};
return state as MonacoPaneState;
return state;
}
setLanguage(languageId: false | string) {

View File

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

View File

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

View File

@@ -148,7 +148,7 @@ class Encoders {
if (id_ok.test(x)) return x;
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 "'" + x + "'";
@@ -293,7 +293,7 @@ class Parser {
const s = this.string;
const c = s.charAt(this.index++);
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') {
// eslint-disable-next-line no-useless-call
return x.call(null, this);
@@ -368,7 +368,7 @@ class Parser {
permittedSigns = '';
continue;
}
state = transitions[state + '+' + c.toLowerCase()];
state = transitions[(state + '+' + c.toLowerCase()) as keyof typeof transitions];
if (state === 'exp') permittedSigns = '-';
} while (state);
this.index = --i;

View File

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

View File

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

View File

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

View File

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

View File

@@ -26,16 +26,19 @@ import {assert} from 'chai';
import {isValidAd} from '../motd.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 {Ad} from '../motd.interfaces.js';
class MotdTests implements ITestable {
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);
}
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');
dateNowStub.returns(dateNow);
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) {
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
return (
`${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 {
const formatNumber = (number, base, chunkSize) => {
const numberString = number.toString(base).toUpperCase();
const formatNumber = (num: bigInt.BigInteger, base: number, chunkSize: number) => {
const numberString = num.toString(base).toUpperCase();
if (digitSeparator !== undefined) {
return addDigitSeparator(numberString, digitSeparator, chunkSize);
} else {

View File

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

View File

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

View File

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

View File

@@ -66,7 +66,9 @@ export class Toggles extends EventEmitter {
// Inject the icon if applicable
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
.find('.state-icon')
.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
button.toggleClass('active', isChecked);

View File

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

View File

@@ -159,7 +159,9 @@ describe('javap parsing', () => {
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', () => {

View File

@@ -24,11 +24,13 @@
// 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 = {
from: string;
to: string;
arrows: string; // <- useless
color: string;
color: EdgeColor;
};
export type NodeDescriptor = {

View File

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

View File

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