Skip to content

Commit 70c2a28

Browse files
committed
started simplifying java frontend code
1 parent 3377cb4 commit 70c2a28

3 files changed

Lines changed: 31 additions & 33 deletions

File tree

‎tests/frontend-regression-tests/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ micro:
1010
@casperjs test --concise test-micro.js
1111

1212
java:
13-
@casperjs test --concise test-java.js
13+
@casperjs test test-java.js
1414

1515
verbose:
1616
@casperjs test test-micro.js

‎v5-unity/js/opt-frontend.ts‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,25 @@
22
// Copyright (C) Philip Guo (philip@pgbovine.net)
33
// LICENSE: https://github.com/pgbovine/OnlinePythonTutor/blob/master/LICENSE.txt
44

5-
// TODOs:
6-
// qtip doesn't work with Webpack, so experimentalPopUpSyntaxErrorSurvey DOESN'T WORK
7-
// deactivate it for now
8-
//require('./lib/jquery.qtip.min.js');
9-
//require('../css/jquery.qtip.css');
5+
/* TODO:
6+
7+
- parse Java viz_options in users' java code:
8+
https://github.com/daveagp/java_visualize/blob/1489078712310eda44391f09405e0f71b2b190c9/jv-frontend.js#L101
9+
10+
- implement other missing Java functionality while i'm at it :0
11+
- also implement these options and stdin support too:
12+
var optionNames = ['showStringsAsObjects', 'showAllFields', 'disableNesting'];
13+
14+
[probably do this in the FRONTEND and not in pytutor.js]
15+
16+
- qtip doesn't work with Webpack, so experimentalPopUpSyntaxErrorSurvey
17+
DOESN'T WORK deactivate it for now
18+
19+
require('./lib/jquery.qtip.min.js');
20+
require('../css/jquery.qtip.css');
21+
22+
*/
23+
1024
var activateSyntaxErrorSurvey = false; // true;
1125

1226
// a list of previous consecutive executions with "compile"-time exceptions

‎v5-unity/js/pytutor.ts‎

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,6 @@
77
- substitute in a non-live version of the live editor from opt-live.js
88
in addition to the janky current version of the editor
99
10-
- test Java after massive refactorings
11-
12-
- parse Java viz_options in users' java code:
13-
https://github.com/daveagp/java_visualize/blob/1489078712310eda44391f09405e0f71b2b190c9/jv-frontend.js#L101
14-
15-
- implement other missing Java functionality while i'm at it :0
16-
- also implement these options and stdin support too:
17-
var optionNames = ['showStringsAsObjects', 'showAllFields', 'disableNesting'];
18-
19-
[probably do this in the FRONTEND and not in pytutor.js]
20-
2110
*/
2211

2312

@@ -735,18 +724,7 @@ export class ExecutionVisualizer {
735724
function(args) {
736725
var obj = args.obj, d3DomElement = args.d3DomElement;
737726
var typ = typeof obj;
738-
// TODO: can probably simplify with default handling and getRealLabel:
739-
if (obj == null)
740-
d3DomElement.append('<span class="nullObj">null</span>');
741-
else if (typ == "number")
742-
d3DomElement.append('<span class="numberObj">' + obj + '</span>');
743-
else if (typ == "boolean") {
744-
if (obj)
745-
d3DomElement.append('<span class="boolObj">true</span>');
746-
else
747-
d3DomElement.append('<span class="boolObj">false</span>');
748-
}
749-
else if (obj instanceof Array && obj[0] == "VOID") {
727+
if (obj instanceof Array && obj[0] == "VOID") {
750728
d3DomElement.append('<span class="voidObj">void</span>');
751729
}
752730
else if (obj instanceof Array && obj[0] == "NUMBER-LITERAL") {
@@ -1176,9 +1154,7 @@ class DataVisualizer {
11761154
} else if (label === 'set') {
11771155
return 'Set';
11781156
}
1179-
}
1180-
1181-
if (this.params.lang === 'ruby') {
1157+
} else if (this.params.lang === 'ruby') {
11821158
if (label === 'dict') {
11831159
return 'hash';
11841160
} else if (label === 'set') {
@@ -1190,9 +1166,17 @@ class DataVisualizer {
11901166
} else if (label === 'Global frame') {
11911167
return 'Global Object';
11921168
}
1169+
} else if (this.params.lang === 'java') {
1170+
if (label === 'None') {
1171+
return 'null';
1172+
} else if (label === 'True') {
1173+
return 'true';
1174+
} else if (label === 'False') {
1175+
return 'false';
1176+
}
11931177
}
11941178

1195-
// default fallthrough case
1179+
// default fallthrough case if no matches above
11961180
return label;
11971181
}
11981182

0 commit comments

Comments
 (0)