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

Commits on Oct 31, 2014

  1. [Truffle] Fix equal?

    eregon committed Oct 31, 2014
    Copy the full SHA
    5ea9eb5 View commit details
  2. [Truffle] Fix Array#==.

    eregon committed Oct 31, 2014
    Copy the full SHA
    3f8c1a7 View commit details
  3. [Truffle] Implement Bignum#==.

    eregon committed Oct 31, 2014
    Copy the full SHA
    09821f7 View commit details
12 changes: 8 additions & 4 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Original file line number Diff line number Diff line change
@@ -507,11 +507,15 @@ public boolean equal(VirtualFrame frame, RubyArray a, RubyArray b) {
return true;
}

// TODO(CS): what to do about all the other cases?

@Specialization
public boolean equal(VirtualFrame frame, RubyArray a, RubySymbol b) {
return false;
public boolean equal(VirtualFrame frame, RubyArray a, Object b) {
notDesignedForCompilation();

if (!(b instanceof RubyArray)) {
return false;
} else {
return equal(frame, a, (RubyArray) b);
}
}

}
Original file line number Diff line number Diff line change
@@ -103,54 +103,24 @@ public ReferenceEqualNode(ReferenceEqualNode prev) {
@Specialization public boolean equal(int a, int b) { return a == b; }
@Specialization public boolean equal(long a, long b) { return a == b; }
@Specialization public boolean equal(double a, double b) { return a == b; }
@Specialization public boolean equal(BigInteger a, BigInteger b) { return a.equals(b); }

@Specialization public boolean equal(boolean a, int b) { return false; }
@Specialization public boolean equal(boolean a, long b) { return false; }
@Specialization public boolean equal(boolean a, double b) { return false; }
@Specialization public boolean equal(boolean a, BigInteger b) { return false; }

@Specialization public boolean equal(int a, boolean b) { return false; }
@Specialization public boolean equal(int a, long b) { return a == b; }
@Specialization public boolean equal(int a, double b) { return false; }
@Specialization public boolean equal(int a, BigInteger b) { return false; }

@Specialization public boolean equal(long a, boolean b) { return false; }
@Specialization public boolean equal(long a, int b) { return a == b; }
@Specialization public boolean equal(long a, double b) { return false; }
@Specialization public boolean equal(long a, BigInteger b) { return false; }

@Specialization public boolean equal(double a, boolean b) { return false; }
@Specialization public boolean equal(double a, int b) { return false; }
@Specialization public boolean equal(double a, long b) { return false; }
@Specialization public boolean equal(double a, BigInteger b) { return false; }

@Specialization public boolean equal(BigInteger a, boolean b) { return false; }
@Specialization public boolean equal(BigInteger a, int b) { return false; }
@Specialization public boolean equal(BigInteger a, long b) { return false; }
@Specialization public boolean equal(BigInteger a, double b) { return false; }

@Specialization(guards = {"!firstUnboxable", "secondUnboxable"})
public boolean equalFirstNotUnboxable(RubyBasicObject a, RubyBasicObject b) {
return false;
}
@Specialization public boolean equal(BigInteger a, BigInteger b) { return a == b; }

@Specialization(guards = {"firstUnboxable", "!secondUnboxable"})
public boolean equalSecondNotUnboxable(RubyBasicObject a, RubyBasicObject b) {
return false;
@Specialization(guards = "bothUnboxable")
public boolean equalUnboxable(Object a, Object b) {
return ((Unboxable) a).unbox().equals(((Unboxable) b).unbox());
}

@Specialization(guards = {"!firstUnboxable", "!secondUnboxable"})
public boolean equal(RubyBasicObject a, RubyBasicObject b) {
return a == b;
}

protected boolean firstUnboxable(Object a, Object b) {
return a instanceof Unboxable;
@Specialization
public boolean equal(Object a, Object b) {
if (a instanceof Unboxable && b instanceof Unboxable) {
return ((Unboxable) a).unbox().equals(((Unboxable) b).unbox());
} else {
return a == b;
}
}

protected boolean secondUnboxable(Object a, Object b) {
return b instanceof Unboxable;
protected boolean bothUnboxable(Object a, Object b) {
return a instanceof Unboxable && b instanceof Unboxable;
}

}
Original file line number Diff line number Diff line change
@@ -360,7 +360,7 @@ public boolean lessEqual(BigInteger a, BigInteger b) {
}
}

@CoreMethod(names = "==", required = 1)
@CoreMethod(names = {"==", "eql?"}, required = 1)
public abstract static class EqualNode extends CoreMethodNode {

public EqualNode(RubyContext context, SourceSection sourceSection) {