aboutsummaryrefslogtreecommitdiff
path: root/emlink.py
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-06-24 16:48:42 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-07-03 15:31:03 -0700
commit0af083b4a07ea912f7d6e1b558fde0e38086da06 (patch)
tree75eee8dba10ec4b6b3b0f9b2df4a5755ada23780 /emlink.py
parentf2178dcdd562f49c9f668c6afae20386168c72b6 (diff)
start to parse imports
Diffstat (limited to 'emlink.py')
-rw-r--r--emlink.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/emlink.py b/emlink.py
index d7784659..686a2bed 100644
--- a/emlink.py
+++ b/emlink.py
@@ -29,9 +29,17 @@ print 'Output:', out
class AsmModule():
def __init__(self, filename):
self.js = open(filename).read()
+ # imports
+ imports_js = self.js[self.js.find(js_optimizer.start_asm_marker):self.js.rfind(js_optimizer.start_funcs_marker)]
+ self.imports = [m.group(0) for m in js_optimizer.import_sig.finditer(imports_js)]
+ #print 'imports', self.imports
+
+ # funcs
funcs_js = self.js[self.js.find(js_optimizer.start_funcs_marker):self.js.rfind(js_optimizer.end_funcs_marker)]
self.funcs = [m.group(2) for m in js_optimizer.func_sig.finditer(funcs_js)]
- print filename, self.funcs
+ #print 'funcs', self.funcs
+
+ # exports
def relocate(self, main):
# Find function name replacements TODO: do not rename duplicate names with duplicate contents, just merge them
@@ -44,8 +52,12 @@ class AsmModule():
replacements[func] = rep
print replacements
+ def write(self, out):
+ open(out, 'w').write(self.js)
+
main = AsmModule(main)
side = AsmModule(side)
side.relocate(main)
+#main.write(out)