diff options
author | Unknown <qadeer@GHALIB.redmond.corp.microsoft.com> | 2011-07-26 16:44:11 -0700 |
---|---|---|
committer | Unknown <qadeer@GHALIB.redmond.corp.microsoft.com> | 2011-07-26 16:44:11 -0700 |
commit | 6cee837b0cf8aeda041633e760b2b9b33d16c675 (patch) | |
tree | a907c14a1c722475657ecfab93397b7e49a470c9 /BCT | |
parent | aab74fa2448b572996da94fcfde638f0ba7ce540 (diff) |
added translation for RightShift and LeftShift
Diffstat (limited to 'BCT')
-rw-r--r-- | BCT/BytecodeTranslator/ExpressionTraverser.cs | 23 | ||||
-rw-r--r-- | BCT/BytecodeTranslator/HeapFactory.cs | 4 |
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
|