20
20
import org .truffleruby .core .cast .StringToSymbolNodeGen ;
21
21
import org .truffleruby .core .cast .ToSNode ;
22
22
import org .truffleruby .core .cast .ToSNodeGen ;
23
- import org .truffleruby .core .encoding .EncodingManager ;
24
23
import org .truffleruby .core .encoding .Encodings ;
25
24
import org .truffleruby .core .encoding .RubyEncoding ;
26
25
import org .truffleruby .core .encoding .TStringUtils ;
@@ -193,7 +192,7 @@ public RubyNode visitBreakNode(Nodes.BreakNode node) {
193
192
}
194
193
195
194
public RubyNode visitCallNode (Nodes .CallNode node ) {
196
- var methodName = new String (node .name , EncodingManager . charsetForEncoding ( sourceEncoding . jcoding ) );
195
+ var methodName = TStringUtils . toJavaStringOrThrow (node .name , sourceEncoding );
197
196
var receiver = node .receiver == null ? new SelfNode () : node .receiver .accept (this );
198
197
var arguments = node .arguments .arguments ;
199
198
@@ -757,10 +756,9 @@ public RubyNode visitStringConcatNode(Nodes.StringConcatNode node) {
757
756
}
758
757
759
758
public RubyNode visitStringNode (Nodes .StringNode node ) {
760
- final RubyEncoding encoding = sourceEncoding ;
761
- final TruffleString tstring = TStringUtils .fromByteArray (node .unescaped , encoding );
762
- final TruffleString cachedTString = language .tstringCache .getTString (tstring , encoding );
763
- final RubyNode rubyNode = new StringLiteralNode (cachedTString , encoding );
759
+ final TruffleString tstring = TStringUtils .fromByteArray (node .unescaped , sourceEncoding );
760
+ final TruffleString cachedTString = language .tstringCache .getTString (tstring , sourceEncoding );
761
+ final RubyNode rubyNode = new StringLiteralNode (cachedTString , sourceEncoding );
764
762
765
763
assignNodePositionInSource (node , rubyNode );
766
764
@@ -772,7 +770,8 @@ public RubyNode visitSuperNode(Nodes.SuperNode node) {
772
770
}
773
771
774
772
public RubyNode visitSymbolNode (Nodes .SymbolNode node ) {
775
- final RubySymbol symbol = language .getSymbol (toString (node ));
773
+ var tstring = TStringUtils .fromByteArray (node .unescaped , sourceEncoding );
774
+ final RubySymbol symbol = language .getSymbol (tstring , sourceEncoding );
776
775
final RubyNode rubyNode = new ObjectLiteralNode (symbol );
777
776
778
777
assignNodePositionInSource (node , rubyNode );
@@ -874,17 +873,11 @@ protected RubyContextSourceNode createCallNode(RubyNode receiver, String method,
874
873
}
875
874
876
875
private String toString (Nodes .Location location ) {
877
- return new String (sourceBytes , location .startOffset , location .length ,
878
- EncodingManager .charsetForEncoding (sourceEncoding .jcoding ));
876
+ return TStringUtils .toJavaStringOrThrow (TruffleString .fromByteArrayUncached (sourceBytes , location .startOffset , location .length , sourceEncoding .tencoding , false ), sourceEncoding );
879
877
}
880
878
881
879
private String toString (Nodes .Node node ) {
882
- return new String (sourceBytes , node .startOffset , node .length ,
883
- EncodingManager .charsetForEncoding (sourceEncoding .jcoding ));
884
- }
885
-
886
- private String toString (Nodes .SymbolNode node ) {
887
- return new String (node .unescaped , EncodingManager .charsetForEncoding (sourceEncoding .jcoding ));
880
+ return TStringUtils .toJavaStringOrThrow (TruffleString .fromByteArrayUncached (sourceBytes , node .startOffset , node .length , sourceEncoding .tencoding , false ), sourceEncoding );
888
881
}
889
882
890
883
private SourceSection getSourceSection (Nodes .Node yarpNode ) {
0 commit comments