summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOri Bernstein <orib@google.com>2013-01-25 18:07:46 -0500
committerOri Bernstein <orib@google.com>2013-01-25 18:07:46 -0500
commit8804ceff06b5562451c8d44c639bb88dd6990d3b (patch)
treeaeab6b2ee2ed2bcf790cfb2e298bb7a8f97b4cee
parent89e3217a0a604f94c68b9993a72166f6aede0b47 (diff)
downloadmc-8804ceff06b5562451c8d44c639bb88dd6990d3b.tar.gz
Add more fold forms.
-rw-r--r--mi/fold.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/mi/fold.c b/mi/fold.c
index 5a4eba0..c9829b8 100644
--- a/mi/fold.c
+++ b/mi/fold.c
@@ -115,6 +115,26 @@ Node *fold(Node *n)
if (islit(args[0], &a))
r = val(n->line, -a, exprtype(n));
break;
+ case Obsl:
+ if (islit(args[0], &a) && islit(args[1], &b))
+ r = val(n->line, a << b, exprtype(n));
+ break;
+ case Obsr:
+ if (islit(args[0], &a) && islit(args[1], &b))
+ r = val(n->line, a >> b, exprtype(n));
+ break;
+ case Obor:
+ if (islit(args[0], &a) && islit(args[1], &b))
+ r = val(n->line, a | b, exprtype(n));
+ break;
+ case Oband:
+ if (islit(args[0], &a) && islit(args[1], &b))
+ r = val(n->line, a & b, exprtype(n));
+ break;
+ case Obxor:
+ if (islit(args[0], &a) && islit(args[1], &b))
+ r = val(n->line, a ^ b, exprtype(n));
+ break;
case Ocast:
/* FIXME: we currentl assume that the bits of the
* val are close enough. */