5353import static com .oracle .graal .python .builtins .modules .io .IONodes .CLOSED ;
5454import static com .oracle .graal .python .builtins .modules .io .IONodes .DETACH ;
5555import static com .oracle .graal .python .builtins .modules .io .IONodes .FILENO ;
56+ import static com .oracle .graal .python .builtins .modules .io .IONodes .FLUSH ;
5657import static com .oracle .graal .python .builtins .modules .io .IONodes .ISATTY ;
5758import static com .oracle .graal .python .builtins .modules .io .IONodes .MODE ;
5859import static com .oracle .graal .python .builtins .modules .io .IONodes .NAME ;
7879import com .oracle .graal .python .builtins .CoreFunctions ;
7980import com .oracle .graal .python .builtins .objects .PNone ;
8081import com .oracle .graal .python .builtins .objects .type .TypeNodes ;
82+ import com .oracle .graal .python .lib .PyObjectCallMethodObjArgs ;
83+ import com .oracle .graal .python .lib .PyObjectGetAttr ;
8184import com .oracle .graal .python .lib .PyObjectLookupAttr ;
82- import com .oracle .graal .python .nodes . call . special . LookupAndCallUnaryNode ;
85+ import com .oracle .graal .python .lib . PyObjectReprAsJavaStringNode ;
8386import com .oracle .graal .python .nodes .function .PythonBuiltinBaseNode ;
8487import com .oracle .graal .python .nodes .function .builtins .PythonBinaryBuiltinNode ;
8588import com .oracle .graal .python .nodes .function .builtins .PythonTernaryClinicBuiltinNode ;
@@ -113,10 +116,10 @@ abstract static class CloseNode extends PythonUnaryWithInitErrorBuiltinNode {
113116
114117 private static Object close (VirtualFrame frame , PBuffered self ,
115118 BufferedIONodes .EnterBufferedNode lock ,
116- IONodes . CallClose callClose ) {
119+ PyObjectCallMethodObjArgs callMethodClose ) {
117120 try {
118121 lock .enter (self );
119- Object res = callClose .execute (frame , self .getRaw ());
122+ Object res = callMethodClose .execute (frame , self .getRaw (), CLOSE );
120123 if (self .getBuffer () != null ) {
121124 self .setBuffer (null );
122125 }
@@ -129,9 +132,9 @@ private static Object close(VirtualFrame frame, PBuffered self,
129132 @ Specialization (guards = "self.isOK()" )
130133 static Object doit (VirtualFrame frame , PBuffered self ,
131134 @ Cached BufferedIONodes .IsClosedNode isClosedNode ,
132- @ Cached IONodes . CallFlush flush ,
133- @ Cached IONodes . CallClose callClose ,
134- @ Cached IONodes . CallDeallocWarn deallocWarn ,
135+ @ Cached PyObjectCallMethodObjArgs callMethodFlush ,
136+ @ Cached PyObjectCallMethodObjArgs callMethodClose ,
137+ @ Cached PyObjectCallMethodObjArgs callMethodDeallocWarn ,
135138 @ Cached BufferedIONodes .EnterBufferedNode lock ,
136139 @ Cached ConditionProfile profile ) {
137140 try {
@@ -141,25 +144,25 @@ static Object doit(VirtualFrame frame, PBuffered self,
141144 }
142145 if (self .isFinalizing ()) {
143146 if (self .getRaw () != null ) {
144- deallocWarn .execute (frame , self .getRaw (), self );
147+ callMethodDeallocWarn .execute (frame , self .getRaw (), _DEALLOC_WARN , self );
145148 }
146149 }
147150 } finally {
148151 BufferedIONodes .EnterBufferedNode .leave (self );
149152 }
150153 /* flush() will most probably re-take the lock, so drop it first */
151154 try {
152- flush .execute (frame , self );
155+ callMethodFlush .execute (frame , self , FLUSH );
153156 } catch (PException e ) {
154157 try {
155- close (frame , self , lock , callClose );
158+ close (frame , self , lock , callMethodClose );
156159 } catch (PException ee ) {
157160 chainExceptions (ee .getEscapedException (), e );
158161 throw ee .getExceptionForReraise ();
159162 }
160163 throw e ;
161164 }
162- return close (frame , self , lock , callClose );
165+ return close (frame , self , lock , callMethodClose );
163166 }
164167 }
165168
@@ -168,8 +171,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
168171 abstract static class DetachNode extends PythonUnaryWithInitErrorBuiltinNode {
169172 @ Specialization (guards = "self.isOK()" )
170173 static Object doit (VirtualFrame frame , PBuffered self ,
171- @ Cached IONodes . CallFlush flush ) {
172- flush .execute (frame , self );
174+ @ Cached PyObjectCallMethodObjArgs callMethodFlush ) {
175+ callMethodFlush .execute (frame , self , FLUSH );
173176 Object raw = self .getRaw ();
174177 self .clearRaw ();
175178 self .setDetached (true );
@@ -183,8 +186,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
183186 abstract static class SeekableNode extends PythonUnaryWithInitErrorBuiltinNode {
184187 @ Specialization (guards = "self.isOK()" )
185188 static Object doit (VirtualFrame frame , PBuffered self ,
186- @ Cached IONodes . CallSeekable seekable ) {
187- return seekable .execute (frame , self .getRaw ());
189+ @ Cached PyObjectCallMethodObjArgs callMethod ) {
190+ return callMethod .execute (frame , self .getRaw (), SEEKABLE );
188191 }
189192 }
190193
@@ -193,8 +196,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
193196 abstract static class FileNoNode extends PythonUnaryWithInitErrorBuiltinNode {
194197 @ Specialization (guards = "self.isOK()" )
195198 static Object doit (VirtualFrame frame , PBuffered self ,
196- @ Cached IONodes . CallFileNo fileNo ) {
197- return fileNo .execute (frame , self .getRaw ());
199+ @ Cached PyObjectCallMethodObjArgs callMethod ) {
200+ return callMethod .execute (frame , self .getRaw (), FILENO );
198201 }
199202 }
200203
@@ -203,8 +206,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
203206 abstract static class IsAttyNode extends PythonUnaryWithInitErrorBuiltinNode {
204207 @ Specialization (guards = "self.isOK()" )
205208 static Object doit (VirtualFrame frame , PBuffered self ,
206- @ Cached IONodes . CallIsAtty isAtty ) {
207- return isAtty .execute (frame , self .getRaw ());
209+ @ Cached PyObjectCallMethodObjArgs callMethod ) {
210+ return callMethod .execute (frame , self .getRaw (), ISATTY );
208211 }
209212 }
210213
@@ -213,8 +216,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
213216 abstract static class DeallocWarnNode extends PythonBinaryBuiltinNode {
214217 @ Specialization (guards = {"self.isOK()" , "self.getRaw() != null" })
215218 static Object doit (VirtualFrame frame , PBuffered self , Object source ,
216- @ Cached IONodes . CallDeallocWarn deallocWarn ) {
217- deallocWarn .execute (frame , self .getRaw (), source );
219+ @ Cached PyObjectCallMethodObjArgs callMethod ) {
220+ callMethod .execute (frame , self .getRaw (), _DEALLOC_WARN , source );
218221 return PNone .NONE ;
219222 }
220223
@@ -296,12 +299,12 @@ static Object doit(VirtualFrame frame, PBuffered self, Object pos,
296299 @ Cached ("create(TRUNCATE)" ) BufferedIONodes .CheckIsClosedNode checkIsClosedNode ,
297300 @ Cached BufferedIONodes .RawTellNode rawTellNode ,
298301 @ Cached BufferedIONodes .FlushAndRewindUnlockedNode flushAndRewindUnlockedNode ,
299- @ Cached IONodes . CallTruncate truncate ) {
302+ @ Cached PyObjectCallMethodObjArgs callMethodTruncate ) {
300303 checkIsClosedNode .execute (frame , self );
301304 try {
302305 lock .enter (self );
303306 flushAndRewindUnlockedNode .execute (frame , self );
304- Object res = truncate .execute (frame , self .getRaw (), pos );
307+ Object res = callMethodTruncate .execute (frame , self .getRaw (), TRUNCATE , pos );
305308 /* Reset cached position */
306309 rawTellNode .execute (frame , self );
307310 return res ;
@@ -349,8 +352,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
349352 abstract static class NameNode extends PythonUnaryWithInitErrorBuiltinNode {
350353 @ Specialization (guards = "self.isOK()" )
351354 static Object doit (VirtualFrame frame , PBuffered self ,
352- @ Cached IONodes . GetName getName ) {
353- return getName .execute (frame , self .getRaw ());
355+ @ Cached PyObjectGetAttr getAttr ) {
356+ return getAttr .execute (frame , self .getRaw (), NAME );
354357 }
355358 }
356359
@@ -359,8 +362,8 @@ static Object doit(VirtualFrame frame, PBuffered self,
359362 abstract static class ModeNode extends PythonUnaryWithInitErrorBuiltinNode {
360363 @ Specialization (guards = "self.isOK()" )
361364 static Object doit (VirtualFrame frame , PBuffered self ,
362- @ Cached IONodes . GetMode getMode ) {
363- return getMode .execute (frame , self .getRaw ());
365+ @ Cached PyObjectGetAttr getAttr ) {
366+ return getAttr .execute (frame , self .getRaw (), MODE );
364367 }
365368 }
366369
@@ -373,8 +376,8 @@ Object repr(VirtualFrame frame, PBuffered self,
373376 @ Cached TypeNodes .GetNameNode getNameNode ,
374377 @ Cached GetClassNode getClassNode ,
375378 @ Cached IsBuiltinClassProfile isValueError ,
376- @ Cached ( "create(__REPR__)" ) LookupAndCallUnaryNode repr ) {
377- Object clazz = getNameNode .execute (getClassNode .execute (self ));
379+ @ Cached PyObjectReprAsJavaStringNode repr ) {
380+ String typeName = getNameNode .execute (getClassNode .execute (self ));
378381 Object nameobj = PNone .NO_VALUE ;
379382 try {
380383 nameobj = lookup .execute (frame , self , NAME );
@@ -383,14 +386,14 @@ Object repr(VirtualFrame frame, PBuffered self,
383386 // ignore
384387 }
385388 if (nameobj instanceof PNone ) {
386- return PythonUtils .format ("<%s>" , clazz );
389+ return PythonUtils .format ("<%s>" , typeName );
387390 } else {
388391 if (!getContext ().reprEnter (self )) {
389- throw raise (RuntimeError , "reentrant call inside %s.__repr__" , clazz );
392+ throw raise (RuntimeError , "reentrant call inside %s.__repr__" , typeName );
390393 } else {
391394 try {
392- Object name = repr .executeObject (frame , nameobj );
393- return PythonUtils .format ("<%s name=%s>" , clazz , name );
395+ String name = repr .execute (frame , nameobj );
396+ return PythonUtils .format ("<%s name=%s>" , typeName , name );
394397 } finally {
395398 getContext ().reprLeave (self );
396399 }
0 commit comments