Skip to content

Commit f954a9c

Browse files
committedJul 19, 2024
Update to new Truffle APIs
1 parent 3b93708 commit f954a9c

File tree

2 files changed

+187
-185
lines changed

2 files changed

+187
-185
lines changed
 

‎graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/code/CodeBuiltins.java

+9-7
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ static Object lines(PCode self) {
338338
private static List<PTuple> computeLinesForBytecodeDSLInterpreter(PBytecodeDSLRootNode root, PythonObjectFactory factory) {
339339
BytecodeNode bytecodeNode = root.getBytecodeNode();
340340
List<int[]> triples = new ArrayList<>();
341-
traverseSourceInformationTree(bytecodeNode.getSourceInformationTree(), triples);
341+
SourceInformationTree sourceInformationTree = bytecodeNode.getSourceInformationTree();
342+
assert sourceInformationTree.getSourceSection() != null;
343+
traverseSourceInformationTree(sourceInformationTree, triples);
342344
return convertTripleBcisToInstructionIndices(bytecodeNode, factory, triples);
343345
}
344346

@@ -355,21 +357,21 @@ private static List<PTuple> computeLinesForBytecodeDSLInterpreter(PBytecodeDSLRo
355357
* assigned the line number of the node.
356358
*/
357359
private static void traverseSourceInformationTree(SourceInformationTree tree, List<int[]> triples) {
358-
int startIndex = tree.getStartIndex();
360+
int startIndex = tree.getStartBytecodeIndex();
359361
int startLine = tree.getSourceSection().getStartLine();
360362
for (SourceInformationTree child : tree.getChildren()) {
361-
if (startIndex < child.getStartIndex()) {
363+
if (startIndex < child.getStartBytecodeIndex()) {
362364
// range before child.start is uncovered
363-
triples.add(new int[]{startIndex, child.getStartIndex(), startLine});
365+
triples.add(new int[]{startIndex, child.getStartBytecodeIndex(), startLine});
364366
}
365367
// recursively handle [child.start, child.end]
366368
traverseSourceInformationTree(child, triples);
367-
startIndex = child.getEndIndex();
369+
startIndex = child.getEndBytecodeIndex();
368370
}
369371

370-
if (startIndex < tree.getEndIndex()) {
372+
if (startIndex < tree.getEndBytecodeIndex()) {
371373
// range after last_child.end is uncovered
372-
triples.add(new int[]{startIndex, tree.getEndIndex(), startLine});
374+
triples.add(new int[]{startIndex, tree.getEndBytecodeIndex(), startLine});
373375
}
374376
}
375377

0 commit comments

Comments
 (0)
Failed to load comments.