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

Commits on Mar 3, 2015

  1. Copy the full SHA
    ec1bf31 View commit details
  2. Copy the full SHA
    edd7034 View commit details
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/hash/each_key_tags.txt

This file was deleted.

7 changes: 0 additions & 7 deletions spec/truffle/tags/core/hash/each_tags.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
fails:Hash#each yields a [[key, value]] Array for each pair to a block expecting |*args|
fails:Hash#each yields the key and value of each pair to a block expecting |key, value|
fails:Hash#each yields the key only to a block expecting |key,|
fails:Hash#each uses the same order as keys() and values()
fails:Hash#each properly expands (or not) child class's 'each'-yielded args
fails:Hash#each returns an Enumerator if called on a non-empty hash without a block
fails:Hash#each returns an Enumerator if called on an empty hash without a block
fails:Hash#each returns an Enumerator if called on a frozen instance
5 changes: 0 additions & 5 deletions spec/truffle/tags/core/hash/each_value_tags.txt

This file was deleted.

15 changes: 15 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/nodes/core/HashNodes.java
Original file line number Diff line number Diff line change
@@ -542,12 +542,15 @@ public Object delete(VirtualFrame frame, RubyHash hash, Object key) {
@ImportGuards(HashGuards.class)
public abstract static class EachNode extends YieldingCoreMethodNode {

@Child private CallDispatchHeadNode toEnumNode;

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

public EachNode(EachNode prev) {
super(prev);
toEnumNode = prev.toEnumNode;
}

@Specialization(guards = "isNull")
@@ -597,6 +600,18 @@ public RubyHash eachBuckets(VirtualFrame frame, RubyHash hash, RubyProc block) {
return hash;
}

@Specialization
public Object each(VirtualFrame frame, RubyHash hash, UndefinedPlaceholder block) {
notDesignedForCompilation();

if (toEnumNode == null) {
CompilerDirectives.transferToInterpreter();
toEnumNode = insert(DispatchHeadNodeFactory.createMethodCall(getContext(), true));
}

return toEnumNode.call(frame, hash, "to_enum", null, getContext().getSymbolTable().getSymbol(getName()));
}

}

@CoreMethod(names = "empty?")
14 changes: 14 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/hash.rb
Original file line number Diff line number Diff line change
@@ -57,4 +57,18 @@ def merge!(other)

alias_method :update, :merge!

def each_key
return to_enum(:each_key) unless block_given?

each_item { |item| yield item.key }
self
end

def each_value
return to_enum(:each_value) unless block_given?

each_item { |item| yield item.value }
self
end

end
12 changes: 0 additions & 12 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -89,18 +89,6 @@ def fetch(key, default=nil)
end
end

def each_key
each do |key, value|
yield key
end
end

def each_value
each do |key, value|
yield value
end
end

def value?(value)
values.any? { |v| v == value }
end