diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/jsifier.js | 14 | ||||
-rw-r--r-- | src/modules.js | 3 |
2 files changed, 15 insertions, 2 deletions
diff --git a/src/jsifier.js b/src/jsifier.js index bd432001..d8ed589e 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -411,7 +411,6 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { funcs: {}, seen: {}, processItem: function(item) { - if (IGNORED_FUNCTIONS.indexOf(item.ident) >= 0) return null; if (this.seen[item.__uid__]) return null; if (item.intertype == 'function') { this.funcs[item.ident] = item; @@ -435,6 +434,8 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { // We have this function all reconstructed, go and finalize it's JS! + if (IGNORED_FUNCTIONS.indexOf(func.ident) >= 0) return null; + func.JS = '\nfunction ' + func.ident + '(' + func.paramIdents.join(', ') + ') {\n'; if (PROFILE) { @@ -931,7 +932,14 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { } generated = generated.concat(itemsDict.function).concat(data.unparsedFunctions); - if (!mainPass) return generated.map(function(item) { return item.JS }).join('\n'); + if (!mainPass) { + Functions.allIdents = Functions.allIdents.concat(itemsDict.function.map(function(func) { + return func.ident; + }).filter(function(func) { + return IGNORED_FUNCTIONS.indexOf(func.ident) < 0; + })); + return generated.map(function(item) { return item.JS }).join('\n'); + } // We are ready to print out the data, but must do so carefully - we are // dealing with potentially *huge* strings. Convenient replacements and @@ -967,6 +975,8 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) { print(Functions.generateIndexing()); // done last, as it may rely on aliases set in postsets print(postParts[1]); print(shellParts[1]); + // Print out some useful metadata (for additional optimizations later, like the eliminator) + print('// EMSCRIPTEN_GENERATED_FUNCTIONS: ' + JSON.stringify(Functions.allIdents) + '\n'); return null; } diff --git a/src/modules.js b/src/modules.js index 3b370878..f04731f8 100644 --- a/src/modules.js +++ b/src/modules.js @@ -228,6 +228,9 @@ var Functions = { // All functions that will be implemented in this file implementedFunctions: null, + // All the function idents seen so far + allIdents: [], + indexedFunctions: [0, 0], // Start at a non-0 (even, see below) value // Mark a function as needing indexing, and returns the index |