25
25
*/
26
26
package com .oracle .graal .python .builtins .objects .list ;
27
27
28
+ import static com .oracle .graal .python .nodes .SpecialAttributeNames .__DOC__ ;
28
29
import static com .oracle .graal .python .nodes .SpecialMethodNames .SORT ;
29
30
import static com .oracle .graal .python .nodes .SpecialMethodNames .__ADD__ ;
30
31
import static com .oracle .graal .python .nodes .SpecialMethodNames .__CONTAINS__ ;
83
84
import com .oracle .graal .python .builtins .objects .tuple .PTuple ;
84
85
import com .oracle .graal .python .nodes .ErrorMessages ;
85
86
import com .oracle .graal .python .nodes .PGuards ;
86
- import static com .oracle .graal .python .nodes .SpecialAttributeNames .__DOC__ ;
87
87
import com .oracle .graal .python .nodes .attributes .GetAttributeNode ;
88
88
import com .oracle .graal .python .nodes .builtins .ListNodes ;
89
89
import com .oracle .graal .python .nodes .builtins .ListNodes .AppendNode ;
99
99
import com .oracle .graal .python .nodes .function .builtins .PythonVarargsBuiltinNode ;
100
100
import com .oracle .graal .python .nodes .object .IsBuiltinClassProfile ;
101
101
import com .oracle .graal .python .nodes .truffle .PythonArithmeticTypes ;
102
+ import com .oracle .graal .python .nodes .util .CastToJavaStringNode ;
102
103
import com .oracle .graal .python .runtime .PythonContext ;
103
104
import com .oracle .graal .python .runtime .PythonCore ;
104
105
import com .oracle .graal .python .runtime .exception .PException ;
114
115
import com .oracle .truffle .api .CompilerDirectives ;
115
116
import com .oracle .truffle .api .CompilerDirectives .TruffleBoundary ;
116
117
import com .oracle .truffle .api .dsl .Cached ;
118
+ import com .oracle .truffle .api .dsl .Cached .Shared ;
117
119
import com .oracle .truffle .api .dsl .CachedContext ;
118
120
import com .oracle .truffle .api .dsl .Fallback ;
119
121
import com .oracle .truffle .api .dsl .GenerateNodeFactory ;
@@ -191,15 +193,14 @@ public Object repr(VirtualFrame frame, PList self,
191
193
}
192
194
193
195
@ Builtin (name = __INIT__ , minNumOfPositionalArgs = 1 , maxNumOfPositionalArgs = 2 )
194
- @ TypeSystemReference (PythonArithmeticTypes .class )
195
196
@ GenerateNodeFactory
196
197
public abstract static class ListInitNode extends PythonBinaryBuiltinNode {
197
198
198
199
public abstract PNone execute (VirtualFrame frame , PList list , Object source );
199
200
200
201
@ Specialization
201
- static PNone init (PList list , String value ,
202
- @ Cached ( "create()" ) AppendNode appendNode ) {
202
+ static PNone initString (PList list , String value ,
203
+ @ Shared ( "appendNode" ) @ Cached AppendNode appendNode ) {
203
204
clearStorage (list );
204
205
char [] chars = value .toCharArray ();
205
206
for (char c : chars ) {
@@ -208,6 +209,13 @@ static PNone init(PList list, String value,
208
209
return PNone .NONE ;
209
210
}
210
211
212
+ @ Specialization
213
+ static PNone initPString (PList list , PString value ,
214
+ @ Cached CastToJavaStringNode castStr ,
215
+ @ Shared ("appendNode" ) @ Cached AppendNode appendNode ) {
216
+ return initString (list , castStr .execute (value ), appendNode );
217
+ }
218
+
211
219
@ Specialization (guards = "isNoValue(none)" )
212
220
static PNone init (PList list , @ SuppressWarnings ("unused" ) PNone none ) {
213
221
clearStorage (list );
0 commit comments