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: 0cf0f61bf2c3^
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: febbf0e802be
Choose a head ref
  • 4 commits
  • 5 files changed
  • 1 contributor

Commits on Jan 10, 2015

  1. Copy the full SHA
    0cf0f61 View commit details
  2. [Truffle] Pulled in Rubinius's implementation of Enumerable now that …

    …Rubinius.single_block_arg works.
    nirvdrum committed Jan 10, 2015
    Copy the full SHA
    145ae71 View commit details
  3. Copy the full SHA
    1245eed View commit details

Commits on Jan 12, 2015

  1. Copy the full SHA
    febbf0e View commit details
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* 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.rubinius;

import com.oracle.truffle.api.frame.*;
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.RubyArray;

public class RubiniusSingleBlockArgNode extends RubyNode {
public RubiniusSingleBlockArgNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

@Override
public Object execute(VirtualFrame frame) {
notDesignedForCompilation();

/**
* This is our implementation of Rubinius.single_block_arg.
*
* In Rubinius, this method inspects the values yielded to the block, regardless of whether the block
* captures the values, and returns the first yielded value.
*/

int userArgumentCount = RubyArguments.getUserArgumentsCount(frame.getArguments());

if (userArgumentCount == 1) {
return RubyArguments.getUserArgument(frame.getArguments(), 0);

} else if (userArgumentCount > 1) {
Object[] extractedArguments = RubyArguments.extractUserArguments(frame.getArguments());

return RubyArray.fromObjects(getContext().getCoreLibrary().getArrayClass(), extractedArguments);

} else {
return getContext().getCoreLibrary().getNilObject();
}
}
}
Original file line number Diff line number Diff line change
@@ -289,6 +289,7 @@ public void initialize() {
objectClass.include(null, kernelModule);
numericClass.include(null, comparableModule);
arrayClass.include(null, enumerableModule);
rangeClass.include(null, enumerableModule);

// Set constants

Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@
import org.jruby.truffle.nodes.objects.SelfNode;
import org.jruby.truffle.nodes.rubinius.CallRubiniusPrimitiveNode;
import org.jruby.truffle.nodes.rubinius.RubiniusPrimitiveConstructor;
import org.jruby.truffle.nodes.rubinius.RubiniusSingleBlockArgNode;
import org.jruby.truffle.nodes.yield.YieldNode;
import org.jruby.truffle.runtime.LexicalScope;
import org.jruby.truffle.runtime.RubyContext;
@@ -364,6 +365,8 @@ public RubyNode visitCallNode(CallNode node) {
return translateRubiniusInvokePrimitive(sourceSection, node);
} else if (node.getName().equals("privately")) {
return translateRubiniusPrivately(sourceSection, node);
} else if (node.getName().equals("single_block_arg")) {
return translateRubiniusSingleBlockArg(sourceSection, node);
}
}

@@ -492,6 +495,10 @@ private RubyNode translateRubiniusPrivately(SourceSection sourceSection, CallNod
}
}

public RubyNode translateRubiniusSingleBlockArg(SourceSection sourceSection, CallNode node) {
return new RubiniusSingleBlockArgNode(context, sourceSection);
}

/**
* See translateDummyAssignment to understand what this is for.
*/
Original file line number Diff line number Diff line change
@@ -8,10 +8,6 @@

module Rubinius

def self.single_block_arg
raise "not implemented"
end

def self.mathn_loaded?
false
end
Loading