aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-09-04 13:59:07 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-09-04 13:59:07 -0700
commit2aa41b3c30beed986f76027acbe87a38effce61b (patch)
tree532a9ecf1393e362f9eab6a43e0b77c782aa64e5 /src
parent5c70758542da772e66037ab2715a8f21dc5f8cf3 (diff)
fix bug with stub functions and implemented library functions
Diffstat (limited to 'src')
-rw-r--r--src/jsifier.js6
-rw-r--r--src/modules.js6
2 files changed, 8 insertions, 4 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 8dac45e5..be9360af 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -26,6 +26,8 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
ident: '_' + ident
});
});
+
+ Functions.implementedFunctions = set(data.unparsedFunctions.map(function(func) { return func.ident }));
}
// Does simple 'macro' substitution, using Django-like syntax,
@@ -262,8 +264,6 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
}
});
- var moduleFunctions = set(data.unparsedFunctions.map(function(func) { return func.ident }));
-
var addedLibraryItems = {};
// functionStub
@@ -279,7 +279,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
if (ident in addedLibraryItems) return '';
// Don't replace implemented functions with library ones (which can happen when we add dependencies).
// Note: We don't return the dependencies here. Be careful not to end up where this matters
- if (('_' + ident) in moduleFunctions) return '';
+ if (('_' + ident) in Functions.implementedFunctions) return '';
addedLibraryItems[ident] = true;
var snippet = LibraryManager.library[ident];
diff --git a/src/modules.js b/src/modules.js
index 70499bcc..8205e9ff 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -221,6 +221,9 @@ var Functions = {
// The list of function datas which are being processed in the jsifier, currently
currFunctions: [],
+ // All functions that will be implemented in this file
+ implementedFunctions: null,
+
indexedFunctions: [0, 0], // Start at a non-0 (even, see below) value
// Mark a function as needing indexing, and returns the index
@@ -273,7 +276,8 @@ var LibraryManager = {
isStubFunction: function(ident) {
var libCall = LibraryManager.library[ident.substr(1)];
- return typeof libCall === 'function' && libCall.toString().replace(/\s/g, '') === 'function(){}';
+ return typeof libCall === 'function' && libCall.toString().replace(/\s/g, '') === 'function(){}'
+ && !(ident in Functions.implementedFunctions);
}
};