Skip to content

Commit

Permalink
[Truffle] Removed Array#each_with_index since it should be defined in…
Browse files Browse the repository at this point in the history
… Enumerable.
  • Loading branch information
nirvdrum committed Jan 12, 2015
1 parent 8f8f95c commit 249ee7b
Showing 1 changed file with 0 additions and 60 deletions.
60 changes: 0 additions & 60 deletions core/src/main/java/org/jruby/truffle/nodes/core/ArrayNodes.java
Expand Up @@ -1515,66 +1515,6 @@ public Object eachObject(VirtualFrame frame, RubyArray array, RubyProc block) {

}

@CoreMethod(names = "each_with_index", needsBlock = true)
@ImportGuards(ArrayGuards.class)
public abstract static class EachWithIndexNode extends YieldingCoreMethodNode {

private final BranchProfile breakProfile = BranchProfile.create();
private final BranchProfile nextProfile = BranchProfile.create();
private final BranchProfile redoProfile = BranchProfile.create();

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

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

@Specialization(guards = "isNull")
public RubyArray eachWithEmpty(VirtualFrame frame, RubyArray array, RubyProc block) {
return array;
}

@Specialization(guards = "isObject")
public Object eachWithIndexObject(VirtualFrame frame, RubyArray array, RubyProc block) {
final Object[] store = (Object[]) array.getStore();

int count = 0;

try {
outer:
for (int n = 0; n < array.getSize(); n++) {
while (true) {
if (CompilerDirectives.inInterpreter()) {
count++;
}

try {
yield(frame, block, store[n], n);
continue outer;
} catch (BreakException e) {
breakProfile.enter();
return e.getResult();
} catch (NextException e) {
nextProfile.enter();
continue outer;
} catch (RedoException e) {
redoProfile.enter();
}
}
}
} finally {
if (CompilerDirectives.inInterpreter()) {
((RubyRootNode) getRootNode()).reportLoopCount(count);
}
}

return array;
}

}

@CoreMethod(names = "empty?")
public abstract static class EmptyNode extends ArrayCoreMethodNode {

Expand Down

0 comments on commit 249ee7b

Please sign in to comment.