Skip to content

Commit c7757be

Browse files
committed
improve dispatch on PFunction, PBuiltinFunction, and PythonBuiltinClass by exporting getLazyPythonClass and thus unifying the type check with the PythonBuiltinClassType
1 parent 848443a commit c7757be

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PBuiltinFunction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,11 @@ public PKeyword[] getKwDefaults() {
158158
public boolean isCallable() {
159159
return true;
160160
}
161+
162+
@Override
163+
@ExportMessage
164+
@SuppressWarnings("static-method")
165+
public Object getLazyPythonClass() {
166+
return PythonBuiltinClassType.PBuiltinFunction;
167+
}
161168
}

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/function/PFunction.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,4 +220,11 @@ private static SourceSection getForeignSourceSection(RootNode rootNode) {
220220
public boolean hasSourceLocation() {
221221
return getSourceLocationDirect() != null;
222222
}
223+
224+
@Override
225+
@ExportMessage
226+
@SuppressWarnings("static-method")
227+
public Object getLazyPythonClass() {
228+
return PythonBuiltinClassType.PFunction;
229+
}
223230
}

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,12 @@ String getMetaSimpleName() {
9797
String getMetaQualifiedName() {
9898
return type.getQualifiedName();
9999
}
100+
101+
@Override
102+
@ExportMessage
103+
@SuppressWarnings("static-method")
104+
public Object getLazyPythonClass() {
105+
// all built-in types have "type" as metaclass
106+
return PythonBuiltinClassType.PythonClass;
107+
}
100108
}

0 commit comments

Comments
 (0)