-
-
Notifications
You must be signed in to change notification settings - Fork 924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Truffle] Adding Array#slice! to array.rb #2710
Conversation
@@ -28,6 +22,48 @@ def copy_from(other, start, length, dest) | |||
|
|||
class Array | |||
|
|||
def copy_from(other, start, length, dest) | |||
# Rubinius.primitive :tuple_copy_from |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any reason to not implement the primitive? At the very least, we should probably add it and just return null
so it falls back to the Ruby code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nirvdrum where are these primitives added? I'll add the null case.
Working with the array methods so far, I think there be a more general purpose primitive that we could create that could replace copy_from
. copy_from
for example doesn't allow growing or shrinking the array.
I think it would be something like this but in java:
def splice_arrays( array, other, a, b, m, n)
array[a,n] = other[m,n]
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have the primitive node classes in org.jruby.truffle.nodes.rubinius
, but surprisingly, we don't seem to have an Array
one yet. That's where I'd advocate putting it.
The primitive name itself forms the actual namespace, so it doesn't need to be tied to a particular class . . . that's just for organization. As an example, Rubinius::Character
is a subclass of String
, much like the Tuple
and Array
relationship. But I recently added a "character" primitive to the StringPrimitiveNodes
class.
c682366
to
04ec0c3
Compare
@nirvdrum added the stubbed out primitive implementation |
[Truffle] Adding Array#slice! to array.rb
Thanks! |
No description provided.