ref: 8804ceff06b5562451c8d44c639bb88dd6990d3b
parent: 89e3217a0a604f94c68b9993a72166f6aede0b47
author: Ori Bernstein <[email protected]>
date: Fri Jan 25 13:07:46 EST 2013
Add more fold forms.
--- a/mi/fold.c
+++ b/mi/fold.c
@@ -115,6 +115,26 @@
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. */