Skip to content

Commit

Permalink
Showing 28 changed files with 137 additions and 38 deletions.
18 changes: 18 additions & 0 deletions test/truffle/pe/core/block_given_pe.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

module BlockGivenFixtures

def self.foo
block_given?
end

end

example "BlockGivenFixtures.foo", false
example "BlockGivenFixtures.foo { }", true
1 change: 1 addition & 0 deletions test/truffle/pe/pe.rb
Original file line number Diff line number Diff line change
@@ -70,6 +70,7 @@ def tagged_counter_example(code)
require_relative 'core/objectid_pe.rb'
require_relative 'core/binding_pe.rb'
require_relative 'core/frozen_pe.rb'
require_relative 'core/block_given_pe.rb'
require_relative 'macro/pushing_pixels_pe.rb'
end

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.nodes.arguments;

import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.source.SourceSection;
import com.oracle.truffle.api.utilities.ConditionProfile;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.runtime.NotProvided;
import org.jruby.truffle.runtime.RubyArguments;
import org.jruby.truffle.runtime.RubyContext;

public class ReadCallerFrameNode extends RubyNode {

private final ConditionProfile hasCallerFrameProfile = ConditionProfile.createBinaryProfile();

public ReadCallerFrameNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
public Object execute(VirtualFrame frame) {
final Object callerFrame = RubyArguments.getCallerFrame(frame.getArguments());

if (hasCallerFrameProfile.profile(callerFrame != null)) {
return callerFrame;
} else {
return NotProvided.INSTANCE;
}
}

}
Original file line number Diff line number Diff line change
@@ -9,8 +9,6 @@
*/
package org.jruby.truffle.nodes.core;

import java.util.Set;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.Cached;
@@ -47,7 +45,7 @@ public static DynamicObject createBinding(RubyContext context, MaterializedFrame
RubyArguments.pack(
RubyArguments.getMethod(arguments),
frame,
RubyArguments.getSelf(arguments),
null, RubyArguments.getSelf(arguments),
RubyArguments.getBlock(arguments),
RubyArguments.extractUserArguments(arguments)),
new FrameDescriptor(context.getCoreLibrary().getNilObject()));
Original file line number Diff line number Diff line change
@@ -46,6 +46,8 @@
*/
boolean isModuleFunction() default false;

boolean needsCallerFrame() default false;

// arguments specification
/** Whether <code>self</code> is passed as first argument to specializations. */
boolean needsSelf() default true;
Original file line number Diff line number Diff line change
@@ -153,13 +153,19 @@ private static RubyRootNode makeGenericMethod(RubyContext context, MethodDetails

final int required = method.required();
final int optional = method.optional();
final boolean needsCallerFrame = method.needsCallerFrame();
final boolean alwaysInline = needsCallerFrame;

final Arity arity = new Arity(required, optional, method.rest());

final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, method.names()[0], false, null, context.getOptions().CORE_ALWAYS_CLONE);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, method.names()[0], false, null, context.getOptions().CORE_ALWAYS_CLONE, alwaysInline, needsCallerFrame);

final List<RubyNode> argumentsNodes = new ArrayList<>();

if (needsCallerFrame) {
argumentsNodes.add(new ReadCallerFrameNode(context, sourceSection));
}

// Do not use needsSelf=true in module functions, it is either the module/class or the instance.
// Usage of needsSelf is quite rare for singleton methods (except constructors).
final boolean needsSelf = method.constructor() || (!method.isModuleFunction() && !method.onSingleton() && method.needsSelf());
Original file line number Diff line number Diff line change
@@ -300,17 +300,24 @@ public DynamicObject binding() {
}
}

@CoreMethod(names = "block_given?", isModuleFunction = true)
@CoreMethod(names = "block_given?", isModuleFunction = true, needsCallerFrame = true)
public abstract static class BlockGivenNode extends CoreMethodArrayArgumentsNode {

public BlockGivenNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Specialization
public boolean blockGiven() {
public boolean blockGiven(MaterializedFrame callerFrame) {
return RubyArguments.getBlock(callerFrame.getArguments()) != null;
}

@TruffleBoundary
@Specialization
public boolean blockGiven(NotProvided noCallerFrame) {
return RubyArguments.getBlock(Truffle.getRuntime().getCallerFrame().getFrame(FrameInstance.FrameAccess.READ_ONLY, false).getArguments()) != null;
}

}

@CoreMethod(names = "__callee__", needsSelf = false)
@@ -564,7 +571,7 @@ public Object evalNoBindingCached(
return callNode.call(frame, RubyArguments.pack(
method,
parentFrame,
callerSelf,
null, callerSelf,
null,
new Object[]{}));
}
Original file line number Diff line number Diff line change
@@ -111,7 +111,7 @@ private Object[] packArguments(DynamicObject method, InternalMethod internalMeth
return RubyArguments.pack(
internalMethod,
internalMethod.getDeclarationFrame(),
Layouts.METHOD.getReceiver(method),
null, Layouts.METHOD.getReceiver(method),
procOrNullNode.executeProcOrNull(block),
arguments);
}
Original file line number Diff line number Diff line change
@@ -405,7 +405,7 @@ public DynamicObject generateAccessor(VirtualFrame frame, DynamicObject module,
final String indicativeName = name + "(attr_" + (isGetter ? "reader" : "writer") + ")";

final CheckArityNode checkArity = new CheckArityNode(getContext(), sourceSection, arity);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, indicativeName, false, null, false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, LexicalScope.NONE, arity, indicativeName, false, null, false, false, false);

final SelfNode self = new SelfNode(getContext(), sourceSection);
final RubyNode accessInstanceVariable;
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ public static Object[] packArguments(DynamicObject proc, Object... args) {
return RubyArguments.pack(
Layouts.PROC.getMethod(proc),
Layouts.PROC.getDeclarationFrame(proc),
Layouts.PROC.getSelf(proc),
null, Layouts.PROC.getSelf(proc),
Layouts.PROC.getBlock(proc),
args);
}
Original file line number Diff line number Diff line change
@@ -139,7 +139,7 @@ protected DynamicObject createProc(VirtualFrame frame, DynamicObject symbol) {

final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(
sourceSection, null, Arity.NO_ARGUMENTS, Layouts.SYMBOL.getString(symbol),
true, null, false);
true, null, false, false, false);

final RubyRootNode rootNode = new RubyRootNode(
getContext(), sourceSection,
Original file line number Diff line number Diff line change
@@ -2251,7 +2251,7 @@ public Object max(VirtualFrame frame, DynamicObject array) {

final InternalMethod method = RubyArguments.getMethod(frame.getArguments());
final VirtualFrame maximumClosureFrame = Truffle.getRuntime().createVirtualFrame(
RubyArguments.pack(method, null, array, null, new Object[] {}), maxBlock.getFrameDescriptor());
RubyArguments.pack(method, null, null, array, null, new Object[] {}), maxBlock.getFrameDescriptor());
maximumClosureFrame.setObject(maxBlock.getFrameSlot(), maximum);

final DynamicObject block = ProcNodes.createRubyProc(getContext().getCoreLibrary().getProcFactory(), ProcNodes.Type.PROC,
@@ -2309,7 +2309,7 @@ public MaxBlock(RubyContext context) {
frameDescriptor = new FrameDescriptor(context.getCoreLibrary().getNilObject());
frameSlot = frameDescriptor.addFrameSlot("maximum_memo");

sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "max", false, null, false);
sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "max", false, null, false, false, false);

callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(
context, sourceSection, null, sharedMethodInfo,
@@ -2356,7 +2356,7 @@ public Object min(VirtualFrame frame, DynamicObject array) {

final InternalMethod method = RubyArguments.getMethod(frame.getArguments());
final VirtualFrame minimumClosureFrame = Truffle.getRuntime().createVirtualFrame(
RubyArguments.pack(method, null, array, null, new Object[] {}), minBlock.getFrameDescriptor());
RubyArguments.pack(method, null, null, array, null, new Object[] {}), minBlock.getFrameDescriptor());
minimumClosureFrame.setObject(minBlock.getFrameSlot(), minimum);

final DynamicObject block = ProcNodes.createRubyProc(getContext().getCoreLibrary().getProcFactory(), ProcNodes.Type.PROC,
@@ -2414,7 +2414,7 @@ public MinBlock(RubyContext context) {
frameDescriptor = new FrameDescriptor(context.getCoreLibrary().getNilObject());
frameSlot = frameDescriptor.addFrameSlot("minimum_memo");

sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "min", false, null, false);
sharedMethodInfo = new SharedMethodInfo(sourceSection, null, Arity.NO_ARGUMENTS, "min", false, null, false, false, false);

callTarget = Truffle.getRuntime().createCallTarget(new RubyRootNode(
context, sourceSection, null, sharedMethodInfo,
Original file line number Diff line number Diff line change
@@ -49,15 +49,15 @@ public CachedBooleanDispatchNode(

if (falseMethod != null) {
this.falseCallDirect = Truffle.getRuntime().createDirectCallNode(falseMethod.getCallTarget());
applySplittingStrategy(falseCallDirect, falseMethod);
applySplittingInliningStrategy(falseCallDirect, falseMethod);
}

this.trueUnmodifiedAssumption = trueUnmodifiedAssumption;
this.trueMethod = trueMethod;

if (trueMethod != null) {
this.trueCallDirect = Truffle.getRuntime().createDirectCallNode(trueMethod.getCallTarget());
applySplittingStrategy(trueCallDirect, trueMethod);
applySplittingInliningStrategy(trueCallDirect, trueMethod);
}
}

Original file line number Diff line number Diff line change
@@ -43,7 +43,7 @@ public CachedBoxedDispatchNode(
this.next = next;
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());
applySplittingStrategy(callNode, method);
applySplittingInliningStrategy(callNode, method);
}

@Override
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ public CachedBoxedSymbolDispatchNode(
this.unmodifiedAssumption = Layouts.MODULE.getFields(context.getCoreLibrary().getSymbolClass()).getUnmodifiedAssumption();
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());
applySplittingStrategy(callNode, method);
applySplittingInliningStrategy(callNode, method);
}

@Override
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
*/
package org.jruby.truffle.nodes.dispatch;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.DirectCallNode;
import com.oracle.truffle.api.object.DynamicObject;
@@ -79,19 +80,26 @@ protected DynamicObject getCachedNameAsSymbol() {
return cachedNameAsSymbol;
}

protected void applySplittingStrategy(DirectCallNode callNode, InternalMethod method) {
protected void applySplittingInliningStrategy(DirectCallNode callNode, InternalMethod method) {
if (callNode.isCallTargetCloningAllowed() && method.getSharedMethodInfo().shouldAlwaysClone()) {
insert(callNode);
callNode.cloneCallTarget();
}

if (method.getSharedMethodInfo().shouldAlwaysInline() && callNode.isInlinable()) {
callNode.forceInlining();
}
}

protected static Object call(DirectCallNode callNode, VirtualFrame frame, InternalMethod method, Object receiver, DynamicObject block, Object[] arguments) {
CompilerAsserts.compilationConstant(method.getSharedMethodInfo().needsCallerFrame());

return callNode.call(
frame,
RubyArguments.pack(
method,
method.getDeclarationFrame(),
method.getSharedMethodInfo().needsCallerFrame() ? frame.materialize() : null,
receiver,
block,
arguments));
Original file line number Diff line number Diff line change
@@ -46,7 +46,7 @@ public CachedSingletonDispatchNode(
this.next = next;
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());
applySplittingStrategy(callNode, method);
applySplittingInliningStrategy(callNode, method);
}

@Override
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public CachedUnboxedDispatchNode(
this.unmodifiedAssumption = unmodifiedAssumption;
this.method = method;
this.callNode = Truffle.getRuntime().createDirectCallNode(method.getCallTarget());
applySplittingStrategy(callNode, method);
applySplittingInliningStrategy(callNode, method);
}

@Override
Original file line number Diff line number Diff line change
@@ -116,6 +116,7 @@ private Object call(VirtualFrame frame, InternalMethod method, Object receiverOb
RubyArguments.pack(
method,
method.getDeclarationFrame(),
null,
receiverObject,
blockObject,
argumentsObjects));
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ public Object execute(VirtualFrame frame) {
Layouts.MODULE.getFields(lexicalScope.getParent().getLiveModule()).addLexicalDependent(module);

final InternalMethod definition = definitionMethod.executeMethod(frame).withDeclaringModule(module);
return callModuleDefinitionNode.call(frame, definition.getCallTarget(), RubyArguments.pack(definition, definition.getDeclarationFrame(), module, null, new Object[]{}));
return callModuleDefinitionNode.call(frame, definition.getCallTarget(), RubyArguments.pack(definition, definition.getDeclarationFrame(), null, module, null, new Object[]{}));
}

}
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ public final Object execute(VirtualFrame frame) {
throw new RaiseException(getContext().getCoreLibrary().noMethodError(String.format("super: no superclass method `%s'", name), name, this));
}

final Object[] frameArguments = RubyArguments.pack(superMethod, superMethod.getDeclarationFrame(), self, blockObject, argumentsArray);
final Object[] frameArguments = RubyArguments.pack(superMethod, superMethod.getDeclarationFrame(), null, self, blockObject, argumentsArray);

return callMethodNode.executeCallMethod(frame, superMethod, frameArguments);
}
Original file line number Diff line number Diff line change
@@ -103,7 +103,7 @@ public final Object execute(VirtualFrame frame) {
final Object[] frameArguments = RubyArguments.pack(
superMethod,
RubyArguments.getDeclarationFrame(originalArguments),
RubyArguments.getSelf(originalArguments),
null, RubyArguments.getSelf(originalArguments),
blockObject,
superArguments);

Original file line number Diff line number Diff line change
@@ -70,7 +70,7 @@ private Object[] packArguments(DynamicObject block, Object self, Object blockArg
return RubyArguments.pack(
Layouts.PROC.getMethod(block),
Layouts.PROC.getDeclarationFrame(block),
self,
null, self,
(DynamicObject) blockArgument,
arguments);
}
Original file line number Diff line number Diff line change
@@ -25,11 +25,12 @@ public final class RubyArguments {

public static final int METHOD_INDEX = 0;
public static final int DECLARATION_FRAME_INDEX = 1;
public static final int CALLER_FRAME_INDEX = 2;
public static final int SELF_INDEX = 3;
public static final int BLOCK_INDEX = 4;
public static final int RUNTIME_ARGUMENT_COUNT = 5;

public static Object[] pack(InternalMethod method, MaterializedFrame declarationFrame, Object self, DynamicObject block, Object[] arguments) {
public static Object[] pack(InternalMethod method, MaterializedFrame declarationFrame, MaterializedFrame callerFrame, Object self, DynamicObject block, Object[] arguments) {
assert method != null;
assert self != null;
assert block == null || RubyGuards.isRubyProc(block);
@@ -39,6 +40,7 @@ public static Object[] pack(InternalMethod method, MaterializedFrame declaration

packed[METHOD_INDEX] = method;
packed[DECLARATION_FRAME_INDEX] = declarationFrame;
packed[CALLER_FRAME_INDEX] = callerFrame;
packed[SELF_INDEX] = self;
packed[BLOCK_INDEX] = block;
ArrayUtils.arraycopy(arguments, 0, packed, RUNTIME_ARGUMENT_COUNT, arguments.length);
@@ -133,6 +135,10 @@ public static MaterializedFrame tryGetDeclarationFrame(Object[] arguments) {
return null;
}

public static MaterializedFrame getCallerFrame(Object[] arguments) {
return (MaterializedFrame) arguments[CALLER_FRAME_INDEX];
}

public static MaterializedFrame getDeclarationFrame(Object[] arguments) {
return (MaterializedFrame) arguments[DECLARATION_FRAME_INDEX];
}
Original file line number Diff line number Diff line change
@@ -206,7 +206,7 @@ public Object send(Object object, String methodName, DynamicObject block, Object
}

return method.getCallTarget().call(
RubyArguments.pack(method, method.getDeclarationFrame(), object, block, arguments));
RubyArguments.pack(method, method.getDeclarationFrame(), null, object, block, arguments));
}

/* For debugging in Java. */
@@ -234,7 +234,7 @@ private MaterializedFrame setupInlineRubyFrame(Frame frame, Object... arguments)
RubyArguments.pack(
RubyArguments.getMethod(frame.getArguments()),
null,
RubyArguments.getSelf(frame.getArguments()),
null, RubyArguments.getSelf(frame.getArguments()),
null,
new Object[]{}),
new FrameDescriptor(frame.getFrameDescriptor().getDefaultValue()));
@@ -435,7 +435,7 @@ public Object execute(Source source, Encoding defaultEncoding, TranslatorDriver.
final InternalMethod method = new InternalMethod(rootNode.getSharedMethodInfo(), rootNode.getSharedMethodInfo().getName(),
getCoreLibrary().getObjectClass(), Visibility.PUBLIC, false, callTarget, parentFrame);

return callTarget.call(RubyArguments.pack(method, parentFrame, self, null, new Object[]{}));
return callTarget.call(RubyArguments.pack(method, parentFrame, null, self, null, new Object[]{}));
}

public long getNextObjectID() {
Original file line number Diff line number Diff line change
@@ -29,8 +29,10 @@ public class SharedMethodInfo {
private final boolean isBlock;
private final ArgumentDescriptor[] argumentDescriptors;
private final boolean alwaysClone;
private final boolean alwaysInline;
private final boolean needsCallerFrame;

public SharedMethodInfo(SourceSection sourceSection, LexicalScope lexicalScope, Arity arity, String name, boolean isBlock, ArgumentDescriptor[] argumentDescriptors, boolean alwaysClone) {
public SharedMethodInfo(SourceSection sourceSection, LexicalScope lexicalScope, Arity arity, String name, boolean isBlock, ArgumentDescriptor[] argumentDescriptors, boolean alwaysClone, boolean alwaysInline, boolean needsCallerFrame) {
assert sourceSection != null;
assert name != null;

@@ -41,6 +43,8 @@ public SharedMethodInfo(SourceSection sourceSection, LexicalScope lexicalScope,
this.isBlock = isBlock;
this.argumentDescriptors = argumentDescriptors;
this.alwaysClone = alwaysClone;
this.alwaysInline = alwaysInline;
this.needsCallerFrame = needsCallerFrame;
}

public SourceSection getSourceSection() {
@@ -71,8 +75,16 @@ public boolean shouldAlwaysClone() {
return alwaysClone;
}

public boolean shouldAlwaysInline() {
return alwaysInline;
}

public boolean needsCallerFrame() {
return needsCallerFrame;
}

public SharedMethodInfo withName(String newName) {
return new SharedMethodInfo(sourceSection, lexicalScope, arity, newName, isBlock, argumentDescriptors, alwaysClone);
return new SharedMethodInfo(sourceSection, lexicalScope, arity, newName, isBlock, argumentDescriptors, alwaysClone, false, false);
}

@Override
Original file line number Diff line number Diff line change
@@ -844,7 +844,7 @@ public RubyNode visitCaseNode(org.jruby.ast.CaseNode node) {
private RubyNode openModule(SourceSection sourceSection, RubyNode defineOrGetNode, String name, Node bodyNode) {
LexicalScope newLexicalScope = environment.pushLexicalScope();
try {
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, newLexicalScope, Arity.NO_ARGUMENTS, name, false, null, false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, newLexicalScope, Arity.NO_ARGUMENTS, name, false, null, false, false, false);

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(context, environment, environment.getParseEnvironment(),
environment.getParseEnvironment().allocateReturnID(), true, true, sharedMethodInfo, name, false, null);
@@ -1135,7 +1135,7 @@ public RubyNode visitDefsNode(org.jruby.ast.DefsNode node) {
}

protected RubyNode translateMethodDefinition(SourceSection sourceSection, RubyNode classNode, String methodName, org.jruby.ast.Node parseTree, org.jruby.ast.ArgsNode argsNode, org.jruby.ast.Node bodyNode) {
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), methodName, false, Helpers.argsNodeToArgumentDescriptors(parseTree.findFirstChild(ArgsNode.class)), false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), methodName, false, Helpers.argsNodeToArgumentDescriptors(parseTree.findFirstChild(ArgsNode.class)), false, false, false);

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(
context, environment, environment.getParseEnvironment(), environment.getParseEnvironment().allocateReturnID(), true, true, sharedMethodInfo, methodName, false, null);
@@ -1800,7 +1800,7 @@ public RubyNode visitIterNode(org.jruby.ast.IterNode node) {
}

// Unset this flag for any for any blocks within the for statement's body
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), currentCallMethodName, true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(ArgsNode.class)), false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), currentCallMethodName, true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(ArgsNode.class)), false, false, false);

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(
context, environment, environment.getParseEnvironment(), environment.getReturnID(), hasOwnScope, false,
@@ -2900,7 +2900,7 @@ public RubyNode visitLambdaNode(org.jruby.ast.LambdaNode node) {
}

// TODO(cs): code copied and modified from visitIterNode - extract common
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), "(lambda)", true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(ArgsNode.class)), false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, environment.getLexicalScope(), MethodTranslator.getArity(argsNode), "(lambda)", true, Helpers.argsNodeToArgumentDescriptors(node.findFirstChild(ArgsNode.class)), false, false, false);

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(
context, environment, environment.getParseEnvironment(), environment.getReturnID(), false, false,
Original file line number Diff line number Diff line change
@@ -119,7 +119,7 @@ private RubyRootNode parse(Node currentNode, RubyContext context, Source source,
parseEnvironment.resetLexicalScope(lexicalScope);

// TODO (10 Feb. 2015): name should be "<top (required)> for the require-d/load-ed files.
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, parseEnvironment.getLexicalScope(), Arity.NO_ARGUMENTS, "<main>", false, null, false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, parseEnvironment.getLexicalScope(), Arity.NO_ARGUMENTS, "<main>", false, null, false, false, false);

final TranslatorEnvironment environment = new TranslatorEnvironment(context, environmentForFrame(context, parentFrame),
parseEnvironment, parseEnvironment.allocateReturnID(), ownScopeForAssignments, false, sharedMethodInfo, sharedMethodInfo.getName(), false, null);
@@ -194,7 +194,7 @@ private TranslatorEnvironment environmentForFrame(RubyContext context, Materiali
return null;
} else {
SourceSection sourceSection = new NullSourceSection("Unknown source section", "(unknown)");
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, context.getRootLexicalScope(), Arity.NO_ARGUMENTS, "(unknown)", false, null, false);
final SharedMethodInfo sharedMethodInfo = new SharedMethodInfo(sourceSection, context.getRootLexicalScope(), Arity.NO_ARGUMENTS, "(unknown)", false, null, false, false, false);
final MaterializedFrame parent = RubyArguments.getDeclarationFrame(frame.getArguments());
// TODO(CS): how do we know if the frame is a block or not?
return new TranslatorEnvironment(context, environmentForFrame(context, parent), parseEnvironment,

0 comments on commit 3de14df

Please sign in to comment.