Skip to content

Commit 4b7c1c8

Browse files
committed
Remove LazyPythonClass use in TypeBuiltins
1 parent 6084ccb commit 4b7c1c8

File tree

1 file changed

+11
-10
lines changed
  • graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type

1 file changed

+11
-10
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/type/TypeBuiltins.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,16 +173,17 @@ Object doit(Object klass,
173173
@Builtin(name = "mro", minNumOfPositionalArgs = 1)
174174
@GenerateNodeFactory
175175
public abstract static class MroNode extends PythonBuiltinNode {
176-
@Specialization
177-
Object doit(LazyPythonClass klass,
178-
@Cached("create()") GetMroNode getMroNode) {
176+
@Specialization(guards = "lib.isLazyPythonClass(klass)")
177+
Object doit(Object klass,
178+
@Cached("create()") GetMroNode getMroNode,
179+
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
179180
PythonAbstractClass[] mro = getMroNode.execute(klass);
180181
return factory().createList(Arrays.copyOf(mro, mro.length, Object[].class));
181182
}
182183

183-
@Specialization(guards = "!isClass(object, iLib)", limit = "3")
184+
@Specialization(guards = "!lib.isLazyPythonClass(object)")
184185
Object doit(Object object,
185-
@SuppressWarnings("unused") @CachedLibrary("object") InteropLibrary iLib) {
186+
@SuppressWarnings("unused") @CachedLibrary(limit = "2") PythonObjectLibrary lib) {
186187
throw raise(TypeError, ErrorMessages.DESCRIPTOR_REQUIRES_OBJ, "mro", "type", object);
187188
}
188189
}
@@ -235,7 +236,7 @@ protected Object doItUnboxedUser(VirtualFrame frame, @SuppressWarnings("unused")
235236
@Cached("first(arguments)") Object cachedSelf,
236237
@SuppressWarnings("unused") @CachedLibrary(limit = "3") InteropLibrary lib,
237238
@CachedLibrary(limit = "3") PythonObjectLibrary plib) {
238-
return op(frame, (PythonAbstractClass) cachedSelf, arguments, keywords, false, plib);
239+
return op(frame, cachedSelf, arguments, keywords, false, plib);
239240

240241
}
241242

@@ -244,7 +245,7 @@ protected Object doItUnboxedBuiltinType(VirtualFrame frame, @SuppressWarnings("u
244245
@Cached("first(arguments)") Object cachedSelf,
245246
@SuppressWarnings("unused") @CachedLibrary(limit = "3") InteropLibrary lib,
246247
@CachedLibrary(limit = "3") PythonObjectLibrary plib) {
247-
return op(frame, (PythonBuiltinClassType) cachedSelf, arguments, keywords, false, plib);
248+
return op(frame, cachedSelf, arguments, keywords, false, plib);
248249
}
249250

250251
@Specialization(replaces = {"doItUnboxedUser", "doItUnboxedBuiltin", "doItUnboxedBuiltinType"})
@@ -324,7 +325,7 @@ protected Object doItIndirect1(VirtualFrame frame, PythonNativeObject self, Obje
324325
return op(frame, PythonNativeClass.cast(self), arguments, keywords, true, plib);
325326
}
326327

327-
private Object op(VirtualFrame frame, LazyPythonClass self, Object[] arguments, PKeyword[] keywords, boolean doCreateArgs, PythonObjectLibrary lib) {
328+
private Object op(VirtualFrame frame, Object self, Object[] arguments, PKeyword[] keywords, boolean doCreateArgs, PythonObjectLibrary lib) {
328329
Object newMethod = lookupNew.execute(self);
329330
if (newMethod != PNone.NO_VALUE) {
330331
CompilerAsserts.partialEvaluationConstant(doCreateArgs);
@@ -597,8 +598,8 @@ private PythonObject getInstanceClassAttr(VirtualFrame frame, Object instance) {
597598
return null;
598599
}
599600

600-
@Specialization
601-
boolean isInstance(VirtualFrame frame, LazyPythonClass cls, Object instance,
601+
@Specialization(guards = "plib.isLazyPythonClass(cls)")
602+
boolean isInstance(VirtualFrame frame, Object cls, Object instance,
602603
@Cached("create()") IsSubtypeNode isSubtypeNode,
603604
@CachedLibrary(limit = "4") PythonObjectLibrary plib) {
604605
if (instance instanceof PythonObject && isSubtypeNode.execute(frame, plib.getLazyPythonClass(instance), cls)) {

0 commit comments

Comments
 (0)