Skip to content

Commit

Permalink
Showing 3 changed files with 12 additions and 26 deletions.
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/kernel/loop_tags.txt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1163,30 +1163,6 @@ public RubyArray localVariables() {

}

@CoreMethod(names = "loop", isModuleFunction = true, returnsEnumeratorIfNoBlock = true)
public abstract static class LoopNode extends CoreMethodNode {

@Child private WhileNode whileNode;

public LoopNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
whileNode = WhileNode.createWhile(context, sourceSection,
new BooleanLiteralNode(context, sourceSection, true),
new YieldNode(context, getSourceSection(), new RubyNode[]{}, false)
);
}

public LoopNode(LoopNode prev) {
super(prev);
whileNode = prev.whileNode;
}

@Specialization
public Object loop(VirtualFrame frame) {
return whileNode.execute(frame);
}
}

@CoreMethod(names = "__method__", needsSelf = false)
public abstract static class MethodNameNode extends CoreMethodNode {

12 changes: 12 additions & 0 deletions truffle/src/main/ruby/core/rubinius/common/kernel.rb
Original file line number Diff line number Diff line change
@@ -228,4 +228,16 @@ def tap
self
end

def loop
return to_enum(:loop) unless block_given?

begin
while true
yield
end
rescue StopIteration
end
end
module_function :loop

end

0 comments on commit bae615c

Please sign in to comment.