Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1acb1f0cd9a5
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 0422e5d3c04b
Choose a head ref
  • 5 commits
  • 10 files changed
  • 1 contributor

Commits on Apr 6, 2015

  1. Copy the full SHA
    b3700e9 View commit details
  2. [Truffle] Fixed the 'encoding_converter_last_error' primitive to retu…

    …rn a properly formatted Rubinius::Lookup object.
    nirvdrum committed Apr 6, 2015
    Copy the full SHA
    b5d03ab View commit details
  3. Copy the full SHA
    5fa675d View commit details
  4. [Truffle] Untagged passing String#encode specs now that Encoding::Con…

    …verter can take options hash.
    nirvdrum committed Apr 6, 2015
    Copy the full SHA
    35c6749 View commit details
  5. Copy the full SHA
    0422e5d View commit details
2 changes: 0 additions & 2 deletions spec/truffle/tags/core/encoding/converter/last_error_tags.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
fails:Encoding::Converter#last_error returns nil if the last conversion succeeded but the penultimate failed
fails:Encoding::Converter#last_error returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :invalid_byte_sequence
fails:Encoding::Converter#last_error returns an Encoding::UndefinedConversionError when #primitive_convert last returned :undefined_conversion
fails:Encoding::Converter#last_error returns an Encoding::InvalidByteSequenceError when #primitive_convert last returned :incomplete_input
fails:Encoding::Converter#last_error returns an Encoding::InvalidByteSequenceError when the last call to #convert produced one
fails:Encoding::Converter#last_error returns an Encoding::UndefinedConversionError when the last call to #convert produced one
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:Encoding::Converter#primitive_convert accepts a nil source buffer
fails:Encoding::Converter#primitive_convert calls #to_int to convert the destination byte size
fails:Encoding::Converter#primitive_convert keeps removing invalid bytes from the source buffer
fails:Encoding::Converter#primitive_convert reuses read-again bytes after the first error
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
fails:Encoding::Converter#primitive_errinfo returns the status of the last primitive conversion, even if it was successful and the previous one wasn't
fails:Encoding::Converter#primitive_errinfo returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #convert last raised InvalidByteSequenceError
fails:Encoding::Converter#primitive_errinfo returns the state, source encoding, target encoding, erroneous bytes, and the read-again bytes when #finish last raised InvalidByteSequenceError
1 change: 0 additions & 1 deletion spec/truffle/tags/core/encoding/converter/putback_tags.txt

This file was deleted.

This file was deleted.

10 changes: 0 additions & 10 deletions spec/truffle/tags/core/string/encode_tags.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,4 @@
fails:String#encode when passed to, options replaces invalid characters in the destination encoding
fails:String#encode when passed to, from, options replaces invalid characters in the destination encoding
fails:String#encode when passed to, from, options calls #to_str to convert the to object to an encoding
fails:String#encode when passed to, from, options calls #to_str to convert the from object to an encoding
fails:String#encode when passed to, from, options calls #to_hash to convert the options object
fails:String#encode given the :xml => :text option replaces undefined characters with their upper-case hexadecimal numeric character references
fails:String#encode given the :xml => :attr option replaces undefined characters with their upper-case hexadecimal numeric character references
fails:String#encode! when passed to, options replaces invalid characters in the destination encoding
fails:String#encode! when passed to, from, options replaces invalid characters in the destination encoding
fails:String#encode! when passed to, from, options calls #to_str to convert the to object to an encoding
fails:String#encode! when passed to, from, options calls #to_str to convert the from object to an encoding
fails:String#encode! when passed to, from, options calls #to_hash to convert the options object
fails:String#encode! given the :xml => :text option replaces undefined characters with their upper-case hexadecimal numeric character references
fails:String#encode! given the :xml => :attr option replaces undefined characters with their upper-case hexadecimal numeric character references
24 changes: 12 additions & 12 deletions spec/truffle/tags/core/string/scan_tags.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
fails:String#scan scans for occurrences of the string if pattern is a string
fails:String#scan tries to convert pattern to a string via to_str
fails:String#scan taints the results if the String argument is tainted
fails:String#scan taints the results when passed a String argument if self is tainted
fails:String#scan taints the results if the Regexp argument is tainted
fails:String#scan taints the results when passed a Regexp argument if self is tainted
fails:String#scan with pattern and block sets $~ for access from the block
fails:String#scan with pattern and block restores $~ after leaving the block
fails:String#scan with pattern and block taints the results if the String argument is tainted
fails:String#scan with pattern and block taints the results when passed a String argument if self is tainted
fails:String#scan with pattern and block taints the results if the Regexp argument is tainted
fails:String#scan with pattern and block taints the results when passed a Regexp argument if self is tainted
fails(regexp):String#scan scans for occurrences of the string if pattern is a string
fails(regexp):String#scan tries to convert pattern to a string via to_str
fails(regexp):String#scan taints the results if the String argument is tainted
fails(regexp):String#scan taints the results when passed a String argument if self is tainted
fails(regexp):String#scan taints the results if the Regexp argument is tainted
fails(regexp):String#scan taints the results when passed a Regexp argument if self is tainted
fails(regexp):String#scan with pattern and block sets $~ for access from the block
fails(regexp):String#scan with pattern and block restores $~ after leaving the block
fails(regexp):String#scan with pattern and block taints the results if the String argument is tainted
fails(regexp):String#scan with pattern and block taints the results when passed a String argument if self is tainted
fails(regexp):String#scan with pattern and block taints the results if the Regexp argument is tainted
fails(regexp):String#scan with pattern and block taints the results when passed a Regexp argument if self is tainted
7 changes: 3 additions & 4 deletions spec/truffle/tags/core/string/sub_tags.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
fails:String#sub with pattern, replacement treats \+ as an empty string if there was no captures
fails:String#sub with pattern and block sets $~ for access from the block
fails:String#sub! with pattern and block sets $~ for access from the block
fails:String#sub! with pattern and block raises a RuntimeError if the string is modified while substituting
fails(regexp):String#sub with pattern and block sets $~ for access from the block
fails(regexp):String#sub! with pattern and block sets $~ for access from the block
fails(regexp):String#sub! with pattern and block raises a RuntimeError if the string is modified while substituting
Original file line number Diff line number Diff line change
@@ -70,6 +70,13 @@ public RubyNilClass initialize(RubyEncodingConverter self, Object source, Object
final IRubyObject destinationAsJRubyObj = getContext().toJRuby(destination);

EncodingUtils.econvArgs(runtime.getCurrentContext(), new IRubyObject[]{sourceAsJRubyObj, destinationAsJRubyObj}, encNames, encs, ecflags, ecopts);

// This method should only be called after the Encoding::Converter instance has already been initialized
// by Rubinius. Rubinius will do the heavy lifting of parsing the options hash and setting the `@options`
// ivar to the resulting int for EConv flags. Since we don't pass the proper data structures to EncodingUtils,
// we must override the flags after its had a pass in order to correct the bad flags value.
ecflags[0] = (int) self.getInstanceVariable("@options");

EConv econv = EncodingUtils.econvOpenOpts(runtime.getCurrentContext(), encNames[0], encNames[1], ecflags[0], ecopts[0]);

if (econv == null) {
Original file line number Diff line number Diff line change
@@ -12,13 +12,16 @@
package org.jruby.truffle.nodes.rubinius;

import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.source.SourceSection;
import org.jcodings.Encoding;
import org.jcodings.Ptr;
import org.jcodings.transcode.EConv;
import org.jcodings.transcode.EConvResult;
import org.jruby.Ruby;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.truffle.nodes.dispatch.CallDispatchHeadNode;
import org.jruby.truffle.nodes.dispatch.DispatchHeadNodeFactory;
import org.jruby.truffle.runtime.RubyContext;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.control.RaiseException;
@@ -29,6 +32,7 @@
import org.jruby.truffle.runtime.core.RubyException;
import org.jruby.truffle.runtime.core.RubyHash;
import org.jruby.truffle.runtime.core.RubyString;
import org.jruby.truffle.runtime.core.RubySymbol;
import org.jruby.util.ByteList;
import org.jruby.util.io.EncodingUtils;

@@ -206,25 +210,60 @@ private RubyString putback(RubyEncodingConverter encodingConverter, int n) {
@RubiniusPrimitive(name = "encoding_converter_last_error")
public static abstract class EncodingConverterLastErrorNode extends RubiniusPrimitiveNode {

@Child private CallDispatchHeadNode newLookupTableNode;
@Child private CallDispatchHeadNode lookupTableWriteNode;

public EncodingConverterLastErrorNode(RubyContext context, SourceSection sourceSection) {
super(context, sourceSection);
newLookupTableNode = DispatchHeadNodeFactory.createMethodCall(context);
lookupTableWriteNode = DispatchHeadNodeFactory.createMethodCall(context);
}

public EncodingConverterLastErrorNode(EncodingConverterLastErrorNode prev) {
super(prev);
newLookupTableNode = prev.newLookupTableNode;
lookupTableWriteNode = prev.lookupTableWriteNode;
}

@Specialization
public Object encodingConverterLastError(RubyEncodingConverter encodingConverter) {
public Object encodingConverterLastError(VirtualFrame frame, RubyEncodingConverter encodingConverter) {
notDesignedForCompilation();

final org.jruby.exceptions.RaiseException e = EncodingUtils.makeEconvException(getContext().getRuntime(), encodingConverter.getEConv());
final EConv ec = encodingConverter.getEConv();
final EConv.LastError lastError = ec.lastError;

if (e == null) {
if (lastError.getResult() != EConvResult.InvalidByteSequence &&
lastError.getResult() != EConvResult.IncompleteInput &&
lastError.getResult() != EConvResult.UndefinedConversion) {
return nil();
}

return getContext().toTruffle(e.getException());
Object ret = newLookupTableNode.call(frame, getContext().getCoreLibrary().getLookupTableClass(), "new", null);

lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("result"), eConvResultToSymbol(lastError.getResult()));
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("source_encoding_name"), getContext().makeString(new ByteList(lastError.getSource())));
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("destination_encoding_name"), getContext().makeString(new ByteList(lastError.getDestination())));
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("error_bytes"), getContext().makeString(new ByteList(lastError.getErrorBytes())));

if (lastError.getReadAgainLength() != 0) {
lookupTableWriteNode.call(frame, ret, "[]=", null, getContext().newSymbol("read_again_bytes"), lastError.getReadAgainLength());
}

return ret;
}

private RubySymbol eConvResultToSymbol(EConvResult result) {
switch(result) {
case InvalidByteSequence: return getContext().newSymbol("invalid_byte_sequence");
case UndefinedConversion: return getContext().newSymbol("undefined_conversion");
case DestinationBufferFull: return getContext().newSymbol("destination_buffer_full");
case SourceBufferEmpty: return getContext().newSymbol("source_buffer_empty");
case Finished: return getContext().newSymbol("finished");
case AfterOutput: return getContext().newSymbol("after_output");
case IncompleteInput: return getContext().newSymbol("incomplete_input");
}

throw new UnsupportedOperationException(String.format("Unknown EConv result: %s", result));
}

}