summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar mikebarnett <unknown>2011-03-09 18:32:10 +0000
committerGravatar mikebarnett <unknown>2011-03-09 18:32:10 +0000
commitb3f70e3d20aa57440ea5b398180581a9933daed4 (patch)
tree456ba07264552ac0a06dd1c96c41db49af30ada4
parent5b1193b10a298876092126e628c08be7151b5140 (diff)
Added a translation for typeof expressions.
Save and restore the value of Sink.RetVariable so that it doesn't get changed during the translation of a method body when new procedures end up getting declared during the translation.
-rw-r--r--BCT/BytecodeTranslator/ExpressionTraverser.cs6
-rw-r--r--BCT/BytecodeTranslator/Sink.cs3
2 files changed, 9 insertions, 0 deletions
diff --git a/BCT/BytecodeTranslator/ExpressionTraverser.cs b/BCT/BytecodeTranslator/ExpressionTraverser.cs
index d4897dc7..4281d81b 100644
--- a/BCT/BytecodeTranslator/ExpressionTraverser.cs
+++ b/BCT/BytecodeTranslator/ExpressionTraverser.cs
@@ -914,6 +914,12 @@ namespace BytecodeTranslator
Bpl.UnaryOperator.Opcode.Not, exp));
}
+ public override void Visit(ITypeOf typeOf) {
+ var v = this.sink.FindOrCreateType(typeOf.TypeToGet);
+ TranslatedExpressions.Push(new Bpl.IdentifierExpr(typeOf.Token(), v));
+ return;
+ }
+
public override void Visit(IVectorLength vectorLength) {
base.Visit(vectorLength.Vector);
var e = TranslatedExpressions.Pop();
diff --git a/BCT/BytecodeTranslator/Sink.cs b/BCT/BytecodeTranslator/Sink.cs
index 670410f6..7f6c7246 100644
--- a/BCT/BytecodeTranslator/Sink.cs
+++ b/BCT/BytecodeTranslator/Sink.cs
@@ -249,6 +249,8 @@ namespace BytecodeTranslator {
#region Look for Returnvalue
+ Bpl.Variable savedRetVariable = this.RetVariable;
+
if (method.Type.TypeCode != PrimitiveTypeCode.Void) {
Bpl.Type rettype = TranslationHelper.CciTypeToBoogie(method.Type);
out_count++;
@@ -370,6 +372,7 @@ namespace BytecodeTranslator {
}
procAndFormalMap = new ProcedureInfo(proc, formalMap, this.RetVariable);
this.declaredMethods.Add(key, procAndFormalMap);
+ this.RetVariable = savedRetVariable;
}
return procAndFormalMap.Procedure;
}