aboutsummaryrefslogtreecommitdiff
path: root/tools/js_optimizer.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-03-09 10:04:07 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-03-09 10:04:07 -0800
commit74a855a0d5a8d1708f47e6531a22ca6ae3f8f76e (patch)
tree33bb840ecd2b819474f394f8e3ef6b46b78816ed /tools/js_optimizer.py
parenta43d5b5a146a4cfc654c2c1dbd05001e58977273 (diff)
improve non-asm parsing of generated functions area to be identical in EMCC_DEBUG=1 and 2
Diffstat (limited to 'tools/js_optimizer.py')
-rw-r--r--tools/js_optimizer.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/tools/js_optimizer.py b/tools/js_optimizer.py
index d089a989..b52f2324 100644
--- a/tools/js_optimizer.py
+++ b/tools/js_optimizer.py
@@ -148,12 +148,19 @@ def run_on_js(filename, passes, js_engine, jcache):
if suffix:
if not asm_registerize:
pre = js[:start_funcs + len(start_funcs_marker)]
- post = js[end_funcs:]
+ post = js[end_funcs + len(end_funcs_marker):]
js = js[start_funcs + len(start_funcs_marker):end_funcs]
if 'asm' not in passes: # can have Module[..] and inlining prevention code, push those to post
- for line in js.split('\n'):
+ class Finals:
+ buf = []
+ def process(line):
if len(line) > 0 and not line.startswith((' ', 'function', '}')):
- post = line + '\n' + post
+ Finals.buf.append(line)
+ return False
+ return True
+ js = '\n'.join(filter(process, js.split('\n')))
+ post = '\n'.join(Finals.buf) + '\n' + post
+ post = end_funcs_marker + post
else:
# We need to split out the asm shell as well, for minification
pre = js[:start_asm + len(start_asm_marker)]