CFG: rename getBody{=>Node} and getCondition{=>Node}

This commit is contained in:
Arthur Baars
2020-12-07 15:30:37 +01:00
parent 6d12bcc2fe
commit 6aea3eff3e
4 changed files with 23 additions and 23 deletions

View File

@@ -223,7 +223,7 @@ module SuccessorTypes {
*
* ```rb
* for arg in args do
* puts arg
* puts arg
* end
* puts "done";
* ```

View File

@@ -99,9 +99,9 @@ private class UnlessModifierAstNode extends IfElsifAstNode, UnlessModifier {
private class CondLoop = @while or @while_modifier or @until or @until_modifier;
class ConditionalLoopAstNode extends AstNode, CondLoop {
AstNode getCondition() { none() }
AstNode getConditionNode() { none() }
AstNode getBody() { none() }
AstNode getBodyNode() { none() }
predicate continueLoop(BooleanCompletion c) { c instanceof TrueCompletion }
@@ -109,29 +109,29 @@ class ConditionalLoopAstNode extends AstNode, CondLoop {
}
private class WhileLoop extends ConditionalLoopAstNode, While {
override UnderscoreStatement getCondition() { result = While.super.getCondition() }
override UnderscoreStatement getConditionNode() { result = this.getCondition() }
override Do getBody() { result = While.super.getBody() }
override Do getBodyNode() { result = this.getBody() }
}
private class WhileModifierLoop extends ConditionalLoopAstNode, WhileModifier {
override AstNode getCondition() { result = WhileModifier.super.getCondition() }
override AstNode getConditionNode() { result = this.getCondition() }
override UnderscoreStatement getBody() { result = WhileModifier.super.getBody() }
override UnderscoreStatement getBodyNode() { result = this.getBody() }
}
private class UntilLoop extends ConditionalLoopAstNode, Until {
override UnderscoreStatement getCondition() { result = Until.super.getCondition() }
override UnderscoreStatement getConditionNode() { result = this.getCondition() }
override Do getBody() { result = Until.super.getBody() }
override Do getBodyNode() { result = this.getBody() }
override predicate continueLoop(BooleanCompletion c) { c instanceof FalseCompletion }
}
private class UntilModifierLoop extends ConditionalLoopAstNode, UntilModifier {
override AstNode getCondition() { result = UntilModifier.super.getCondition() }
override AstNode getConditionNode() { result = this.getCondition() }
override UnderscoreStatement getBody() { result = UntilModifier.super.getBody() }
override UnderscoreStatement getBodyNode() { result = this.getBody() }
override predicate continueLoop(BooleanCompletion c) { c instanceof FalseCompletion }
}

View File

@@ -120,7 +120,7 @@ private predicate mustHaveBooleanCompletion(AstNode n) {
private predicate inBooleanContext(AstNode n) {
n = any(IfElsifAstNode parent).getConditionNode()
or
n = any(ConditionalLoopAstNode parent).getCondition()
n = any(ConditionalLoopAstNode parent).getConditionNode()
or
exists(LogicalAndAstNode parent |
n = parent.getLeft()

View File

@@ -979,39 +979,39 @@ private module Trees {
}
private class ConditionalLoopTree extends PreOrderTree, ConditionalLoopAstNode {
final override predicate propagatesAbnormal(AstNode child) { child = this.getCondition() }
final override predicate propagatesAbnormal(AstNode child) { child = this.getConditionNode() }
final override predicate last(AstNode last, Completion c) {
last(this.getCondition(), last, c) and
last(this.getConditionNode(), last, c) and
this.endLoop(c)
or
last(this.getBody(), last, c) and
last(this.getBodyNode(), last, c) and
not c.continuesLoop() and
not c instanceof BreakCompletion and
not c instanceof RedoCompletion
or
c =
any(NestedCompletion nc |
last(this.getBody(), last, nc.getInnerCompletion().(BreakCompletion)) and
last(this.getBodyNode(), last, nc.getInnerCompletion().(BreakCompletion)) and
nc.getOuterCompletion() instanceof SimpleCompletion
)
}
final override predicate succ(AstNode pred, AstNode succ, Completion c) {
pred = this and
first(this.getCondition(), succ) and
first(this.getConditionNode(), succ) and
c instanceof SimpleCompletion
or
last(this.getCondition(), pred, c) and
last(this.getConditionNode(), pred, c) and
this.continueLoop(c) and
first(this.getBody(), succ)
first(this.getBodyNode(), succ)
or
last(this.getBody(), pred, c) and
first(this.getCondition(), succ) and
last(this.getBodyNode(), pred, c) and
first(this.getConditionNode(), succ) and
c.continuesLoop()
or
last(this.getBody(), pred, any(RedoCompletion rc)) and
first(this.getBody(), succ) and
last(this.getBodyNode(), pred, any(RedoCompletion rc)) and
first(this.getBodyNode(), succ) and
c instanceof SimpleCompletion
}
}