37
37
import org .truffleruby .language .control .RaiseException ;
38
38
import org .truffleruby .language .library .RubyStringLibrary ;
39
39
40
- import com .oracle .truffle .api .CompilerDirectives ;
41
40
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
42
41
import com .oracle .truffle .api .dsl .Cached ;
43
42
import com .oracle .truffle .api .dsl .Cached .Shared ;
@@ -59,8 +58,6 @@ int hash(RubyRegexp regexp) {
59
58
@ CoreMethod (names = { "quote" , "escape" }, onSingleton = true , required = 1 )
60
59
public abstract static class QuoteNode extends CoreMethodArrayArgumentsNode {
61
60
62
- @ Child private QuoteNode quoteNode ;
63
-
64
61
public abstract RubyString execute (Object raw );
65
62
66
63
public static QuoteNode create () {
@@ -75,22 +72,16 @@ RubyString quoteString(Object raw,
75
72
76
73
@ Specialization
77
74
RubyString quoteSymbol (RubySymbol raw ) {
78
- return doQuoteString ( createString (raw .tstring , raw .encoding ));
75
+ return createString (ClassicRegexp . quote19 ( new ATStringWithEncoding ( raw .tstring , raw .encoding ) ));
79
76
}
80
77
81
78
@ Fallback
82
79
RubyString quote (Object raw ,
83
- @ Cached ToStrNode toStrNode ) {
84
- return doQuoteString (toStrNode .execute (this , raw ));
80
+ @ Cached ToStrNode toStrNode ,
81
+ @ Cached QuoteNode recursive ) {
82
+ return recursive .execute (toStrNode .execute (this , raw ));
85
83
}
86
84
87
- private RubyString doQuoteString (Object raw ) {
88
- if (quoteNode == null ) {
89
- CompilerDirectives .transferToInterpreterAndInvalidate ();
90
- quoteNode = insert (QuoteNode .create ());
91
- }
92
- return quoteNode .execute (raw );
93
- }
94
85
}
95
86
96
87
@ CoreMethod (names = "source" )
0 commit comments