aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Hammond <github.com@nathanhammond.com>2012-03-07 21:31:08 -0500
committerNathan Hammond <github.com@nathanhammond.com>2012-03-07 21:31:08 -0500
commit8219427f95f5e40e04822e2e2371d7adedc11cdc (patch)
tree426bce3f9f0e3692171f001b4c12fdd3f22a7a87
parent1c1e00f1ddf6a816872991e3d10cbfcc38ff5134 (diff)
parent84c9c225258ae9ab77eda0163b1368e95cb55f10 (diff)
Merge with @richardassar's changes.
-rw-r--r--AUTHORS1
-rwxr-xr-xemcc5
-rw-r--r--src/jsifier.js5
-rw-r--r--src/library.js4
-rw-r--r--src/shell.html1
-rwxr-xr-xtests/runner.py10
6 files changed, 20 insertions, 6 deletions
diff --git a/AUTHORS b/AUTHORS
index b392ea80..248c345d 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -14,4 +14,5 @@ under the licensing terms detailed in LICENSE.
* Julien Hamaide <julien.hamaide@gmail.com>
* Ehsan Akhgari <ehsan.akhgari@gmail.com> (copyright owned by Mozilla Foundation)
* Adrian Taylor <adrian@macrobug.com>
+* Richard Assar <richard.assar@gmail.com>
* Nathan Hammond <emscripten@nathanhammond.com>
diff --git a/emcc b/emcc
index d015d85e..f646108b 100755
--- a/emcc
+++ b/emcc
@@ -442,6 +442,11 @@ try:
for i in range(len(newargs)): # find input files XXX this a simple heuristic. we should really analyze based on a full understanding of gcc params,
# right now we just assume that what is left contains no more |-x OPT| things
arg = newargs[i]
+
+ if i > 0:
+ prev = newargs[i-1]
+ if prev == '-MT': continue # ignore this gcc-style argument
+
if arg.endswith(SOURCE_SUFFIXES + BITCODE_SUFFIXES + DYNAMICLIB_SUFFIXES + ASSEMBLY_SUFFIXES) or shared.Building.is_ar(arg): # we already removed -o <target>, so all these should be inputs
newargs[i] = ''
if os.path.exists(arg):
diff --git a/src/jsifier.js b/src/jsifier.js
index b54aace3..5ad1573b 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -921,13 +921,16 @@ function JSify(data, functionsOnly, givenFunctions) {
});
var ret = '';
var first = true;
+ var signedIdent = makeSignOp(item.ident, item.type, 're'); // we need to standardize for purpose of comparison
for (var targetLabel in targetLabels) {
if (!first) {
ret += 'else ';
} else {
first = false;
}
- ret += 'if (' + targetLabels[targetLabel].map(function(value) { return makeComparison(item.ident, value, item.type) }).join(' || ') + ') {\n';
+ ret += 'if (' + targetLabels[targetLabel].map(function(value) {
+ return makeComparison(signedIdent, makeSignOp(value, item.type, 're'), item.type)
+ }).join(' || ') + ') {\n';
ret += ' ' + getPhiSetsForLabel(phiSets, targetLabel) + makeBranch(targetLabel, item.currLabelId || null) + '\n';
ret += '}\n';
}
diff --git a/src/library.js b/src/library.js
index 74a8a0ac..86897f11 100644
--- a/src/library.js
+++ b/src/library.js
@@ -219,8 +219,8 @@ LibraryManager.library = {
// Creates a file record from existing data.
createDataFile: function(parent, name, data, canRead, canWrite) {
if (typeof data === 'string') {
- var dataArray = [];
- for (var i = 0; i < data.length; i++) dataArray.push(data.charCodeAt(i));
+ var dataArray = new Array(data.length);
+ for (var i = 0, len = data.length; i < len; ++i) dataArray[i] = data.charCodeAt(i);
data = dataArray;
}
var properties = {isDevice: false, contents: data};
diff --git a/src/shell.html b/src/shell.html
index a41086b9..2f34ace3 100644
--- a/src/shell.html
+++ b/src/shell.html
@@ -19,6 +19,7 @@
print: (function() {
var element = document.getElementById('output');
return function(text) {
+ text = text.replace(/&/g, "&amp;");
text = text.replace(/</g, "&lt;");
text = text.replace(/>/g, "&gt;");
text = text.replace('\n', '<br>', 'g');
diff --git a/tests/runner.py b/tests/runner.py
index e8bcb72e..b8641d9a 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -2287,6 +2287,8 @@ def process(filename):
self.do_run(src, '*nameA,nameB*')
def test_llvmswitch(self):
+ Settings.CORRECT_SIGNS = 1
+
src = '''
#include <stdio.h>
#include <string.h>
@@ -2298,18 +2300,20 @@ def process(filename):
case 'b':
case 'c':
return p-1;
- case 'd':
+ case 0xfffffff1:
return p+1;
}
return p;
}
int main( int argc, const char *argv[] ) {
- printf("*%d,%d,%d,%d,%d*\\n", switcher('a'), switcher('b'), switcher('c'), switcher('d'), switcher('e'));
+ unsigned int x = 0xfffffff1;
+ x >>= 0; // force it to be unsigned for purpose of checking our switch comparison in signed/unsigned
+ printf("*%d,%d,%d,%d,%d,%d*\\n", switcher('a'), switcher('b'), switcher('c'), switcher(x), switcher(-15), switcher('e'));
return 0;
}
'''
- self.do_run(src, '*96,97,98,101,101*')
+ self.do_run(src, '*96,97,98,-14,-14,101*')
def test_indirectbr(self):
src = '''