aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/options.interfaces.ts9
-rw-r--r--static/panes/compiler.ts43
2 files changed, 30 insertions, 22 deletions
diff --git a/static/options.interfaces.ts b/static/options.interfaces.ts
index a1d6bf60e..374273552 100644
--- a/static/options.interfaces.ts
+++ b/static/options.interfaces.ts
@@ -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';
+import {Language, LanguageKey} from '../types/languages.interfaces';
import {CompilerInfo} from '../types/compiler.interfaces';
export type LibraryVersion = {
@@ -51,12 +51,13 @@ export type LibsPerRemote = Record<string, LanguageLibs>;
export type Options = {
libs: Libs;
remoteLibs: LibsPerRemote;
- languages: Record<string, Language>;
+ languages: Record<LanguageKey, Language>;
compilers: CompilerInfo[];
- defaultCompiler: Record<string, string>;
- defaultLibs: Record<string, string | null>;
+ defaultCompiler: Record<LanguageKey, string>;
+ defaultLibs: Record<LanguageKey, string | null>;
defaultFontScale: number;
sentryDsn?: string;
release?: string;
sentryEnvironment?: string;
+ compileOptions: Record<LanguageKey, string>
};
diff --git a/static/panes/compiler.ts b/static/panes/compiler.ts
index 0924fb652..eaf08c114 100644
--- a/static/panes/compiler.ts
+++ b/static/panes/compiler.ts
@@ -195,7 +195,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
private compilerService: CompilerService;
private readonly id: number;
private sourceTreeId: number | null;
- private readonly sourceEditorId: number | null;
+ private sourceEditorId: number | null;
private originalCompilerId: string;
private readonly infoByLang: Record<string, {compiler: string; options: string}>;
private deferCompiles: boolean;
@@ -314,23 +314,15 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
// eslint-disable-next-line max-statements
constructor(hub: Hub, container: Container, state: MonacoPaneState & CompilerState) {
super(hub, container, state);
- this.compilerService = hub.compilerService;
- this.id = state.id || hub.nextCompilerId();
- this.sourceTreeId = state.tree ? state.tree : null;
- if (this.sourceTreeId) {
- this.sourceEditorId = null;
- } else {
- this.sourceEditorId = state.source || 1;
- }
+ this.id = state.id || hub.nextCompilerId();
this.settings = Settings.getStoredSettings();
- this.originalCompilerId = state.compiler;
- this.initLangAndCompiler(state);
+
this.infoByLang = {};
this.deferCompiles = hub.deferred;
this.needsCompile = false;
- this.deviceViewOpen = !!state.deviceViewOpen;
- this.options = state.options || (options.compileOptions as any)[this.currentLangId ?? ''];
+ this.initLangAndCompiler(state);
+
this.source = '';
this.assembly = [];
this.colours = [];
@@ -342,9 +334,9 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
this.nextRequest = null;
this.nextCMakeRequest = null;
this.optViewOpen = false;
- this.flagsViewOpen = state.flagsViewOpen || false;
+
this.cfgViewOpen = false;
- this.wantOptInfo = state.wantOptInfo;
+
this.decorations = {
labelUsages: [],
};
@@ -354,7 +346,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
this.alertSystem.prefixMessage = 'Compiler #' + this.id;
this.awaitingInitialResults = false;
- this.selection = state.selection;
+
this.linkedFadeTimeoutId = null;
this.toolsMenu = null;
@@ -371,9 +363,7 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
this.compiler?.id ?? '',
this.onCompilerChange.bind(this)
);
-
this.initLibraries(state);
-
// MonacoPane's registerCallbacks is not called late enough either
this.initCallbacks();
// Handle initial settings
@@ -388,6 +378,23 @@ export class Compiler extends MonacoPane<monaco.editor.IStandaloneCodeEditor, Co
}
}
+ override initializeStateDependentProperties(state: MonacoPaneState & CompilerState) {
+ this.compilerService = this.hub.compilerService;
+ this.sourceTreeId = state.tree ? state.tree : null;
+ if (this.sourceTreeId) {
+ this.sourceEditorId = null;
+ } else {
+ this.sourceEditorId = state.source || 1;
+ }
+ this.options = state.options || (options.compileOptions[this.currentLangId ?? ''] ?? '');
+
+ this.deviceViewOpen = !!state.deviceViewOpen;
+ this.flagsViewOpen = state.flagsViewOpen || false;
+ this.wantOptInfo = state.wantOptInfo;
+ this.originalCompilerId = state.compiler;
+ this.selection = state.selection;
+ }
+
override getInitialHTML() {
return $('#compiler').html();
}