Skip to content
Permalink
Browse files
[Truffle] Last of the defined? specs.
  • Loading branch information
chrisseaton committed Dec 4, 2014
1 parent 684d1bf commit 3f0df65e4890d0f40334b0b5c634295b549f7a5a
@@ -39,7 +39,7 @@ public Object execute(VirtualFrame frame) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.LAMBDA,
method.getSharedMethodInfo(), method.getCallTarget(), method.getCallTarget(),
method.getDeclarationFrame(), method.getDeclaringModule(), RubyArguments.getSelf(frame.getArguments()), null);
method.getDeclarationFrame(), method.getDeclaringModule(), method, RubyArguments.getSelf(frame.getArguments()), null);
}

@Override
@@ -2366,7 +2366,7 @@ public Object max(VirtualFrame frame, RubyArray array) {

final RubyProc block = new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
maxBlock.getSharedMethodInfo(), maxBlock.getCallTarget(), maxBlock.getCallTarget(),
maximumClosureFrame.materialize(), null, array, null);
maximumClosureFrame.materialize(), null, null, array, null);

eachNode.call(frame, array, "each", block);

@@ -2485,7 +2485,7 @@ public Object min(VirtualFrame frame, RubyArray array) {

final RubyProc block = new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
minBlock.getSharedMethodInfo(), minBlock.getCallTarget(), minBlock.getCallTarget(),
minimumClosureFrame.materialize(), null, array, null);
minimumClosureFrame.materialize(), null, null, array, null);

eachNode.call(frame, array, "each", block);

@@ -1084,7 +1084,7 @@ public RubyProc proc(RubyProc block) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.LAMBDA,
block.getSharedMethodInfo(), block.getCallTargetForMethods(), block.getCallTargetForMethods(),
block.getDeclarationFrame(), block.getDeclaringModule(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
block.getDeclarationFrame(), block.getDeclaringModule(), block.getMethod(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
}
}

@@ -1320,7 +1320,7 @@ public RubyProc proc(RubyProc block) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
block.getSharedMethodInfo(), block.getCallTarget(), block.getCallTargetForMethods(), block.getDeclarationFrame(),
block.getDeclaringModule(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
block.getDeclaringModule(), block.getMethod(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
}
}

@@ -40,7 +40,7 @@ public InitializeNode(InitializeNode prev) {
@Specialization
public RubyNilClass initialize(RubyProc proc, RubyProc block) {
proc.initialize(block.getSharedMethodInfo(), block.getCallTargetForMethods(), block.getCallTargetForMethods(),
block.getDeclarationFrame(), block.getDeclaringModule(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
block.getDeclarationFrame(), block.getDeclaringModule(), block.getMethod(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());

return getContext().getCoreLibrary().getNilObject();
}
@@ -57,7 +57,7 @@ public Object execute(VirtualFrame frame) {
}

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC, sharedMethodInfo,
callTarget, callTargetForMethods, declarationFrame, declaringModule, RubyArguments.getSelf(frame.getArguments()),
callTarget, callTargetForMethods, declarationFrame, declaringModule, RubyArguments.getMethod(frame.getArguments()), RubyArguments.getSelf(frame.getArguments()),
RubyArguments.getBlock(frame.getArguments()));
}

@@ -10,6 +10,7 @@
package org.jruby.truffle.nodes.supercall;

import com.oracle.truffle.api.*;
import com.oracle.truffle.api.frame.FrameInstance;
import com.oracle.truffle.api.source.*;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
@@ -19,21 +20,20 @@
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyClass;
import org.jruby.truffle.runtime.core.RubyModule;
import org.jruby.truffle.runtime.core.RubyProc;
import org.jruby.truffle.runtime.methods.MethodLike;
import org.jruby.truffle.runtime.methods.RubyMethod;
import org.jruby.truffle.runtime.LexicalScope;

public abstract class AbstractGeneralSuperCallNode extends RubyNode {

private final String name;

@Child protected DirectCallNode callNode;

@CompilerDirectives.CompilationFinal protected Assumption unmodifiedAssumption;
@CompilerDirectives.CompilationFinal protected RubyMethod method;

public AbstractGeneralSuperCallNode(RubyContext context, SourceSection sourceSection, String name) {
public AbstractGeneralSuperCallNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
this.name = name;
}

protected boolean guard() {
@@ -44,6 +44,15 @@ protected boolean guard() {
protected void lookup(VirtualFrame frame) {
CompilerAsserts.neverPartOfCompilation();

final FrameInstance currentFrame = Truffle.getRuntime().getCurrentFrame();
MethodLike methodLike = RubyCallStack.getMethod(currentFrame);

while (!(methodLike instanceof RubyMethod)) {
methodLike = ((RubyProc) methodLike).getMethod();
}

final String name = ((RubyMethod) methodLike).getName();

// TODO: this is wrong, we need the lexically enclosing method (or define_method)'s module
final RubyModule declaringModule = RubyCallStack.getCurrentDeclaringModule();
final RubyClass selfMetaClass = getContext().getCoreLibrary().getMetaClass(RubyArguments.getSelf(frame.getArguments()));
@@ -29,8 +29,8 @@ public class GeneralSuperCallNode extends AbstractGeneralSuperCallNode {
@Child protected RubyNode block;
@Children protected final RubyNode[] arguments;

public GeneralSuperCallNode(RubyContext context, SourceSection sourceSection, String name, RubyNode block, RubyNode[] arguments, boolean isSplatted) {
super(context, sourceSection, name);
public GeneralSuperCallNode(RubyContext context, SourceSection sourceSection, RubyNode block, RubyNode[] arguments, boolean isSplatted) {
super(context, sourceSection);
assert arguments != null;
assert !isSplatted || arguments.length == 1;
this.block = block;
@@ -19,8 +19,8 @@ public class GeneralSuperReCallNode extends AbstractGeneralSuperCallNode {

private final boolean inBlock;

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

@@ -95,7 +95,7 @@ public RubyMethod visitFrame(FrameInstance frameInstance) {
});
}

private static MethodLike getMethod(FrameInstance frame) {
public static MethodLike getMethod(FrameInstance frame) {
CompilerAsserts.neverPartOfCompilation();

if (frame == null) {
@@ -56,6 +56,7 @@ public static enum Type {
@CompilationFinal private CallTarget callTargetForMethods;
@CompilationFinal private MaterializedFrame declarationFrame;
@CompilationFinal private RubyModule declaringModule;
@CompilationFinal private MethodLike method;
@CompilationFinal private Object self;
@CompilationFinal private RubyProc block;

@@ -65,18 +66,19 @@ public RubyProc(RubyClass procClass, Type type) {
}

public RubyProc(RubyClass procClass, Type type, SharedMethodInfo sharedMethodInfo, CallTarget callTarget,
CallTarget callTargetForMethods, MaterializedFrame declarationFrame, RubyModule declaringModule, Object self, RubyProc block) {
CallTarget callTargetForMethods, MaterializedFrame declarationFrame, RubyModule declaringModule, MethodLike method, Object self, RubyProc block) {
this(procClass, type);
initialize(sharedMethodInfo, callTarget, callTargetForMethods, declarationFrame, declaringModule, self, block);
initialize(sharedMethodInfo, callTarget, callTargetForMethods, declarationFrame, declaringModule, method, self, block);
}

public void initialize(SharedMethodInfo sharedMethodInfo, CallTarget callTarget, CallTarget callTargetForMethods,
MaterializedFrame declarationFrame, RubyModule declaringModule, Object self, RubyProc block) {
MaterializedFrame declarationFrame, RubyModule declaringModule, MethodLike method, Object self, RubyProc block) {
this.sharedMethodInfo = sharedMethodInfo;
this.callTarget = callTarget;
this.callTargetForMethods = callTargetForMethods;
this.declarationFrame = declarationFrame;
this.declaringModule = declaringModule;
this.method = method;
this.self = self;
this.block = block;
}
@@ -125,6 +127,10 @@ public RubyModule getDeclaringModule() {
return declaringModule;
}

public MethodLike getMethod() {
return method;
}

public Object getSelfCapturedInScope() {
return self;
}
@@ -53,7 +53,7 @@ public RubyProc toProc(SourceSection sourceSection, final RubyNode currentNode)
final CallTarget callTarget = Truffle.getRuntime().createCallTarget(rootNode);

return new RubyProc(context.getCoreLibrary().getProcClass(), RubyProc.Type.PROC, sharedMethodInfo, callTarget,
callTarget, null, null, getContext().getCoreLibrary().getNilObject(), null);
callTarget, null, null, null, getContext().getCoreLibrary().getNilObject(), null);
}

public org.jruby.RubySymbol getJRubySymbol() {
@@ -210,7 +210,7 @@ public RubyNode visitSuperNode(org.jruby.ast.SuperNode node) {

final ArgumentsAndBlockTranslation argumentsAndBlock = translateArgumentsAndBlock(sourceSection, node.getIterNode(), node.getArgsNode(), null, environment.getNamedMethodName());

return new GeneralSuperCallNode(context, sourceSection, environment.getNamedMethodName(), argumentsAndBlock.getBlock(), argumentsAndBlock.getArguments(), argumentsAndBlock.isSplatted());
return new GeneralSuperCallNode(context, sourceSection, argumentsAndBlock.getBlock(), argumentsAndBlock.getArguments(), argumentsAndBlock.isSplatted());
}

@Override
@@ -222,7 +222,7 @@ public RubyNode visitZSuperNode(org.jruby.ast.ZSuperNode node) {
environment.setNeedsDeclarationFrame();
}

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

@Override

This file was deleted.

@@ -1,12 +1,9 @@
fails:The super keyword calls the correct method when the method visibility is modified
fails:The super keyword calls the superclass method when initial method is defined_method'd
fails:The super keyword can call through a define_method multiple times (caching check)
fails:The super keyword supers up appropriate name even if used for multiple method names
fails:The super keyword can be used with implicit arguments from a method defined with define_method
fails:The super keyword passes along modified rest args when they weren't originally empty
fails:The super keyword passes along modified rest args when they were originally empty
fails:The super keyword raises a RuntimeError when called with implicit arguments from a method defined with define_method
fails:The super keyword invokes methods from a chain of anonymous modules
fails:The super keyword respects the original module a method is aliased from
fails:The super keyword calls method_missing when a superclass method is not found
fails:The super keyword sees the included version of a module a method is alias from

0 comments on commit 3f0df65

Please sign in to comment.