aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-11-28 16:52:51 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-12-07 14:23:19 -0800
commited00768f160aa4674ffedc74b98e6194da0493df (patch)
treee3238d0468aec78484d19ee22c723cd26f082e92
parent709d9bf788b78992ab6aa7676e6a9f59ac696efa (diff)
put library signatures in separate storage instead of reusing libraryFunctions
-rwxr-xr-xemscripten.py8
-rw-r--r--src/modules.js7
-rw-r--r--src/parseTools.js4
3 files changed, 10 insertions, 9 deletions
diff --git a/emscripten.py b/emscripten.py
index 26d4a24e..50a1fb97 100755
--- a/emscripten.py
+++ b/emscripten.py
@@ -236,8 +236,8 @@ def emscript(infile, settings, outfile, libraries=[]):
if settings.get('ASM_JS'):
for key in curr_forwarded_json['Functions']['implementedFunctions'].iterkeys():
if key in all_exported_functions: exported_implemented_functions.add(key)
- for key, value in curr_forwarded_json['Functions']['libraryFunctions'].iteritems():
- forwarded_json['Functions']['libraryFunctions'][key] = value
+ for key, value in curr_forwarded_json['Functions']['unimplementedFunctions'].iteritems():
+ forwarded_json['Functions']['unimplementedFunctions'][key] = value
funcs_js = ''.join([output[0] for output in outputs])
@@ -250,10 +250,10 @@ def emscript(infile, settings, outfile, libraries=[]):
# caculate globals
global_vars = forwarded_json['Variables']['globals'].keys()
global_funcs = ['_' + x for x in forwarded_json['Functions']['libraryFunctions'].keys()]
- asm_globals = ''.join([' var ' + g + '=env.' + g + ';\n' for g in global_vars + global_funcs])
+ asm_globals = ''.join([' var ' + g + '=env.' + g + ';\n' for g in global_funcs])
# sent data
basics = ['buffer', 'Int8Array', 'Int16Array', 'Int32Array', 'Uint8Array', 'Uint16Array', 'Uint32Array', 'Float32Array', 'Float64Array']
- sending = '{ ' + ', '.join([s + ': ' + s for s in basics + global_vars + global_funcs]) + ' }'
+ sending = '{ ' + ', '.join([s + ': ' + s for s in basics + global_funcs]) + ' }'
# received
receiving = ';\n'.join(['var ' + s + ' = Module["' + s + '"] = asm.' + s for s in exported_implemented_functions])
# finalize
diff --git a/src/modules.js b/src/modules.js
index de84d9e4..6847e1de 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -218,7 +218,8 @@ var Types = {
var Functions = {
// All functions that will be implemented in this file. Maps id to signature
implementedFunctions: {},
- libraryFunctions: {}, // functions added from the library. Maps id to 1, or to a signature if we need indexing
+ libraryFunctions: {}, // functions added from the library
+ unimplementedFunctions: {}, // library etc. functions that we need to index, maps id to signature
indexedFunctions: {},
nextIndex: 2, // Start at a non-0 (even, see below) value
@@ -264,7 +265,7 @@ var Functions = {
});
}
for (var ident in this.indexedFunctions) {
- var sig = ASM_JS ? Functions.implementedFunctions[ident] || Functions.libraryFunctions[ident] : 'x';
+ var sig = ASM_JS ? Functions.implementedFunctions[ident] || Functions.unimplementedFunctions[ident] : 'x';
assert(sig, ident);
if (!tables[sig]) tables[sig] = zeros(this.nextIndex); // TODO: make them compact
tables[sig][this.indexedFunctions[ident]] = ident;
@@ -348,7 +349,7 @@ var PassManager = {
blockAddresses: Functions.blockAddresses,
indexedFunctions: Functions.indexedFunctions,
implementedFunctions: ASM_JS ? Functions.implementedFunctions : [],
- libraryFunctions: Functions.libraryFunctions,
+ unimplementedFunctions: Functions.unimplementedFunctions,
}
}));
} else if (phase == 'post') {
diff --git a/src/parseTools.js b/src/parseTools.js
index 080ef6fd..eb1c6ab0 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -1006,8 +1006,8 @@ function indexizeFunctions(value, type) {
var out = {};
if (type && isFunctionType(type, out) && value[0] === '_') { // checking for _ differentiates from $ (local vars)
// add signature to library functions that we now know need indexing
- if (!(value in Functions.implementedFunctions) && !(value in Functions.libraryFunctions)) {
- Functions.libraryFunctions[value] = Functions.getSignature(out.returnType, out.segments ? out.segments.map(function(segment) { return segment[0].text }) : []);
+ if (!(value in Functions.implementedFunctions) && !(value in Functions.unimplementedFunctions)) {
+ Functions.unimplementedFunctions[value] = Functions.getSignature(out.returnType, out.segments ? out.segments.map(function(segment) { return segment[0].text }) : []);
}
if (BUILD_AS_SHARED_LIB) {