blob: 2fabfe99507a6965758b7e1a7afa35bbd16d8210 [file] [log] [blame] [raw]
Partoufb99cc612018-09-26 00:17:49 +02001// Copyright (c) 2018, Compiler Explorer Authors
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7// * Redistributions of source code must retain the above copyright notice,
8// this list of conditions and the following disclaimer.
9// * Redistributions in binary form must reproduce the above copyright
10// notice, this list of conditions and the following disclaimer in the
11// documentation and/or other materials provided with the distribution.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
17// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ,
22// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
23// POSSIBILITY OF SUCH DAMAGE.
24"use strict";
25
26let ClientState = require('./clientstate');
27
28class ClientStateNormalizer {
29 constructor() {
30 this.normalized = new ClientState.State();
31 }
32
33 fromGoldenLayoutContent(content) {
Partouf3fa93fa2018-09-30 11:19:26 +020034 content.forEach((component) => {
35 this.fromGoldenLayoutComponent(component);
36 });
Partoufb99cc612018-09-26 00:17:49 +020037 }
38
Partoufef42dbb2020-06-20 21:20:45 +020039 setFilterSettingsFromComponent(compiler, component) {
40 compiler.filters.binary = component.componentState.filters.binary;
41 compiler.filters.labels = component.componentState.filters.labels;
42 compiler.filters.directives = component.componentState.filters.directives;
43 compiler.filters.commentOnly = component.componentState.filters.commentOnly;
44 compiler.filters.trim = component.componentState.filters.trim;
45 compiler.filters.intel = component.componentState.filters.intel;
46 compiler.filters.demangle = component.componentState.filters.demangle;
Partoufef42dbb2020-06-20 21:20:45 +020047 }
48
Partoufb99cc612018-09-26 00:17:49 +020049 fromGoldenLayoutComponent(component) {
50 if (component.componentName === "codeEditor") {
Partouf428b09c2018-09-30 11:11:53 +020051 const session = this.normalized.findOrCreateSession(component.componentState.id);
Partoufb99cc612018-09-26 00:17:49 +020052 session.language = component.componentState.lang;
53 session.source = component.componentState.source;
54 } else if (component.componentName === "compiler") {
Partouf428b09c2018-09-30 11:11:53 +020055 const session = this.normalized.findOrCreateSession(component.componentState.source);
Partoufb99cc612018-09-26 00:17:49 +020056
Partouf428b09c2018-09-30 11:11:53 +020057 const compiler = new ClientState.Compiler();
Partoufb99cc612018-09-26 00:17:49 +020058 compiler.id = component.componentState.compiler;
59 compiler.options = component.componentState.options;
60 compiler.libs = component.componentState.libs;
Partoufef42dbb2020-06-20 21:20:45 +020061 this.setFilterSettingsFromComponent(compiler, component);
Partoufb99cc612018-09-26 00:17:49 +020062
63 session.compilers.push(compiler);
Partoufd5659af2019-09-07 17:51:54 +020064 } else if (component.componentName === "executor") {
65 const session = this.normalized.findOrCreateSession(component.componentState.source);
66
67 const executor = new ClientState.Executor();
68 executor.compiler.id = component.componentState.compiler;
69 executor.compiler.options = component.componentState.options;
70 executor.compiler.libs = component.componentState.libs;
71 executor.compilerVisible = component.componentState.compilationPanelShown;
72 executor.compilerOutputVisible = component.componentState.compilerOutShown;
73 executor.arguments = component.componentState.execArgs;
74 executor.argumentsVisible = component.componentState.argsPanelShown;
75 executor.stdin = component.componentState.execStdin;
76 executor.stdinVisible = component.componentState.stdinPanelShown;
77
78 session.executors.push(executor);
Partouf428b09c2018-09-30 11:11:53 +020079 } else if (component.componentName === "ast") {
80 const session = this.normalized.findOrCreateSession(component.componentState.editorid);
81 const compiler = session.findOrCreateCompiler(component.componentState.id);
82
83 compiler.specialoutputs.push("ast");
84 } else if (component.componentName === "opt") {
85 const session = this.normalized.findOrCreateSession(component.componentState.editorid);
86 const compiler = session.findOrCreateCompiler(component.componentState.id);
87
88 compiler.specialoutputs.push("opt");
89 } else if (component.componentName === "cfg") {
90 const session = this.normalized.findOrCreateSession(component.componentState.editorid);
91 const compiler = session.findOrCreateCompiler(component.componentState.id);
92
93 compiler.specialoutputs.push("cfg");
94 } else if (component.componentName === "gccdump") {
Partouf1b6ddc32018-09-30 11:35:41 +020095 const session = this.normalized.findOrCreateSession(component.componentState._editorid);
96 const compiler = session.findOrCreateCompiler(component.componentState._compilerid);
Partouf428b09c2018-09-30 11:11:53 +020097
98 compiler.specialoutputs.push("gccdump");
Partoufefe13272020-06-20 02:12:14 +020099 } else if (component.componentName === "output") {
100 const session = this.normalized.findOrCreateSession(component.componentState.editor);
101 const compiler = session.findOrCreateCompiler(component.componentState.compiler);
102
103 compiler.specialoutputs.push("compilerOutput");
Partouf1d24eea2018-10-14 02:15:28 +0200104 } else if (component.componentName === "conformance") {
Partoufa51ebd42018-10-14 00:39:58 +0200105 const session = this.normalized.findOrCreateSession(component.componentState.editorid);
106 session.conformanceview = new ClientState.ConformanceView(component.componentState);
Partouf7d1a83f2018-10-26 16:16:27 +0200107 } else if (component.componentName === "tool") {
108 const session = this.normalized.findOrCreateSession(component.componentState.editor);
109 const compiler = session.findOrCreateCompiler(component.componentState.compiler);
110
111 compiler.tools.push({
112 id: component.componentState.toolId,
113 args: component.componentState.args
114 });
Partoufb99cc612018-09-26 00:17:49 +0200115 } else if (component.content) {
116 this.fromGoldenLayoutContent(component.content);
117 }
118 }
119
120 fromGoldenLayout(globj) {
121 if (globj.content) {
122 this.fromGoldenLayoutContent(globj.content);
123 }
124 }
125}
126
Partoufefe13272020-06-20 02:12:14 +0200127class GoldenLayoutComponents {
128 createSourceComponent(session, customSessionId) {
129 return {
130 type: "component",
131 componentName: "codeEditor",
132 componentState: {
133 id: customSessionId ? customSessionId : session.id,
134 source: session.source,
Partouf37e93d72020-06-20 21:44:08 +0200135 lang: session.language
Partoufefe13272020-06-20 02:12:14 +0200136 },
137 isClosable: true,
138 reorderEnabled: true
139 };
140 }
141
142 createAstComponent(session, compilerIndex, customSessionId) {
143 return {
144 type: "component",
145 componentName: "ast",
146 componentState: {
147 id: compilerIndex,
148 editorid: customSessionId ? customSessionId : session.id
149 },
150 isClosable: true,
151 reorderEnabled: true
152 };
153 }
154
155 createOptComponent(session, compilerIndex, customSessionId) {
156 return {
157 type: "component",
158 componentName: "opt",
159 componentState: {
160 id: compilerIndex,
161 editorid: customSessionId ? customSessionId : session.id
162 },
163 isClosable: true,
164 reorderEnabled: true
165 };
166 }
167
168 createCfgComponent(session, compilerIndex, customSessionId) {
169 return {
170 type: "component",
171 componentName: "opt",
172 componentState: {
173 id: compilerIndex,
174 editorid: customSessionId ? customSessionId : session.id,
175 options: {
176 navigation: false,
177 physics: false
178 }
179 },
180 isClosable: true,
181 reorderEnabled: true
182 };
183 }
184
185 createGccDumpComponent(session, compilerIndex, customSessionId) {
186 return {
187 type: "component",
188 componentName: "gccdump",
189 componentState: {
190 _compilerid: compilerIndex,
191 _editorid: customSessionId ? customSessionId : session.id
192 },
193 isClosable: true,
194 reorderEnabled: true
195 };
196 }
197
198 createCompilerOutComponent(session, compilerIndex, customSessionId) {
199 return {
200 type: "component",
201 componentName: "output",
202 componentState: {
203 compiler: compilerIndex,
204 editor: customSessionId ? customSessionId : session.id,
205 wrap: false,
206 fontScale: 14
207 },
208 isClosable: true,
209 reorderEnabled: true
210 };
211 }
212
213 createToolComponent(session, compilerIndex, toolId, args, customSessionId) {
214 return {
215 type: "component",
216 componentName: "tool",
217 componentState: {
218 editor: customSessionId ? customSessionId : session.id,
219 compiler: compilerIndex,
220 toolId: toolId,
221 args: args
222 },
223 isClosable: true,
224 reorderEnabled: true
225 };
226 }
227
228 createConformanceViewComponent(session, conformanceview, customSessionId) {
229 return {
230 type: "component",
231 componentName: "conformance",
232 componentState: {
233 editorid: customSessionId ? customSessionId : session.id,
234 langId: session.language,
235 compilers: [],
236 libs: conformanceview.libs
237 },
238 isClosable: true,
239 reorderEnabled: true
240 };
241 }
242
243 createCompilerComponent(session, compiler, customSessionId) {
244 return {
245 type: "component",
246 componentName: "compiler",
247 componentState: {
248 compiler: compiler.id,
249 source: customSessionId ? customSessionId : session.id,
250 options: compiler.options,
251 filters: {
252 binary: compiler.filters.binary,
253 execute: compiler.filters.execute,
254 labels: compiler.filters.labels,
255 directives: compiler.filters.directives,
256 commentOnly: compiler.filters.commentOnly,
257 trim: compiler.filters.trim,
258 intel: compiler.filters.intel,
Partouf37e93d72020-06-20 21:44:08 +0200259 demangle: compiler.filters.demangle
Partoufefe13272020-06-20 02:12:14 +0200260 },
261 libs: compiler.libs,
262 lang: session.language
263 },
264 isClosable: true,
265 reorderEnabled: true
266 };
267 }
268
269 createExecutorComponent(session, executor, customSessionId) {
270 return {
271 type: "component",
272 componentName: "executor",
273 componentState: {
274 compiler: executor.compiler.id,
275 source: customSessionId ? customSessionId : session.id,
276 options: executor.compiler.options,
277 execArgs: executor.arguments,
278 execStdin: executor.stdin,
279 libs: executor.compiler.libs,
280 lang: session.language,
281 compilationPanelShown: executor.compilerVisible,
282 compilerOutShown: executor.compilerOutputVisible,
283 argsPanelShown: executor.argumentsVisible,
284 stdinPanelShown: executor.stdinVisible
285 },
286 isClosable: true,
287 reorderEnabled: true
288 };
289 }
290
291 createDiffComponent(left, right) {
292 return {
293 type: "component",
294 componentName: "diff",
295 componentState:
296 {
297 lhs: left,
298 rhs: right,
299 lhsdifftype: 0,
300 rhsdifftype: 0,
301 fontScale: 14
302 }
303 };
304 }
305
306 createSpecialOutputComponent(viewtype, session, idxCompiler, customSessionId) {
307 let component = null;
308 if (viewtype === "ast") {
309 component = this.createAstComponent(session, idxCompiler + 1, customSessionId);
310 } else if (viewtype === "opt") {
311 component = this.createOptComponent(session, idxCompiler + 1, customSessionId);
312 } else if (viewtype === "cfg") {
313 component = this.createCfgComponent(session, idxCompiler + 1, customSessionId);
314 } else if (viewtype === "gccdump") {
315 component = this.createGccDumpComponent(session, idxCompiler + 1, customSessionId);
316 } else if (viewtype === "compilerOutput") {
317 component = this.createCompilerOutComponent(session, idxCompiler + 1, customSessionId);
318 }
319
320 return component;
321 }
322}
323
324class ClientStateGoldenifier extends GoldenLayoutComponents {
Partoufb99cc612018-09-26 00:17:49 +0200325 constructor() {
Partoufefe13272020-06-20 02:12:14 +0200326 super();
Partoufb99cc612018-09-26 00:17:49 +0200327 this.golden = {};
328 }
329
Partouf7b5b31a2018-10-02 22:05:24 +0200330 newStackWithOneComponent(width, component) {
Partoufb99cc612018-09-26 00:17:49 +0200331 return {
332 type: "stack",
333 width: width,
Partouf7b5b31a2018-10-02 22:05:24 +0200334 content: [component]
Partouf428b09c2018-09-30 11:11:53 +0200335 };
Partouf7b5b31a2018-10-02 22:05:24 +0200336 }
337
338 newSourceStackFromSession(session, width) {
339 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200340 this.createSourceComponent(session)
Partouf7b5b31a2018-10-02 22:05:24 +0200341 );
Partouf428b09c2018-09-30 11:11:53 +0200342 }
343
Partoufefe13272020-06-20 02:12:14 +0200344 newAstStackFromCompiler(session, compilerIndex, width) {
Partouf7b5b31a2018-10-02 22:05:24 +0200345 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200346 this.createAstComponent(session, compilerIndex)
Partouf7b5b31a2018-10-02 22:05:24 +0200347 );
Partouf428b09c2018-09-30 11:11:53 +0200348 }
349
Partoufefe13272020-06-20 02:12:14 +0200350 newOptStackFromCompiler(session, compilerIndex, width) {
Partouf7b5b31a2018-10-02 22:05:24 +0200351 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200352 this.createOptComponent(session, compilerIndex)
Partouf7b5b31a2018-10-02 22:05:24 +0200353 );
Partouf428b09c2018-09-30 11:11:53 +0200354 }
355
Partoufefe13272020-06-20 02:12:14 +0200356 newCfgStackFromCompiler(session, compilerIndex, width) {
Partouf7b5b31a2018-10-02 22:05:24 +0200357 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200358 this.createCfgComponent(session, compilerIndex)
Partouf7b5b31a2018-10-02 22:05:24 +0200359 );
Partouf428b09c2018-09-30 11:11:53 +0200360 }
361
Partoufefe13272020-06-20 02:12:14 +0200362 newGccDumpStackFromCompiler(session, compilerIndex, width) {
Partouf7b5b31a2018-10-02 22:05:24 +0200363 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200364 this.createGccDumpComponent(session, compilerIndex)
Partouf7d1a83f2018-10-26 16:16:27 +0200365 );
366 }
367
Partoufefe13272020-06-20 02:12:14 +0200368 newCompilerOutStackFromCompiler(session, compilerIndex, width) {
Partouf7d1a83f2018-10-26 16:16:27 +0200369 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200370 this.createCompilerOutComponent(session, compilerIndex)
371 );
372 }
373
374 newToolStackFromCompiler(session, compilerIndex, toolId, args, width) {
375 return this.newStackWithOneComponent(width,
376 this.createToolComponent(session, compilerIndex, toolId, args)
Partouf7b5b31a2018-10-02 22:05:24 +0200377 );
Partoufb99cc612018-09-26 00:17:49 +0200378 }
379
Partoufa51ebd42018-10-14 00:39:58 +0200380 newConformanceViewStack(session, width, conformanceview) {
381 const stack = this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200382 this.createConformanceViewComponent(session, conformanceview)
Partoufa51ebd42018-10-14 00:39:58 +0200383 );
384
385 conformanceview.compilers.forEach((compiler) => {
386 const compjson = {
387 compilerId: compiler.id,
388 options: compiler.options
389 };
390
391 stack.content[0].componentState.compilers.push(compjson);
392 });
393
394 return stack;
395 }
396
Partoufb99cc612018-09-26 00:17:49 +0200397 newCompilerStackFromSession(session, compiler, width) {
Partouf7b5b31a2018-10-02 22:05:24 +0200398 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200399 this.createCompilerComponent(session, compiler)
Partouf7b5b31a2018-10-02 22:05:24 +0200400 );
Partouf7583df92020-06-18 23:19:45 +0200401 }
402
Partoufd5659af2019-09-07 17:51:54 +0200403 newExecutorStackFromSession(session, executor, width) {
404 return this.newStackWithOneComponent(width,
Partoufefe13272020-06-20 02:12:14 +0200405 this.createExecutorComponent(session, executor)
Partoufd5659af2019-09-07 17:51:54 +0200406 );
Partoufb99cc612018-09-26 00:17:49 +0200407 }
408
Partouf70871822020-06-18 20:53:04 +0200409 createSourceContentArray(state, left, right) {
410 if (left.session === right.session) {
411 return [this.createPresentationModeComponents(state.sessions[left.session], 1, 100)];
412 } else {
413 return [
414 this.createPresentationModeComponents(state.sessions[left.session], 1),
415 this.createPresentationModeComponents(state.sessions[right.session], 2)
416 ];
417 }
418 }
419
420 getPresentationModeEmptyLayout() {
421 return {
422 settings: {
423 hasHeaders: true,
424 constrainDragToContainer: false,
425 reorderEnabled: true,
426 selectionEnabled: false,
427 popoutWholeStack: false,
428 blockedPopoutsThrowError: true,
429 closePopoutsOnUnload: true,
430 showPopoutIcon: false,
431 showMaximiseIcon: true,
432 showCloseIcon: false,
433 responsiveMode: "onload",
434 tabOverlapAllowance: 0,
435 reorderOnTabMenuClick: true,
436 tabControlOffset: 10
437 },
438 dimensions:
439 {
440 borderWidth: 5,
441 borderGrabWidth: 15,
442 minItemHeight: 10,
443 minItemWidth: 10,
444 headerHeight: 20,
445 dragProxyWidth: 300,
446 dragProxyHeight: 200
447 },
448 labels:
449 {
450 close: "close",
451 maximise: "maximise",
452 minimise: "minimise",
453 popout: "open in new window",
454 popin: "pop in",
455 tabDropdown: "additional tabs"
456 },
457 content: [
458 {
459 type: "column",
460 content: []
461 }
462 ]
463 };
464 }
465
466 getPresentationModeLayoutForSource(state, left) {
467 const gl = this.getPresentationModeEmptyLayout();
468 gl.content[0].content = [
469 {
470 type: "column",
471 width: 100,
472 content: this.createSourceContentArray(state, left, left)
473 }];
474
475 return gl;
476 }
477
Partouf70871822020-06-18 20:53:04 +0200478 getPresentationModeLayoutForComparisonSlide(state, left, right) {
479 const gl = this.getPresentationModeEmptyLayout();
480 gl.content[0].content = [
481 {
482 type: "row",
483 height: 50,
484 content: this.createSourceContentArray(state, left, right)
485 },
486 {
487 type: "row",
488 height: 50,
489 content: [
490 {
491 type: "stack",
492 width: 100,
493 content: [
Partoufefe13272020-06-20 02:12:14 +0200494 this.createDiffComponent(left.compiler + 1, right.compiler + 1)
Partouf70871822020-06-18 20:53:04 +0200495 ]
496 }
497 ]
498 }
499 ];
500
501 return gl;
502 }
503
Partoufefe13272020-06-20 02:12:14 +0200504 createPresentationModeComponents(session, customSessionId, customWidth) {
505 const stack = {
Partouf70871822020-06-18 20:53:04 +0200506 type: "stack",
507 width: customWidth ? customWidth : 50,
508 activeItemIndex: 0,
509 content: [
Partoufefe13272020-06-20 02:12:14 +0200510 this.createSourceComponent(session, customSessionId)
Partouf70871822020-06-18 20:53:04 +0200511 ]
512 };
513
Partoufefe13272020-06-20 02:12:14 +0200514 for (let idxCompiler = 0; idxCompiler < session.compilers.length; idxCompiler++) {
515 const compiler = session.compilers[idxCompiler];
Partouf70871822020-06-18 20:53:04 +0200516 stack.content.push(
Partoufefe13272020-06-20 02:12:14 +0200517 this.createCompilerComponent(session, compiler, customSessionId)
Partouf70871822020-06-18 20:53:04 +0200518 );
Partoufefe13272020-06-20 02:12:14 +0200519
520 compiler.specialoutputs.forEach((viewtype) => {
521 stack.content.push(
522 this.createSpecialOutputComponent(viewtype, session, idxCompiler, customSessionId)
523 );
524 });
525
526 compiler.tools.forEach((tool) => {
527 stack.content.push(
528 this.createToolComponent(session, idxCompiler + 1, tool.id, tool.args, customSessionId)
529 );
530 });
Partouf70871822020-06-18 20:53:04 +0200531 }
532
Partouf7583df92020-06-18 23:19:45 +0200533 for (let idxExecutor = 0; idxExecutor < session.executors.length; idxExecutor++) {
534 stack.content.push(
Partoufefe13272020-06-20 02:12:14 +0200535 this.createExecutorComponent(session, session.executors[idxExecutor], customSessionId)
Partouf7583df92020-06-18 23:19:45 +0200536 );
537 }
538
Partouf70871822020-06-18 20:53:04 +0200539 return stack;
540 }
541
542 generatePresentationModeMobileViewerSlides(state) {
543 const slides = [];
544
545 for (var idxSession = 0; idxSession < state.sessions.length; idxSession++) {
Partoufefe13272020-06-20 02:12:14 +0200546 const gl = this.getPresentationModeLayoutForSource(state, {
547 session: idxSession,
548 compiler: 0
549 });
Partouf70871822020-06-18 20:53:04 +0200550 slides.push(gl);
551 }
552
553 return slides;
554 }
555
Partoufb99cc612018-09-26 00:17:49 +0200556 fromClientState(state) {
557 this.golden = {
558 settings: {
559 hasHeaders: true,
560 constrainDragToContainer: false,
561 reorderEnabled: true,
562 selectionEnabled: false,
563 popoutWholeStack: false,
564 blockedPopoutsThrowError: true,
565 closePopoutsOnUnload: true,
566 showPopoutIcon: false,
567 showMaximiseIcon: true,
568 showCloseIcon: true,
569 responsiveMode: "onload",
570 tabOverlapAllowance: 0,
571 reorderOnTabMenuClick: true,
572 tabControlOffset: 10
573 },
574 dimensions: {
575 borderWidth: 5,
576 borderGrabWidth: 15,
577 minItemHeight: 10,
578 minItemWidth: 10,
579 headerHeight: 20,
580 dragProxyWidth: 300,
581 dragProxyHeight: 200
582 },
583 labels: {
584 close: "close",
585 maximise: "maximise",
586 minimise: "minimise",
587 popout: "open in new window",
588 popin: "pop in",
589 tabDropdown: "additional tabs"
590 },
591 content: [
592 {
593 type: "row",
594 content: [
595 ]
596 }
597 ]
598 };
599
600 if (state.sessions.length > 1) {
601 const sessionWidth = 100.0 / state.sessions.length;
Partoufefe13272020-06-20 02:12:14 +0200602
Partoufb99cc612018-09-26 00:17:49 +0200603 for (let idxSession = 0; idxSession < state.sessions.length; idxSession++) {
604 const session = state.sessions[idxSession];
605
606 this.golden.content[0].content[idxSession] = {
607 type: "column",
608 isClosable: true,
609 reorderEnabled: true,
610 width: sessionWidth,
611 content: [
612 {
613 type: "row",
614 content: [
615 ]
616 },
617 {
618 type: "row",
619 content: [
620 ]
621 }
622 ]
623 };
Partoufefe13272020-06-20 02:12:14 +0200624
Partoufde6d3552018-10-01 19:24:19 +0200625 let stack = this.newSourceStackFromSession(session, 100.0);
626 this.golden.content[0].content[idxSession].content[0].content.push(stack);
Partoufb99cc612018-09-26 00:17:49 +0200627
Partouf7d1a83f2018-10-26 16:16:27 +0200628 const compilerWidth = 100.0 /
Partoufd5659af2019-09-07 17:51:54 +0200629 (1 + session.compilers.length + session.executors.length +
630 session.countNumberOfSpecialOutputsAndTools());
631
Partoufa51ebd42018-10-14 00:39:58 +0200632 if (session.conformanceview) {
633 const stack = this.newConformanceViewStack(session, compilerWidth, session.conformanceview);
634 this.golden.content[0].content[idxSession].content[1].content.push(stack);
635 }
636
637 for (let idxCompiler = 0; idxCompiler < session.compilers.length; idxCompiler++) {
638 const compiler = session.compilers[idxCompiler];
Partoufde6d3552018-10-01 19:24:19 +0200639 let stack = this.newCompilerStackFromSession(session, compiler, compilerWidth);
640 this.golden.content[0].content[idxSession].content[1].content.push(stack);
Partoufefe13272020-06-20 02:12:14 +0200641
Partoufa51ebd42018-10-14 00:39:58 +0200642 compiler.specialoutputs.forEach((viewtype) => {
Partoufefe13272020-06-20 02:12:14 +0200643 let stack = this.newStackWithOneComponent(compilerWidth,
644 this.createSpecialOutputComponent(viewtype, session, idxCompiler));
645
Partoufa51ebd42018-10-14 00:39:58 +0200646 if (stack) {
647 this.golden.content[0].content[idxSession].content[1].content.push(stack);
648 }
649 });
Partouf7d1a83f2018-10-26 16:16:27 +0200650
651 compiler.tools.forEach((tool) => {
Partoufefe13272020-06-20 02:12:14 +0200652 let stack = this.newToolStackFromCompiler(session, idxCompiler + 1,
Partouf7d1a83f2018-10-26 16:16:27 +0200653 tool.id, tool.args, compilerWidth);
654 this.golden.content[0].content[idxSession].content[1].content.push(stack);
655 });
Partoufa51ebd42018-10-14 00:39:58 +0200656 }
Partoufd5659af2019-09-07 17:51:54 +0200657
658 for (let idxExecutor = 0; idxExecutor < session.executors.length; idxExecutor++) {
659 const executor = session.executors[idxExecutor];
660 let stack = this.newExecutorStackFromSession(session, executor, compilerWidth);
661 this.golden.content[0].content[idxSession].content[1].content.push(stack);
662 }
Partoufb99cc612018-09-26 00:17:49 +0200663 }
664 } else if (state.sessions.length === 1) {
665 const session = state.sessions[0];
666 this.golden.content[0] = {
667 type: "row",
668 content: [
669 ]
670 };
671
Partoufd5659af2019-09-07 17:51:54 +0200672 const width = 100.0 / (1 + session.compilers.length + session.executors.length +
673 session.countNumberOfSpecialOutputsAndTools());
Partoufb99cc612018-09-26 00:17:49 +0200674 this.golden.content[0].content.push(this.newSourceStackFromSession(session, width));
675
Partoufa51ebd42018-10-14 00:39:58 +0200676 if (session.conformanceview) {
677 const stack = this.newConformanceViewStack(session, width, session.conformanceview);
678 this.golden.content[0].content.push(stack);
679 }
680
Partoufb99cc612018-09-26 00:17:49 +0200681 for (let idxCompiler = 0; idxCompiler < session.compilers.length; idxCompiler++) {
Partouf428b09c2018-09-30 11:11:53 +0200682 const compiler = session.compilers[idxCompiler];
Partoufde6d3552018-10-01 19:24:19 +0200683 let stack = this.newCompilerStackFromSession(session, compiler, width);
684 this.golden.content[0].content.push(stack);
Partouf428b09c2018-09-30 11:11:53 +0200685
686 compiler.specialoutputs.forEach((viewtype) => {
Partoufefe13272020-06-20 02:12:14 +0200687 let stack = this.newStackWithOneComponent(width,
688 this.createSpecialOutputComponent(viewtype, session, idxCompiler));
Partoufde6d3552018-10-01 19:24:19 +0200689
690 if (stack) {
691 this.golden.content[0].content.push(stack);
Partouf428b09c2018-09-30 11:11:53 +0200692 }
693 });
Partouf7d1a83f2018-10-26 16:16:27 +0200694
695 compiler.tools.forEach((tool) => {
696 let stack = this.newToolStackFromCompiler(session, compiler, idxCompiler + 1,
697 tool.id, tool.args, width);
698 this.golden.content[0].content.push(stack);
699 });
Partoufb99cc612018-09-26 00:17:49 +0200700 }
Partoufd5659af2019-09-07 17:51:54 +0200701
702 session.executors.forEach((executor) => {
703 let stack = this.newExecutorStackFromSession(session, executor, width);
704 this.golden.content[0].content.push(stack);
705 });
Partoufb99cc612018-09-26 00:17:49 +0200706 }
707 }
708}
709
710module.exports = {
711 ClientStateNormalizer: ClientStateNormalizer,
712 ClientStateGoldenifier: ClientStateGoldenifier
713};