Skip to content

Commit 716a16c

Browse files
committed
[Truffle] Moving Kernel#Array to kernel.rb.
1 parent cb72352 commit 716a16c

File tree

5 files changed

+15
-56
lines changed

5 files changed

+15
-56
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
fails:Enumerator#next_values returns an empty array if yield is called without arguments
2+
fails:Enumerator#next_values returns an array with only nil if yield is called with nil
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
fails:Enumerator#peek_values returns an empty array if yield is called without arguments
2+
fails:Enumerator#peek_values returns an array with only nil if yield is called with nil

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

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

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

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -257,44 +257,6 @@ public RubyNilClass abort() {
257257
}
258258
}
259259

260-
@CoreMethod(names = "Array", isModuleFunction = true, argumentsAsArray = true)
261-
public abstract static class ArrayNode extends CoreMethodNode {
262-
263-
@Child ArrayBuilderNode arrayBuilderNode;
264-
265-
public ArrayNode(RubyContext context, SourceSection sourceSection) {
266-
super(context, sourceSection);
267-
arrayBuilderNode = new ArrayBuilderNode.UninitializedArrayBuilderNode(context);
268-
}
269-
270-
public ArrayNode(ArrayNode prev) {
271-
super(prev);
272-
arrayBuilderNode = prev.arrayBuilderNode;
273-
}
274-
275-
@Specialization(guards = "isOneArrayElement")
276-
public RubyArray arrayOneArrayElement(Object[] args) {
277-
return (RubyArray) args[0];
278-
}
279-
280-
@Specialization(guards = "!isOneArrayElement")
281-
public RubyArray array(Object[] args) {
282-
final int length = args.length;
283-
Object store = arrayBuilderNode.start(length);
284-
285-
for (int n = 0; n < length; n++) {
286-
store = arrayBuilderNode.append(store, n, args[n]);
287-
}
288-
289-
return new RubyArray(getContext().getCoreLibrary().getArrayClass(), arrayBuilderNode.finish(store, length), length);
290-
}
291-
292-
protected boolean isOneArrayElement(Object[] args) {
293-
return args.length == 1 && args[0] instanceof RubyArray;
294-
}
295-
296-
}
297-
298260
@CoreMethod(names = "at_exit", isModuleFunction = true, needsBlock = true)
299261
public abstract static class AtExitNode extends CoreMethodNode {
300262

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,19 @@
2828

2929
module Kernel
3030

31+
def Array(obj)
32+
ary = Rubinius::Type.check_convert_type obj, Array, :to_ary
33+
34+
return ary if ary
35+
36+
if array = Rubinius::Type.check_convert_type(obj, Array, :to_a)
37+
array
38+
else
39+
[obj]
40+
end
41+
end
42+
module_function :Array
43+
3144
def Complex(*args)
3245
Rubinius.privately do
3346
Complex.convert(*args)

0 commit comments

Comments
 (0)