aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-02-10 15:47:49 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-02-10 15:48:47 -0800
commitdea258716e66c370cfbd7b66eed1f7f3465dfe97 (patch)
treebddc998683cb1f1126b68e5698284ffb99d7b909 /src
parentb5f9734ee91a55bdc7176ee28ed125beed02c353 (diff)
add aborting stubs in main modules, and replace them with functions from side modules
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 6742f504..35846d39 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -395,6 +395,13 @@ function JSify(data, functionsOnly) {
// Note: We don't return the dependencies here. Be careful not to end up where this matters
if (('_' + ident) in Functions.implementedFunctions) return '';
+ if (!LibraryManager.library.hasOwnProperty(ident) && !LibraryManager.library.hasOwnProperty(ident + '__inline')) {
+ if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + ident);
+ else if (VERBOSE || (WARN_ON_UNDEFINED_SYMBOLS && !LINKABLE)) warn('unresolved symbol: ' + ident);
+ // emit a stub that will fail at runtime
+ LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);");
+ }
+
var snippet = LibraryManager.library[ident];
var redirectedIdent = null;
var deps = LibraryManager.library[ident + '__deps'] || [];
@@ -456,7 +463,7 @@ function JSify(data, functionsOnly) {
} else {
ident = '_' + ident;
}
- if (VERBOSE) printErr('adding ' + ident + ' and deps ' + deps);
+ if (VERBOSE) printErr('adding ' + ident + ' and deps ' + deps + ' : ' + (snippet + '').substr(0, 40));
var depsText = (deps ? '\n' + deps.map(addFromLibrary).filter(function(x) { return x != '' }).join('\n') : '');
var contentText = isFunction ? snippet : ('var ' + ident + '=' + snippet + ';');
if (ASM_JS) {
@@ -486,7 +493,6 @@ function JSify(data, functionsOnly) {
item.JS = '';
} else {
// If this is not linkable, anything not in the library is definitely missing
- var cancel = false;
if (item.ident in DEAD_FUNCTIONS) {
if (LibraryManager.library[shortident + '__asm']) {
warn('cannot kill asm library function ' + item.ident);
@@ -496,13 +502,7 @@ function JSify(data, functionsOnly) {
delete LibraryManager.library[shortident + '__deps'];
}
}
- if (!LINKABLE && !LibraryManager.library.hasOwnProperty(shortident) && !LibraryManager.library.hasOwnProperty(shortident + '__inline')) {
- if (ERROR_ON_UNDEFINED_SYMBOLS) error('unresolved symbol: ' + shortident);
- else if (VERBOSE || WARN_ON_UNDEFINED_SYMBOLS) warn('unresolved symbol: ' + shortident);
- // emit a stub that will fail at runtime
- LibraryManager.library[shortident] = new Function("Module['printErr']('missing function: " + shortident + "'); abort(-1);");
- }
- item.JS = cancel ? ';' : addFromLibrary(shortident);
+ item.JS = addFromLibrary(shortident);
}
}