Skip to content

Commit

Permalink
[Truffle] String#byte_append.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Mar 14, 2015
1 parent e09e135 commit cf89fd2
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 18 deletions.
2 changes: 0 additions & 2 deletions spec/truffle/tags/rubysl/rubysl-stringio/spec/append_tags.txt
Expand Up @@ -6,5 +6,3 @@ fails:StringIO#<< when passed [Object] taints self's String when the passed argu
fails:StringIO#<< when passed [Object] does not taint self when the passed argument is tainted
fails:StringIO#<< when passed [Object] updates self's position
fails:StringIO#<< when passed [Object] tries to convert the passed argument to a String using #to_s
fails:StringIO#<< when in append mode appends the passed argument to the end of self, ignoring current position
fails:StringIO#<< when in append mode correctly updates self's position

This file was deleted.

2 changes: 0 additions & 2 deletions spec/truffle/tags/rubysl/rubysl-stringio/spec/printf_tags.txt
Expand Up @@ -2,5 +2,3 @@ fails:StringIO#printf returns nil
fails:StringIO#printf pads self with \000 when the current position is after the end
fails:StringIO#printf performs format conversion
fails:StringIO#printf updates the current position
fails:StringIO#printf when in append mode appends the passed argument to the end of self
fails:StringIO#printf when in append mode correctly updates self's position
Expand Up @@ -6,4 +6,3 @@ fails:StringIO#putc when passed [String] writes a byte into the io
fails:StringIO#putc when passed [Object] it writes the passed Integer % 256 to self
fails:StringIO#putc when passed [Object] pads self with \000 when the current position is after the end
fails:StringIO#putc when passed [Object] tries to convert the passed argument to an Integer using #to_int
fails:StringIO#putc when in append mode appends to the end of self
3 changes: 0 additions & 3 deletions spec/truffle/tags/rubysl/rubysl-stringio/spec/puts_tags.txt
Expand Up @@ -13,6 +13,3 @@ fails:StringIO#puts when passed 1 or more objects prints a newline when passed n
fails:StringIO#puts when passed no arguments returns nil
fails:StringIO#puts when passed no arguments prints a newline
fails:StringIO#puts when passed no arguments does not honor the global output record separator $\
fails:StringIO#puts when in append mode appends the passed argument to the end of self
fails:StringIO#puts when in append mode correctly updates self's position
fails:StringIO#puts when passed an encoded string stores the bytes unmodified
2 changes: 0 additions & 2 deletions spec/truffle/tags/rubysl/rubysl-stringio/spec/reopen_tags.txt
Expand Up @@ -7,6 +7,4 @@ fails:StringIO#reopen when passed [Object, Integer] raises a TypeError when tryi
fails:StringIO#reopen when passed [Object, Integer] raises a RuntimeError when trying to reopen self with a frozen String in truncate-mode
fails:StringIO#reopen when passed [Object, Integer] does not raise IOError when passed a frozen String in read-mode
fails:StringIO#reopen reopens a stream when given a String argument
fails:StringIO#reopen reopens a stream in append mode when flagged as such
fails:StringIO#reopen reopens and truncate when reopened in write mode
fails:StringIO#reopen does not truncate the content even when the StringIO argument is in the truncate mode
Expand Up @@ -8,5 +8,3 @@ fails:StringIO#syswrite when passed [String] does not taint self when the passed
fails:StringIO#syswrite when passed [String] writes binary data into the io
fails:StringIO#syswrite when passed [String] retains the original encoding
fails:StringIO#syswrite when passed [String] pads multibyte characters properly
fails:StringIO#syswrite when in append mode appends the passed argument to the end of self
fails:StringIO#syswrite when in append mode correctly updates self's position
Expand Up @@ -8,5 +8,3 @@ fails:StringIO#write_nonblock when passed [String] does not taint self when the
fails:StringIO#write_nonblock when passed [String] writes binary data into the io
fails:StringIO#write_nonblock when passed [String] retains the original encoding
fails:StringIO#write_nonblock when passed [String] pads multibyte characters properly
fails:StringIO#write_nonblock when in append mode appends the passed argument to the end of self
fails:StringIO#write_nonblock when in append mode correctly updates self's position
2 changes: 0 additions & 2 deletions spec/truffle/tags/rubysl/rubysl-stringio/spec/write_tags.txt
Expand Up @@ -8,5 +8,3 @@ fails:StringIO#write when passed [String] does not taint self when the passed ar
fails:StringIO#write when passed [String] writes binary data into the io
fails:StringIO#write when passed [String] retains the original encoding
fails:StringIO#write when passed [String] pads multibyte characters properly
fails:StringIO#write when in append mode appends the passed argument to the end of self
fails:StringIO#write when in append mode correctly updates self's position
Expand Up @@ -687,4 +687,24 @@ public Object stringToInum(RubyString string, int fixBase, boolean strict) {

}

@RubiniusPrimitive(name = "string_byte_append")
public static abstract class StringByteAppendPrimitiveNode extends RubiniusPrimitiveNode {

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

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

@Specialization
public RubyString stringByteAppend(RubyString string, RubyString other) {
notDesignedForCompilation();
string.getByteList().append(other.getByteList());
return string;
}

}

}
5 changes: 5 additions & 0 deletions truffle/src/main/ruby/core/rubinius/bootstrap/string.rb
Expand Up @@ -84,5 +84,10 @@ def find_character(offset)
def num_bytes
@num_bytes
end

def byte_append(str)
Rubinius.primitive :string_byte_append
raise TypeError, "String#byte_append primitive only accepts Strings"
end

end

0 comments on commit cf89fd2

Please sign in to comment.