diff options
Diffstat (limited to 'src/modules.js')
-rw-r--r-- | src/modules.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/modules.js b/src/modules.js index fd5c23cd..56f4c827 100644 --- a/src/modules.js +++ b/src/modules.js @@ -443,6 +443,31 @@ var LibraryManager = { } } + // apply synonyms. these are typically not speed-sensitive, and doing it this way makes it possible to not include hacks in the compiler + // (and makes it simpler to switch between SDL verisons, fastcomp and non-fastcomp, etc.). + var lib = LibraryManager.library; + libloop: for (var x in lib) { + if (x.lastIndexOf('__') > 0) continue; // ignore __deps, __* + if (lib[x + '__asm']) continue; // ignore asm library functions, those need to be fully optimized + if (typeof lib[x] === 'string') { + var target = x; + while (typeof lib[target] === 'string') { + if (lib[target].indexOf('(') >= 0) continue libloop; + target = lib[target]; + } + if (typeof lib[target] === 'undefined' || typeof lib[target] === 'function') { + if (target.indexOf('Math_') < 0) { + lib[x] = new Function('return _' + target + '.apply(null, arguments)'); + if (!lib[x + '__deps']) lib[x + '__deps'] = []; + lib[x + '__deps'].push(target); + } else { + lib[x] = new Function('return ' + target + '.apply(null, arguments)'); + } + continue; + } + } + } + /* // export code for CallHandlers.h printErr('============================'); |