aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/jsifier.js7
-rw-r--r--tests/runner.py5
2 files changed, 7 insertions, 5 deletions
diff --git a/src/jsifier.js b/src/jsifier.js
index e4525a66..765c41f8 100644
--- a/src/jsifier.js
+++ b/src/jsifier.js
@@ -778,6 +778,9 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions, givenGlobalVaria
for (var i = 1; i <= 4; i++) {
if (item['param'+i]) {
item['ident'+i] = indexizeFunctions(finalizeLLVMParameter(item['param'+i]));
+ if (!isNumber(item['ident'+i])) {
+ item['ident'+i] = '(' + item['ident'+i] + ')'; // we may have nested expressions. So enforce the order of operations we want
+ }
} else {
item['ident'+i] = null; // just so it exists for purposes of reading ident2 etc. later on, and no exception is thrown
}
@@ -852,8 +855,8 @@ function JSify(data, functionsOnly, givenTypes, givenFunctions, givenGlobalVaria
// Unlike extending, which we just 'do' (by doing nothing),
// truncating can change the number, e.g. by truncating to an i1
// in order to get the first bit
- assert(ident2[0] == 'i');
- var bitsLeft = ident2.substr(1);
+ assert(ident2[1] == 'i');
+ var bitsLeft = ident2.substr(2, ident2.length-3); // remove (i and ), to leave number
assert(bitsLeft <= 32, 'Cannot truncate to more than 32 bits, since we use a native & op');
return '((' + ident1 + ') & ' + (Math.pow(2, bitsLeft)-1) + ')';
}
diff --git a/tests/runner.py b/tests/runner.py
index a9de9b51..828ff460 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -1012,7 +1012,6 @@ if 'benchmark' not in sys.argv:
self.do_test(src, '*4096,4096,8192,69632*')
def test_pystruct(self):
- if COMPILER != LLVM_GCC: return # TODO: Clang here
src = '''
#include <stdio.h>
@@ -1070,10 +1069,10 @@ if 'benchmark' not in sys.argv:
PyGC_Head *list = GEN_HEAD(i);
printf("%d:%d,%d\\n", i, (int)list == (int)(list->gc.gc_prev), (int)list ==(int)(list->gc.gc_next));
}
- printf("*%d*\\n", int(GEN_HEAD(2)) - int(GEN_HEAD(1)));
+ printf("*%d,%d,%d*\\n", sizeof(PyGC_Head), sizeof(gc_generation), int(GEN_HEAD(2)) - int(GEN_HEAD(1)));
}
'''
- self.do_test(src, '*0,0,0,4,8,12,16,20*\n*1,0,0*\n*0*\n0:1,1\n1:1,1\n2:1,1\n*20*')
+ self.do_test(src, '*0,0,0,4,8,12,16,20*\n*1,0,0*\n*0*\n0:1,1\n1:1,1\n2:1,1\n*12,20,20*')
def test_ptrtoint(self):
src = '''