summaryrefslogtreecommitdiff
path: root/BCT/BytecodeTranslator
diff options
context:
space:
mode:
authorGravatar Unknown <qadeer@GHALIB.redmond.corp.microsoft.com>2011-07-26 16:44:11 -0700
committerGravatar Unknown <qadeer@GHALIB.redmond.corp.microsoft.com>2011-07-26 16:44:11 -0700
commit6cee837b0cf8aeda041633e760b2b9b33d16c675 (patch)
treea907c14a1c722475657ecfab93397b7e49a470c9 /BCT/BytecodeTranslator
parentaab74fa2448b572996da94fcfde638f0ba7ce540 (diff)
added translation for RightShift and LeftShift
Diffstat (limited to 'BCT/BytecodeTranslator')
-rw-r--r--BCT/BytecodeTranslator/ExpressionTraverser.cs23
-rw-r--r--BCT/BytecodeTranslator/HeapFactory.cs4
2 files changed, 27 insertions, 0 deletions
diff --git a/BCT/BytecodeTranslator/ExpressionTraverser.cs b/BCT/BytecodeTranslator/ExpressionTraverser.cs
index dd1396cd..ef6d550d 100644
--- a/BCT/BytecodeTranslator/ExpressionTraverser.cs
+++ b/BCT/BytecodeTranslator/ExpressionTraverser.cs
@@ -1186,6 +1186,29 @@ namespace BytecodeTranslator
TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Neq, lexp, rexp));
}
+ public override void Visit(IRightShift rightShift) {
+ base.Visit(rightShift);
+ Bpl.Expr rexp = TranslatedExpressions.Pop();
+ Bpl.Expr lexp = TranslatedExpressions.Pop();
+ Bpl.Expr e = new Bpl.NAryExpr(
+ rightShift.Token(),
+ new Bpl.FunctionCall(this.sink.Heap.RightShift),
+ new Bpl.ExprSeq(lexp, rexp)
+ );
+ TranslatedExpressions.Push(e);
+ }
+
+ public override void Visit(ILeftShift leftShift) {
+ base.Visit(leftShift);
+ Bpl.Expr rexp = TranslatedExpressions.Pop();
+ Bpl.Expr lexp = TranslatedExpressions.Pop();
+ Bpl.Expr e = new Bpl.NAryExpr(
+ leftShift.Token(),
+ new Bpl.FunctionCall(this.sink.Heap.LeftShift),
+ new Bpl.ExprSeq(lexp, rexp)
+ );
+ TranslatedExpressions.Push(e);
+ }
/// <summary>
/// There aren't any logical-and expressions or logical-or expressions in CCI.
/// Instead they are encoded as "x ? y : 0" for "x && y" and "x ? 1 : y"
diff --git a/BCT/BytecodeTranslator/HeapFactory.cs b/BCT/BytecodeTranslator/HeapFactory.cs
index c656a21e..27c510e6 100644
--- a/BCT/BytecodeTranslator/HeapFactory.cs
+++ b/BCT/BytecodeTranslator/HeapFactory.cs
@@ -221,6 +221,10 @@ namespace BytecodeTranslator {
public Bpl.Function BitwiseExclusiveOr = null;
[RepresentationFor("BitwiseNegation", "function BitwiseNegation(int): int;")]
public Bpl.Function BitwiseNegation = null;
+ [RepresentationFor("RightShift", "function RightShift(int): int;")]
+ public Bpl.Function RightShift = null;
+ [RepresentationFor("LeftShift", "function LeftShift(int): int;")]
+ public Bpl.Function LeftShift = null;
#endregion
#endregion