summaryrefslogtreecommitdiff
path: root/BCT/BytecodeTranslator/WholeProgram.cs
diff options
context:
space:
mode:
authorGravatar Mike Barnett <mbarnett@microsoft.com>2011-11-10 15:43:33 -0800
committerGravatar Mike Barnett <mbarnett@microsoft.com>2011-11-10 15:43:33 -0800
commit277d5007f1b5d6988014d758e7ca1a486e1c6395 (patch)
tree0e01d31f349903b0bc7ea714d527572c7c056fd3 /BCT/BytecodeTranslator/WholeProgram.cs
parent4b18a65874f9e8d4c7ea042f22f7b57c512c6c71 (diff)
Many, many bug fixes related to generics and some other random problems.
Diffstat (limited to 'BCT/BytecodeTranslator/WholeProgram.cs')
-rw-r--r--BCT/BytecodeTranslator/WholeProgram.cs18
1 files changed, 12 insertions, 6 deletions
diff --git a/BCT/BytecodeTranslator/WholeProgram.cs b/BCT/BytecodeTranslator/WholeProgram.cs
index d90176a8..e1d2d73a 100644
--- a/BCT/BytecodeTranslator/WholeProgram.cs
+++ b/BCT/BytecodeTranslator/WholeProgram.cs
@@ -163,11 +163,19 @@ namespace BytecodeTranslator {
foreach (var typeMethodPair in overrides) {
var t = typeMethodPair.Item1;
var m = typeMethodPair.Item2;
- var typeForT = this.sink.FindOrCreateTypeReference(t);
- if (typeForT == null) {
+
+ // guard: is#T($DynamicType(local_variable))
+ var typeFunction = this.sink.FindOrDefineType(t);
+ if (typeFunction == null) {
// BUGBUG!! This just silently skips the branch that would dispatch to t's implementation of the method!
continue;
}
+ var funcName = String.Format("is#{0}", typeFunction.Name);
+ var identExpr = Bpl.Expr.Ident(new Bpl.LocalVariable(token, new Bpl.TypedIdent(token, funcName, Bpl.Type.Bool)));
+ var funcCall = new Bpl.FunctionCall(identExpr);
+ var exprs = new Bpl.ExprSeq(this.sink.Heap.DynamicType(inexpr[0]));
+ var guard = new Bpl.NAryExpr(token, funcCall, exprs);
+
var thenBranch = new Bpl.StmtListBuilder();
methodname = TranslationHelper.CreateUniqueMethodName(m); // REVIEW: Shouldn't this be call to FindOrCreateProcedure?
if (attrib != null)
@@ -175,11 +183,9 @@ namespace BytecodeTranslator {
else
call = new Bpl.CallCmd(token, methodname, inexpr, outvars);
thenBranch.Add(call);
+
ifcmd = new Bpl.IfCmd(token,
- Bpl.Expr.Binary(Bpl.BinaryOperator.Opcode.Eq,
- this.sink.Heap.DynamicType(inexpr[0]),
- typeForT
- ),
+ guard,
thenBranch.Collect(token),
null,
elseBranch.Collect(token)