Skip to content

Commit 2f0f6c7

Browse files
committed
Add bit-shifting ops to ast_util::eval_const_expr
Closes #1659
1 parent edd8612 commit 2f0f6c7

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/comp/syntax/ast_util.rs

+4
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ fn eval_const_expr(e: @expr) -> const_val {
265265
mul { const_int(a * b) } div { const_int(a / b) }
266266
rem { const_int(a % b) } and | bitand { const_int(a & b) }
267267
or | bitor { const_int(a | b) } bitxor { const_int(a ^ b) }
268+
lsl { const_int(a << b) } lsr { const_int(a >> b) }
269+
asr { const_int(a >>> b) }
268270
eq { fromb(a == b) } lt { fromb(a < b) }
269271
le { fromb(a <= b) } ne { fromb(a != b) }
270272
ge { fromb(a >= b) } gt { fromb(a > b) }
@@ -276,6 +278,8 @@ fn eval_const_expr(e: @expr) -> const_val {
276278
mul { const_uint(a * b) } div { const_uint(a / b) }
277279
rem { const_uint(a % b) } and | bitand { const_uint(a & b) }
278280
or | bitor { const_uint(a | b) } bitxor { const_uint(a ^ b) }
281+
lsl { const_int(a << b as i64) } lsr { const_int(a >> b as i64) }
282+
asr { const_int(a >>> b as i64) }
279283
eq { fromb(a == b) } lt { fromb(a < b) }
280284
le { fromb(a <= b) } ne { fromb(a != b) }
281285
ge { fromb(a >= b) } gt { fromb(a > b) }

0 commit comments

Comments
 (0)