Skip to content

Commit b302541

Browse files
author
Nicolas Laurent
committed
refactor ArrayHelpers#createArray to take a language argument
1 parent a38cb57 commit b302541

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/main/java/org/truffleruby/core/array/ArrayHelpers.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@ public static void setSize(RubyArray array, int size) {
2929
array.size = size;
3030
}
3131

32-
public static RubyArray createArray(RubyContext context, Object store, int size) {
32+
public static RubyArray createArray(RubyContext context, RubyLanguage language, Object store, int size) {
3333
assert !(store instanceof Object[]) || store.getClass() == Object[].class;
34-
return new RubyArray(context.getCoreLibrary().arrayClass, RubyLanguage.arrayShape, store, size);
34+
return new RubyArray(context.getCoreLibrary().arrayClass, language.arrayShape, store, size);
3535
}
3636

37-
public static RubyArray createArray(RubyContext context, int[] store) {
38-
return createArray(context, store, store.length);
37+
public static RubyArray createArray(RubyContext context, RubyLanguage language, int[] store) {
38+
return createArray(context, language, store, store.length);
3939
}
4040

41-
public static RubyArray createArray(RubyContext context, long[] store) {
42-
return createArray(context, store, store.length);
41+
public static RubyArray createArray(RubyContext context, RubyLanguage language, long[] store) {
42+
return createArray(context, language, store, store.length);
4343
}
4444

45-
public static RubyArray createArray(RubyContext context, Object[] store) {
45+
public static RubyArray createArray(RubyContext context, RubyLanguage language, Object[] store) {
4646
assert store.getClass() == Object[].class;
47-
return createArray(context, store, store.length);
47+
return createArray(context, language, store, store.length);
4848
}
4949

50-
public static RubyArray createEmptyArray(RubyContext context) {
50+
public static RubyArray createEmptyArray(RubyContext context, RubyLanguage language) {
5151
return new RubyArray(
5252
context.getCoreLibrary().arrayClass,
53-
RubyLanguage.arrayShape,
53+
language.arrayShape,
5454
ArrayStoreLibrary.INITIAL_STORE,
5555
0);
5656
}
@@ -72,14 +72,15 @@ public static Object specializedJavaArrayOf(ArrayBuilderNode builder, Object...
7272
}
7373

7474
/** Returns a Ruby array backed by a store of the narrowest possible type, holding {@code object}. */
75-
public static RubyArray specializedRubyArrayOf(RubyContext context, ArrayBuilderNode builder, Object object) {
76-
return createArray(context, specializedJavaArrayOf(builder, object), 1);
75+
public static RubyArray specializedRubyArrayOf(RubyContext context, RubyLanguage language, ArrayBuilderNode builder,
76+
Object object) {
77+
return createArray(context, language, specializedJavaArrayOf(builder, object), 1);
7778
}
7879

7980
/** Returns a Ruby array backed by a store of the narrowest possible type, holding the {@code objects}. */
80-
public static RubyArray specializedRubyArrayOf(RubyContext context, ArrayBuilderNode builder,
81+
public static RubyArray specializedRubyArrayOf(RubyContext context, RubyLanguage language, ArrayBuilderNode builder,
8182
Object... objects) {
82-
return createArray(context, specializedJavaArrayOf(builder, objects), objects.length);
83+
return createArray(context, language, specializedJavaArrayOf(builder, objects), objects.length);
8384
}
8485

8586
}

0 commit comments

Comments
 (0)