Skip to content

Commit a36d370

Browse files
committed
yay
1 parent 17b8299 commit a36d370

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎v4-cokapi/cokapi.js‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,20 +146,30 @@ function exec_js_handler(useJSONP /* use bind first */, req, res) {
146146
app.get('/exec_java', exec_java_handler.bind(null, false));
147147
app.get('/exec_java_jsonp', exec_java_handler.bind(null, true));
148148

149+
// runs David Pritchard's Java backend in backends/java/
149150
function exec_java_handler(useJSONP /* use bind first */, req, res) {
150151
var usrCod = req.query.user_script;
151152

153+
var parsedOptions = JSON.parse(req.query.options_json);
154+
var heapPrimitives = parsedOptions.heap_primitives;
155+
152156
var exeFile;
153157
var args = [];
154158

155159
var inputObj = {};
156160
inputObj.usercode = usrCod;
157-
//inputObj.usercode = "public class Testtt { public static void main(String[] args) { int x = 3; x += x; } }"; // for testing
158161
// TODO: add options, arg, and stdin later ...
159162
inputObj.options = {};
160163
inputObj.args = [];
161164
inputObj.stdin = "";
162165

166+
// VERY unintuitive -- to get strings to display as heap objects and
167+
// NOT 'primitive' values in the Java backend, set showStringsAsValues
168+
// to false
169+
if (heapPrimitives) {
170+
inputObj.options.showStringsAsValues = false;
171+
}
172+
163173
var inputObjJSON = JSON.stringify(inputObj);
164174

165175
if (USE_DOCKER_SANDBOX) {
@@ -168,9 +178,6 @@ function exec_java_handler(useJSONP /* use bind first */, req, res) {
168178
args.push('run', '--rm', 'pgbovine/cokapi:v1',
169179
'/tmp/run-java-backend.sh',
170180
inputObjJSON);
171-
172-
//'{ "usercode": "public class Test \n\n{ public static void main(String[] args) { \n\nint x = 3; \nx += x; } }", "options": {}, "args": [], "stdin": "" }');
173-
174181
} else {
175182
assert(false);
176183
}

0 commit comments

Comments
 (0)