Skip to content
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

Merged
merged 1 commit into from Mar 16, 2015

Conversation

bjfish
Copy link
Contributor

@bjfish bjfish commented Mar 16, 2015

No description provided.

@@ -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
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

@bjfish
Copy link
Contributor Author

bjfish commented Mar 16, 2015

@nirvdrum added the stubbed out primitive implementation

nirvdrum added a commit that referenced this pull request Mar 16, 2015
[Truffle] Adding Array#slice! to array.rb
@nirvdrum nirvdrum merged commit ec4bc4e into jruby:master Mar 16, 2015
@nirvdrum
Copy link
Contributor

Thanks!

@chrisseaton chrisseaton modified the milestone: truffle-dev May 4, 2015
@enebo enebo added this to the Non-Release milestone Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants