Skip to content

Commit 3260911

Browse files
committed
extend findSourceLocation somewhat
1 parent b27de84 commit 3260911

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/PythonLanguage.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import com.oracle.graal.python.builtins.objects.method.PMethod;
4949
import com.oracle.graal.python.builtins.objects.module.PythonModule;
5050
import com.oracle.graal.python.builtins.objects.object.PythonObject;
51-
import com.oracle.graal.python.builtins.objects.type.PythonBuiltinClass;
51+
import com.oracle.graal.python.builtins.objects.type.PythonClass;
5252
import com.oracle.graal.python.nodes.BuiltinNames;
5353
import com.oracle.graal.python.nodes.NodeFactory;
5454
import com.oracle.graal.python.nodes.PNode;
@@ -386,10 +386,20 @@ protected Iterable<Scope> findTopScopes(PythonContext context) {
386386
}
387387

388388
@Override
389+
@TruffleBoundary
389390
protected SourceSection findSourceLocation(PythonContext context, Object value) {
390391
if (value instanceof PFunction || value instanceof PMethod) {
391392
PythonCallable callable = (PythonCallable) value;
392393
return callable.getCallTarget().getRootNode().getSourceSection();
394+
} else if (value instanceof PCode) {
395+
return ((PCode) value).getRootNode().getSourceSection();
396+
} else if (value instanceof PythonClass) {
397+
for (String k : ((PythonClass) value).getAttributeNames()) {
398+
SourceSection attrSourceLocation = findSourceLocation(context, ((PythonClass) value).getAttribute(k));
399+
if (attrSourceLocation != null) {
400+
return attrSourceLocation;
401+
}
402+
}
393403
}
394404
return null;
395405
}

0 commit comments

Comments
 (0)