Skip to content

Commit 6502fb2

Browse files
committed
rename asIndex* to asSize* to be parallel to PyNumber_AsSsize_t
1 parent 7c7a9b6 commit 6502fb2

24 files changed

+83
-83
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ public Object bytearray(LazyPythonClass cls, @SuppressWarnings("unused") PNone s
238238
@Specialization(guards = {"lib.canBeIndex(capObj)", "isNoValue(encoding)", "isNoValue(errors)"})
239239
public Object bytearray(VirtualFrame frame, LazyPythonClass cls, Object capObj, @SuppressWarnings("unused") PNone encoding, @SuppressWarnings("unused") PNone errors,
240240
@SuppressWarnings("unused") @CachedLibrary(limit = "1") PythonObjectLibrary lib) {
241-
int cap = lib.asIndexWithState(capObj, PArguments.getThreadState(frame));
241+
int cap = lib.asSizeWithState(capObj, PArguments.getThreadState(frame));
242242
return create(cls, BytesUtils.fromSize(getCore(), cap));
243243
}
244244

@@ -1199,7 +1199,7 @@ Object parsePIntError(LazyPythonClass cls, String number, int base) {
11991199
@Specialization(guards = "!isNoValue(base)", limit = "getCallSiteInlineCacheMaxDepth()")
12001200
Object createIntError(VirtualFrame frame, LazyPythonClass cls, String number, Object base,
12011201
@CachedLibrary("base") PythonObjectLibrary lib) {
1202-
int intBase = lib.asIndexWithState(base, PArguments.getThreadState(frame));
1202+
int intBase = lib.asSizeWithState(base, PArguments.getThreadState(frame));
12031203
checkBase(intBase);
12041204
return stringToInt(cls, number, intBase);
12051205
}

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ private int asInt(VirtualFrame frame, Object obj) {
282282
CompilerDirectives.transferToInterpreterAndInvalidate();
283283
castToLongNode = insert(PythonObjectLibrary.getFactory().createDispatched(2));
284284
}
285-
return castToLongNode.asIndexWithState(obj, PArguments.getThreadState(frame));
285+
return castToLongNode.asSizeWithState(obj, PArguments.getThreadState(frame));
286286
}
287287

288288
private int len(VirtualFrame frame, Object obj) {
@@ -316,11 +316,11 @@ PLZMACompressor doCreate(VirtualFrame frame, LazyPythonClass cls, Object formatO
316316
int preset = LZMA2Options.PRESET_DEFAULT;
317317

318318
if (!isNoneOrNoValue(formatObj)) {
319-
format = lib.asIndexWithState(formatObj, PArguments.getThreadState(frame));
319+
format = lib.asSizeWithState(formatObj, PArguments.getThreadState(frame));
320320
}
321321

322322
if (!isNoneOrNoValue(checkObj)) {
323-
check = lib.asIndexWithState(checkObj, PArguments.getThreadState(frame));
323+
check = lib.asSizeWithState(checkObj, PArguments.getThreadState(frame));
324324
}
325325

326326
if (format != FORMAT_XZ && check != -1 && check != XZ.CHECK_NONE) {
@@ -331,7 +331,7 @@ PLZMACompressor doCreate(VirtualFrame frame, LazyPythonClass cls, Object formatO
331331
}
332332

333333
if (!isNoneOrNoValue(presetObj)) {
334-
preset = lib.asIndexWithState(presetObj, PArguments.getThreadState(frame));
334+
preset = lib.asSizeWithState(presetObj, PArguments.getThreadState(frame));
335335
}
336336

337337
try {
@@ -431,14 +431,14 @@ PLZMADecompressor doCreate(VirtualFrame frame, LazyPythonClass cls, Object forma
431431
int memlimit = Integer.MAX_VALUE;
432432

433433
if (!isNoneOrNoValue(formatObj)) {
434-
format = lib.asIndexWithState(formatObj, PArguments.getThreadState(frame));
434+
format = lib.asSizeWithState(formatObj, PArguments.getThreadState(frame));
435435
}
436436

437437
if (!isNoneOrNoValue(memlimitObj)) {
438438
if (format == FORMAT_RAW) {
439439
throw raise(ValueError, "Cannot specify memory limit with FORMAT_RAW");
440440
}
441-
memlimit = lib.asIndexWithState(memlimitObj, PArguments.getThreadState(frame));
441+
memlimit = lib.asSizeWithState(memlimitObj, PArguments.getThreadState(frame));
442442
}
443443

444444
if (format == FORMAT_RAW && isNoneOrNoValue(filters)) {

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -497,7 +497,7 @@ Object fstat(VirtualFrame frame, int fd,
497497
Object fstatPInt(VirtualFrame frame, Object fd,
498498
@CachedLibrary("fd") PythonObjectLibrary lib,
499499
@Cached("create()") FstatNode recursive) {
500-
return recursive.executeWith(frame, lib.asIndexWithState(fd, PArguments.getThreadState(frame)));
500+
return recursive.executeWith(frame, lib.asSizeWithState(fd, PArguments.getThreadState(frame)));
501501
}
502502

503503
protected static FstatNode create() {
@@ -1073,7 +1073,7 @@ public abstract static class CloseNode extends PythonFileNode {
10731073
Object close(VirtualFrame frame, Object fdObject,
10741074
@CachedLibrary("fdObject") PythonObjectLibrary lib,
10751075
@Cached("createClassProfile()") ValueProfile channelClassProfile) {
1076-
int fd = lib.asIndexWithState(fdObject, PArguments.getThreadState(frame));
1076+
int fd = lib.asSizeWithState(fdObject, PArguments.getThreadState(frame));
10771077
PosixResources resources = getResources();
10781078
Channel channel = resources.getFileChannel(fd, channelClassProfile);
10791079
if (noFile.profile(channel == null)) {
@@ -1208,7 +1208,7 @@ Object write(int fd, PByteArray data,
12081208
Object writePInt(VirtualFrame frame, Object fd, Object data,
12091209
@CachedLibrary("fd") PythonObjectLibrary lib,
12101210
@Cached("create()") WriteNode recursive) {
1211-
return recursive.executeWith(frame, lib.asIndexWithState(fd, PArguments.getThreadState(frame)), data);
1211+
return recursive.executeWith(frame, lib.asSizeWithState(fd, PArguments.getThreadState(frame)), data);
12121212
}
12131213

12141214
private byte[] getByteArray(PIBytesLike pByteArray) {
@@ -1513,7 +1513,7 @@ PTuple waitpid(VirtualFrame frame, int pid, int options) {
15131513
PTuple waitpidFallback(VirtualFrame frame, Object pid, Object options,
15141514
@CachedLibrary(limit = "2") PythonObjectLibrary lib) {
15151515
ThreadState threadState = PArguments.getThreadState(frame);
1516-
return waitpid(frame, lib.asIndexWithState(pid, threadState), lib.asIndexWithState(options, threadState));
1516+
return waitpid(frame, lib.asSizeWithState(pid, threadState), lib.asSizeWithState(options, threadState));
15171517
}
15181518
}
15191519

@@ -1733,7 +1733,7 @@ public abstract static class AccessNode extends PythonBuiltinNode {
17331733
boolean doGeneric(VirtualFrame frame, Object path, Object mode, @SuppressWarnings("unused") PNone dir_fd, @SuppressWarnings("unused") PNone effective_ids,
17341734
@SuppressWarnings("unused") PNone follow_symlinks,
17351735
@CachedLibrary("mode") PythonObjectLibrary lib) {
1736-
return access(castToPath(frame, path), lib.asIndexWithState(mode, PArguments.getThreadState(frame)), PNone.NONE, false, true);
1736+
return access(castToPath(frame, path), lib.asSizeWithState(mode, PArguments.getThreadState(frame)), PNone.NONE, false, true);
17371737
}
17381738

17391739
private String castToPath(VirtualFrame frame, Object path) {
@@ -2012,7 +2012,7 @@ PNone killFallback(VirtualFrame frame, Object pid, Object signal,
20122012
@Cached ReadAttributeFromObjectNode readSignalNode,
20132013
@Cached IsNode isNode) {
20142014
ThreadState state = PArguments.getThreadState(frame);
2015-
return kill(frame, lib.asIndexWithState(pid, state), lib.asIndexWithState(signal, state), readSignalNode, isNode);
2015+
return kill(frame, lib.asSizeWithState(pid, state), lib.asSizeWithState(signal, state), readSignalNode, isNode);
20162016
}
20172017
}
20182018

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -259,14 +259,14 @@ int forkExecDefault(VirtualFrame frame, Object args, Object executable_list, Obj
259259

260260
return forkExec(castArgs.execute(frame, args), castExecList.execute(frame, executable_list), castCloseFds.executeBoolean(frame, close_fds),
261261
castFdsToKeep.execute(frame, fdsToKeep), actualCwd, actualEnv,
262-
lib.asIndexWithState(p2cread, PArguments.getThreadState(frame)),
263-
lib.asIndexWithState(p2cwrite, PArguments.getThreadState(frame)),
264-
lib.asIndexWithState(c2pread, PArguments.getThreadState(frame)),
265-
lib.asIndexWithState(c2pwrite, PArguments.getThreadState(frame)),
266-
lib.asIndexWithState(errread, PArguments.getThreadState(frame)),
267-
lib.asIndexWithState(errwrite, PArguments.getThreadState(frame)),
268-
lib.asIndexWithState(errpipe_read, PArguments.getThreadState(frame)),
269-
lib.asIndexWithState(errpipe_write, PArguments.getThreadState(frame)),
262+
lib.asSizeWithState(p2cread, PArguments.getThreadState(frame)),
263+
lib.asSizeWithState(p2cwrite, PArguments.getThreadState(frame)),
264+
lib.asSizeWithState(c2pread, PArguments.getThreadState(frame)),
265+
lib.asSizeWithState(c2pwrite, PArguments.getThreadState(frame)),
266+
lib.asSizeWithState(errread, PArguments.getThreadState(frame)),
267+
lib.asSizeWithState(errwrite, PArguments.getThreadState(frame)),
268+
lib.asSizeWithState(errpipe_read, PArguments.getThreadState(frame)),
269+
lib.asSizeWithState(errpipe_write, PArguments.getThreadState(frame)),
270270
castRestoreSignals.executeBoolean(frame, restore_signals), castSetsid.executeBoolean(frame, call_setsid), preexec_fn);
271271
}
272272
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,9 +359,9 @@ PTuple doGeneric(VirtualFrame frame, Object size,
359359
@CachedLibrary("size") PythonObjectLibrary lib) {
360360
int index;
361361
if (gotFrame.profile(frame != null)) {
362-
index = lib.asIndexWithState(size, PArguments.getThreadState(frame));
362+
index = lib.asSizeWithState(size, PArguments.getThreadState(frame));
363363
} else {
364-
index = lib.asIndex(size);
364+
index = lib.asSize(size);
365365
}
366366
return factory().createTuple(new Object[index]);
367367
}
@@ -2580,7 +2580,7 @@ int resize(VirtualFrame frame, PBytes self, long newSizeL,
25802580
@Cached CastToByteNode castToByteNode) {
25812581

25822582
SequenceStorage storage = self.getSequenceStorage();
2583-
int newSize = lib.asIndex(newSizeL);
2583+
int newSize = lib.asSize(newSizeL);
25842584
int len = lenNode.execute(storage);
25852585
byte[] smaller = new byte[newSize];
25862586
for (int i = 0; i < newSize && i < len; i++) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,7 @@ abstract static class MkTimeNode extends PythonUnaryBuiltinNode {
661661
}
662662
int[] integers = new int[9];
663663
for (int i = 0; i < ELEMENT_COUNT; i++) {
664-
integers[i] = lib.asIndexWithState(items[i], PArguments.getThreadState(frame));
664+
integers[i] = lib.asSizeWithState(items[i], PArguments.getThreadState(frame));
665665
}
666666
return op(integers);
667667
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/PythonAbstractObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ public final boolean canBeIndex(@Exclusive @Cached HasInheritedAttributeNode.Dyn
709709
}
710710

711711
@ExportMessage
712-
public int asIndexWithState(LazyPythonClass type, ThreadState state,
712+
public int asSizeWithState(LazyPythonClass type, ThreadState state,
713713
@Exclusive @Cached("createBinaryProfile()") ConditionProfile wasPInt,
714714
@Exclusive @Cached("createBinaryProfile()") ConditionProfile gotState,
715715
@Exclusive @Cached("createBinaryProfile()") ConditionProfile noIndex,

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/bytes/BytesBuiltins.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ public Object mul(VirtualFrame frame, PBytes self, int times,
298298
public Object mul(VirtualFrame frame, PBytes self, Object times,
299299
@Cached("create()") SequenceStorageNodes.RepeatNode repeatNode,
300300
@CachedLibrary("times") PythonObjectLibrary lib) {
301-
SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), lib.asIndexWithState(times, PArguments.getThreadState(frame)));
301+
SequenceStorage res = repeatNode.execute(frame, self.getSequenceStorage(), lib.asSizeWithState(times, PArguments.getThreadState(frame)));
302302
return factory().createBytes(res);
303303
}
304304

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/DynamicObjectNativeWrapper.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ long doTpBasicsize(PythonManagedClass object, @SuppressWarnings("unused") String
432432
@CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") PythonObjectLibrary lib,
433433
@Cached PInteropGetAttributeNode getAttrNode) {
434434
Object val = getAttrNode.execute(object, __BASICSIZE__);
435-
return val != PNone.NO_VALUE ? lib.asIndex(val) : 0L;
435+
return val != PNone.NO_VALUE ? lib.asSize(val) : 0L;
436436
}
437437

438438
@Specialization(guards = "eq(TP_ITEMSIZE, key)")
@@ -445,7 +445,7 @@ long doTpItemsize(PythonManagedClass object, @SuppressWarnings("unused") String
445445
if (val == PNone.NO_VALUE) {
446446
return 0L;
447447
}
448-
return val != PNone.NO_VALUE ? lib.asIndex(val) : 0L;
448+
return val != PNone.NO_VALUE ? lib.asSize(val) : 0L;
449449
}
450450

451451
@Specialization(guards = "eq(TP_DICTOFFSET, key)")
@@ -457,7 +457,7 @@ long doTpDictoffset(PythonManagedClass object, @SuppressWarnings("unused") Strin
457457
return 0L;
458458
}
459459
Object dictoffset = getAttrNode.execute(object, __DICTOFFSET__);
460-
return dictoffset != PNone.NO_VALUE ? lib.asIndex(dictoffset) : 0L;
460+
return dictoffset != PNone.NO_VALUE ? lib.asSize(dictoffset) : 0L;
461461
}
462462

463463
@Specialization(guards = "eq(TP_WEAKLISTOFFSET, key)")

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/cext/PyDateTimeMRNode.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ Object doData(PythonObject object, @SuppressWarnings("unused") String key,
9494
@Cached PInteropGetAttributeNode getUSecNode,
9595
@CachedLibrary(limit = "getCallSiteInlineCacheMaxDepth()") PythonObjectLibrary lib) {
9696
// passing null here should be ok, since we should be in an interop situation
97-
int year = lib.asIndex(getYearNode.execute(object, YEAR));
98-
int month = lib.asIndex(getMonthNode.execute(object, MONTH));
99-
int day = lib.asIndex(getDayNode.execute(object, DAY));
100-
int hour = lib.asIndex(getHourNode.execute(object, HOUR));
101-
int min = lib.asIndex(getMinNode.execute(object, MIN));
102-
int sec = lib.asIndex(getSecNode.execute(object, SEC));
103-
int usec = lib.asIndex(getUSecNode.execute(object, USEC));
97+
int year = lib.asSize(getYearNode.execute(object, YEAR));
98+
int month = lib.asSize(getMonthNode.execute(object, MONTH));
99+
int day = lib.asSize(getDayNode.execute(object, DAY));
100+
int hour = lib.asSize(getHourNode.execute(object, HOUR));
101+
int min = lib.asSize(getMinNode.execute(object, MIN));
102+
int sec = lib.asSize(getSecNode.execute(object, SEC));
103+
int usec = lib.asSize(getUSecNode.execute(object, USEC));
104104
assert year >= 0 && year < 0x10000;
105105
assert month >= 0 && month < 0x100;
106106
assert day >= 0 && day < 0x100;

0 commit comments

Comments
 (0)