Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 8991b57bbcd6
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 8e87a969f109
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 15, 2015

  1. [Truffle] Lambdas should have their own ReturnID.

    * Inheriting the one from the encapsulating method works but is confusing at best.
    eregon committed Dec 15, 2015
    Copy the full SHA
    48491ec View commit details
  2. [Truffle] Clarify the meaning of isProc in MethodTranslator.

    * the LoadArgumentsTranslator wants to know if it should do Proc-like arguments handling.
    * The other usages differentiate methods from proc/lambda.
    eregon committed Dec 15, 2015
    Copy the full SHA
    8e87a96 View commit details
Original file line number Diff line number Diff line change
@@ -1762,10 +1762,13 @@ private RubyNode translateBlockLikeNode(org.jruby.ast.IterNode node, boolean isL

final String namedMethodName = isLambda ? sharedMethodInfo.getName(): environment.getNamedMethodName();

final ParseEnvironment parseEnvironment = environment.getParseEnvironment();
final ReturnID returnID = isLambda ? parseEnvironment.allocateReturnID() : environment.getReturnID();

final TranslatorEnvironment newEnvironment = new TranslatorEnvironment(
context, environment, environment.getParseEnvironment(), environment.getReturnID(), hasOwnScope, false,
sharedMethodInfo, namedMethodName, true, environment.getParseEnvironment().allocateBreakID());
final MethodTranslator methodCompiler = new MethodTranslator(currentNode, context, this, newEnvironment, isProc, source, argsNode);
context, environment, parseEnvironment, returnID, hasOwnScope, false,
sharedMethodInfo, namedMethodName, true, parseEnvironment.allocateBreakID());
final MethodTranslator methodCompiler = new MethodTranslator(currentNode, context, this, newEnvironment, true, source, argsNode);

if (isProc) {
methodCompiler.translatingForStatement = translatingForStatement;
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ public int getPreviousIndex() {
}
}

private final boolean isBlock;
private final boolean isProc;
private final BodyTranslator methodBodyTranslator;
private final Deque<ArraySlot> arraySlotStack = new ArrayDeque<>();

@@ -74,9 +74,9 @@ private enum State {

private org.jruby.ast.ArgsNode argsNode;

public LoadArgumentsTranslator(Node currentNode, RubyContext context, Source source, boolean isBlock, BodyTranslator methodBodyTranslator) {
public LoadArgumentsTranslator(Node currentNode, RubyContext context, Source source, boolean isProc, BodyTranslator methodBodyTranslator) {
super(currentNode, context, source);
this.isBlock = isBlock;
this.isProc = isProc;
this.methodBodyTranslator = methodBodyTranslator;
}

@@ -214,7 +214,7 @@ private RubyNode readArgument(SourceSection sourceSection) {
return PrimitiveArrayNodeFactory.read(context, sourceSection, loadArray(sourceSection), index);
} else {
if (state == State.PRE) {
return new ReadPreArgumentNode(context, sourceSection, index, isBlock ? MissingArgumentBehaviour.NIL : MissingArgumentBehaviour.RUNTIME_ERROR);
return new ReadPreArgumentNode(context, sourceSection, index, isProc ? MissingArgumentBehaviour.NIL : MissingArgumentBehaviour.RUNTIME_ERROR);
} else if (state == State.POST) {
return new ReadPostArgumentNode(context, sourceSection, index);
} else {
Original file line number Diff line number Diff line change
@@ -81,7 +81,8 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String
parentSourceSection.pop();
}

final LoadArgumentsTranslator loadArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, isBlock, this);
final boolean isProc = type == Type.PROC;
final LoadArgumentsTranslator loadArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, isProc, this);
final RubyNode loadArguments = argsNode.accept(loadArgumentsTranslator);

final RubyNode preludeProc;
@@ -91,7 +92,7 @@ public BlockDefinitionNode compileBlockNode(SourceSection sourceSection, String
final FrameSlot arraySlot = environment.declareVar(environment.allocateLocalTemp("destructure"));
final RubyNode writeArrayNode = new WriteLocalVariableNode(context, sourceSection, castArrayNode, arraySlot);

final LoadArgumentsTranslator destructureArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, isBlock, this);
final LoadArgumentsTranslator destructureArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, isProc, this);
destructureArgumentsTranslator.pushArraySlot(arraySlot);
final RubyNode newDestructureArguments = argsNode.accept(destructureArgumentsTranslator);

@@ -175,7 +176,7 @@ public RubyNode doCompileMethodBody(SourceSection sourceSection, String methodNa
parentSourceSection.pop();
}

final LoadArgumentsTranslator loadArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, isBlock, this);
final LoadArgumentsTranslator loadArgumentsTranslator = new LoadArgumentsTranslator(currentNode, context, source, false, this);
final RubyNode loadArguments = argsNode.accept(loadArgumentsTranslator);

final RubyNode prelude;