aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralon@honor <none@none>2010-09-02 20:37:30 -0700
committeralon@honor <none@none>2010-09-02 20:37:30 -0700
commit1ba6a6f48ff22002037b1628587bb49c75a56da7 (patch)
treecf4eb4eaa5d7973eeee4b93ceaf6e0e74db092d2
parent26753c442d2fe09190005d999da48f886fcf996f (diff)
and/or support
-rw-r--r--src/parser.js4
-rw-r--r--tests/runner.py8
2 files changed, 9 insertions, 3 deletions
diff --git a/src/parser.js b/src/parser.js
index 7fb9432b..8936e87b 100644
--- a/src/parser.js
+++ b/src/parser.js
@@ -702,7 +702,7 @@ function intertyper(data) {
// mathops
substrate.addZyme('Mathops', {
selectItem: function(item) { return item.indent === -1 && item.tokens && item.tokens.length >= 3 &&
- ['add', 'sub', 'sdiv', 'mul', 'icmp', 'zext', 'urem', 'srem', 'fadd', 'fmul', 'fdiv', 'fcmp', 'uitofp', 'sitofp', 'fpext', 'fptoui', 'fptosi', 'trunc', 'sext', 'select', 'shl', 'shr', 'ashl', 'ashr', 'xor']
+ ['add', 'sub', 'sdiv', 'mul', 'icmp', 'zext', 'urem', 'srem', 'fadd', 'fmul', 'fdiv', 'fcmp', 'uitofp', 'sitofp', 'fpext', 'fptoui', 'fptosi', 'trunc', 'sext', 'select', 'shl', 'shr', 'ashl', 'ashr', 'xor', 'or', 'and']
.indexOf(item.tokens[0].text) != -1 && !item.intertype },
processItem: function(item) {
item.intertype = 'mathop';
@@ -2226,6 +2226,8 @@ function JSify(data) {
case 'sdiv': case 'udiv': return 'Math.floor(' + ident + ' / ' + ident2 + ')';
case 'mul': return ident + ' * ' + ident2;
case 'urem': case 'srem': return 'Math.floor(' + ident + ' % ' + ident2 + ')';
+ case 'or': return ident + ' | ' + ident2;
+ case 'and': return ident + ' & ' + ident2;
case 'xor': return ident + ' ^ ' + ident2;
case 'shl': case 'ashl': return ident + ' << ' + ident2;
case 'shr': case 'ashr': return ident + ' >> ' + ident2;
diff --git a/tests/runner.py b/tests/runner.py
index c72b1e86..165f2aa4 100644
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -167,11 +167,15 @@ class T(unittest.TestCase):
int j = i << 6;
j >>= 1;
j = j ^ 5;
- printf("*%d,%d,%d,%d,%d,%d,%d*\\n", x, y, z, w, k, i, j);
+ int h = 1;
+ h |= 0;
+ int p = h;
+ p &= 0;
+ printf("*%d,%d,%d,%d,%d,%d,%d,%d,%d*\\n", x, y, z, w, k, i, j, h, p);
return 0;
}
'''
- self.do_test(src, '*5,23,10,19,101,1,37*')
+ self.do_test(src, '*5,23,10,19,101,1,37,1,0*')
def test_floatvars(self):
src = '''