Skip to content

Commit bae615c

Browse files
committed
[Truffle] Try moving Kernel#loop to Rubinius.
1 parent 5385f46 commit bae615c

File tree

3 files changed

+12
-26
lines changed

3 files changed

+12
-26
lines changed

spec/truffle/tags/core/kernel/loop_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

truffle/src/main/java/org/jruby/truffle/nodes/core/KernelNodes.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,30 +1163,6 @@ public RubyArray localVariables() {
11631163

11641164
}
11651165

1166-
@CoreMethod(names = "loop", isModuleFunction = true, returnsEnumeratorIfNoBlock = true)
1167-
public abstract static class LoopNode extends CoreMethodNode {
1168-
1169-
@Child private WhileNode whileNode;
1170-
1171-
public LoopNode(RubyContext context, SourceSection sourceSection) {
1172-
super(context, sourceSection);
1173-
whileNode = WhileNode.createWhile(context, sourceSection,
1174-
new BooleanLiteralNode(context, sourceSection, true),
1175-
new YieldNode(context, getSourceSection(), new RubyNode[]{}, false)
1176-
);
1177-
}
1178-
1179-
public LoopNode(LoopNode prev) {
1180-
super(prev);
1181-
whileNode = prev.whileNode;
1182-
}
1183-
1184-
@Specialization
1185-
public Object loop(VirtualFrame frame) {
1186-
return whileNode.execute(frame);
1187-
}
1188-
}
1189-
11901166
@CoreMethod(names = "__method__", needsSelf = false)
11911167
public abstract static class MethodNameNode extends CoreMethodNode {
11921168

truffle/src/main/ruby/core/rubinius/common/kernel.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,4 +228,16 @@ def tap
228228
self
229229
end
230230

231+
def loop
232+
return to_enum(:loop) unless block_given?
233+
234+
begin
235+
while true
236+
yield
237+
end
238+
rescue StopIteration
239+
end
240+
end
241+
module_function :loop
242+
231243
end

0 commit comments

Comments
 (0)