File tree Expand file tree Collapse file tree 3 files changed +13
-4
lines changed
src/main/java/org/truffleruby/core Expand file tree Collapse file tree 3 files changed +13
-4
lines changed Original file line number Diff line number Diff line change 12
12
*/
13
13
package org .truffleruby .core .encoding ;
14
14
15
+ import com .oracle .truffle .api .CompilerDirectives ;
15
16
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
17
+ import com .oracle .truffle .api .strings .TruffleString ;
16
18
import org .jcodings .Encoding ;
17
19
import org .jcodings .EncodingDB ;
18
20
import org .jcodings .specific .ASCIIEncoding ;
@@ -72,8 +74,11 @@ private static RubyEncoding[] initializeRubyEncodings() {
72
74
if (encoding == USASCIIEncoding .INSTANCE ) {
73
75
rubyEncoding = US_ASCII ;
74
76
} else {
75
- final ImmutableRubyString name = FrozenStringLiterals .createStringAndCacheLater (
76
- TStringConstants .TSTRING_CONSTANTS .get (encoding .toString ()), US_ASCII );
77
+ TruffleString tstring = TStringConstants .TSTRING_CONSTANTS .get (encoding .toString ());
78
+ if (tstring == null ) {
79
+ throw CompilerDirectives .shouldNotReachHere ("no TStringConstants for " + encoding );
80
+ }
81
+ final ImmutableRubyString name = FrozenStringLiterals .createStringAndCacheLater (tstring , US_ASCII );
77
82
rubyEncoding = new RubyEncoding (encoding , name , encoding .getIndex ());
78
83
}
79
84
encodings [encoding .getIndex ()] = rubyEncoding ;
Original file line number Diff line number Diff line change 35
35
import org .truffleruby .language .dispatch .DispatchNode ;
36
36
import org .truffleruby .language .library .RubyStringLibrary ;
37
37
38
+ import java .util .Objects ;
39
+
38
40
/** All ImmutableRubyString are interned and must be created through
39
41
* {@link FrozenStringLiterals#getFrozenStringLiteral}. */
40
42
@ ExportLibrary (InteropLibrary .class )
@@ -47,8 +49,8 @@ public final class ImmutableRubyString extends ImmutableRubyObjectCopyable imple
47
49
ImmutableRubyString (TruffleString tstring , RubyEncoding encoding ) {
48
50
assert tstring .isCompatibleToUncached (encoding .tencoding );
49
51
assert tstring .isManaged ();
50
- this .tstring = tstring ;
51
- this .encoding = encoding ;
52
+ this .tstring = Objects . requireNonNull ( tstring ) ;
53
+ this .encoding = Objects . requireNonNull ( encoding ) ;
52
54
}
53
55
54
56
/** should only be used for debugging */
Original file line number Diff line number Diff line change @@ -203,6 +203,8 @@ public class TStringConstants {
203
203
public static final TruffleString STATELESS_ISO_2022_JP_KDDI = ascii ("stateless-ISO-2022-JP-KDDI" );
204
204
public static final TruffleString UTF8_SOFTBANK = ascii ("UTF8-SoftBank" );
205
205
public static final TruffleString SJIS_SOFTBANK = ascii ("SJIS-SoftBank" );
206
+ public static final TruffleString IBM720 = ascii ("IBM720" );
207
+ public static final TruffleString CESU_8 = ascii ("CESU-8" );
206
208
207
209
private static TruffleString ascii (String string ) {
208
210
if (string .length () == 1 ) {
You can’t perform that action at this time.
0 commit comments