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

Commits on Oct 8, 2015

  1. Copy the full SHA
    3807072 View commit details
  2. Copy the full SHA
    ac5cf50 View commit details
1 change: 1 addition & 0 deletions spec/truffle/tags/core/proc/call_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Proc#call on a Proc created with Kernel#lambda or Kernel#proc will call #to_ary on argument and return self if return is nil
1 change: 1 addition & 0 deletions spec/truffle/tags/core/proc/case_compare_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Proc#=== on a Proc created with Kernel#lambda or Kernel#proc will call #to_ary on argument and return self if return is nil
1 change: 1 addition & 0 deletions spec/truffle/tags/core/proc/element_reference_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Proc#call on a Proc created with Kernel#lambda or Kernel#proc will call #to_ary on argument and return self if return is nil
1 change: 1 addition & 0 deletions spec/truffle/tags/core/proc/yield_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Proc#yield on a Proc created with Kernel#lambda or Kernel#proc will call #to_ary on argument and return self if return is nil
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.util.ArgumentDescriptorUtils;
import org.jruby.util.StringSupport;

@CoreClass(name = "Method")
@@ -164,8 +165,7 @@ public ParametersNode(RubyContext context, SourceSection sourceSection) {
public DynamicObject parameters(DynamicObject method) {
final ArgumentDescriptor[] argsDesc = Layouts.METHOD.getMethod(method).getSharedMethodInfo().getArgumentDescriptors();

return getContext().toTruffle(Helpers.argumentDescriptorsToParameters(getContext().getRuntime(),
argsDesc, true));
return ArgumentDescriptorUtils.argumentDescriptorsToParameters(getContext(), argsDesc, true);
}

}
Original file line number Diff line number Diff line change
@@ -42,6 +42,7 @@
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.methods.InternalMethod;
import org.jruby.truffle.runtime.methods.SharedMethodInfo;
import org.jruby.truffle.runtime.util.ArgumentDescriptorUtils;
import org.jruby.util.StringSupport;

@CoreClass(name = "Proc")
@@ -266,8 +267,7 @@ public ParametersNode(RubyContext context, SourceSection sourceSection) {
public DynamicObject parameters(DynamicObject proc) {
final ArgumentDescriptor[] argsDesc = Layouts.PROC.getSharedMethodInfo(proc).getArgumentDescriptors();

return getContext().toTruffle(Helpers.argumentDescriptorsToParameters(getContext().getRuntime(),
argsDesc, Layouts.PROC.getType(proc) == Type.LAMBDA));
return ArgumentDescriptorUtils.argumentDescriptorsToParameters(getContext(), argsDesc, Layouts.PROC.getType(proc) == Type.LAMBDA);
}

}
Original file line number Diff line number Diff line change
@@ -29,6 +29,7 @@
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.StringOperations;
import org.jruby.truffle.runtime.layouts.Layouts;
import org.jruby.truffle.runtime.util.ArgumentDescriptorUtils;
import org.jruby.util.StringSupport;

@CoreClass(name = "UnboundMethod")
@@ -159,8 +160,7 @@ public ParametersNode(RubyContext context, SourceSection sourceSection) {
public DynamicObject parameters(DynamicObject method) {
final ArgumentDescriptor[] argsDesc = Layouts.UNBOUND_METHOD.getMethod(method).getSharedMethodInfo().getArgumentDescriptors();

return getContext().toTruffle(Helpers.argumentDescriptorsToParameters(getContext().getRuntime(),
argsDesc, true));
return ArgumentDescriptorUtils.argumentDescriptorsToParameters(getContext(), argsDesc, true);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.runtime.util;

import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.runtime.ArgumentType;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.layouts.Layouts;

public class ArgumentDescriptorUtils {

public static DynamicObject argumentDescriptorsToParameters(RubyContext context, ArgumentDescriptor[] argsDesc, boolean isLambda) {
final Object[] params = new Object[argsDesc.length];

for (int i = 0; i < argsDesc.length; i++) {
params[i] = toArray(context, argsDesc[i], isLambda);
}

return Layouts.ARRAY.createArray(context.getCoreLibrary().getArrayFactory(), params, params.length);
}

public static DynamicObject toArray(RubyContext context, ArgumentDescriptor argDesc, boolean isLambda) {
if ((argDesc.type == ArgumentType.req) && ! isLambda) {
return toArray(context, ArgumentType.opt, argDesc.name);
}
return toArray(context, argDesc.type, argDesc.name);
}

public static DynamicObject toArray(RubyContext context, ArgumentType argType, String name) {
final Object[] store;

if (argType.anonymous || name == null) {
store = new Object[] { context.getSymbol(argType.symbolicName) };
} else {
store = new Object[] { context.getSymbol(argType.symbolicName), context.getSymbol(name) };
}

return Layouts.ARRAY.createArray(context.getCoreLibrary().getArrayFactory(), store, store.length);
}
}