Skip to content

Commit e8b9c86

Browse files
committed
Remove qualified class usage where possible
1 parent b4bbedc commit e8b9c86

File tree

7 files changed

+85
-65
lines changed

7 files changed

+85
-65
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/AbstractBufferedIOBuiltins.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
import com.oracle.graal.python.PythonLanguage;
5050
import com.oracle.graal.python.builtins.PythonBuiltinClassType;
5151
import com.oracle.graal.python.builtins.PythonBuiltins;
52+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.RawTellNode;
53+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodesFactory.RawTellNodeGen;
5254
import com.oracle.graal.python.builtins.objects.PNone;
5355
import com.oracle.graal.python.builtins.objects.exception.OSErrorEnum;
5456
import com.oracle.graal.python.builtins.objects.exception.PBaseException;
@@ -63,6 +65,7 @@
6365
import com.oracle.graal.python.nodes.function.builtins.clinic.ArgumentClinicProvider;
6466
import com.oracle.graal.python.nodes.object.GetClassNode;
6567
import com.oracle.graal.python.runtime.PosixSupportLibrary;
68+
import com.oracle.graal.python.runtime.PosixSupportLibrary.PosixException;
6669
import com.oracle.graal.python.runtime.PythonOptions;
6770
import com.oracle.graal.python.runtime.exception.PException;
6871
import com.oracle.graal.python.runtime.object.PythonObjectFactory;
@@ -78,7 +81,7 @@ abstract class AbstractBufferedIOBuiltins extends PythonBuiltins {
7881

7982
public abstract static class BufferedInitNode extends PNodeWithRaise {
8083

81-
@Child private BufferedIONodes.RawTellNode rawTellNode = BufferedIONodesFactory.RawTellNodeGen.create(true);
84+
@Child private RawTellNode rawTellNode = RawTellNodeGen.create(true);
8285

8386
public abstract void execute(VirtualFrame frame, PBuffered self, int bufferSize, PythonObjectFactory factory);
8487

@@ -111,7 +114,7 @@ public static void internalInit(PBuffered self, int bufferSize, PythonObjectFact
111114
init(self, bufferSize, factory);
112115
try {
113116
FileIOBuiltins.TellNode.internalTell(self.getFileIORaw(), posixSupport, posixLib);
114-
} catch (PosixSupportLibrary.PosixException e) {
117+
} catch (PosixException e) {
115118
// ignore.. it's ok if it's not seekable
116119
}
117120
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedIOMixinBuiltins.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777
import com.oracle.graal.python.annotations.ArgumentClinic;
7878
import com.oracle.graal.python.builtins.Builtin;
7979
import com.oracle.graal.python.builtins.CoreFunctions;
80+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.CheckIsClosedNode;
81+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.EnterBufferedNode;
82+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.FlushAndRewindUnlockedNode;
83+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.RawTellNode;
8084
import com.oracle.graal.python.builtins.objects.PNone;
8185
import com.oracle.graal.python.builtins.objects.type.TypeNodes;
8286
import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
@@ -115,7 +119,7 @@ protected List<? extends NodeFactory<? extends PythonBuiltinBaseNode>> getNodeFa
115119
abstract static class CloseNode extends PythonUnaryWithInitErrorBuiltinNode {
116120

117121
private static Object close(VirtualFrame frame, PBuffered self,
118-
BufferedIONodes.EnterBufferedNode lock,
122+
EnterBufferedNode lock,
119123
PyObjectCallMethodObjArgs callMethodClose) {
120124
try {
121125
lock.enter(self);
@@ -125,7 +129,7 @@ private static Object close(VirtualFrame frame, PBuffered self,
125129
}
126130
return res;
127131
} finally {
128-
BufferedIONodes.EnterBufferedNode.leave(self);
132+
EnterBufferedNode.leave(self);
129133
}
130134
}
131135

@@ -135,7 +139,7 @@ static Object doit(VirtualFrame frame, PBuffered self,
135139
@Cached PyObjectCallMethodObjArgs callMethodFlush,
136140
@Cached PyObjectCallMethodObjArgs callMethodClose,
137141
@Cached PyObjectCallMethodObjArgs callMethodDeallocWarn,
138-
@Cached BufferedIONodes.EnterBufferedNode lock,
142+
@Cached EnterBufferedNode lock,
139143
@Cached ConditionProfile profile) {
140144
try {
141145
lock.enter(self);
@@ -148,7 +152,7 @@ static Object doit(VirtualFrame frame, PBuffered self,
148152
}
149153
}
150154
} finally {
151-
BufferedIONodes.EnterBufferedNode.leave(self);
155+
EnterBufferedNode.leave(self);
152156
}
153157
/* flush() will most probably re-take the lock, so drop it first */
154158
try {
@@ -245,7 +249,7 @@ protected static boolean isSupportedWhence(int whence) {
245249

246250
@Specialization(guards = {"self.isOK()", "isSupportedWhence(whence)"})
247251
static long doit(VirtualFrame frame, PBuffered self, Object off, int whence,
248-
@Cached("create(SEEK)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
252+
@Cached("create(SEEK)") CheckIsClosedNode checkIsClosedNode,
249253
@Cached BufferedIONodes.CheckIsSeekabledNode checkIsSeekabledNode,
250254
@Cached BufferedIONodes.AsOffNumberNode asOffNumberNode,
251255
@Cached BufferedIONodes.SeekNode seekNode) {
@@ -275,7 +279,7 @@ Object initError(PBuffered self, @SuppressWarnings("unused") int off, @SuppressW
275279
abstract static class TellNode extends PythonUnaryWithInitErrorBuiltinNode {
276280
@Specialization(guards = "self.isOK()")
277281
static long doit(VirtualFrame frame, PBuffered self,
278-
@Cached BufferedIONodes.RawTellNode rawTellNode) {
282+
@Cached RawTellNode rawTellNode) {
279283
long pos = rawTellNode.execute(frame, self);
280284
pos -= rawOffset(self);
281285
/* TODO: sanity check (pos >= 0) */
@@ -295,10 +299,10 @@ protected ArgumentClinicProvider getArgumentClinic() {
295299

296300
@Specialization(guards = {"self.isOK()", "self.isWritable()"})
297301
static Object doit(VirtualFrame frame, PBuffered self, Object pos,
298-
@Cached BufferedIONodes.EnterBufferedNode lock,
299-
@Cached("create(TRUNCATE)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
300-
@Cached BufferedIONodes.RawTellNode rawTellNode,
301-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
302+
@Cached EnterBufferedNode lock,
303+
@Cached("create(TRUNCATE)") CheckIsClosedNode checkIsClosedNode,
304+
@Cached RawTellNode rawTellNode,
305+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
302306
@Cached PyObjectCallMethodObjArgs callMethodTruncate) {
303307
checkIsClosedNode.execute(frame, self);
304308
try {
@@ -309,7 +313,7 @@ static Object doit(VirtualFrame frame, PBuffered self, Object pos,
309313
rawTellNode.execute(frame, self);
310314
return res;
311315
} finally {
312-
BufferedIONodes.EnterBufferedNode.leave(self);
316+
EnterBufferedNode.leave(self);
313317
}
314318
}
315319

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedReaderMixinBuiltins.java

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@
7070
import com.oracle.graal.python.annotations.ArgumentClinic;
7171
import com.oracle.graal.python.builtins.Builtin;
7272
import com.oracle.graal.python.builtins.CoreFunctions;
73+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.CheckIsClosedNode;
74+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.EnterBufferedNode;
75+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.FlushAndRewindUnlockedNode;
76+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodesFactory.CheckIsClosedNodeGen;
7377
import com.oracle.graal.python.builtins.objects.PNone;
7478
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
7579
import com.oracle.graal.python.builtins.objects.bytes.BytesNodes;
@@ -251,10 +255,10 @@ Object readFast(VirtualFrame frame, PBuffered self, int size) {
251255
*/
252256
@Specialization(guards = {"self.isOK()", "size > 0", "!isReadFast(self, size)"})
253257
Object bufferedreaderReadGeneric(VirtualFrame frame, PBuffered self, int size,
254-
@Cached BufferedIONodes.EnterBufferedNode lock,
258+
@Cached EnterBufferedNode lock,
255259
@Cached RawReadNode rawReadNode,
256260
@Cached FillBufferNode fillBufferNode,
257-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) {
261+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) {
258262
checkIsClosedNode.execute(frame, self);
259263
try {
260264
lock.enter(self);
@@ -337,7 +341,7 @@ reads, which could block indefinitely (e.g. on a socket).
337341

338342
return factory().createBytes(res);
339343
} finally {
340-
BufferedIONodes.EnterBufferedNode.leave(self);
344+
EnterBufferedNode.leave(self);
341345
}
342346
}
343347

@@ -348,8 +352,8 @@ reads, which could block indefinitely (e.g. on a socket).
348352
*/
349353
@Specialization(guards = {"self.isOK()", "isReadAll(size)"})
350354
Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused") int size,
351-
@Cached BufferedIONodes.EnterBufferedNode lock,
352-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
355+
@Cached EnterBufferedNode lock,
356+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
353357
@Cached("create(READALL)") LookupAttributeInMRONode readallAttr,
354358
@Cached ConditionProfile hasReadallProfile,
355359
@Cached CallUnaryMethodNode dispatchGetattribute,
@@ -426,7 +430,7 @@ Object bufferedreaderReadAll(VirtualFrame frame, PBuffered self, @SuppressWarnin
426430
}
427431
}
428432
} finally {
429-
BufferedIONodes.EnterBufferedNode.leave(self);
433+
EnterBufferedNode.leave(self);
430434
}
431435
}
432436

@@ -449,8 +453,8 @@ protected ArgumentClinicProvider getArgumentClinic() {
449453

450454
@Specialization(guards = "self.isOK()")
451455
PBytes doit(VirtualFrame frame, PBuffered self, int size,
452-
@Cached BufferedIONodes.EnterBufferedNode lock,
453-
@Cached("create(READ)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
456+
@Cached EnterBufferedNode lock,
457+
@Cached("create(READ)") CheckIsClosedNode checkIsClosedNode,
454458
@Cached RawReadNode rawReadNode) {
455459
checkIsClosedNode.execute(frame, self);
456460
int n = size;
@@ -476,7 +480,7 @@ PBytes doit(VirtualFrame frame, PBuffered self, int size,
476480
byte[] fill = rawReadNode.execute(frame, self, n);
477481
return factory().createBytes(fill == BLOCKED ? PythonUtils.EMPTY_BYTE_ARRAY : fill);
478482
} finally {
479-
BufferedIONodes.EnterBufferedNode.leave(self);
483+
EnterBufferedNode.leave(self);
480484
}
481485
}
482486
}
@@ -486,16 +490,16 @@ PBytes doit(VirtualFrame frame, PBuffered self, int size,
486490
@GenerateNodeFactory
487491
abstract static class ReadIntoNode extends PythonBinaryWithInitErrorClinicBuiltinNode {
488492

489-
@Child BufferedIONodes.CheckIsClosedNode checkIsClosedNode = BufferedIONodesFactory.CheckIsClosedNodeGen.create(READLINE);
493+
@Child private CheckIsClosedNode checkIsClosedNode = CheckIsClosedNodeGen.create(READLINE);
490494

491495
/**
492496
* implementation of cpython/Modules/_io/bufferedio.c:_buffered_readinto_generic
493497
*/
494498
@Specialization(guards = "self.isOK()", limit = "3")
495499
Object bufferedReadintoGeneric(VirtualFrame frame, PBuffered self, Object buffer,
496500
@CachedLibrary("buffer") PythonBufferAccessLibrary bufferLib,
497-
@Cached BufferedIONodes.EnterBufferedNode lock,
498-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
501+
@Cached EnterBufferedNode lock,
502+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
499503
@Cached RawReadNode rawReadNode,
500504
@Cached FillBufferNode fillBufferNode) {
501505
checkIsClosedNode.execute(frame, self);
@@ -571,7 +575,7 @@ Object bufferedReadintoGeneric(VirtualFrame frame, PBuffered self, Object buffer
571575

572576
return written;
573577
} finally {
574-
BufferedIONodes.EnterBufferedNode.leave(self);
578+
EnterBufferedNode.leave(self);
575579
bufferLib.release(buffer, frame, this);
576580
}
577581
}
@@ -610,8 +614,8 @@ abstract static class BufferedReadlineNode extends PNodeWithContext {
610614

611615
@Specialization
612616
static byte[] readline(VirtualFrame frame, PBuffered self, int size,
613-
@Cached BufferedIONodes.EnterBufferedNode lock,
614-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
617+
@Cached EnterBufferedNode lock,
618+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode,
615619
@Cached FillBufferNode fillBufferNode,
616620
@Cached ConditionProfile notFound,
617621
@Cached ConditionProfile reachedLimit) {
@@ -683,7 +687,7 @@ static byte[] readline(VirtualFrame frame, PBuffered self, int size,
683687
}
684688
return toByteArray(chunks);
685689
} finally {
686-
BufferedIONodes.EnterBufferedNode.leave(self);
690+
EnterBufferedNode.leave(self);
687691
}
688692
}
689693
}
@@ -700,7 +704,7 @@ protected ArgumentClinicProvider getArgumentClinic() {
700704

701705
@Specialization(guards = "self.isOK()")
702706
PBytes doit(VirtualFrame frame, PBuffered self, int size,
703-
@Cached("create(READLINE)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
707+
@Cached("create(READLINE)") CheckIsClosedNode checkIsClosedNode,
704708
@Cached BufferedReadlineNode readlineNode) {
705709
checkIsClosedNode.execute(frame, self);
706710
byte[] res = readlineNode.execute(frame, self, size);
@@ -746,10 +750,10 @@ static byte[] bufferedreaderPeekUnlocked(VirtualFrame frame, PBuffered self,
746750

747751
@Specialization(guards = "self.isOK()")
748752
Object doit(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused") int size,
749-
@Cached BufferedIONodes.EnterBufferedNode lock,
750-
@Cached("create(PEEK)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
753+
@Cached EnterBufferedNode lock,
754+
@Cached("create(PEEK)") CheckIsClosedNode checkIsClosedNode,
751755
@Cached FillBufferNode fillBufferNode,
752-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) {
756+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) {
753757
checkIsClosedNode.execute(frame, self);
754758
try {
755759
lock.enter(self);
@@ -758,7 +762,7 @@ Object doit(VirtualFrame frame, PBuffered self, @SuppressWarnings("unused") int
758762
}
759763
return factory().createBytes(bufferedreaderPeekUnlocked(frame, self, fillBufferNode));
760764
} finally {
761-
BufferedIONodes.EnterBufferedNode.leave(self);
765+
EnterBufferedNode.leave(self);
762766
}
763767
}
764768
}
@@ -770,7 +774,7 @@ abstract static class NextNode extends PythonUnaryWithInitErrorBuiltinNode {
770774

771775
@Specialization(guards = "self.isOK()")
772776
PBytes doit(VirtualFrame frame, PBuffered self,
773-
@Cached("create(READLINE)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
777+
@Cached("create(READLINE)") CheckIsClosedNode checkIsClosedNode,
774778
@Cached BufferedReadlineNode readlineNode) {
775779
checkIsClosedNode.execute(frame, self);
776780
byte[] line = readlineNode.execute(frame, self, -1);

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterBuiltins.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@
4747

4848
import com.oracle.graal.python.builtins.Builtin;
4949
import com.oracle.graal.python.builtins.CoreFunctions;
50+
import com.oracle.graal.python.builtins.modules.io.BufferedWriterBuiltinsFactory.BufferedWriterInitNodeGen;
51+
import com.oracle.graal.python.builtins.modules.io.IOBaseBuiltins.CheckWritableNode;
5052
import com.oracle.graal.python.nodes.function.PythonBuiltinBaseNode;
5153
import com.oracle.graal.python.nodes.object.GetClassNode;
5254
import com.oracle.graal.python.runtime.PosixSupportLibrary;
@@ -71,7 +73,7 @@ public abstract static class BufferedWriterInit extends Node {
7173

7274
@Specialization
7375
static void doInit(VirtualFrame frame, PBuffered self, Object raw, int bufferSize, PythonObjectFactory factory,
74-
@Cached IOBaseBuiltins.CheckWritableNode checkWritableNode,
76+
@Cached CheckWritableNode checkWritableNode,
7577
@Cached BufferedInitNode bufferedInitNode,
7678
@Cached GetClassNode getSelfClass,
7779
@Cached GetClassNode getRawClass) {

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/io/BufferedWriterMixinBuiltins.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@
5151
import com.oracle.graal.python.annotations.ArgumentClinic;
5252
import com.oracle.graal.python.builtins.Builtin;
5353
import com.oracle.graal.python.builtins.CoreFunctions;
54+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.CheckIsClosedNode;
55+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.EnterBufferedNode;
56+
import com.oracle.graal.python.builtins.modules.io.BufferedIONodes.FlushAndRewindUnlockedNode;
5457
import com.oracle.graal.python.builtins.objects.PNone;
5558
import com.oracle.graal.python.builtins.objects.buffer.PythonBufferAccessLibrary;
5659
import com.oracle.graal.python.lib.PyObjectCallMethodObjArgs;
@@ -90,16 +93,16 @@ abstract static class WriteNode extends PythonBinaryWithInitErrorClinicBuiltinNo
9093
@Specialization(guards = "self.isOK()")
9194
Object write(@SuppressWarnings("unused") VirtualFrame frame, PBuffered self, Object buffer,
9295
@CachedLibrary(limit = "3") PythonBufferAccessLibrary bufferLib,
93-
@Cached BufferedIONodes.EnterBufferedNode lock,
94-
@Cached("create(WRITE)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
96+
@Cached EnterBufferedNode lock,
97+
@Cached("create(WRITE)") CheckIsClosedNode checkIsClosedNode,
9598
@Cached BufferedWriterNodes.WriteNode writeNode) {
9699
try {
97100
lock.enter(self);
98101
checkIsClosedNode.execute(frame, self);
99102
return writeNode.execute(frame, self, buffer);
100103
} finally {
101104
bufferLib.release(buffer, frame, this);
102-
BufferedIONodes.EnterBufferedNode.leave(self);
105+
EnterBufferedNode.leave(self);
103106
}
104107
}
105108

@@ -116,15 +119,15 @@ abstract static class FlushNode extends PythonUnaryWithInitErrorBuiltinNode {
116119

117120
@Specialization(guards = "self.isOK()")
118121
static Object doit(VirtualFrame frame, PBuffered self,
119-
@Cached BufferedIONodes.EnterBufferedNode lock,
120-
@Cached("create(FLUSH)") BufferedIONodes.CheckIsClosedNode checkIsClosedNode,
121-
@Cached BufferedIONodes.FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) {
122+
@Cached EnterBufferedNode lock,
123+
@Cached("create(FLUSH)") CheckIsClosedNode checkIsClosedNode,
124+
@Cached FlushAndRewindUnlockedNode flushAndRewindUnlockedNode) {
122125
checkIsClosedNode.execute(frame, self);
123126
try {
124127
lock.enter(self);
125128
flushAndRewindUnlockedNode.execute(frame, self);
126129
} finally {
127-
BufferedIONodes.EnterBufferedNode.leave(self);
130+
EnterBufferedNode.leave(self);
128131
}
129132
return PNone.NONE;
130133
}

0 commit comments

Comments
 (0)