summaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-05-29 12:49:42 -0700
committerAlon Zakai <alonzakai@gmail.com>2014-05-29 13:47:02 -0700
commitb2e680a109d2a8fbc84e58a2c31b619671a78e8c (patch)
treeb43d073b09705a3bdcba0c261d637df625438a19 /src/preamble.js
parent4ae305542c80f31b06c5e8325c63ade2bb4a3f33 (diff)
NO_DYNAMIC_EXECUTION option to disable features using eval() or new Function()
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 58b442ab..bba2fc46 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -312,10 +312,15 @@ var globalScope = this;
// Returns the C function with a specified identifier (for C++, you need to do manual name mangling)
function getCFunc(ident) {
- try {
- var func = Module['_' + ident]; // closure exported function
- if (!func) func = eval('_' + ident); // explicit lookup
- } catch(e) {
+ var func = Module['_' + ident]; // closure exported function
+ if (!func) {
+#if NO_DYNAMIC_EXECUTION == 0
+ try {
+ func = eval('_' + ident); // explicit lookup
+ } catch(e) {}
+#else
+ abort('NO_DYNAMIC_EXECUTION was set, cannot eval - ccall/cwrap are not functional');
+#endif
}
assert(func, 'Cannot call unknown function ' + ident + ' (perhaps LLVM optimizations or closure removed it?)');
return func;
@@ -458,7 +463,11 @@ var cwrap, ccall;
funcstr += JSsource['stackRestore'].body + ';';
}
funcstr += 'return ret})';
+#if NO_DYNAMIC_EXECUTION == 0
return eval(funcstr);
+#else
+ abort('NO_DYNAMIC_EXECUTION was set, cannot eval - ccall is not functional');
+#endif
};
})();
Module["cwrap"] = cwrap;