Treat conditional expressions as if-then-else

This commit is contained in:
Arthur Baars
2020-11-26 16:58:37 +01:00
parent 97fab0d18b
commit b60ea74e8a

View File

@@ -40,7 +40,7 @@ class LogicalOrAstNode extends Binary {
AstNode getAnOperand() { result in [left, right] }
}
private class If_or_elisif = @if or @elsif;
private class If_or_elisif = @if or @elsif or @conditional;
class IfElsifAstNode extends AstNode, If_or_elisif {
AstNode getConditionNode() { none() }
@@ -66,6 +66,14 @@ private class ElsifAstNode extends IfElsifAstNode, Elsif {
override AstNode getAlternativeNode() { result = this.getAlternative() }
}
private class ConditionalAstNode extends IfElsifAstNode, Conditional {
override AstNode getConditionNode() { result = this.getCondition() }
override AstNode getConsequenceNode() { result = this.getConsequence() }
override AstNode getAlternativeNode() { result = this.getAlternative() }
}
class ParenthesizedStatement extends ParenthesizedStatements {
ParenthesizedStatement() { strictcount(int i | exists(this.getChild(i))) = 1 }