Skip to content

Commit

Permalink
Showing 3 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -12,18 +12,23 @@
import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.core.RubyNilClass;
import org.jruby.truffle.runtime.core.RubyProc;

import java.util.Arrays;

public class GeneralSuperReCallNode extends AbstractGeneralSuperCallNode {

private final boolean inBlock;
@Child private RubyNode block;

public GeneralSuperReCallNode(RubyContext context, SourceSection sourceSection, boolean inBlock) {
public GeneralSuperReCallNode(RubyContext context, SourceSection sourceSection, boolean inBlock, RubyNode block) {
super(context, sourceSection);
this.inBlock = inBlock;
this.block = block;
}

@Override
@@ -45,6 +50,16 @@ public final Object execute(VirtualFrame frame) {

final Object[] superArguments = Arrays.copyOf(originalArguments, originalArguments.length);

if (block != null) {
Object blockObject = block.execute(frame);

if (blockObject == nil()) {
blockObject = null;
}

superArguments[RubyArguments.BLOCK_INDEX] = blockObject;
}

superArguments[RubyArguments.METHOD_INDEX] = superMethod;

return callNode.call(frame, superArguments);
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ public class BodyTranslator extends Translator {
public boolean useClassVariablesAsIfInClass = false;
private boolean translatingNextExpression = false;
private boolean translatingWhile = false;
private String currentCallMethodName = null;
protected String currentCallMethodName = null;

private boolean privately = false;

Original file line number Diff line number Diff line change
@@ -268,7 +268,17 @@ public RubyNode visitZSuperNode(org.jruby.ast.ZSuperNode node) {
environment.setNeedsDeclarationFrame();
}

return new GeneralSuperReCallNode(context, sourceSection, environment.isBlock());
final RubyNode blockNode;

if (node.getIterNode() != null) {
currentCallMethodName = environment.getNamedMethodName();
node.getIterNode().accept(this);
blockNode = null;
} else {
blockNode = null;
}

return new GeneralSuperReCallNode(context, sourceSection, environment.isBlock(), blockNode);
}

@Override

1 comment on commit 36fbd3b

@nirvdrum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any specs or MRI tests for this? If not, we should probably add a language spec.

Please sign in to comment.