diff --git a/package-lock.json b/package-lock.json index 7c6612a1c..341f5a5df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -88,6 +88,7 @@ "@types/shell-quote": "^1.7.1", "@types/tar-fs": "^2.0.1", "@types/underscore": "^1.11.4", + "@types/webpack-env": "^1.18.0", "@typescript-eslint/eslint-plugin": "^5.8.0", "@typescript-eslint/parser": "^5.8.0", "ajv": "^8.8.2", @@ -2078,6 +2079,12 @@ "integrity": "sha512-uO4CD2ELOjw8tasUrAhvnn2W4A0ZECOvMjCivJr4gA9pGgjv+qxKWY9GLTMVEK8ej85BxQOocUyE7hImmSQYcg==", "dev": true }, + "node_modules/@types/webpack-env": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.18.0.tgz", + "integrity": "sha512-56/MAlX5WMsPVbOg7tAxnYvNYMMWr/QJiIp6BxVSW3JJXUVzzOn64qW8TzQyMSqSUFM2+PVI4aUHcHOzIz/1tg==", + "dev": true + }, "node_modules/@types/ws": { "version": "8.5.3", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz", @@ -16893,6 +16900,12 @@ "integrity": "sha512-uO4CD2ELOjw8tasUrAhvnn2W4A0ZECOvMjCivJr4gA9pGgjv+qxKWY9GLTMVEK8ej85BxQOocUyE7hImmSQYcg==", "dev": true }, + "@types/webpack-env": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@types/webpack-env/-/webpack-env-1.18.0.tgz", + "integrity": "sha512-56/MAlX5WMsPVbOg7tAxnYvNYMMWr/QJiIp6BxVSW3JJXUVzzOn64qW8TzQyMSqSUFM2+PVI4aUHcHOzIz/1tg==", + "dev": true + }, "@types/ws": { "version": "8.5.3", "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.3.tgz", diff --git a/package.json b/package.json index 149ba8772..20cbfe8cf 100644 --- a/package.json +++ b/package.json @@ -99,6 +99,7 @@ "@types/shell-quote": "^1.7.1", "@types/tar-fs": "^2.0.1", "@types/underscore": "^1.11.4", + "@types/webpack-env": "^1.18.0", "@typescript-eslint/eslint-plugin": "^5.8.0", "@typescript-eslint/parser": "^5.8.0", "ajv": "^8.8.2", diff --git a/static/components.ts b/static/components.ts index c0a45a235..cfc9eef46 100644 --- a/static/components.ts +++ b/static/components.ts @@ -103,6 +103,7 @@ import { EmptyLLVMOptPipelineViewState, PopulatedLLVMOptPipelineViewState, } from './components.interfaces'; +import {OptCodeEntry} from './panes/opt-view.interfaces'; /** Get an empty compiler component. */ export function getCompiler(editorId: number, lang: string): ComponentConfig { diff --git a/static/event-map.ts b/static/event-map.ts index 4454cfa98..01ffce5c2 100644 --- a/static/event-map.ts +++ b/static/event-map.ts @@ -52,7 +52,12 @@ export type EventMap = { treeId: number ) => void; compilerClose: (compilerId: number, treeId: boolean | number) => void; - compileResult: (compilerId: number, compiler: CompilerInfo, result: CompilationResult, language: Language) => void; + compileResult: ( + compilerId: number, + compiler: CompilerInfo, + result: CompilationResult, + language: Language | undefined + ) => void; compilerFavoriteChange: (compilerId: number) => void; compilerFlagsChange: (compilerId: number, options: string) => void; compilerOpen: (compilerId: number, editorId: number, treeId: number | boolean) => void; diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts index 5721d08dd..3e22296e8 100644 --- a/static/panes/compiler.ts +++ b/static/panes/compiler.ts @@ -27,7 +27,6 @@ import $ from 'jquery'; import {ga} from '../analytics'; import * as colour from '../colour'; import {Toggles} from '../widgets/toggles'; -import {FontScale} from '../widgets/fontscale'; import * as Components from '../components'; import LruCache from 'lru-cache'; import {options} from '../options'; @@ -43,7 +42,6 @@ import {CompilerService} from '../compiler-service'; import {Settings, SiteSettings} from '../settings'; import * as LibUtils from '../lib-utils'; import {getAssemblyDocumentation} from '../api/api'; -import {PaneRenaming} from '../widgets/pane-renaming'; import {MonacoPane} from './pane'; import {CompilerInfo} from '../../types/compiler.interfaces'; import {MonacoPaneState} from './pane.interfaces'; @@ -65,7 +63,6 @@ import {CompilationResult} from '../../types/compilation/compilation.interfaces' import {ResultLine} from '../../types/resultline/resultline.interfaces'; import * as utils from '../utils'; -// @ts-ignore const toolIcons = require.context('../../views/resources/logos', false, /\.(png|svg)$/); const OpcodeCache = new LruCache({ @@ -92,23 +89,6 @@ function patchOldFilters(filters) { const languages = options.languages; -type LastResult = { - ppOutput: unknown; - astOutput: unknown; - irOutput: unknown; - devices: unknown; - rustMirOutput: unknown; - rustMacroExpOutput: unknown; - rustHirOutput: unknown; - haskellCoreOutput: unknown; - haskellStgOutput: unknown; - haskellCmmOutput: unknown; - gccDumpOutput?: Record; - gnatDebugTreeOutput: unknown; - gnatDebugOutput: unknown; - optOutput: unknown; -}; - type CompilerCurrentState = CompilerState & MonacoPaneState & { filters: Record; @@ -225,7 +205,7 @@ export class Compiler extends MonacoPane { + this.optButton.on('click', () => { const insertPoint = this.hub.findParentRowOrColumn(this.container.parent) || this.container.layoutManager.root.contentItems[0]; @@ -1024,7 +983,7 @@ export class Compiler extends MonacoPane { if (e && e.target && e.target.position) { if (this.isLabelCtxKey.get()) { @@ -1143,9 +1101,7 @@ export class Compiler extends MonacoPane { - // @ts-expect-error: Those types do actually match + // @ts-ignore this.setAssembly({asm: this.fakeAsm('')}, 0); }, 500); this.compilerService @@ -1559,9 +1515,10 @@ export class Compiler extends MonacoPane { - this.fontScale.setScale(scale); - this.updateState(); - }); - this.paneRenaming.on('renamePane', this.updateState.bind(this)); - - this.container.on('destroy', this.close, this); - this.container.on('resize', this.resize, this); + override registerCallbacks(): void { this.container.on('shown', this.resize, this); this.container.on('open', () => { this.eventHub.emit('compilerOpen', this.id, this.sourceEditorId ?? 0, this.sourceTreeId ?? 0); @@ -2711,7 +2657,6 @@ export class Compiler extends MonacoPane { if (id === this.id) { this.eventHub.emit('filtersChange', this.id, this.getEffectiveFilters() as any); @@ -2775,13 +2719,15 @@ export class Compiler extends MonacoPane { - TimingWidget.displayCompilationTiming(this.lastResult, this.lastTimeTaken); - }); + this.eventHub.on('initialised', this.undefer, this); } initCallbacks(): void { - this.initListeners(); + this.filters.on('change', this.onFilterChange.bind(this)); + + this.fullTimingInfo.off('click').on('click', () => { + TimingWidget.displayCompilationTiming(this.lastResult, this.lastTimeTaken); + }); const optionsChange = _.debounce(e => { this.onOptionsChange($(e.target).val() as string); @@ -2834,8 +2780,6 @@ export class Compiler extends MonacoPane opt === '-flto') && !this.filters.state.binary && !wasCmake) { + if (optionsArray.some(opt => opt === '-flto') && !this.filters.isSet('binary') && !wasCmake) { this.alertSystem.notify('Option -flto is being used without Compile to Binary.', { group: 'unwiseOption', collapseSimilar: true, @@ -2903,15 +2845,12 @@ export class Compiler extends MonacoPane - this.alertSystem.notify(notification, { - group: 'compilerwarning', - alertClass: 'notification-info', - dismissTime: 7000, - }) - ); + if (this.compiler.notification.length > 0) { + this.alertSystem.notify(this.compiler.notification, { + group: 'compilerwarning', + alertClass: 'notification-info', + dismissTime: 7000, + }); } this.prependOptions.data('content', this.compiler.options); } @@ -3060,9 +2999,16 @@ export class Compiler extends MonacoPaneCompiler Version: ' + notification + '')[0] + ? ($.parseHTML('Compiler Version: ' + notification + '')[0] as Element) : 'Full compiler version', content: bodyContent, template: @@ -3422,7 +3367,6 @@ export class Compiler extends MonacoPane { - this.fontScale.setScale(scale); - this.updateState(); - }); - - this.container.on('resize', this.resize, this); this.container.on('shown', this.resize, this); this.container.on('open', () => { this.eventHub.emit('editorOpen', this.id); }); - this.container.on('destroy', this.close, this); this.container.layoutManager.on('initialised', () => { // Once initialized, let everyone know what text we have. this.maybeEmitChange(); @@ -380,18 +373,14 @@ export class Editor extends MonacoPane { - decorations: any = {}; currentDecorations: string[] = []; // Note: bool | undef here instead of just bool because of an issue with field initialization order isCompilerSupported?: boolean; diff --git a/static/widgets/toggles.ts b/static/widgets/toggles.ts index 26643cf16..5c11cf72e 100644 --- a/static/widgets/toggles.ts +++ b/static/widgets/toggles.ts @@ -97,6 +97,10 @@ export class Toggles extends EventEmitter { return {...this.state}; } + isSet(key: string): boolean { + return key in this.state && this.state[key]; + } + set(key: string, value: boolean) { const before = this.get(); this.state[key] = value; diff --git a/types/compilation/compilation.interfaces.ts b/types/compilation/compilation.interfaces.ts index b53efec9b..198550e4e 100644 --- a/types/compilation/compilation.interfaces.ts +++ b/types/compilation/compilation.interfaces.ts @@ -58,6 +58,7 @@ export type CompilationResult = { ppOutput?: any; hasOptOutput?: boolean; + optOutput?: any; optPath?: string; hasAstOutput?: boolean; @@ -87,6 +88,8 @@ export type CompilationResult = { hasHaskellCmmOutput?: boolean; haskellCmmOutput?: any; + devices?: unknown; + forceBinaryView?: boolean; bbcdiskimage?: string; hints?: string[]; diff --git a/types/compiler.interfaces.ts b/types/compiler.interfaces.ts index 11c1883fb..62c5d43d5 100644 --- a/types/compiler.interfaces.ts +++ b/types/compiler.interfaces.ts @@ -67,7 +67,7 @@ export type CompilerInfo = { ldPath: string[]; // [env, setting][] envVars: [string, string][]; - notification: string[]; + notification: string; isSemVer: boolean; semver: string; libsArr: Library['id'][];