Skip to content

Commit

Permalink
Update to new Truffle APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
DSouzaM committed Jul 19, 2024
1 parent 3b93708 commit f954a9c
Show file tree
Hide file tree
Showing 2 changed files with 187 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,9 @@ static Object lines(PCode self) {
private static List<PTuple> computeLinesForBytecodeDSLInterpreter(PBytecodeDSLRootNode root, PythonObjectFactory factory) {
BytecodeNode bytecodeNode = root.getBytecodeNode();
List<int[]> triples = new ArrayList<>();
traverseSourceInformationTree(bytecodeNode.getSourceInformationTree(), triples);
SourceInformationTree sourceInformationTree = bytecodeNode.getSourceInformationTree();
assert sourceInformationTree.getSourceSection() != null;
traverseSourceInformationTree(sourceInformationTree, triples);
return convertTripleBcisToInstructionIndices(bytecodeNode, factory, triples);
}

Expand All @@ -355,21 +357,21 @@ private static List<PTuple> computeLinesForBytecodeDSLInterpreter(PBytecodeDSLRo
* assigned the line number of the node.
*/
private static void traverseSourceInformationTree(SourceInformationTree tree, List<int[]> triples) {
int startIndex = tree.getStartIndex();
int startIndex = tree.getStartBytecodeIndex();
int startLine = tree.getSourceSection().getStartLine();
for (SourceInformationTree child : tree.getChildren()) {
if (startIndex < child.getStartIndex()) {
if (startIndex < child.getStartBytecodeIndex()) {
// range before child.start is uncovered
triples.add(new int[]{startIndex, child.getStartIndex(), startLine});
triples.add(new int[]{startIndex, child.getStartBytecodeIndex(), startLine});
}
// recursively handle [child.start, child.end]
traverseSourceInformationTree(child, triples);
startIndex = child.getEndIndex();
startIndex = child.getEndBytecodeIndex();
}

if (startIndex < tree.getEndIndex()) {
if (startIndex < tree.getEndBytecodeIndex()) {
// range after last_child.end is uncovered
triples.add(new int[]{startIndex, tree.getEndIndex(), startLine});
triples.add(new int[]{startIndex, tree.getEndBytecodeIndex(), startLine});
}
}

Expand Down
Loading

0 comments on commit f954a9c

Please sign in to comment.