Skip to content

Commit 6167b62

Browse files
committed
[truffle] Make nqp::can more correct
Still doesn't do the full logic
1 parent 337063c commit 6167b62

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/vm/jvm/runtime/org/perl6/nqp/truffle/nodes/expression/NQPCanNode.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import com.oracle.truffle.api.frame.VirtualFrame;
33
import com.oracle.truffle.api.nodes.NodeInfo;
44
import org.perl6.nqp.truffle.nodes.NQPNode;
5-
import org.perl6.nqp.truffle.nodes.NQPIntNode;
5+
import org.perl6.nqp.truffle.nodes.NQPNodeWithSTableGetting;
66

77
import org.perl6.nqp.truffle.sixmodel.TypeObject;
88

99
import org.perl6.nqp.dsl.Deserializer;
1010

1111
@NodeInfo(shortName = "can")
12-
public final class NQPCanNode extends NQPIntNode {
12+
public final class NQPCanNode extends NQPNodeWithSTableGetting {
1313
@Child private NQPNode invocantNode;
1414
@Child private NQPNode nameNode;
1515

@@ -24,13 +24,12 @@ public long executeInt(VirtualFrame frame) {
2424
Object invocant = invocantNode.execute(frame);
2525
String name = nameNode.executeStr(frame);
2626

27-
if (invocant instanceof TypeObject) {
28-
System.out.println("can on typeobject: " + name);
29-
TypeObject typeObject = (TypeObject) invocant;
30-
return typeObject.stable.methodCache.containsKey(name) ? 1 : 0;
31-
} else {
32-
System.out.println("nqp::can on " + invocant);
33-
return 0;
34-
}
27+
// TODO not authorative method caches
28+
return getStable(invocant).methodCache.containsKey(name) ? 1 : 0;
29+
}
30+
31+
@Override
32+
public void executeVoid(VirtualFrame frame) {
33+
executeInt(frame);
3534
}
3635
}

0 commit comments

Comments
 (0)