diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-24 17:16:14 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 15:31:03 -0700 |
commit | 5cee70c892ac444f6030e4989755313cc3215569 (patch) | |
tree | 11a055311ea61368c6954b7521b1efe44831b20e | |
parent | b65d9c36bf6af43f03913d10f442b9eab4319e82 (diff) |
invoke relocation pass in js optimizer
-rw-r--r-- | emlink.py | 15 | ||||
-rw-r--r-- | tools/shared.py | 2 |
2 files changed, 14 insertions, 3 deletions
@@ -28,6 +28,7 @@ print 'Output:', out class AsmModule(): def __init__(self, filename): + self.filename = filename self.js = open(filename).read() self.start_asm = self.js.find(js_optimizer.start_asm_marker) @@ -51,7 +52,7 @@ class AsmModule(): self.tables_js = post_js[:ret] self.exports_js = post_js[ret:] - def relocate(self, main): + def relocate_into(self, main): # imports main_imports = set(main.imports) new_imports = [imp for imp in self.imports if imp not in main_imports] @@ -68,11 +69,21 @@ class AsmModule(): replacements[func] = rep #print replacements + temp = shared.Building.js_optimizer(self.filename, ['asm', 'relocate']) + relocated_funcs = AsmModule(temp) + shared.try_delete(temp) + main.extra_funcs_js = relocated_funcs.funcs_js + + # tables + + # exports + def write(self, out): f = open(out, 'w') f.write(self.js[:self.start_asm]) f.write(self.imports_js) f.write(self.funcs_js) + f.write(self.extra_funcs_js) f.write(self.tables_js) f.write(self.exports_js) f.write(self.js[self.end_asm:]) @@ -81,6 +92,6 @@ class AsmModule(): main = AsmModule(main) side = AsmModule(side) -side.relocate(main) +side.relocate_into(main) main.write(out) diff --git a/tools/shared.py b/tools/shared.py index fc6950d5..5819f39e 100644 --- a/tools/shared.py +++ b/tools/shared.py @@ -1210,7 +1210,7 @@ set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)''' % { 'winfix': '' if not WINDOWS e return opts @staticmethod - def js_optimizer(filename, passes, jcache, debug): + def js_optimizer(filename, passes, jcache=False, debug=False): return js_optimizer.run(filename, passes, listify(NODE_JS), jcache, debug) @staticmethod |