aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js26
-rw-r--r--src/library.js15
-rw-r--r--src/modules.js2
-rw-r--r--src/parseTools.js2
-rw-r--r--tests/runner.py16
5 files changed, 11 insertions, 50 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index 5a92ba52..62acf8d7 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -3,10 +3,8 @@
// Main function
function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
- var mainPass = !functionsOnly;
-
// Add additional necessary items for the main pass
- if (mainPass) {
+ 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.')
@@ -33,15 +31,11 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
substrate = new Substrate('JSifyer');
- var GLOBAL_VARIABLES = !mainPass ? givenGlobalVariables : data.globalVariables;
-
- Functions.currFunctions = !mainPass ? givenFunctions : {};
- if (mainPass) {
- Functions.currExternalFunctions = set(data.functionStubs.map(function(item) { return item.ident }));
- }
+ var GLOBAL_VARIABLES = functionsOnly ? givenGlobalVariables : data.globalVariables;
- // Now that first-pass analysis has completed (so we have basic types, etc.), we can get around to handling unparsedFunctions
- (!mainPass ? data.functions : data.unparsedFunctions.concat(data.functions)).forEach(function(func) {
+ Functions.currFunctions = functionsOnly ? givenFunctions : {};
+ // Now that analysis has completed, we can get around to handling unparsedFunctions
+ (functionsOnly ? data.functions : data.unparsedFunctions.concat(data.functions)).forEach(function(func) {
// Save just what we need, to save memory
Functions.currFunctions[func.ident] = {
hasVarArgs: func.hasVarArgs,
@@ -63,11 +57,7 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
if (data.unparsedFunctions.length > 0) {
// We are now doing the final JS generation
dprint('unparsedFunctions', '== Completed unparsedFunctions ==\n');
-
- // Save some memory, before the final heavy lifting
- //Functions.currFunctions = null;
- //Functions.currExternalFunctions = null;
- //Debugging.clear();
+ //Debugging.clear(); // Save some memory, before the final heavy lifting
}
// Actors
@@ -781,12 +771,12 @@ function JSify(data, functionsOnly, givenFunctions, givenGlobalVariables) {
items = null;
var generated = [];
- if (mainPass) {
+ if (!functionsOnly) {
generated = generated.concat(itemsDict.type).concat(itemsDict.GlobalVariableStub).concat(itemsDict.functionStub);
}
generated = generated.concat(itemsDict.function).concat(data.unparsedFunctions);
- if (!mainPass) return generated.map(function(item) { return item.JS }).join('\n');
+ if (functionsOnly) return generated.map(function(item) { return item.JS }).join('\n');
// We are ready to print out the data, but must do so carefully - we are
// dealing with potentially *huge* strings. Convenient replacements and
diff --git a/src/library.js b/src/library.js
index 685f839a..284f093d 100644
--- a/src/library.js
+++ b/src/library.js
@@ -1476,17 +1476,7 @@ var Library = {
// ==========================================================================
- // dlfcn.h - Dynamic library loading
- //
- // Some limitations:
- //
- // * Minification on each file separately may not work, as they will
- // have different shortened names. You can in theory combine them, then
- // minify, then split... perhaps.
- //
- // * LLVM optimizations may fail. If the child wants to access a function
- // in the parent, LLVM opts may remove it from the parent when it is
- // being compiled. Not sure how to tell LLVM to not do so.
+ // dlfcn.h
// ==========================================================================
// Data for dlfcn.h.
@@ -1520,9 +1510,6 @@ var Library = {
try {
var lib_module = eval(lib_data)(FUNCTION_TABLE.length);
} catch (e) {
-#if ASSERTIONS
- print('Error in loading dynamic library: ' + e);
-#endif
DLFCN_DATA.isError = true;
return 0;
}
diff --git a/src/modules.js b/src/modules.js
index f9185725..91758609 100644
--- a/src/modules.js
+++ b/src/modules.js
@@ -124,8 +124,6 @@ var Types = {
var Functions = {
// The list of function datas which are being processed in the jsifier, currently
currFunctions: [],
- // The list of functions that are external'ly defined
- currExternalFunctions: [],
indexedFunctions: [0, 0], // Start at a non-0 (even, see below) value
diff --git a/src/parseTools.js b/src/parseTools.js
index fe71ff3b..4f0cda35 100644
--- a/src/parseTools.js
+++ b/src/parseTools.js
@@ -695,7 +695,7 @@ function makeGetValue(ptr, pos, type, noNeedFirst, unsigned) {
}
function indexizeFunctions(value) {
- if (value in Functions.currFunctions || value in Functions.currExternalFunctions) {
+ if (value in Functions.currFunctions) {
if (BUILD_AS_SHARED_LIB) {
return '(FUNCTION_TABLE_OFFSET + ' + Functions.getIndex(value) + ')';
} else {
diff --git a/tests/runner.py b/tests/runner.py
index fdf15d44..4b433b13 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1924,24 +1924,14 @@ if 'benchmark' not in sys.argv:
output_nicerizer=lambda x: x.replace('\n', '*'))
def test_dlfcn_data_and_fptr(self):
- global LLVM_OPTS
- if LLVM_OPTS: return self.skip() # LLVM opts will optimize out parent_func
-
global BUILD_AS_SHARED_LIB, EXPORTED_FUNCTIONS, EXPORTED_GLOBALS
lib_src = '''
#include <stdio.h>
int global = 42;
- extern void parent_func(); // a function that is defined in the parent
-
void lib_fptr() {
printf("Second calling lib_fptr from main.\\n");
- parent_func();
- // call it also through a pointer, to check indexizing
- void (*p_f)();
- p_f = parent_func;
- p_f();
}
void (*func(int x, void(*fptr)()))() {
@@ -1966,10 +1956,6 @@ if 'benchmark' not in sys.argv:
FUNCTYPE func;
- void parent_func() {
- printf("parent_func called from child\\n");
- }
-
void main_fptr() {
printf("First calling main_fptr from lib.\\n");
}
@@ -2011,7 +1997,7 @@ if 'benchmark' not in sys.argv:
BUILD_AS_SHARED_LIB = 0
EXPORTED_FUNCTIONS = ['_main']
EXPORTED_GLOBALS = []
- self.do_test(src, 'In func: 13*First calling main_fptr from lib.*Second calling lib_fptr from main.*parent_func called from child*parent_func called from child*Var: 42*',
+ self.do_test(src, 'In func: 13*First calling main_fptr from lib.*Second calling lib_fptr from main.*Var: 42*',
output_nicerizer=lambda x: x.replace('\n', '*'))
def test_strtod(self):