diff options
author | max99x <max99x@gmail.com> | 2011-07-31 04:48:43 +0300 |
---|---|---|
committer | max99x <max99x@gmail.com> | 2011-07-31 04:48:43 +0300 |
commit | 7f735afe5ee57f693602b661e8e6286dcc914c72 (patch) | |
tree | b2600adf0702544c40453febbf8fd5e09e048102 /src | |
parent | 4477fc67dea3cf0e6d54f4ae59946a70b069e7ae (diff) | |
parent | 3928f293b817a48797faf10b10a69240236de767 (diff) |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler.js | 18 | ||||
-rw-r--r-- | src/library.js | 9 | ||||
-rw-r--r-- | src/preamble.js | 9 | ||||
-rw-r--r-- | src/shell.js | 12 |
4 files changed, 26 insertions, 22 deletions
diff --git a/src/compiler.js b/src/compiler.js index 8cb023d9..8980da93 100644 --- a/src/compiler.js +++ b/src/compiler.js @@ -12,6 +12,9 @@ if (!this['load']) { if (!this['read']) { read = function(f) { snarf(f) }; } +if (!this['arguments']) { + arguments = scriptArgs; +} // Basic utilities @@ -21,7 +24,10 @@ load('utility.js'); load('settings.js'); -var settings = JSON.parse(readline()); +var settings_file = arguments[0]; +var ll_file = arguments[1]; + +var settings = JSON.parse(read(settings_file)); for (setting in settings) { this[setting] = settings[setting]; } @@ -64,13 +70,9 @@ eval(processMacros(preprocess(read('runtime.js')))); // Read llvm -var lines = []; -var line; -do { - line = readline(); - if (line == null) break; - lines.push(line); -} while(true); +var raw = read(ll_file); +var lines = raw.split('\n'); +raw = null; // Do it diff --git a/src/library.js b/src/library.js index a1bd16ae..dcd1e22c 100644 --- a/src/library.js +++ b/src/library.js @@ -264,10 +264,15 @@ LibraryManager.library = { // TODO: Use mozResponseArrayBuffer, responseStream, etc. if available. var xhr = new XMLHttpRequest(); xhr.open('GET', obj.url, false); - xhr.overrideMimeType('text/plain; charset=x-user-defined'); // Binary. + xhr.responseType = 'arraybuffer'; // hint to the browser that we want binary data + xhr.overrideMimeType('text/plain; charset=x-user-defined'); // another hint xhr.send(null); if (xhr.status != 200 && xhr.status != 0) success = false; - obj.contents = intArrayFromString(xhr.responseText || '', true); + if (xhr.response) { + obj.contents = new Uint8Array(xhr.response); + } else { + obj.contents = intArrayFromString(xhr.responseText || '', true); + } } else if (typeof read !== 'undefined') { // Command-line. try { diff --git a/src/preamble.js b/src/preamble.js index 99288244..d4f5e570 100644 --- a/src/preamble.js +++ b/src/preamble.js @@ -549,13 +549,8 @@ function String_copy(ptr, addZero) { // Tools -function jrint(label, obj) { // XXX manual debugging - if (!obj) { - obj = label; - label = ''; - } else - label = label + ' : '; - print(label + JSON.stringify(obj)); +if (typeof print === 'undefined') { + print = console.log; // we are on the web } // This processes a JS string into a C-line array of numbers, 0-terminated. diff --git a/src/shell.js b/src/shell.js index 06cf4175..222aba26 100644 --- a/src/shell.js +++ b/src/shell.js @@ -12,13 +12,15 @@ if (!this['Module']) { this['Module'] = {}; } -try { - Module.arguments = scriptArgs; -} catch(e) { +if (!Module.arguments) { try { - Module.arguments = arguments; + Module.arguments = scriptArgs; } catch(e) { - Module.arguments = []; + try { + Module.arguments = arguments; + } catch(e) { + Module.arguments = []; + } } } //*/ |