@@ -109,37 +109,7 @@ function TogetherjsCloseHandler() {
109109 }
110110}
111111
112-
113- function executeCode ( forceStartingInstr , forceRawInputLst ) {
114- if ( forceRawInputLst !== undefined ) {
115- rawInputLst = forceRawInputLst ; // UGLY global across modules, FIXME
116- }
117-
118- var backend_script = null ;
119- if ( $ ( '#pythonVersionSelector' ) . val ( ) == '2' ) {
120- backend_script = python2_backend_script ;
121- }
122- else if ( $ ( '#pythonVersionSelector' ) . val ( ) == '3' ) {
123- backend_script = python3_backend_script ;
124- }
125- // experimental KRAZY MODE!!!
126- else if ( $ ( '#pythonVersionSelector' ) . val ( ) == '2crazy' ) {
127- backend_script = python2crazy_backend_script ;
128- }
129- else if ( $ ( '#pythonVersionSelector' ) . val ( ) == 'js' ) {
130- backend_script = js_backend_script ;
131- }
132- else if ( $ ( '#pythonVersionSelector' ) . val ( ) == 'ts' ) {
133- backend_script = ts_backend_script ;
134- }
135- else if ( $ ( '#pythonVersionSelector' ) . val ( ) == 'ruby' ) {
136- backend_script = ruby_backend_script ;
137- }
138- else if ( $ ( '#pythonVersionSelector' ) . val ( ) == 'java' ) {
139- backend_script = java_backend_script ;
140- }
141- assert ( backend_script ) ;
142-
112+ function getBaseBackendOptionsObj ( ) {
143113 var backendOptionsObj = { cumulative_mode : ( $ ( '#cumulativeModeSelector' ) . val ( ) == 'true' ) ,
144114 heap_primitives : ( $ ( '#heapPrimitivesSelector' ) . val ( ) == 'true' ) ,
145115 show_only_outputs : false ,
@@ -151,10 +121,11 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
151121 backendOptionsObj . survey = surveyObj ;
152122 }
153123
154- var startingInstruction = forceStartingInstr ? forceStartingInstr : 0 ;
124+ return backendOptionsObj ;
125+ }
155126
156- var frontendOptionsObj = { startingInstruction : startingInstruction ,
157- // tricky: selector 'true' and 'false' values are strings!
127+ function getBaseFrontendOptionsObj ( ) {
128+ var frontendOptionsObj = { // tricky: selector 'true' and 'false' values are strings!
158129 disableHeapNesting : ( $ ( '#heapPrimitivesSelector' ) . val ( ) == 'true' ) ,
159130 textualMemoryLabels : ( $ ( '#textualMemoryLabelsSelector' ) . val ( ) == 'true' ) ,
160131 executeCodeWithRawInputFunc : executeCodeWithRawInput ,
@@ -172,6 +143,21 @@ function executeCode(forceStartingInstr, forceRawInputLst) {
172143 pyCrazyMode : ( $ ( '#pythonVersionSelector' ) . val ( ) == '2crazy' ) ,
173144 holisticMode : ( $ ( '#cumulativeModeSelector' ) . val ( ) == 'holistic' )
174145 }
146+ return frontendOptionsObj ;
147+ }
148+
149+ function executeCode ( forceStartingInstr , forceRawInputLst ) {
150+ if ( forceRawInputLst !== undefined ) {
151+ rawInputLst = forceRawInputLst ; // UGLY global across modules, FIXME
152+ }
153+
154+ var backend_script = langToBackendScript ( $ ( '#pythonVersionSelector' ) . val ( ) ) ;
155+ var backendOptionsObj = getBaseBackendOptionsObj ( ) ;
156+
157+ var startingInstruction = forceStartingInstr ? forceStartingInstr : 0 ;
158+
159+ var frontendOptionsObj = getBaseFrontendOptionsObj ( ) ;
160+ frontendOptionsObj . startingInstruction = startingInstruction ;
175161
176162 executePythonCode ( pyInputGetValue ( ) ,
177163 backend_script , backendOptionsObj ,
0 commit comments