aboutsummaryrefslogtreecommitdiff
path: root/emlink.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-29 14:33:08 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-03 15:31:04 -0700
commit8544ce1cc79e93b5110760fae046a8024249e53a (patch)
tree64fb6a18b300176a90763d96e4619e71270900f2 /emlink.py
parent8c44f912d8f07a754c23d0b60dd3fd0c60594f50 (diff)
do not add imports that are implemented by the main module
Diffstat (limited to 'emlink.py')
-rw-r--r--emlink.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/emlink.py b/emlink.py
index 16b42fc4..a7ecb236 100644
--- a/emlink.py
+++ b/emlink.py
@@ -118,11 +118,6 @@ class AsmModule():
main.pre_js = re.sub(shared.JS.memory_initializer_pattern if main.mem_init_js else shared.JS.no_memory_initializer_pattern, full_allocation, main.pre_js, count=1)
main.pre_js = re.sub('STATICTOP = STATIC_BASE \+ (\d+);', 'STATICTOP = STATIC_BASE + %d' % (main.mem_init_size + side.mem_init_size), main.pre_js, count=1)
- # imports
- main_imports = set(main.imports)
- new_imports = [imp for imp in self.imports if imp not in main_imports]
- main.imports_js += '\n'.join(new_imports)
-
# Find function name replacements TODO: do not rename duplicate names with duplicate contents, just merge them
main_funcs = set(main.funcs)
replacements = {}
@@ -133,6 +128,12 @@ class AsmModule():
replacements[func] = rep
#print >> sys.stderr, 'replacements:', replacements
+ # imports
+ main_imports = set(main.imports)
+ new_imports = [imp for imp in self.imports if imp not in main_imports and
+ imp.split('var ')[1].split('=')[0] not in main_funcs] # a previous import may now be implemented # TODO: reverse
+ main.imports_js += '\n'.join(new_imports)
+
# sendings: add invokes for new tables
new_sendings = []
for table in self.tables: