aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-02-27 19:16:54 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-02-27 19:16:54 -0800
commit0b147ccfb48288ea9d17d52205c3b74f7e9ae9de (patch)
tree162ab231ab23be34317d694620ccc9e9f3bac730 /src/preamble.js
parentc268ebe0b939f39743e3542cad1afc2b590ccae2 (diff)
parent7c5ebb729659c6b9e83d371dfce6b751a871a5e4 (diff)
Merge pull request #882 from lptr/function-lookup-from-module
Reverse the order of function lookup in getCFunc() to avoid eval()
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 71b123e7..0bfeda1b 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -270,11 +270,9 @@ Module["ccall"] = ccall;
// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
function getCFunc(ident) {
try {
- var func = eval('_' + ident);
+ var func = globalScope['Module']['_' + ident]; // closure exported function
+ if (!func) func = eval('_' + ident); // explicit lookup
} catch(e) {
- try {
- func = globalScope['Module']['_' + ident]; // closure exported function
- } catch(e) {}
}
assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
return func;