summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Unknown <mbarnett@MBARNETT-LAP2.redmond.corp.microsoft.com>2011-04-21 08:15:31 -0700
committerGravatar Unknown <mbarnett@MBARNETT-LAP2.redmond.corp.microsoft.com>2011-04-21 08:15:31 -0700
commit18720c60027f4c641c44e19f8f95dce51ce0e5ec (patch)
tree3f3dd2f845945f349c094eb3502816ea39e351f5
parent5bd736fee46b289c130110fdf5cad91aa97d9475 (diff)
Added translation for "x is T" expressions.
-rw-r--r--BCT/BytecodeTranslator/ExpressionTraverser.cs14
-rw-r--r--BCT/BytecodeTranslator/Program.cs2
2 files changed, 15 insertions, 1 deletions
diff --git a/BCT/BytecodeTranslator/ExpressionTraverser.cs b/BCT/BytecodeTranslator/ExpressionTraverser.cs
index 40e13f8a..3db99307 100644
--- a/BCT/BytecodeTranslator/ExpressionTraverser.cs
+++ b/BCT/BytecodeTranslator/ExpressionTraverser.cs
@@ -897,6 +897,20 @@ namespace BytecodeTranslator
#region Translate Unary Operators
+ public override void Visit(ICheckIfInstance checkIfInstance) {
+ var v = this.sink.FindOrCreateType(checkIfInstance.TypeToCheck);
+ //var callTypeOf = new Bpl.NAryExpr(
+ // checkIfInstance.Token(),
+ // new Bpl.FunctionCall(this.sink.Heap.TypeOfFunction),
+ // new Bpl.ExprSeq(new Bpl.IdentifierExpr(checkIfInstance.Token(), v))
+ // );
+ base.Visit(checkIfInstance.Operand);
+ var exp = TranslatedExpressions.Pop();
+ var dynTypeOfOperand = this.sink.Heap.DynamicType(exp);
+ TranslatedExpressions.Push(Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Eq, dynTypeOfOperand, new Bpl.IdentifierExpr(checkIfInstance.Token(), v)));
+ return;
+ }
+
public override void Visit(IUnaryNegation unaryNegation)
{
base.Visit(unaryNegation);
diff --git a/BCT/BytecodeTranslator/Program.cs b/BCT/BytecodeTranslator/Program.cs
index 387e6134..68107f82 100644
--- a/BCT/BytecodeTranslator/Program.cs
+++ b/BCT/BytecodeTranslator/Program.cs
@@ -101,7 +101,7 @@ namespace BytecodeTranslator {
Contract.Requires(assemblyNames != null);
Contract.Requires(heapFactory != null);
- var host = new CodeContractAwareHostEnvironment(libPaths != null ? libPaths : IteratorHelper.GetEmptyEnumerable<string>(), true, true);
+ var host = new CodeContractAwareHostEnvironment(libPaths != null ? libPaths : Enumerable<string>.Empty, true, true);
Host = host;
var modules = new List<Tuple<IModule,PdbReader/*?*/>>();