Skip to content
Snippets Groups Projects
Commit 7af622e8 authored by Lukas Stadler's avatar Lukas Stadler
Browse files

provide RSyntaxNode for WhileRepeatingNode and ForRepeatingNode

parent 3ded91ba
Branches
No related tags found
No related merge requests found
......@@ -54,7 +54,7 @@ public final class ForNode extends AbstractLoopNode implements VisibilityControl
this.writeIndexNode = WriteVariableNode.createAnonymous(indexName, null, Mode.REGULAR);
this.writeRangeNode = WriteVariableNode.createAnonymous(rangeName, range, Mode.REGULAR);
this.writeLengthNode = WriteVariableNode.createAnonymous(lengthName, RLengthNodeGen.create(ReadVariableNode.create(rangeName, false)), Mode.REGULAR);
this.loopNode = Truffle.getRuntime().createLoopNode(new ForRepeatingNode(cvar, body, indexName, lengthName, rangeName));
this.loopNode = Truffle.getRuntime().createLoopNode(new ForRepeatingNode(this, cvar, body, indexName, lengthName, rangeName));
}
public static ForNode create(WriteVariableNode cvar, RSyntaxNode range, RSyntaxNode body) {
......@@ -140,7 +140,11 @@ public final class ForNode extends AbstractLoopNode implements VisibilityControl
@Child private WriteVariableNode writeIndexNode;
@Child private RNode loadElement;
public ForRepeatingNode(WriteVariableNode cvar, RNode body, String indexName, String lengthName, String rangeName) {
// used as RSyntaxNode
private final ForNode forNode;
public ForRepeatingNode(ForNode forNode, WriteVariableNode cvar, RNode body, String indexName, String lengthName, String rangeName) {
this.forNode = forNode;
this.writeElementNode = cvar;
this.body = body;
......@@ -193,6 +197,11 @@ public final class ForNode extends AbstractLoopNode implements VisibilityControl
}
}
@Override
protected RSyntaxNode getRSyntaxNode() {
return forNode;
}
@Override
public String toString() {
RootNode rootNode = getRootNode();
......
......@@ -45,7 +45,7 @@ public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, Vi
private final boolean isRepeat;
private WhileNode(RSyntaxNode condition, RSyntaxNode body, boolean isRepeat) {
this.loop = Truffle.getRuntime().createLoopNode(new WhileRepeatingNode(ConvertBooleanNode.create(condition), body.asRNode()));
this.loop = Truffle.getRuntime().createLoopNode(new WhileRepeatingNode(this, ConvertBooleanNode.create(condition), body.asRNode()));
this.isRepeat = isRepeat;
}
......@@ -122,7 +122,11 @@ public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, Vi
private final BranchProfile breakBlock = BranchProfile.create();
private final BranchProfile nextBlock = BranchProfile.create();
public WhileRepeatingNode(ConvertBooleanNode condition, RNode body) {
// used as RSyntaxNode
private final WhileNode whileNode;
public WhileRepeatingNode(WhileNode whileNode, ConvertBooleanNode condition, RNode body) {
this.whileNode = whileNode;
this.condition = condition;
this.body = body;
// pre-initialize the profile so that loop exits to not deoptimize
......@@ -154,6 +158,11 @@ public final class WhileNode extends AbstractLoopNode implements RSyntaxNode, Vi
}
}
@Override
protected RSyntaxNode getRSyntaxNode() {
return whileNode;
}
@Override
public String toString() {
RootNode rootNode = getRootNode();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment