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: 051adb38dde7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: b3e76ee32659
Choose a head ref
  • 3 commits
  • 1 file changed
  • 1 contributor

Commits on Jun 22, 2015

  1. Copy the full SHA
    9ab8e74 View commit details
  2. Copy the full SHA
    10e2de8 View commit details
  3. Copy the full SHA
    b3e76ee View commit details
Showing with 21 additions and 18 deletions.
  1. +21 −18 truffle/src/main/java/org/jruby/truffle/translator/BodyTranslator.java
Original file line number Diff line number Diff line change
@@ -74,6 +74,7 @@
import org.jruby.truffle.runtime.core.RubyEncoding;
import org.jruby.truffle.runtime.core.RubyRegexp;
import org.jruby.truffle.runtime.methods.Arity;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.translator.TranslatorEnvironment.BreakID;
import org.jruby.util.ByteList;
@@ -440,6 +441,10 @@ private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallNod
*
* CallRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
*
* or
*
* ModuleDefinedIn.foo arg1, arg2, ..., argN
*
* Where the arguments are the same arguments as the method. It looks like this is only exercised with simple
* arguments so we're not worrying too much about what happens when they're more complicated (rest,
* keywords etc).
@@ -483,7 +488,8 @@ private RubyNode translateRubiniusPrimitive(SourceSection sourceSection, CallNod

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

final int argumentsCount = callConstructor.getModule().getMethods().get(callConstructor.getMethod()).getSharedMethodInfo().getArity().getRequired();
final InternalMethod method = callConstructor.getModule().getMethods().get(callConstructor.getMethod());
final int argumentsCount = method.getSharedMethodInfo().getArity().getRequired();

for (int n = 0; n < argumentsCount; n++) {
RubyNode readArgumentNode = new ReadPreArgumentNode(context, sourceSection, n, MissingArgumentBehaviour.UNDEFINED);
@@ -512,6 +518,10 @@ private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, C
* into
*
* InvokeRubiniusPrimitiveNode(FooNode(arg1, arg2, ..., argN))
*
* or
*
* ModuleDefinedIn.foo arg1, arg2, ..., argN
*/

if (node.getArgsNode().childNodes().size() < 1 || !(node.getArgsNode().childNodes().get(0) instanceof org.jruby.ast.SymbolNode)) {
@@ -522,35 +532,28 @@ private RubyNode translateRubiniusInvokePrimitive(SourceSection sourceSection, C

final RubiniusPrimitiveConstructor primitive = context.getRubiniusPrimitiveManager().getPrimitive(primitiveName);

if (primitive instanceof RubiniusPrimitiveNodeConstructor) {
final RubiniusPrimitiveNodeConstructor nodeConstructor = (RubiniusPrimitiveNodeConstructor) primitive;
final List<RubyNode> arguments = new ArrayList<>();

final List<RubyNode> arguments = new ArrayList<>();
// The first argument was the symbol so we ignore it
for (int n = 1; n < node.getArgsNode().childNodes().size(); n++) {
RubyNode readArgumentNode = node.getArgsNode().childNodes().get(n).accept(this);
arguments.add(readArgumentNode);
}

// The first argument was the symbol so we ignore it
for (int n = 1; n < node.getArgsNode().childNodes().size(); n++) {
RubyNode readArgumentNode = node.getArgsNode().childNodes().get(n).accept(this);
if (primitive instanceof RubiniusPrimitiveNodeConstructor) {
final RubiniusPrimitiveNodeConstructor nodeConstructor = (RubiniusPrimitiveNodeConstructor) primitive;

for (int n = 1; n < arguments.size(); n++) {
if (ArrayUtils.contains(nodeConstructor.getAnnotation().lowerFixnumParameters(), n)) {
readArgumentNode = new FixnumLowerNode(readArgumentNode);
arguments.set(n, new FixnumLowerNode(arguments.get(n)));
}

arguments.add(readArgumentNode);
}

return new InvokeRubiniusPrimitiveNode(context, sourceSection,
nodeConstructor.getFactory().createNode(context, sourceSection, arguments.toArray(new RubyNode[arguments.size()])));
} else if (primitive instanceof RubiniusPrimitiveCallConstructor) {
final RubiniusPrimitiveCallConstructor callConstructor = (RubiniusPrimitiveCallConstructor) primitive;

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

// The first argument was the symbol so we ignore it
for (int n = 1; n < node.getArgsNode().childNodes().size(); n++) {
RubyNode readArgumentNode = node.getArgsNode().childNodes().get(n).accept(this);
arguments.add(readArgumentNode);
}

return new RubyCallNode(
context,
sourceSection,