diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler.js | 31 | ||||
-rw-r--r-- | src/jsifier.js | 2 | ||||
-rw-r--r-- | src/library.js | 3 | ||||
-rw-r--r-- | src/settings.js | 6 |
4 files changed, 31 insertions, 11 deletions
diff --git a/src/compiler.js b/src/compiler.js index 89da32d5..2863afda 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -31,15 +31,30 @@ if (ENVIRONMENT_IS_NODE) { var nodeFS = require('fs'); var nodePath = require('path'); - read = function(filename) { - filename = nodePath['normalize'](filename); - var ret = nodeFS['readFileSync'](filename).toString(); - // The path is absolute if the normalized version is the same as the resolved. - if (!ret && filename != nodePath['resolve'](filename)) { - filename = path.join(__dirname, '..', 'src', filename); - ret = nodeFS['readFileSync'](filename).toString(); + if (!nodeFS.existsSync) { + nodeFS.existsSync = function(path) { + try { + return !!nodeFS.readFileSync(path); + } catch(e) { + return false; + } + } + } + + function find(filename) { + var prefixes = [__dirname, process.cwd()]; + for (var i = 0; i < prefixes.length; ++i) { + var combined = nodePath.join(prefixes[i], filename); + if (nodeFS.existsSync(combined)) { + return combined; + } } - return ret; + return filename; + } + + read = function(filename) { + var absolute = find(filename); + return nodeFS['readFileSync'](absolute).toString(); }; load = function(f) { diff --git a/src/jsifier.js b/src/jsifier.js index 01ecd7d3..92b39b7d 100644 --- a/src/jsifier.js +++ b/src/jsifier.js @@ -32,7 +32,7 @@ function JSify(data, functionsOnly, givenFunctions) { // else. This lets us not hold any strings in memory, we simply print // things out as they are ready. - var shellFile = BUILD_AS_SHARED_LIB ? 'shell_sharedlib.js' : 'shell.js'; + var shellFile = SHELL_FILE ? SHELL_FILE : (BUILD_AS_SHARED_LIB ? 'shell_sharedlib.js' : 'shell.js'); var shellParts = read(shellFile).split('{{BODY}}'); print(shellParts[0]); var preFile = BUILD_AS_SHARED_LIB ? 'preamble_sharedlib.js' : 'preamble.js'; diff --git a/src/library.js b/src/library.js index 1c150bc9..3531db97 100644 --- a/src/library.js +++ b/src/library.js @@ -4850,6 +4850,7 @@ LibraryManager.library = { // RTTI hacks for exception handling, defining type_infos for common types. // The values are dummies. We simply use the addresses of these statically // allocated variables as unique identifiers. + _ZTIb: [0], // bool _ZTIi: [0], // int _ZTIj: [0], // unsigned int _ZTIl: [0], // long @@ -4863,7 +4864,7 @@ LibraryManager.library = { _ZTIa: [0], // signed char _ZTIh: [0], // unsigned char _ZTIs: [0], // short - _ZTIt: [0], // signed short + _ZTIt: [0], // unsigned short _ZTIv: [0], // void _ZTIPv: [0], // void* diff --git a/src/settings.js b/src/settings.js index fe532bda..f8a81711 100644 --- a/src/settings.js +++ b/src/settings.js @@ -53,9 +53,11 @@ var FAST_MEMORY = 2*1024*1024; // The amount of memory to initialize to 0. This var MICRO_OPTS = 1; // Various micro-optimizations, like nativizing variables var RELOOP = 0; // Recreate js native loops from llvm data var USE_TYPED_ARRAYS = 2; // Use typed arrays for the heap. See https://github.com/kripken/emscripten/wiki/Code-Generation-Modes/ + // 0 means no typed arrays are used. // 1 has two heaps, IHEAP (int32) and FHEAP (double), // and addresses there are a match for normal addresses. - // 2 is a single heap, accessible through views as int8, int32, etc. + // 2 is a single heap, accessible through views as int8, int32, etc. This is + // the recommended mode both for performance and for compatibility. var USE_FHEAP = 1; // Relevant in USE_TYPED_ARRAYS == 1. If this is disabled, only IHEAP will be used, and FHEAP // not generated at all. This is useful if your code is 100% ints without floats or doubles var DOUBLE_MODE = 1; // How to load and store 64-bit doubles. Without typed arrays or in typed array mode 1, @@ -196,6 +198,8 @@ var INCLUDE_FULL_LIBRARY = 0; // Whether to include the whole library rather tha // dynamically loading modules that make use of runtime // library functions that are not used in the main module. +var SHELL_FILE = 0; // set this to a string to override the shell file used + var SHOW_LABELS = 0; // Show labels in the generated code var BUILD_AS_SHARED_LIB = 0; // Whether to build the code as a shared library, which |