@@ -136,8 +136,8 @@ def emscript(infile, settings, outfile, libraries=[]):
136
136
open (pre_file , 'w' ).write ('' .join (pre ) + '\n ' + meta )
137
137
out = shared .run_js (compiler , shared .COMPILER_ENGINE , [settings_file , pre_file , 'pre' ] + libraries , stdout = subprocess .PIPE , cwd = path_from_root ('src' ))
138
138
js , forwarded_data = out .split ('//FORWARDED_DATA:' )
139
- #print 'js', js
140
- #print >> sys.stderr, 'FORWARDED_DATA 1:', forwarded_data, type(forwarded_data)
139
+ outfile . write ( js )
140
+ js = None
141
141
forwarded_file = temp_files .get ('.json' ).name
142
142
open (forwarded_file , 'w' ).write (forwarded_data )
143
143
if DEBUG : print >> sys .stderr , ' emscript: phase 1 took %s seconds' % (time .time () - t )
@@ -180,15 +180,17 @@ def emscript(infile, settings, outfile, libraries=[]):
180
180
else :
181
181
outputs = [process_funcs (commands [0 ])]
182
182
183
- for funcs_js , curr_forwarded_data in outputs :
184
- js += funcs_js
183
+ funcs_js = '' .join ([output [0 ] for output in outputs ])
184
+
185
+ for func_js , curr_forwarded_data in outputs :
185
186
# merge forwarded data
186
187
curr_forwarded_json = json .loads (curr_forwarded_data )
187
188
forwarded_json ['Types' ]['preciseI64MathUsed' ] = forwarded_json ['Types' ]['preciseI64MathUsed' ] or curr_forwarded_json ['Types' ]['preciseI64MathUsed' ]
188
189
for key , value in curr_forwarded_json ['Functions' ]['blockAddresses' ].iteritems ():
189
190
forwarded_json ['Functions' ]['blockAddresses' ][key ] = value
190
191
for key in curr_forwarded_json ['Functions' ]['indexedFunctions' ].iterkeys ():
191
192
indexed_functions .add (key )
193
+ outputs = None
192
194
if DEBUG : print >> sys .stderr , ' emscript: phase 2 took %s seconds' % (time .time () - t )
193
195
if DEBUG : t = time .time ()
194
196
@@ -202,6 +204,9 @@ def emscript(infile, settings, outfile, libraries=[]):
202
204
indexing = forwarded_json ['Functions' ]['indexedFunctions' ]
203
205
def indexize (js ):
204
206
return re .sub (r'{{{ FI_([\w\d_$]+) }}}' , lambda m : str (indexing [m .groups (0 )[0 ]]), js )
207
+ outfile .write (indexize (funcs_js ))
208
+ funcs_js = None
209
+
205
210
# forward
206
211
forwarded_data = json .dumps (forwarded_json )
207
212
forwarded_file = temp_files .get ('.2.json' ).name
@@ -213,11 +218,9 @@ def indexize(js):
213
218
post_file = temp_files .get ('.post.ll' ).name
214
219
open (post_file , 'w' ).write ('' .join (post ) + '\n ' + meta )
215
220
out = shared .run_js (compiler , shared .COMPILER_ENGINE , [settings_file , post_file , 'post' , forwarded_file ] + libraries , stdout = subprocess .PIPE , cwd = path_from_root ('src' ))
216
- js += out
217
- js = indexize (js )
221
+ outfile .write (indexize (out ))
218
222
if DEBUG : print >> sys .stderr , ' emscript: phase 3 took %s seconds' % (time .time () - t )
219
223
220
- outfile .write (js ) # TODO: write in parts (see previous line though)
221
224
outfile .close ()
222
225
223
226
0 commit comments