Skip to content

Commit

Permalink
Showing 6 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -955,8 +955,8 @@ public LambdaNode(RubyContext context, SourceSection sourceSection) {
@Specialization
public RubyProc proc(RubyProc block) {
return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.LAMBDA,
block.getSharedMethodInfo(), block.getCallTargetForMethods(), block.getCallTargetForMethods(),
block.getCallTargetForMethods(), block.getDeclarationFrame(), block.getMethod(),
block.getSharedMethodInfo(), block.getCallTargetForLambdas(), block.getCallTargetForLambdas(),
block.getCallTargetForLambdas(), block.getDeclarationFrame(), block.getMethod(),
block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
}
}
@@ -1179,7 +1179,7 @@ public RubyProc proc(RubyProc block) {

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC,
block.getSharedMethodInfo(), block.getCallTargetForProcs(), block.getCallTargetForProcs(),
block.getCallTargetForMethods(), block.getDeclarationFrame(), block.getMethod(),
block.getCallTargetForLambdas(), block.getDeclarationFrame(), block.getMethod(),
block.getSelfCapturedInScope(), block.getBlockCapturedInScope());
}
}
Original file line number Diff line number Diff line change
@@ -1033,7 +1033,7 @@ public RubySymbol defineMethod(VirtualFrame frame, RubyModule module, String nam
private RubySymbol defineMethod(RubyModule module, String name, RubyProc proc) {
CompilerDirectives.transferToInterpreter();

final CallTarget modifiedCallTarget = proc.getCallTargetForMethods();
final CallTarget modifiedCallTarget = proc.getCallTargetForLambdas();
final SharedMethodInfo info = proc.getSharedMethodInfo().withName(name);
final InternalMethod modifiedMethod = new InternalMethod(info, name, module, Visibility.PUBLIC, false, modifiedCallTarget, proc.getDeclarationFrame());

Original file line number Diff line number Diff line change
@@ -98,7 +98,7 @@ public InitializeNode(RubyContext context, SourceSection sourceSection) {
@Specialization
public RubyBasicObject initialize(RubyProc proc, RubyProc block) {
proc.initialize(block.getSharedMethodInfo(), block.getCallTargetForProcs(),
block.getCallTargetForProcs(), block.getCallTargetForMethods(), block.getDeclarationFrame(),
block.getCallTargetForProcs(), block.getCallTargetForLambdas(), block.getDeclarationFrame(),
block.getMethod(), block.getSelfCapturedInScope(), block.getBlockCapturedInScope());

return nil();
Original file line number Diff line number Diff line change
@@ -34,20 +34,20 @@ public class BlockDefinitionNode extends RubyNode {

private final CallTarget callTargetForBlocks;
private final CallTarget callTargetForProcs;
private final CallTarget callTargetForMethods;
private final CallTarget callTargetForLambdas;

private final boolean requiresDeclarationFrame;
private final BreakID breakID;

public BlockDefinitionNode(RubyContext context, SourceSection sourceSection, SharedMethodInfo sharedMethodInfo,
boolean requiresDeclarationFrame, CallTarget callTargetForBlocks,
CallTarget callTargetForProcs, CallTarget callTargetForMethods, BreakID breakID) {
CallTarget callTargetForProcs, CallTarget callTargetForLambdas, BreakID breakID) {
super(context, sourceSection);
this.sharedMethodInfo = sharedMethodInfo;

this.callTargetForBlocks = callTargetForBlocks;
this.callTargetForProcs = callTargetForProcs;
this.callTargetForMethods = callTargetForMethods;
this.callTargetForLambdas = callTargetForLambdas;

this.requiresDeclarationFrame = requiresDeclarationFrame;
this.breakID = breakID;
@@ -68,7 +68,7 @@ public Object execute(VirtualFrame frame) {
}

return new RubyProc(getContext().getCoreLibrary().getProcClass(), RubyProc.Type.PROC, sharedMethodInfo,
callTargetForBlocks, callTargetForProcs, callTargetForMethods,
callTargetForBlocks, callTargetForProcs, callTargetForLambdas,
declarationFrame,
RubyArguments.getMethod(frame.getArguments()),
RubyArguments.getSelf(frame.getArguments()),
Original file line number Diff line number Diff line change
@@ -36,7 +36,7 @@ public static enum Type {
/** Call target for actual Proc arguments, which handle break differently */
@CompilationFinal private CallTarget callTargetForProcs;
/** Call target for lambdas and methods, which have strict arguments destructuring */
@CompilationFinal private CallTarget callTargetForMethods;
@CompilationFinal private CallTarget callTargetForLambdas;
@CompilationFinal private MaterializedFrame declarationFrame;
/** The method which defined the block, that is the lexically enclosing method.
* Notably used by super to figure out in which method we were. */
@@ -50,20 +50,20 @@ public RubyProc(RubyClass procClass, Type type) {
}

public RubyProc(RubyClass procClass, Type type, SharedMethodInfo sharedMethodInfo, CallTarget callTargetForBlocks,
CallTarget callTargetForProcs, CallTarget callTargetForMethods, MaterializedFrame declarationFrame,
CallTarget callTargetForProcs, CallTarget callTargetForLambdas, MaterializedFrame declarationFrame,
InternalMethod method, Object self, RubyProc block) {
this(procClass, type);
initialize(sharedMethodInfo, callTargetForBlocks, callTargetForProcs, callTargetForMethods, declarationFrame,
initialize(sharedMethodInfo, callTargetForBlocks, callTargetForProcs, callTargetForLambdas, declarationFrame,
method, self, block);
}

public void initialize(SharedMethodInfo sharedMethodInfo, CallTarget callTargetForBlocks, CallTarget callTargetForProcs,
CallTarget callTargetForMethods, MaterializedFrame declarationFrame, InternalMethod method,
CallTarget callTargetForLambdas, MaterializedFrame declarationFrame, InternalMethod method,
Object self, RubyProc block) {
this.sharedMethodInfo = sharedMethodInfo;
this.callTargetForBlocks = callTargetForBlocks;
this.callTargetForProcs = callTargetForProcs;
this.callTargetForMethods = callTargetForMethods;
this.callTargetForLambdas = callTargetForLambdas;
this.declarationFrame = declarationFrame;
this.method = method;
this.self = self;
@@ -77,7 +77,7 @@ public CallTarget getCallTargetForType() {
case PROC:
return callTargetForProcs;
case LAMBDA:
return callTargetForMethods;
return callTargetForLambdas;
}

throw new UnsupportedOperationException(type.toString());
@@ -105,8 +105,8 @@ public CallTarget getCallTargetForProcs() {
return callTargetForProcs;
}

public CallTarget getCallTargetForMethods() {
return callTargetForMethods;
public CallTarget getCallTargetForLambdas() {
return callTargetForLambdas;
}

public MaterializedFrame getDeclarationFrame() {
Original file line number Diff line number Diff line change
@@ -220,29 +220,29 @@ public RubyNode compileFunctionNode(SourceSection sourceSection, String methodNa

final CallTarget callTargetAsProc = Truffle.getRuntime().createCallTarget(newRootNodeForProcs);

// Methods
final RubyRootNode newRootNodeForMethods = rootNode.cloneRubyRootNode();
// Lambdas
final RubyRootNode newRootNodeForLambdas = rootNode.cloneRubyRootNode();

for (BehaveAsBlockNode behaveAsBlockNode : NodeUtil.findAllNodeInstances(newRootNodeForMethods, BehaveAsBlockNode.class)) {
for (BehaveAsBlockNode behaveAsBlockNode : NodeUtil.findAllNodeInstances(newRootNodeForLambdas, BehaveAsBlockNode.class)) {
behaveAsBlockNode.replace(behaveAsBlockNode.getNotAsBlock());
}

for (BehaveAsProcNode behaveAsProcNode : NodeUtil.findAllNodeInstances(newRootNodeForMethods, BehaveAsProcNode.class)) {
for (BehaveAsProcNode behaveAsProcNode : NodeUtil.findAllNodeInstances(newRootNodeForLambdas, BehaveAsProcNode.class)) {
behaveAsProcNode.replace(behaveAsProcNode.getNotAsProc());
}

final RubyRootNode newRootNodeWithCatchReturn = new RubyRootNode(
context,
newRootNodeForMethods.getSourceSection(),
newRootNodeForMethods.getFrameDescriptor(), newRootNodeForMethods.getSharedMethodInfo(),
newRootNodeForLambdas.getSourceSection(),
newRootNodeForLambdas.getFrameDescriptor(), newRootNodeForLambdas.getSharedMethodInfo(),
new CatchBreakAsReturnNode(context, sourceSection,
new CatchReturnNode(context, newRootNodeForMethods.getSourceSection(),
newRootNodeForMethods.getBody(), getEnvironment().getReturnID())));
new CatchReturnNode(context, newRootNodeForLambdas.getSourceSection(),
newRootNodeForLambdas.getBody(), getEnvironment().getReturnID())));

final CallTarget callTargetAsMethod = Truffle.getRuntime().createCallTarget(newRootNodeWithCatchReturn);
final CallTarget callTargetAsLambda = Truffle.getRuntime().createCallTarget(newRootNodeWithCatchReturn);

return new BlockDefinitionNode(context, sourceSection, environment.getSharedMethodInfo(),
environment.needsDeclarationFrame(), callTargetAsBlock, callTargetAsProc, callTargetAsMethod, environment.getBreakID());
environment.needsDeclarationFrame(), callTargetAsBlock, callTargetAsProc, callTargetAsLambda, environment.getBreakID());
} else {
return new MethodDefinitionNode(context, sourceSection, methodName, environment.getSharedMethodInfo(),
environment.needsDeclarationFrame(), Truffle.getRuntime().createCallTarget(rootNode));

0 comments on commit dbabcff

Please sign in to comment.