diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-06-24 16:36:05 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-03 15:31:03 -0700 |
commit | f2178dcdd562f49c9f668c6afae20386168c72b6 (patch) | |
tree | 404b92ed52d97f6508df14526ac90b5e5ee5e92f /emlink.py | |
parent | c8ba74664f1ce245918cbcd4e5a9b7dc41fc404f (diff) |
start to parse asm modules
Diffstat (limited to 'emlink.py')
-rw-r--r-- | emlink.py | 24 |
1 files changed, 24 insertions, 0 deletions
@@ -14,6 +14,7 @@ side modules into a main module that way. import os, subprocess, sys from tools import shared +from tools import js_optimizer try: me, main, side, out = sys.argv[:4] @@ -25,3 +26,26 @@ print 'Main module:', main print 'Side module:', side print 'Output:', out +class AsmModule(): + def __init__(self, filename): + self.js = open(filename).read() + 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 + + def relocate(self, main): + # Find function name replacements TODO: do not rename duplicate names with duplicate contents, just merge them + main_funcs = set(main.funcs) + replacements = {} + for i in range(len(self.funcs)): + rep = func = self.funcs[i] + while rep in main_funcs: + rep += '_' + replacements[func] = rep + print replacements + +main = AsmModule(main) +side = AsmModule(side) + +side.relocate(main) + |