Skip to content

Commit 4cb3990

Browse files
committed
Merge dispatched libraries
1 parent 9517955 commit 4cb3990

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/modules/BuiltinFunctions.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,31 +1577,29 @@ public abstract static class PrintNode extends PythonBuiltinNode {
15771577
@Specialization
15781578
PNone printNoKeywords(VirtualFrame frame, Object[] values, @SuppressWarnings("unused") PNone sep, @SuppressWarnings("unused") PNone end, @SuppressWarnings("unused") PNone file,
15791579
@SuppressWarnings("unused") PNone flush,
1580-
@CachedLibrary(limit = "1") PythonObjectLibrary fileLib,
1581-
@CachedLibrary(limit = "2") PythonObjectLibrary methodLib,
1580+
@CachedLibrary(limit = "3") PythonObjectLibrary lib,
15821581
@CachedLibrary(limit = "3") PythonObjectLibrary valueLib) {
15831582
Object stdout = getStdout();
1584-
return printAllGiven(frame, values, DEFAULT_SEPARATOR, DEFAULT_END, stdout, false, fileLib, methodLib, valueLib);
1583+
return printAllGiven(frame, values, DEFAULT_SEPARATOR, DEFAULT_END, stdout, false, lib, valueLib);
15851584
}
15861585

1587-
@Specialization(guards = {"!isNone(file)", "!isNoValue(file)"}, limit = "2")
1586+
@Specialization(guards = {"!isNone(file)", "!isNoValue(file)"})
15881587
PNone printAllGiven(VirtualFrame frame, Object[] values, String sep, String end, Object file, boolean flush,
1589-
@CachedLibrary("file") PythonObjectLibrary fileLib,
1590-
@CachedLibrary(limit = "2") PythonObjectLibrary methodLib,
1588+
@CachedLibrary(limit = "3") PythonObjectLibrary lib,
15911589
@CachedLibrary(limit = "3") PythonObjectLibrary valueLib) {
15921590
int lastValue = values.length - 1;
1593-
Object writeMethod = fileLib.lookupAttributeStrict(file, frame, "write");
1591+
Object writeMethod = lib.lookupAttributeStrict(file, frame, "write");
15941592
for (int i = 0; i < lastValue; i++) {
1595-
methodLib.callObject(writeMethod, frame, valueLib.asPString(values[i]));
1596-
methodLib.callObject(writeMethod, frame, sep);
1593+
lib.callObject(writeMethod, frame, valueLib.asPString(values[i]));
1594+
lib.callObject(writeMethod, frame, sep);
15971595
}
15981596
if (lastValue >= 0) {
1599-
methodLib.callObject(writeMethod, frame, valueLib.asPString(values[lastValue]));
1597+
lib.callObject(writeMethod, frame, valueLib.asPString(values[lastValue]));
16001598
}
1601-
methodLib.callObject(writeMethod, frame, end);
1599+
lib.callObject(writeMethod, frame, end);
16021600
if (flush) {
1603-
Object flushMethod = fileLib.lookupAttributeStrict(file, frame, "flush");
1604-
methodLib.callObject(flushMethod, frame);
1601+
Object flushMethod = lib.lookupAttributeStrict(file, frame, "flush");
1602+
lib.callObject(flushMethod, frame);
16051603
}
16061604
return PNone.NONE;
16071605
}
@@ -1612,8 +1610,7 @@ PNone printGeneric(VirtualFrame frame, Object[] values, Object sepIn, Object end
16121610
@Cached CastToJavaStringNode castEnd,
16131611
@Cached("createIfTrueNode()") CoerceToBooleanNode castFlush,
16141612
@Cached PRaiseNode raiseNode,
1615-
@CachedLibrary(limit = "2") PythonObjectLibrary fileLib,
1616-
@CachedLibrary(limit = "2") PythonObjectLibrary methodLib,
1613+
@CachedLibrary(limit = "4") PythonObjectLibrary lib,
16171614
@CachedLibrary(limit = "3") PythonObjectLibrary valueLib) {
16181615
String sep;
16191616
try {
@@ -1641,7 +1638,7 @@ PNone printGeneric(VirtualFrame frame, Object[] values, Object sepIn, Object end
16411638
} else {
16421639
flush = castFlush.executeBoolean(frame, flushIn);
16431640
}
1644-
return printAllGiven(frame, values, sep, end, file, flush, fileLib, methodLib, valueLib);
1641+
return printAllGiven(frame, values, sep, end, file, flush, lib, valueLib);
16451642
}
16461643

16471644
private Object getStdout() {

0 commit comments

Comments
 (0)