Skip to content

Commit

Permalink
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion test/mri_truffle.index
Original file line number Diff line number Diff line change
@@ -237,7 +237,7 @@ ruby/test_unicode_escape.rb
ruby/test_variable.rb
ruby/test_whileuntil.rb
ruby/test_yield.rb
# scanf/test_scanf.rb # cannot load such file -- scanf.rb
# scanf/test_scanf.rb # difficult method name exclude
# scanf/test_scanfblocks.rb
# socket/test_basicsocket.rb
# socket/test_nonblock.rb
Original file line number Diff line number Diff line change
@@ -9,12 +9,14 @@
*/
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.CompilerDirectives;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.source.SourceSection;
import org.jruby.truffle.nodes.core.CoreClass;
import org.jruby.truffle.nodes.core.CoreMethod;
import org.jruby.truffle.nodes.core.CoreMethodNode;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.rubinius.RubiniusByteArray;
import org.jruby.util.ByteList;
@@ -40,6 +42,30 @@ public int getByte(RubiniusByteArray bytes, int index) {

}

@CoreMethod(names = "set_byte", required = 2, lowerFixnumParameters = {1, 2})
public abstract static class SetByteNode extends CoreMethodNode {

public SetByteNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
}

public SetByteNode(SetByteNode prev) {
super(prev);
}

@Specialization
public Object setByte(RubiniusByteArray bytes, int index, int value) {
if (index < 0 || index >= bytes.getBytes().getRealSize()) {
CompilerDirectives.transferToInterpreter();
throw new RaiseException(getContext().getCoreLibrary().indexError("index out of bounds", this));
}

bytes.getBytes().set(index, value);
return bytes.getBytes().get(index);
}

}

@CoreMethod(names = "locate", required = 3)
public abstract static class LocateNode extends CoreMethodNode {

1 change: 1 addition & 0 deletions truffle/src/main/ruby/core/shims.rb
Original file line number Diff line number Diff line change
@@ -161,6 +161,7 @@ def initialize(*args)
class Rubinius::ByteArray

alias_method :[], :get_byte
alias_method :[]=, :set_byte

end

0 comments on commit 7d07f90

Please sign in to comment.