aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-01-10 17:14:52 -0800
committerAlon Zakai <alonzakai@gmail.com>2013-01-10 17:14:52 -0800
commit05680318f03c86660f009c14d98cfad5f856db1c (patch)
treea9b65e7f8b540d448b4c523529331b76cef0fe4a
parentd233c379208c40e0721eceec852182914b26a549 (diff)
auto-export some special functions if they are dependencies of a JS library element
-rw-r--r--src/jsifier.js12
-rw-r--r--src/settings.js6
2 files changed, 18 insertions, 0 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 5e5baf33..e41bcf67 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -459,6 +459,18 @@ function JSify(data, functionsOnly, givenFunctions) {
if (redirectedIdent) {
deps = deps.concat(LibraryManager.library[redirectedIdent + '__deps'] || []);
}
+ if (ASM_JS) {
+ // In asm, dependencies implemented in C might be needed by JS library functions.
+ // We don't know yet if they are implemented in C or not. To be safe, export such
+ // special cases.
+ [LIBRARY_DEPS_TO_AUTOEXPORT].forEach(function(special) {
+ deps.forEach(function(dep) {
+ if (dep == special && !EXPORTED_FUNCTIONS[dep]) {
+ EXPORTED_FUNCTIONS[dep] = 1;
+ }
+ });
+ });
+ }
// $ident's are special, we do not prefix them with a '_'.
if (ident[0] === '$') {
ident = ident.substr(1);
diff --git a/src/settings.js b/src/settings.js
index 11af4692..8ae287f9 100644
--- a/src/settings.js
+++ b/src/settings.js
@@ -222,6 +222,12 @@ var DEFAULT_LIBRARY_FUNCS_TO_INCLUDE = ['memcpy', 'memset', 'malloc', 'free', '$
// add it here (and in EXPORTED FUNCTIONS with prefix
// "_", for closure).
+var LIBRARY_DEPS_TO_AUTOEXPORT = ['memcpy']; // This list is also used to determine
+ // auto-exporting of library dependencies (i.e., functions that
+ // might be dependencies of JS library functions, that if
+ // so we must export so that if they are implemented in C
+ // they will be accessible, in ASM_JS mode).
+
var IGNORED_FUNCTIONS = []; // Functions that we should not generate, neither a stub nor a complete function.
// This is useful if your project code includes a function, and you want to replace
// that in the compiled code with your own handwritten JS. (Of course even without