Skip to content

Commit d5659af

Browse files
committed
add executor to clientstate
1 parent 097bf48 commit d5659af

8 files changed

+313
-7
lines changed

lib/clientstate-normalizer.js

+55-3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ class ClientStateNormalizer {
5757
compiler.filters.demangle = component.componentState.filters.demangle;
5858

5959
session.compilers.push(compiler);
60+
} else if (component.componentName === "executor") {
61+
const session = this.normalized.findOrCreateSession(component.componentState.source);
62+
63+
const executor = new ClientState.Executor();
64+
executor.compiler.id = component.componentState.compiler;
65+
executor.compiler.options = component.componentState.options;
66+
executor.compiler.libs = component.componentState.libs;
67+
executor.compilerVisible = component.componentState.compilationPanelShown;
68+
executor.compilerOutputVisible = component.componentState.compilerOutShown;
69+
executor.arguments = component.componentState.execArgs;
70+
executor.argumentsVisible = component.componentState.argsPanelShown;
71+
executor.stdin = component.componentState.execStdin;
72+
executor.stdinVisible = component.componentState.stdinPanelShown;
73+
74+
session.executors.push(executor);
6075
} else if (component.componentName === "ast") {
6176
const session = this.normalized.findOrCreateSession(component.componentState.editorid);
6277
const compiler = session.findOrCreateCompiler(component.componentState.id);
@@ -266,6 +281,30 @@ class ClientStateGoldenifier {
266281
);
267282
}
268283

284+
newExecutorStackFromSession(session, executor, width) {
285+
return this.newStackWithOneComponent(width,
286+
{
287+
type: "component",
288+
componentName: "executor",
289+
componentState: {
290+
compiler: executor.compiler.id,
291+
source: session.id,
292+
options: executor.compiler.options,
293+
execArgs: executor.arguments,
294+
execStdin: executor.stdin,
295+
libs: executor.compiler.libs,
296+
lang: session.language,
297+
compilationPanelShown: executor.compilerVisible,
298+
compilerOutShown: executor.compilerOutputVisible,
299+
argsPanelShown: executor.argumentsVisible,
300+
stdinPanelShown: executor.stdinVisible
301+
},
302+
isClosable: true,
303+
reorderEnabled: true
304+
}
305+
);
306+
}
307+
269308
newSpecialOutputStack(viewtype, session, compiler, idxCompiler, compilerWidth) {
270309
let stack = null;
271310
if (viewtype === "ast") {
@@ -354,8 +393,9 @@ class ClientStateGoldenifier {
354393
this.golden.content[0].content[idxSession].content[0].content.push(stack);
355394

356395
const compilerWidth = 100.0 /
357-
(1 + session.compilers.length + session.countNumberOfSpecialOutputsAndTools());
358-
396+
(1 + session.compilers.length + session.executors.length +
397+
session.countNumberOfSpecialOutputsAndTools());
398+
359399
if (session.conformanceview) {
360400
const stack = this.newConformanceViewStack(session, compilerWidth, session.conformanceview);
361401
this.golden.content[0].content[idxSession].content[1].content.push(stack);
@@ -380,6 +420,12 @@ class ClientStateGoldenifier {
380420
this.golden.content[0].content[idxSession].content[1].content.push(stack);
381421
});
382422
}
423+
424+
for (let idxExecutor = 0; idxExecutor < session.executors.length; idxExecutor++) {
425+
const executor = session.executors[idxExecutor];
426+
let stack = this.newExecutorStackFromSession(session, executor, compilerWidth);
427+
this.golden.content[0].content[idxSession].content[1].content.push(stack);
428+
}
383429
}
384430
} else if (state.sessions.length === 1) {
385431
const session = state.sessions[0];
@@ -389,7 +435,8 @@ class ClientStateGoldenifier {
389435
]
390436
};
391437

392-
const width = 100.0 / (1 + session.compilers.length + session.countNumberOfSpecialOutputsAndTools());
438+
const width = 100.0 / (1 + session.compilers.length + session.executors.length +
439+
session.countNumberOfSpecialOutputsAndTools());
393440
this.golden.content[0].content.push(this.newSourceStackFromSession(session, width));
394441

395442
if (session.conformanceview) {
@@ -416,6 +463,11 @@ class ClientStateGoldenifier {
416463
this.golden.content[0].content.push(stack);
417464
});
418465
}
466+
467+
session.executors.forEach((executor) => {
468+
let stack = this.newExecutorStackFromSession(session, executor, width);
469+
this.golden.content[0].content.push(stack);
470+
});
419471
}
420472
}
421473
}

lib/clientstate.js

+35
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,39 @@ class ClientStateCompiler {
9393
}
9494
}
9595

96+
class ClientStateExecutor {
97+
constructor(jsondata) {
98+
if (jsondata) {
99+
this.fromJsonData(jsondata);
100+
} else {
101+
this.compiler = new ClientStateCompiler();
102+
this.compilerVisible = false;
103+
this.compilerOutputVisible = false;
104+
this.arguments = [];
105+
this.argumentsVisible = false;
106+
this.stdin = "";
107+
this.stdinVisible = false;
108+
}
109+
}
110+
111+
fromJsonData(jsondata) {
112+
if (typeof jsondata.compilerVisible !== 'undefined')
113+
this.compilerVisible = jsondata.compilerVisible;
114+
if (typeof jsondata.compilerOutputVisible !== 'undefined')
115+
this.compilerOutputVisible = jsondata.compilerOutputVisible;
116+
if (typeof jsondata.arguments !== 'undefined')
117+
this.arguments = jsondata.arguments;
118+
if (typeof jsondata.argumentsVisible !== 'undefined')
119+
this.argumentsVisible = jsondata.argumentsVisible;
120+
if (typeof jsondata.stdin !== 'undefined')
121+
this.stdin = jsondata.stdin;
122+
if (typeof jsondata.stdinVisible !== 'undefined')
123+
this.stdinVisible = jsondata.stdinVisible;
124+
125+
this.compiler = new ClientStateCompiler(JSON.stringify(jsondata.compiler));
126+
}
127+
}
128+
96129
class ClientStateConformanceView {
97130
constructor(jsondata) {
98131
this.libs = [];
@@ -116,6 +149,7 @@ class ClientStateSession {
116149
this.source = "";
117150
this.conformanceview = false;
118151
this.compilers = [];
152+
this.executors = [];
119153

120154
if (jsondata) this.fromJsonData(jsondata);
121155
}
@@ -201,6 +235,7 @@ module.exports = {
201235
State: ClientState,
202236
Session: ClientStateSession,
203237
Compiler: ClientStateCompiler,
238+
Executor: ClientStateExecutor,
204239
CompilerOptions: ClientStateCompilerOptions,
205240
ConformanceView: ClientStateConformanceView
206241
};

test/state/andthekitchensink.json.normalized

+2-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@
4646
],
4747
"tools": []
4848
}
49-
]
49+
],
50+
"executors": []
5051
}
5152
]
5253
}

test/state/conformanceview.json.normalized

+2-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@
9595
"specialoutputs": [],
9696
"tools": []
9797
}
98-
]
98+
],
99+
"executors": []
99100
}
100101
]
101102
}

test/state/executor.json

+142
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
{
2+
"settings": {
3+
"hasHeaders": true,
4+
"constrainDragToContainer": false,
5+
"reorderEnabled": true,
6+
"selectionEnabled": false,
7+
"popoutWholeStack": false,
8+
"blockedPopoutsThrowError": true,
9+
"closePopoutsOnUnload": true,
10+
"showPopoutIcon": false,
11+
"showMaximiseIcon": true,
12+
"showCloseIcon": true,
13+
"responsiveMode": "onload",
14+
"tabOverlapAllowance": 0,
15+
"reorderOnTabMenuClick": true,
16+
"tabControlOffset": 10
17+
},
18+
"dimensions": {
19+
"borderWidth": 5,
20+
"borderGrabWidth": 15,
21+
"minItemHeight": 10,
22+
"minItemWidth": 10,
23+
"headerHeight": 20,
24+
"dragProxyWidth": 300,
25+
"dragProxyHeight": 200
26+
},
27+
"labels": {
28+
"close": "close",
29+
"maximise": "maximise",
30+
"minimise": "minimise",
31+
"popout": "open in new window",
32+
"popin": "pop in",
33+
"tabDropdown": "additional tabs"
34+
},
35+
"content": [
36+
{
37+
"type": "row",
38+
"isClosable": true,
39+
"reorderEnabled": true,
40+
"title": "",
41+
"content": [
42+
{
43+
"type": "stack",
44+
"width": 33.333333333333336,
45+
"isClosable": true,
46+
"reorderEnabled": true,
47+
"title": "",
48+
"activeItemIndex": 0,
49+
"content": [
50+
{
51+
"type": "component",
52+
"componentName": "codeEditor",
53+
"componentState": {
54+
"id": 1,
55+
"source": "// Type your code here, or load an example.\nint square(int num) {\n auto x = 344 + 5 + 1;\n return num * num + 234 + x;\n}\n\nint main() {\n return square(23);\n}\n",
56+
"lang": "c++"
57+
},
58+
"isClosable": true,
59+
"reorderEnabled": true,
60+
"title": "C++ source #1"
61+
}
62+
]
63+
},
64+
{
65+
"type": "stack",
66+
"width": 33.333333333333336,
67+
"isClosable": true,
68+
"reorderEnabled": true,
69+
"title": "",
70+
"activeItemIndex": 0,
71+
"content": [
72+
{
73+
"type": "component",
74+
"componentName": "compiler",
75+
"componentState": {
76+
"compiler": "g92",
77+
"source": 1,
78+
"options": "-O3",
79+
"filters": {
80+
"binary": false,
81+
"execute": false,
82+
"labels": true,
83+
"libraryCode": false,
84+
"directives": true,
85+
"commentOnly": true,
86+
"trim": false,
87+
"intel": true,
88+
"demangle": true
89+
},
90+
"libs": [],
91+
"lang": "c++"
92+
},
93+
"isClosable": true,
94+
"reorderEnabled": true,
95+
"title": "x86-64 gcc 9.2 (Editor #1, Compiler #1) C++"
96+
}
97+
]
98+
},
99+
{
100+
"type": "stack",
101+
"width": 33.33333333333333,
102+
"isClosable": true,
103+
"reorderEnabled": true,
104+
"title": "",
105+
"activeItemIndex": 0,
106+
"content": [
107+
{
108+
"type": "component",
109+
"componentName": "executor",
110+
"componentState": {
111+
"compiler": "g92",
112+
"source": 1,
113+
"options": "-O3",
114+
"execArgs": "test",
115+
"execStdin": "",
116+
"libs": [
117+
{
118+
"name": "openssl",
119+
"ver": "111c"
120+
}
121+
],
122+
"lang": "c++",
123+
"compilationPanelShown": false,
124+
"compilerOutShown": true,
125+
"argsPanelShown": true,
126+
"stdinPanelShown": false
127+
},
128+
"isClosable": true,
129+
"reorderEnabled": true,
130+
"title": "x86-64 gcc 9.2 Executor (Editor #1) C++"
131+
}
132+
]
133+
}
134+
]
135+
}
136+
],
137+
"isClosable": true,
138+
"reorderEnabled": true,
139+
"title": "",
140+
"openPopouts": [],
141+
"maximisedItemId": null
142+
}

test/state/executor.json.normalized

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
{
2+
"sessions": [
3+
{
4+
"id": 1,
5+
"language": "c++",
6+
"source": "// Type your code here, or load an example.\nint square(int num) {\n auto x = 344 + 5 + 1;\n return num * num + 234 + x;\n}\n\nint main() {\n return square(23);\n}\n",
7+
"compilers": [
8+
{
9+
"filters": {
10+
"binary": false,
11+
"commentOnly": true,
12+
"demangle": true,
13+
"directives": true,
14+
"execute": false,
15+
"intel": true,
16+
"labels": true,
17+
"trim": false
18+
},
19+
"id": "g92",
20+
"libs": [],
21+
"options": "-O3",
22+
"specialoutputs": [],
23+
"tools": []
24+
}
25+
],
26+
"conformanceview": false,
27+
"executors": [
28+
{
29+
"arguments": "test",
30+
"argumentsVisible": true,
31+
"compiler": {
32+
"id": "g92",
33+
"libs": [
34+
{
35+
"name": "openssl",
36+
"ver": "111c"
37+
}
38+
],
39+
"options": "-O3",
40+
"specialoutputs": [],
41+
"tools": [],
42+
"filters": {
43+
"binary": false,
44+
"commentOnly": true,
45+
"demangle": true,
46+
"directives": true,
47+
"execute": false,
48+
"intel": true,
49+
"labels": true,
50+
"trim": false
51+
}
52+
},
53+
"compilerOutputVisible": true,
54+
"compilerVisible": false,
55+
"stdin": "",
56+
"stdinVisible": false
57+
}
58+
]
59+
}
60+
]
61+
}

0 commit comments

Comments
 (0)