Skip to content

Commit

Permalink
[truffle] Implement nqp::setmethcache
Browse files Browse the repository at this point in the history
  • Loading branch information
pmurias committed Nov 4, 2019
1 parent fb82379 commit 0dc156c
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/vm/jvm/Truffle.nqp
Expand Up @@ -272,6 +272,8 @@ class QAST::OperationsTruffle {
add_simple_op('scwbenable', $INT, []);
add_simple_op('scwbdisable', $INT, []);

add_simple_op('setmethcache', $OBJ, [$OBJ, $OBJ], :decont(0));

add_op('list_b', sub ($comp, $node, :$want) {
my @cuids;
for $node.list -> $block {
Expand Down
@@ -0,0 +1,27 @@
package org.perl6.nqp.truffle.nodes.sixmodel;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.NodeInfo;
import org.perl6.nqp.truffle.nodes.NQPNode;
import org.perl6.nqp.truffle.nodes.NQPObjNodeWithSTableGetting;
import org.perl6.nqp.truffle.runtime.NQPHash;
import org.perl6.nqp.dsl.Deserializer;

@NodeInfo(shortName = "setmethcache")
public final class NQPSetmethcacheNode extends NQPObjNodeWithSTableGetting {
@Child private NQPNode objNode;
@Child private NQPNode methodsNode;

@Deserializer
public NQPSetmethcacheNode(NQPNode objNode, NQPNode methodsNode) {
this.objNode = objNode;
this.methodsNode = methodsNode;
}

@Override
public Object execute(VirtualFrame frame) {
Object obj = objNode.execute(frame);
NQPHash methodCache = ((NQPHash) methodsNode.execute(frame));
getStable(obj).methodCache = methodCache.getContents();
return obj;
}
}

0 comments on commit 0dc156c

Please sign in to comment.