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: 70a633038882
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: abed82b16045
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on Apr 13, 2015

  1. Copy the full SHA
    ad97895 View commit details
  2. Merge pull request #2830 from bjfish/truffle_regexp_case_equals

    [Truffle] Move Regexp#=== to regexp.rb.
    nirvdrum committed Apr 13, 2015
    Copy the full SHA
    abed82b View commit details
Showing with 20 additions and 27 deletions.
  1. +0 −27 truffle/src/main/java/org/jruby/truffle/nodes/core/RegexpNodes.java
  2. +20 −0 truffle/src/main/ruby/core/rubinius/common/regexp.rb
Original file line number Diff line number Diff line change
@@ -109,33 +109,6 @@ protected RubyString escape(VirtualFrame frame, RubyString string) {
}
}

@CoreMethod(names = "===", required = 1)
public abstract static class CaseEqualNode extends CoreMethodNode {

public CaseEqualNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public CaseEqualNode(CaseEqualNode prev) {
super(prev);
}

@Specialization
public Object match(RubyRegexp regexp, RubyString string) {
notDesignedForCompilation();

return regexp.matchCommon(string, true, false) != nil();
}

@Specialization
public Object match(RubyRegexp regexp, RubySymbol symbol) {
notDesignedForCompilation();

return regexp.matchCommon(symbol.toRubyString(), true, false) != nil();
}

}

@CoreMethod(names = "=~", required = 1)
public abstract static class MatchOperatorNode extends CoreMethodNode {

20 changes: 20 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/regexp.rb
Original file line number Diff line number Diff line change
@@ -120,6 +120,26 @@ def initialize_copy(other)
initialize other.source, other.options
end

def ===(other)
if other.kind_of? Symbol
other = other.to_s
elsif !other.kind_of? String
other = Rubinius::Type.check_convert_type other, String, :to_str
unless other
Regexp.last_match = nil
return false
end
end

if match = match_from(other, 0)
Regexp.last_match = match
true
else
Regexp.last_match = nil
false
end
end

def eql?(other)
return false unless other.kind_of?(Regexp)
return false unless source == other.source