diff options
Diffstat (limited to 'emscripten.py')
-rwxr-xr-x | emscripten.py | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/emscripten.py b/emscripten.py index 35edc515..629bbe5f 100755 --- a/emscripten.py +++ b/emscripten.py @@ -288,6 +288,8 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, exported_implemented_functions.add(key) for key, value in curr_forwarded_json['Functions']['unimplementedFunctions'].iteritems(): forwarded_json['Functions']['unimplementedFunctions'][key] = value + for key, value in curr_forwarded_json['Functions']['neededTables'].iteritems(): + forwarded_json['Functions']['neededTables'][key] = value if settings.get('ASM_JS'): parts = pre.split('// ASM_LIBRARY FUNCTIONS\n') @@ -302,18 +304,24 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, # calculations on merged forwarded data forwarded_json['Functions']['indexedFunctions'] = {} - i = 2 + i = 2 # universal counter if settings['ASM_JS']: i += 2*settings['RESERVED_FUNCTION_POINTERS'] + table_counters = {} # table-specific counters + alias = settings['ASM_JS'] and settings['ALIASING_FUNCTION_POINTERS'] + sig = None for indexed in indexed_functions: - #print >> sys.stderr, 'function indexing', indexed, i - forwarded_json['Functions']['indexedFunctions'][indexed] = i # make sure not to modify this python object later - we use it in indexize - i += 2 - forwarded_json['Functions']['nextIndex'] = i - function_table_size = forwarded_json['Functions']['nextIndex'] - i = 1 - while i < function_table_size: - i *= 2 - function_table_size = i + if alias: + sig = forwarded_json['Functions']['implementedFunctions'].get(indexed) or forwarded_json['Functions']['unimplementedFunctions'].get(indexed) + assert sig, indexed + if sig not in table_counters: + table_counters[sig] = 2 + 2*settings['RESERVED_FUNCTION_POINTERS'] + curr = table_counters[sig] + table_counters[sig] += 2 + else: + curr = i + i += 2 + #print >> sys.stderr, 'function indexing', indexed, curr, sig + forwarded_json['Functions']['indexedFunctions'][indexed] = curr # make sure not to modify this python object later - we use it in indexize def split_32(x): x = int(x) @@ -370,14 +378,6 @@ def emscript(infile, settings, outfile, libraries=[], compiler_engine=None, pre_tables = last_forwarded_json['Functions']['tables']['pre'] del last_forwarded_json['Functions']['tables']['pre'] - # Find function table calls without function tables generated for them - for funcs_js_item in funcs_js: - for use in set(re.findall(r'{{{ FTM_[\w\d_$]+ }}}', funcs_js_item)): - sig = use[8:len(use)-4] - if sig not in last_forwarded_json['Functions']['tables']: - if DEBUG: print >> sys.stderr, 'add empty function table', sig - last_forwarded_json['Functions']['tables'][sig] = 'var FUNCTION_TABLE_' + sig + ' = [' + ','.join(['0']*function_table_size) + '];\n' - def make_table(sig, raw): i = Counter.i Counter.i += 1 |