diff options
author | max99x <max99x@gmail.com> | 2011-06-26 00:34:58 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-06-26 00:34:58 +0300 |
commit | 30c26439216b6f07848ee3611412671fe84cd19a (patch) | |
tree | 1b17127a4fd00eb0aff9ba1058b6638650facbc9 /src/parseTools.js | |
parent | b7cd8aad767e9cb4b0555a60c489966df8dc9405 (diff) | |
parent | 019267ac61bdbbf9f4ed340887687b7a2b9312bb (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src/parseTools.js')
-rw-r--r-- | src/parseTools.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/parseTools.js b/src/parseTools.js index e307a710..39537ab2 100644 --- a/src/parseTools.js +++ b/src/parseTools.js @@ -692,7 +692,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned) { } } -function indexizeFunctions(value) { // TODO: Also check for externals +function indexizeFunctions(value) { if (value in Functions.currFunctions) { if (BUILD_AS_SHARED_LIB) { return '(FUNCTION_TABLE_OFFSET + ' + Functions.getIndex(value) + ')'; @@ -702,8 +702,15 @@ function indexizeFunctions(value) { // TODO: Also check for externals } if (value && value[0] && value[0] == '_') { var rootIdent = LibraryManager.getRootIdent(value.slice(1)); - if (rootIdent && typeof Library[rootIdent] === 'function') { + if (!rootIdent) return value; + if (typeof Library[rootIdent] === 'function') { return Functions.getIndex('_' + rootIdent); + } else if (rootIdent.substr(0, 5) === 'Math.') { + // Library[..] can be a string, in which case we apply that string. There is one + // case where this can be a function: Math.*, since we try to optimize those as much + // as possible. In other words, we don't want to have a wrapper function(x) return Math.sqrt(x). + // If other functions are deemed important as well, we will need to add them here. + return Functions.getIndex(rootIdent); } } return value; |