Skip to content

Commit

Permalink
[mmd] Implement redispatching to candidate list
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Apr 7, 2011
1 parent f95532e commit 70fa410
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
23 changes: 17 additions & 6 deletions lib/Kernel.cs
Expand Up @@ -22,6 +22,7 @@ public sealed class DispatchEnt {
public Frame outer;
public P6any ip6;

public DispatchEnt() {}
public DispatchEnt(DispatchEnt next, P6any ip6) {
this.ip6 = ip6;
this.next = next;
Expand Down Expand Up @@ -1340,6 +1341,13 @@ public class MMDCandidateLongname {
while ((dth.info.param0 as P6any[]) == null) dth = dth.outer;

Console.WriteLine("---");
DispatchEnt root = new DispatchEnt();
DispatchEnt ptr = root;

// XXX I think this is a harmless race
//MMDCandidate[] cs = dth.info.param1 as MMDCandidate[];
//if (cs == null)
// dth.info.param1 = cs = MMDAnalyze(dth.info.param0 as P6any[]);
foreach (P6any p in dth.info.param0 as P6any[]) {
Console.WriteLine((new MMDCandidateLongname(p)).LongName());
SubInfo si = (SubInfo)p.GetSlot("info");
Expand All @@ -1349,17 +1357,20 @@ public class MMDCandidateLongname {
Console.WriteLine("NOT BINDABLE");
} else {
Console.WriteLine("BINDABLE");
ptr.next = new DispatchEnt(null, p);
ptr = ptr.next;
}
}

// XXX I think this is a harmless race
//MMDCandidate[] cs = dth.info.param1 as MMDCandidate[];
//if (cs == null)
// dth.info.param1 = cs = MMDAnalyze(dth.info.param0 as P6any[]);
root = root.next;
if (root == null)
return Kernel.Die(th, "No matching candidates to dispatch for " + dth.info.name);

if (tailcall) th = th.caller;
th.resultSlot = NewROScalar(AnyP);
return th;
Frame nf = root.info.Binder(th.MakeChild(root.outer, root.info),
dth.pos, dth.named, false);
nf.curDisp = root;
return nf;
}

private static Frame StandardTypeProtoC(Frame th) {
Expand Down
3 changes: 2 additions & 1 deletion test2.pl
Expand Up @@ -121,7 +121,8 @@
is C20.b3(True), "bool", "multimethod sorting works (3)";
is C20.b3("foo"), "any", "multimethod sorting works (4)";

dies_ok { C20.b4("foo", "bar") }, "multimethod tie checking works";
dies_ok { C20.b4("foo", "bar") }, "multimethod fail checking works";
dies_ok { C20.b4(True, True) }, "multimethod tie checking works";
}

#is $?FILE, 'test.pl', '$?FILE works';
Expand Down

0 comments on commit 70fa410

Please sign in to comment.