aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2011-06-26 14:49:47 -0700
committerAlon Zakai <alonzakai@gmail.com>2011-06-26 14:49:47 -0700
commit1f78e3d974142071e03768ada5c14dfd26ed0058 (patch)
tree98c674c029ab3adf668b797ce3cbf7df913d252e /src
parent1f1fde4d1c320304de147451cfa043b1f580b4d7 (diff)
optimize inclusion of default library items
Diffstat (limited to 'src')
-rw-r--r--src/analyzer.js17
-rw-r--r--src/jsifier.js17
2 files changed, 18 insertions, 16 deletions
diff --git a/src/analyzer.js b/src/analyzer.js
index bae05ec8..9b8af51b 100644
--- a/src/analyzer.js
+++ b/src/analyzer.js
@@ -1124,21 +1124,6 @@ function analyzer(data) {
}, 'Sorter');
// Solve it
- var ret = substrate.solve();
-
- // Add additional necessary items
- if (INCLUDE_FULL_LIBRARY) {
- assert(!BUILD_AS_SHARED_LIB, 'Cannot have both INCLUDE_FULL_LIBRARY and BUILD_AS_SHARED_LIB set.')
- var libFuncsToInclude = keys(Library);
- } else {
- var libFuncsToInclude = ['memset', 'malloc', 'free'];
- }
- libFuncsToInclude.forEach(function(ident) {
- ret.functionStubs.push({
- intertype: 'functionStub',
- ident: '_' + ident
- });
- });
- return ret;
+ return substrate.solve();
}
diff --git a/src/jsifier.js b/src/jsifier.js
index d20812ae..4af1223a 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -3,6 +3,23 @@
// Main function
function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
+ // Add additional necessary items for the main pass
+ if (!functionsOnly) {
+ var libFuncsToInclude;
+ if (INCLUDE_FULL_LIBRARY) {
+ assert(!BUILD_AS_SHARED_LIB, 'Cannot have both INCLUDE_FULL_LIBRARY and BUILD_AS_SHARED_LIB set.')
+ libFuncsToInclude = keys(Library);
+ } else {
+ libFuncsToInclude = ['memset', 'malloc', 'free'];
+ }
+ libFuncsToInclude.forEach(function(ident) {
+ data.functionStubs.push({
+ intertype: 'functionStub',
+ ident: '_' + ident
+ });
+ });
+ }
+
// Does simple 'macro' substitution, using Django-like syntax,
// {{{ code }}} will be replaced with |eval(code)|.
function processMacros(text) {