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

Commits on Feb 6, 2015

  1. Copy the full SHA
    1653315 View commit details
  2. Copy the full SHA
    21a7cdb View commit details
Showing with 7 additions and 2 deletions.
  1. +7 −2 truffle/src/main/java/org/jruby/truffle/nodes/coerce/ToStrNode.java
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@

package org.jruby.truffle.nodes.coerce;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
@@ -37,12 +38,12 @@ public ToStrNode(ToStrNode prev) {
}

@Specialization
public RubyString doRubyString(RubyString string) {
public RubyString coerceRubyString(RubyString string) {
return string;
}

@Specialization(guards = "!isRubyString")
public RubyString doObject(VirtualFrame frame, Object object) {
public RubyString coerceObject(VirtualFrame frame, Object object) {
notDesignedForCompilation();

final Object coerced;
@@ -51,6 +52,8 @@ public RubyString doObject(VirtualFrame frame, Object object) {
coerced = toStr.call(frame, object, "to_str", null);
} catch (RaiseException e) {
if (e.getRubyException().getLogicalClass() == getContext().getCoreLibrary().getNoMethodErrorClass()) {
CompilerDirectives.transferToInterpreter();

throw new RaiseException(
getContext().getCoreLibrary().typeError(
String.format("no implicit conversion of %s into String", getContext().getCoreLibrary().getLogicalClass(object).getName()),
@@ -63,6 +66,8 @@ public RubyString doObject(VirtualFrame frame, Object object) {
if (coerced instanceof RubyString) {
return (RubyString) coerced;
} else {
CompilerDirectives.transferToInterpreter();

final String uncoercedClassName = getContext().getCoreLibrary().getLogicalClass(object).getName();

throw new RaiseException(