diff --git a/ql/src/codeql_ruby/ast/Expr.qll b/ql/src/codeql_ruby/ast/Expr.qll index 6f27b0462bc..a113103d09b 100644 --- a/ql/src/codeql_ruby/ast/Expr.qll +++ b/ql/src/codeql_ruby/ast/Expr.qll @@ -57,16 +57,6 @@ class ArgumentList extends Expr, TArgumentList { class StmtSequence extends Expr, TStmtSequence { override string getAPrimaryQlClass() { result = "StmtSequence" } - override string toString() { - exists(int c | c = this.getNumberOfStatements() | - c = 0 and result = ";" - or - c = 1 and result = this.getStmt(0).toString() - or - c > 1 and result = "...; ..." - ) - } - /** Gets the `n`th statement in this sequence. */ Stmt getStmt(int n) { none() } @@ -91,6 +81,8 @@ private class Then extends StmtSequence, TThen { Then() { this = TThen(g) } override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } + + final override string toString() { result = "then ..." } } private class Else extends StmtSequence, TElse { @@ -99,6 +91,8 @@ private class Else extends StmtSequence, TElse { Else() { this = TElse(g) } override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } + + final override string toString() { result = "else ..." } } private class Do extends StmtSequence, TDo { @@ -107,6 +101,8 @@ private class Do extends StmtSequence, TDo { Do() { this = TDo(g) } override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } + + final override string toString() { result = "do ..." } } private class Ensure extends StmtSequence, TEnsure { @@ -212,13 +208,7 @@ class ParenthesizedExpr extends StmtSequence, TParenthesizedExpr { final override string getAPrimaryQlClass() { result = "ParenthesizedExpr" } - final override string toString() { - exists(int c | c = this.getNumberOfStatements() | - c = 0 and result = "()" - or - c > 0 and result = "(" + StmtSequence.super.toString() + ")" - ) - } + final override string toString() { result = "( ... )" } final override Stmt getStmt(int n) { toGenerated(result) = g.getChild(n) } } diff --git a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll index 83091c2f87b..15097a58d85 100644 --- a/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll +++ b/ql/src/codeql_ruby/controlflow/internal/ControlFlowGraphImpl.qll @@ -107,12 +107,6 @@ abstract private class ControlFlowTree extends AstNode { */ pragma[nomagic] abstract predicate succ(AstNode pred, AstNode succ, Completion c); - - /** - * Holds if this node should be hidden in the CFG. That is, edges - * `pred -> this -> succ` are converted to a single edge `pred -> succ`. - */ - predicate isHidden() { none() } } /** Holds if `first` is the first element executed within AST node `n`. */ @@ -132,62 +126,35 @@ predicate last(ControlFlowTree n, AstNode last, Completion c) { ) } -private predicate succImpl(AstNode pred, AstNode succ, Completion c) { - any(ControlFlowTree cft).succ(pred, succ, c) -} - -private predicate isHidden(ControlFlowTree t) { t.isHidden() } - -private predicate succImplIfHidden(AstNode pred, AstNode succ) { - isHidden(pred) and - succImpl(pred, succ, any(SimpleCompletion c)) -} - /** * Holds if `succ` is a control flow successor for `pred`, given that `pred` * finishes with completion `c`. */ pragma[nomagic] predicate succ(AstNode pred, AstNode succ, Completion c) { - exists(AstNode n | - succImpl(pred, n, c) and - succImplIfHidden*(n, succ) and - not isHidden(pred) and - not isHidden(succ) - ) + any(ControlFlowTree cft).succ(pred, succ, c) } /** Holds if `first` is first executed when entering `scope`. */ pragma[nomagic] -predicate succEntry(CfgScope::Range_ scope, AstNode first) { - exists(AstNode n | - scope.entry(n) and - succImplIfHidden*(n, first) and - not isHidden(first) - ) -} +predicate succEntry(CfgScope::Range_ scope, AstNode first) { scope.entry(first) } /** Holds if `last` with completion `c` can exit `scope`. */ pragma[nomagic] -predicate succExit(CfgScope::Range_ scope, AstNode last, Completion c) { - exists(AstNode n | - scope.exit(n, c) and - succImplIfHidden*(last, n) and - not isHidden(last) - ) -} +predicate succExit(CfgScope::Range_ scope, AstNode last, Completion c) { scope.exit(last, c) } /** * An AST node where the children are evaluated following a standard left-to-right * evaluation. The actual evaluation order is determined by the predicate * `getChildNode()`. */ -abstract private class StandardNode extends ControlFlowTree { +abstract private class StandardTree extends ControlFlowTree { /** Gets the `i`th child node, in order of evaluation. */ abstract ControlFlowTree getChildNode(int i); - private AstNode getChildNodeRanked(int i) { - result = rank[i + 1](AstNode child, int j | child = this.getChildNode(j) | child order by j) + private ControlFlowTree getChildNodeRanked(int i) { + result = + rank[i + 1](ControlFlowTree child, int j | child = this.getChildNode(j) | child order by j) } /** Gets the first child node of this element. */ @@ -236,24 +203,17 @@ private class ForRange extends ForExpr { } } -// TODO: remove this predicate -predicate isValidFor(Completion c, ControlFlowTree node) { - c instanceof SimpleCompletion and isHidden(node) - or - c.isValidFor(node) -} - -abstract private class StandardPreOrderTree extends StandardNode, PreOrderTree { +abstract private class StandardPreOrderTree extends StandardTree, PreOrderTree { final override predicate last(AstNode last, Completion c) { last(this.getLastChildNode(), last, c) or not exists(this.getLastChildNode()) and - isValidFor(c, this) and + c.isValidFor(this) and last = this } final override predicate succ(AstNode pred, AstNode succ, Completion c) { - StandardNode.super.succ(pred, succ, c) + StandardTree.super.succ(pred, succ, c) or pred = this and first(this.getFirstChildNode(), succ) and @@ -264,11 +224,11 @@ abstract private class StandardPreOrderTree extends StandardNode, PreOrderTree { abstract private class PostOrderTree extends ControlFlowTree { override predicate last(AstNode last, Completion c) { last = this and - isValidFor(c, last) + c.isValidFor(last) } } -abstract private class StandardPostOrderTree extends StandardNode, PostOrderTree { +abstract private class StandardPostOrderTree extends StandardTree, PostOrderTree { final override predicate first(AstNode first) { first(this.getFirstChildNode(), first) or @@ -277,7 +237,7 @@ abstract private class StandardPostOrderTree extends StandardNode, PostOrderTree } final override predicate succ(AstNode pred, AstNode succ, Completion c) { - StandardNode.super.succ(pred, succ, c) + StandardTree.super.succ(pred, succ, c) or last(this.getLastChildNode(), pred, c) and succ = this and @@ -291,11 +251,11 @@ abstract private class LeafTree extends PreOrderTree, PostOrderTree { override predicate succ(AstNode pred, AstNode succ, Completion c) { none() } } -abstract class ScopeTree extends StandardNode, LeafTree { +abstract class ScopeTree extends StandardTree, LeafTree { final override predicate propagatesAbnormal(AstNode child) { none() } final override predicate succ(AstNode pred, AstNode succ, Completion c) { - StandardNode.super.succ(pred, succ, c) + StandardTree.super.succ(pred, succ, c) } } @@ -309,10 +269,14 @@ module Trees { } } - private class ArgumentListTree extends StandardPostOrderTree, ArgumentList { + private class ArgumentListTree extends StandardTree, ArgumentList { final override ControlFlowTree getChildNode(int i) { result = this.getElement(i) } - override predicate isHidden() { any() } + final override predicate first(AstNode first) { first(this.getFirstChildNode(), first) } + + final override predicate last(AstNode last, Completion c) { + last(this.getLastChildNode(), last, c) + } } private class ArrayLiteralTree extends StandardPostOrderTree, ArrayLiteral { @@ -335,8 +299,10 @@ module Trees { } } - private class BeginTree extends BodyStmtPreOrderTree, BeginExpr { - override predicate isHidden() { any() } + private class BeginTree extends BodyStmtTree, BeginExpr { + final override predicate first(AstNode first) { this.firstInner(first) } + + final override predicate last(AstNode last, Completion c) { this.lastInner(last, c) } } private class BinaryOperationTree extends StandardPostOrderTree, BinaryOperation { @@ -416,11 +382,6 @@ module Trees { } override predicate succ(AstNode pred, AstNode succ, Completion c) { - this instanceof PreOrderTree and - pred = this and - c instanceof SimpleCompletion and - this.firstInner(succ) - or // Normal left-to-right evaluation in the body exists(int i | last(this.getBodyChild(i, _), pred, c) and @@ -498,12 +459,14 @@ module Trees { * Gets a descendant that belongs to the `ensure` block of this block, if any. * Nested `ensure` blocks are not included. */ + pragma[nomagic] AstNode getAnEnsureDescendant() { result = this.getEnsure() or exists(AstNode mid | mid = this.getAnEnsureDescendant() and - result = getAChildInScope(mid, getCfgScope(mid)) and + result = mid.getAChild() and + getCfgScope(result) = getCfgScope(mid) and not exists(BodyStmt nestedBlock | result = nestedBlock.getEnsure() and nestedBlock != this @@ -517,7 +480,8 @@ module Trees { */ private predicate nestedEnsure(BodyStmtTree innerBlock) { exists(StmtSequence innerEnsure | - innerEnsure = getAChildInScope(this.getAnEnsureDescendant(), getCfgScope(this)) and + innerEnsure = this.getAnEnsureDescendant().getAChild() and + getCfgScope(innerEnsure) = getCfgScope(this) and innerEnsure = innerBlock.(BodyStmt).getEnsure() ) } @@ -565,7 +529,15 @@ module Trees { or not exists(this.getAChild(_)) and last = this and - isValidFor(c, this) + c.isValidFor(this) + } + + final override predicate succ(AstNode pred, AstNode succ, Completion c) { + BodyStmtTree.super.succ(pred, succ, c) + or + pred = this and + c instanceof SimpleCompletion and + this.firstInner(succ) } } @@ -1041,7 +1013,7 @@ module Trees { or not exists(this.getAnException()) and last = this and - isValidFor(c, this) + c.isValidFor(this) ) ) } @@ -1127,7 +1099,15 @@ module Trees { final override predicate first(AstNode first) { first(this.getStmt(0), first) } - override predicate propagatesAbnormal(AstNode child) { child = this.getAStmt() } + final override predicate propagatesAbnormal(AstNode child) { child = this.getAStmt() } + + final override predicate succ(AstNode pred, AstNode succ, Completion c) { + succ = this and + last(this.getLastBodyChild(), pred, c) and + c instanceof NormalCompletion + or + StmtSequenceTree.super.succ(pred, succ, c) + } } /** @@ -1145,25 +1125,21 @@ module Trees { not this instanceof ParenthesizedExpr } - override predicate propagatesAbnormal(AstNode child) { child = this.getAStmt() } - - override predicate isHidden() { - this instanceof ASTInternal::TElse or - this instanceof ASTInternal::TThen or - this instanceof ASTInternal::TDo - } - - final AstNode getLastChildNode() { result = this.getStmt(this.getNumberOfStatements() - 1) } + final override predicate propagatesAbnormal(AstNode child) { child = this.getAStmt() } final override predicate last(AstNode last, Completion c) { - last(this.getLastChildNode(), last, c) + last(this.getLastStmt(), last, c) or - not exists(this.getLastChildNode()) and - isValidFor(c, this) and + not exists(this.getLastStmt()) and + c.isValidFor(this) and last = this } - override predicate succ(AstNode pred, AstNode succ, Completion c) { + final override predicate succ(AstNode pred, AstNode succ, Completion c) { + pred = this and + first(this.getBodyChild(0, _), succ) and + c instanceof SimpleCompletion + or StmtSequenceTree.super.succ(pred, succ, c) } } @@ -1213,7 +1189,7 @@ module Trees { rescuable = true } - AstNode getLastBodyChild() { + final AstNode getLastBodyChild() { exists(int i | result = this.getBodyChild(i, _) and not exists(this.getBodyChild(i + 1, _)) @@ -1221,16 +1197,6 @@ module Trees { } override predicate succ(AstNode pred, AstNode succ, Completion c) { - this instanceof PreOrderTree and - pred = this and - first(this.getBodyChild(0, _), succ) and - c instanceof SimpleCompletion - or - this instanceof PostOrderTree and - succ = this and - last(this.getLastBodyChild(), pred, c) and - c instanceof NormalCompletion - or // Normal left-to-right evaluation in the body exists(int i | last(this.getBodyChild(i, _), pred, c) and @@ -1240,18 +1206,14 @@ module Trees { } } - private class StringConcatenationTree extends StandardPostOrderTree, StringConcatenation { + private class StringConcatenationTree extends StandardTree, StringConcatenation { final override ControlFlowTree getChildNode(int i) { result = this.getString(i) } - override predicate isHidden() { any() } - } + final override predicate first(AstNode first) { first(this.getFirstChildNode(), first) } - private class StringTextComponentTree extends LeafTree, StringTextComponent { - override predicate isHidden() { any() } - } - - private class StringEscapeSequenceComponentTree extends LeafTree, StringEscapeSequenceComponent { - override predicate isHidden() { any() } + final override predicate last(AstNode last, Completion c) { + last(this.getLastChildNode(), last, c) + } } private class StringlikeLiteralTree extends StandardPostOrderTree, StringlikeLiteral { @@ -1264,14 +1226,20 @@ module Trees { final override ControlFlowTree getChildNode(int i) { result = this.getArgument(i) } } - private class ToplevelTree extends BodyStmtPreOrderTree, Toplevel { + private class ToplevelTree extends BodyStmtTree, Toplevel { final override AstNode getBodyChild(int i, boolean rescuable) { result = this.getBeginBlock(i) and rescuable = true or - result = BodyStmtPreOrderTree.super.getBodyChild(i - count(this.getABeginBlock()), rescuable) + result = BodyStmtTree.super.getBodyChild(i - count(this.getABeginBlock()), rescuable) } - override predicate isHidden() { any() } + final override predicate first(AstNode first) { this.firstInner(first) } + + final override predicate last(AstNode last, Completion c) { this.lastInner(last, c) } + + final override predicate succ(AstNode pred, AstNode succ, Completion c) { + BodyStmtTree.super.succ(pred, succ, c) + } } private class TuplePatternTree extends StandardPostOrderTree, TuplePattern { @@ -1329,13 +1297,6 @@ module Trees { private class YieldCallTree extends StandardPreOrderTree, YieldCall { final override ControlFlowTree getChildNode(int i) { result = this.getArgument(i) } } - - /** Gets a child of `n` that is in CFG scope `scope`. */ - pragma[noinline] - private AstNode getAChildInScope(AstNode n, CfgScope scope) { - result.getParent() = n and - scope = getCfgScope(result) - } } private Scope parent(Scope n) { @@ -1343,11 +1304,20 @@ private Scope parent(Scope n) { not n instanceof CfgScope::Range_ } +/** Gets the CFG scope of node `n`. */ +pragma[inline] +CfgScope getCfgScope(AstNode n) { + exists(AstNode n0 | + pragma[only_bind_into](n0) = n and + pragma[only_bind_into](result) = getCfgScopeImpl(n0) + ) +} + cached private module Cached { /** Gets the CFG scope of node `n`. */ cached - CfgScope getCfgScope(AstNode n) { + CfgScope getCfgScopeImpl(AstNode n) { result = parent*(ASTInternal::fromGenerated(scopeOf(ASTInternal::toGenerated(n)))) } diff --git a/ql/test/library-tests/ast/Ast.expected b/ql/test/library-tests/ast/Ast.expected index 8b74d275522..5c411c581b7 100644 --- a/ql/test/library-tests/ast/Ast.expected +++ b/ql/test/library-tests/ast/Ast.expected @@ -43,9 +43,9 @@ calls/calls.rb: # 46| getStmt: [MethodCall] call to foo # 47| getStmt: [MethodCall] call to foo # 47| getReceiver: [ConstantReadAccess] X -# 50| getStmt: [ParenthesizedExpr] (call to foo) +# 50| getStmt: [ParenthesizedExpr] ( ... ) # 50| getStmt: [MethodCall] call to foo -# 51| getStmt: [ParenthesizedExpr] (call to foo) +# 51| getStmt: [ParenthesizedExpr] ( ... ) # 51| getStmt: [MethodCall] call to foo # 51| getReceiver: [ConstantReadAccess] X # 54| getStmt: [MethodCall] call to some_func @@ -117,7 +117,7 @@ calls/calls.rb: # 106| getValue: [MethodCall] call to foo # 107| getBranch: [WhenExpr] when ... # 107| getPattern: [MethodCall] call to bar -# 107| getBody: [StmtSequence] call to baz +# 107| getBody: [StmtSequence] then ... # 108| getStmt: [MethodCall] call to baz # 110| getStmt: [CaseExpr] case ... # 110| getValue: [MethodCall] call to foo @@ -125,7 +125,7 @@ calls/calls.rb: # 111| getBranch: [WhenExpr] when ... # 111| getPattern: [MethodCall] call to bar # 111| getReceiver: [ConstantReadAccess] X -# 111| getBody: [StmtSequence] call to baz +# 111| getBody: [StmtSequence] then ... # 112| getStmt: [MethodCall] call to baz # 112| getReceiver: [ConstantReadAccess] X # 116| getStmt: [Class] MyClass @@ -189,27 +189,27 @@ calls/calls.rb: # 167| getReceiver: [ConstantReadAccess] X # 170| getStmt: [IfExpr] if ... # 170| getCondition: [MethodCall] call to foo -# 170| getBranch/getThen: [StmtSequence] call to wibble +# 170| getBranch/getThen: [StmtSequence] then ... # 171| getStmt: [MethodCall] call to wibble # 172| getBranch/getElse: [IfExpr] elsif ... # 172| getCondition: [MethodCall] call to bar -# 172| getBranch/getThen: [StmtSequence] call to wobble +# 172| getBranch/getThen: [StmtSequence] then ... # 173| getStmt: [MethodCall] call to wobble -# 174| getBranch/getElse: [StmtSequence] call to wabble +# 174| getBranch/getElse: [StmtSequence] else ... # 175| getStmt: [MethodCall] call to wabble # 177| getStmt: [IfExpr] if ... # 177| getCondition: [MethodCall] call to foo # 177| getReceiver: [ConstantReadAccess] X -# 177| getBranch/getThen: [StmtSequence] call to wibble +# 177| getBranch/getThen: [StmtSequence] then ... # 178| getStmt: [MethodCall] call to wibble # 178| getReceiver: [ConstantReadAccess] X # 179| getBranch/getElse: [IfExpr] elsif ... # 179| getCondition: [MethodCall] call to bar # 179| getReceiver: [ConstantReadAccess] X -# 179| getBranch/getThen: [StmtSequence] call to wobble +# 179| getBranch/getThen: [StmtSequence] then ... # 180| getStmt: [MethodCall] call to wobble # 180| getReceiver: [ConstantReadAccess] X -# 181| getBranch/getElse: [StmtSequence] call to wabble +# 181| getBranch/getElse: [StmtSequence] else ... # 182| getStmt: [MethodCall] call to wabble # 182| getReceiver: [ConstantReadAccess] X # 186| getStmt: [IfModifierExpr] ... if ... @@ -222,12 +222,12 @@ calls/calls.rb: # 187| getReceiver: [ConstantReadAccess] X # 190| getStmt: [UnlessExpr] unless ... # 190| getCondition: [MethodCall] call to foo -# 190| getBranch/getThen: [StmtSequence] call to bar +# 190| getBranch/getThen: [StmtSequence] then ... # 191| getStmt: [MethodCall] call to bar # 193| getStmt: [UnlessExpr] unless ... # 193| getCondition: [MethodCall] call to foo # 193| getReceiver: [ConstantReadAccess] X -# 193| getBranch/getThen: [StmtSequence] call to bar +# 193| getBranch/getThen: [StmtSequence] then ... # 194| getStmt: [MethodCall] call to bar # 194| getReceiver: [ConstantReadAccess] X # 198| getStmt: [UnlessModifierExpr] ... unless ... @@ -240,12 +240,12 @@ calls/calls.rb: # 199| getReceiver: [ConstantReadAccess] X # 202| getStmt: [WhileExpr] while ... # 202| getCondition: [MethodCall] call to foo -# 202| getBody: [StmtSequence] call to bar +# 202| getBody: [StmtSequence] do ... # 203| getStmt: [MethodCall] call to bar # 205| getStmt: [WhileExpr] while ... # 205| getCondition: [MethodCall] call to foo # 205| getReceiver: [ConstantReadAccess] X -# 205| getBody: [StmtSequence] call to bar +# 205| getBody: [StmtSequence] do ... # 206| getStmt: [MethodCall] call to bar # 206| getReceiver: [ConstantReadAccess] X # 210| getStmt: [WhileModifierExpr] ... while ... @@ -258,12 +258,12 @@ calls/calls.rb: # 211| getReceiver: [ConstantReadAccess] X # 214| getStmt: [UntilExpr] until ... # 214| getCondition: [MethodCall] call to foo -# 214| getBody: [StmtSequence] call to bar +# 214| getBody: [StmtSequence] do ... # 215| getStmt: [MethodCall] call to bar # 217| getStmt: [UntilExpr] until ... # 217| getCondition: [MethodCall] call to foo # 217| getReceiver: [ConstantReadAccess] X -# 217| getBody: [StmtSequence] call to bar +# 217| getBody: [StmtSequence] do ... # 218| getStmt: [MethodCall] call to bar # 218| getReceiver: [ConstantReadAccess] X # 222| getStmt: [UntilModifierExpr] ... until ... @@ -278,14 +278,14 @@ calls/calls.rb: # 226| getPattern: [LocalVariableAccess] x # 226| : [???] In # 226| getValue: [MethodCall] call to bar -# 226| getBody: [StmtSequence] call to baz +# 226| getBody: [StmtSequence] do ... # 227| getStmt: [MethodCall] call to baz # 229| getStmt: [ForExpr] for ... in ... # 229| getPattern: [LocalVariableAccess] x # 229| : [???] In # 229| getValue: [MethodCall] call to bar # 229| getReceiver: [ConstantReadAccess] X -# 229| getBody: [StmtSequence] call to baz +# 229| getBody: [StmtSequence] do ... # 230| getStmt: [MethodCall] call to baz # 230| getReceiver: [ConstantReadAccess] X # 234| getStmt: [ElementReference] ...[...] @@ -492,33 +492,33 @@ control/cases.rb: # 8| getValue: [LocalVariableAccess] a # 9| getBranch: [WhenExpr] when ... # 9| getPattern: [LocalVariableAccess] b -# 9| getBody: [StmtSequence] 100 +# 9| getBody: [StmtSequence] then ... # 10| getStmt: [IntegerLiteral] 100 # 11| getBranch: [WhenExpr] when ... # 11| getPattern: [LocalVariableAccess] c # 11| getPattern: [LocalVariableAccess] d -# 11| getBody: [StmtSequence] 200 +# 11| getBody: [StmtSequence] then ... # 12| getStmt: [IntegerLiteral] 200 -# 13| getBranch: [StmtSequence] 300 +# 13| getBranch: [StmtSequence] else ... # 14| getStmt: [IntegerLiteral] 300 # 18| getStmt: [CaseExpr] case ... # 19| getBranch: [WhenExpr] when ... # 19| getPattern: [GTExpr] ... > ... # 19| getAnOperand/getGreaterOperand/getLeftOperand: [LocalVariableAccess] a # 19| getAnOperand/getLesserOperand/getRightOperand: [LocalVariableAccess] b -# 19| getBody: [StmtSequence] 10 +# 19| getBody: [StmtSequence] then ... # 19| getStmt: [IntegerLiteral] 10 # 20| getBranch: [WhenExpr] when ... # 20| getPattern: [EqExpr] ... == ... # 20| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 20| getAnOperand/getRightOperand: [LocalVariableAccess] b -# 20| getBody: [StmtSequence] 20 +# 20| getBody: [StmtSequence] then ... # 20| getStmt: [IntegerLiteral] 20 # 21| getBranch: [WhenExpr] when ... # 21| getPattern: [LTExpr] ... < ... # 21| getAnOperand/getLeftOperand/getLesserOperand: [LocalVariableAccess] a # 21| getAnOperand/getGreaterOperand/getRightOperand: [LocalVariableAccess] b -# 21| getBody: [StmtSequence] 30 +# 21| getBody: [StmtSequence] then ... # 21| getStmt: [IntegerLiteral] 30 modules/classes.rb: # 2| [Toplevel] classes.rb @@ -589,61 +589,61 @@ control/conditionals.rb: # 10| getCondition: [GTExpr] ... > ... # 10| getAnOperand/getGreaterOperand/getLeftOperand: [LocalVariableAccess] a # 10| getAnOperand/getLesserOperand/getRightOperand: [LocalVariableAccess] b -# 10| getBranch/getThen: [StmtSequence] c +# 10| getBranch/getThen: [StmtSequence] then ... # 11| getStmt: [LocalVariableAccess] c # 15| getStmt: [IfExpr] if ... # 15| getCondition: [EqExpr] ... == ... # 15| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 15| getAnOperand/getRightOperand: [LocalVariableAccess] b -# 15| getBranch/getThen: [StmtSequence] c +# 15| getBranch/getThen: [StmtSequence] then ... # 16| getStmt: [LocalVariableAccess] c -# 17| getBranch/getElse: [StmtSequence] d +# 17| getBranch/getElse: [StmtSequence] else ... # 18| getStmt: [LocalVariableAccess] d # 22| getStmt: [IfExpr] if ... # 22| getCondition: [EqExpr] ... == ... # 22| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 22| getAnOperand/getRightOperand: [IntegerLiteral] 0 -# 22| getBranch/getThen: [StmtSequence] c +# 22| getBranch/getThen: [StmtSequence] then ... # 23| getStmt: [LocalVariableAccess] c # 24| getBranch/getElse: [IfExpr] elsif ... # 24| getCondition: [EqExpr] ... == ... # 24| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 24| getAnOperand/getRightOperand: [IntegerLiteral] 1 -# 24| getBranch/getThen: [StmtSequence] d +# 24| getBranch/getThen: [StmtSequence] then ... # 25| getStmt: [LocalVariableAccess] d # 26| getBranch/getElse: [IfExpr] elsif ... # 26| getCondition: [EqExpr] ... == ... # 26| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 26| getAnOperand/getRightOperand: [IntegerLiteral] 2 -# 26| getBranch/getThen: [StmtSequence] e +# 26| getBranch/getThen: [StmtSequence] then ... # 27| getStmt: [LocalVariableAccess] e -# 28| getBranch/getElse: [StmtSequence] f +# 28| getBranch/getElse: [StmtSequence] else ... # 29| getStmt: [LocalVariableAccess] f # 33| getStmt: [IfExpr] if ... # 33| getCondition: [EqExpr] ... == ... # 33| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 33| getAnOperand/getRightOperand: [IntegerLiteral] 0 -# 33| getBranch/getThen: [StmtSequence] b +# 33| getBranch/getThen: [StmtSequence] then ... # 34| getStmt: [LocalVariableAccess] b # 35| getBranch/getElse: [IfExpr] elsif ... # 35| getCondition: [EqExpr] ... == ... # 35| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 35| getAnOperand/getRightOperand: [IntegerLiteral] 1 -# 35| getBranch/getThen: [StmtSequence] c +# 35| getBranch/getThen: [StmtSequence] then ... # 36| getStmt: [LocalVariableAccess] c # 40| getStmt: [UnlessExpr] unless ... # 40| getCondition: [GTExpr] ... > ... # 40| getAnOperand/getGreaterOperand/getLeftOperand: [LocalVariableAccess] a # 40| getAnOperand/getLesserOperand/getRightOperand: [LocalVariableAccess] b -# 40| getBranch/getThen: [StmtSequence] c +# 40| getBranch/getThen: [StmtSequence] then ... # 41| getStmt: [LocalVariableAccess] c # 45| getStmt: [UnlessExpr] unless ... # 45| getCondition: [EqExpr] ... == ... # 45| getAnOperand/getLeftOperand: [LocalVariableAccess] a # 45| getAnOperand/getRightOperand: [LocalVariableAccess] b -# 45| getBranch/getThen: [StmtSequence] c +# 45| getBranch/getThen: [StmtSequence] then ... # 46| getStmt: [LocalVariableAccess] c -# 47| getBranch/getElse: [StmtSequence] d +# 47| getBranch/getElse: [StmtSequence] else ... # 48| getStmt: [LocalVariableAccess] d # 52| getStmt: [IfModifierExpr] ... if ... # 52| getBody/getBranch: [AssignExpr] ... = ... @@ -671,6 +671,20 @@ control/conditionals.rb: # 58| getBranch/getElse: [SubExpr] ... - ... # 58| getAnOperand/getLeftOperand: [LocalVariableAccess] e # 58| getAnOperand/getRightOperand: [IntegerLiteral] 2 +# 61| getStmt: [IfExpr] if ... +# 61| getCondition: [GTExpr] ... > ... +# 61| getAnOperand/getGreaterOperand/getLeftOperand: [LocalVariableAccess] a +# 61| getAnOperand/getLesserOperand/getRightOperand: [LocalVariableAccess] b +# 61| getBranch/getThen: [StmtSequence] then ... +# 62| getStmt: [LocalVariableAccess] c +# 63| getBranch/getElse: [StmtSequence] else ... +# 67| getStmt: [IfExpr] if ... +# 67| getCondition: [GTExpr] ... > ... +# 67| getAnOperand/getGreaterOperand/getLeftOperand: [LocalVariableAccess] a +# 67| getAnOperand/getLesserOperand/getRightOperand: [LocalVariableAccess] b +# 67| getBranch/getThen: [StmtSequence] then ... +# 68| getBranch/getElse: [StmtSequence] else ... +# 69| getStmt: [LocalVariableAccess] c constants/constants.rb: # 1| [Toplevel] constants.rb # 1| getStmt: [Module] ModuleA @@ -973,31 +987,31 @@ literals/literals.rb: # 114| getValue: [IntegerLiteral] 7 # 114| getElement: [HashSplatArgument] **... # 114| getValue: [MethodCall] call to bar -# 117| getStmt: [ParenthesizedExpr] (_ .. _) +# 117| getStmt: [ParenthesizedExpr] ( ... ) # 117| getStmt: [RangeLiteral] _ .. _ # 117| getBegin: [IntegerLiteral] 1 # 117| getEnd: [IntegerLiteral] 10 -# 118| getStmt: [ParenthesizedExpr] (_ ... _) +# 118| getStmt: [ParenthesizedExpr] ( ... ) # 118| getStmt: [RangeLiteral] _ ... _ # 118| getBegin: [IntegerLiteral] 1 # 118| getEnd: [IntegerLiteral] 10 -# 119| getStmt: [ParenthesizedExpr] (_ .. _) +# 119| getStmt: [ParenthesizedExpr] ( ... ) # 119| getStmt: [RangeLiteral] _ .. _ # 119| getBegin: [IntegerLiteral] 1 # 119| getEnd: [IntegerLiteral] 0 -# 120| getStmt: [ParenthesizedExpr] (_ .. _) +# 120| getStmt: [ParenthesizedExpr] ( ... ) # 120| getStmt: [RangeLiteral] _ .. _ # 120| getBegin: [MethodCall] call to start # 120| getEnd: [AddExpr] ... + ... # 120| getAnOperand/getLeftOperand: [IntegerLiteral] 2 # 120| getAnOperand/getRightOperand: [IntegerLiteral] 3 -# 121| getStmt: [ParenthesizedExpr] (_ .. _) +# 121| getStmt: [ParenthesizedExpr] ( ... ) # 121| getStmt: [RangeLiteral] _ .. _ # 121| getBegin: [IntegerLiteral] 1 -# 122| getStmt: [ParenthesizedExpr] (_ .. _) +# 122| getStmt: [ParenthesizedExpr] ( ... ) # 122| getStmt: [RangeLiteral] _ .. _ # 122| getEnd: [IntegerLiteral] 1 -# 123| getStmt: [ParenthesizedExpr] (... - ...) +# 123| getStmt: [ParenthesizedExpr] ( ... ) # 123| getStmt: [SubExpr] ... - ... # 123| getAnOperand/getLeftOperand: [RangeLiteral] _ .. _ # 123| getBegin: [IntegerLiteral] 0 @@ -1144,7 +1158,7 @@ control/loops.rb: # 9| getValue: [RangeLiteral] _ .. _ # 9| getBegin: [IntegerLiteral] 1 # 9| getEnd: [IntegerLiteral] 10 -# 9| getBody: [StmtSequence] ...; ... +# 9| getBody: [StmtSequence] do ... # 10| getStmt: [AssignAddExpr] ... += ... # 10| getAnOperand/getLeftOperand: [LocalVariableAccess] sum # 10| getAnOperand/getRightOperand: [LocalVariableAccess] n @@ -1157,7 +1171,7 @@ control/loops.rb: # 16| getValue: [RangeLiteral] _ .. _ # 16| getBegin: [IntegerLiteral] 1 # 16| getEnd: [IntegerLiteral] 10 -# 16| getBody: [StmtSequence] ...; ... +# 16| getBody: [StmtSequence] do ... # 17| getStmt: [AssignAddExpr] ... += ... # 17| getAnOperand/getLeftOperand: [LocalVariableAccess] sum # 17| getAnOperand/getRightOperand: [LocalVariableAccess] n @@ -1176,7 +1190,7 @@ control/loops.rb: # 22| getElement: [Pair] Pair # 22| getKey: [SymbolLiteral] :bar # 22| getValue: [IntegerLiteral] 1 -# 22| getBody: [StmtSequence] ...; ... +# 22| getBody: [StmtSequence] do ... # 23| getStmt: [AssignAddExpr] ... += ... # 23| getAnOperand/getLeftOperand: [LocalVariableAccess] sum # 23| getAnOperand/getRightOperand: [LocalVariableAccess] value @@ -1195,7 +1209,7 @@ control/loops.rb: # 28| getElement: [Pair] Pair # 28| getKey: [SymbolLiteral] :bar # 28| getValue: [IntegerLiteral] 1 -# 28| getBody: [StmtSequence] ...; ... +# 28| getBody: [StmtSequence] do ... # 29| getStmt: [AssignAddExpr] ... += ... # 29| getAnOperand/getLeftOperand: [LocalVariableAccess] sum # 29| getAnOperand/getRightOperand: [LocalVariableAccess] value @@ -1207,7 +1221,7 @@ control/loops.rb: # 35| getCondition: [LTExpr] ... < ... # 35| getAnOperand/getLeftOperand/getLesserOperand: [LocalVariableAccess] x # 35| getAnOperand/getGreaterOperand/getRightOperand: [LocalVariableAccess] y -# 35| getBody: [StmtSequence] ...; ... +# 35| getBody: [StmtSequence] do ... # 36| getStmt: [AssignAddExpr] ... += ... # 36| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 36| getAnOperand/getRightOperand: [IntegerLiteral] 1 @@ -1219,7 +1233,7 @@ control/loops.rb: # 42| getCondition: [LTExpr] ... < ... # 42| getAnOperand/getLeftOperand/getLesserOperand: [LocalVariableAccess] x # 42| getAnOperand/getGreaterOperand/getRightOperand: [LocalVariableAccess] y -# 42| getBody: [StmtSequence] ...; ... +# 42| getBody: [StmtSequence] do ... # 43| getStmt: [AssignAddExpr] ... += ... # 43| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 43| getAnOperand/getRightOperand: [IntegerLiteral] 1 @@ -1237,7 +1251,7 @@ control/loops.rb: # 51| getCondition: [EqExpr] ... == ... # 51| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 51| getAnOperand/getRightOperand: [LocalVariableAccess] y -# 51| getBody: [StmtSequence] ...; ... +# 51| getBody: [StmtSequence] do ... # 52| getStmt: [AssignAddExpr] ... += ... # 52| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 52| getAnOperand/getRightOperand: [IntegerLiteral] 1 @@ -1248,7 +1262,7 @@ control/loops.rb: # 57| getCondition: [GTExpr] ... > ... # 57| getAnOperand/getGreaterOperand/getLeftOperand: [LocalVariableAccess] x # 57| getAnOperand/getLesserOperand/getRightOperand: [LocalVariableAccess] y -# 57| getBody: [StmtSequence] ...; ... +# 57| getBody: [StmtSequence] do ... # 58| getStmt: [AssignAddExpr] ... += ... # 58| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 58| getAnOperand/getRightOperand: [IntegerLiteral] 1 @@ -1262,6 +1276,11 @@ control/loops.rb: # 63| getCondition: [EqExpr] ... == ... # 63| getAnOperand/getLeftOperand: [LocalVariableAccess] x # 63| getAnOperand/getRightOperand: [IntegerLiteral] 0 +# 66| getStmt: [WhileExpr] while ... +# 66| getCondition: [LTExpr] ... < ... +# 66| getAnOperand/getLeftOperand/getLesserOperand: [LocalVariableAccess] x +# 66| getAnOperand/getGreaterOperand/getRightOperand: [LocalVariableAccess] y +# 66| getBody: [StmtSequence] do ... misc/misc.rb: # 1| [Toplevel] misc.rb # 1| getStmt: [AssignExpr] ... = ... diff --git a/ql/test/library-tests/ast/control/CaseExpr.expected b/ql/test/library-tests/ast/control/CaseExpr.expected index bf54ec6f095..ff2b223690a 100644 --- a/ql/test/library-tests/ast/control/CaseExpr.expected +++ b/ql/test/library-tests/ast/control/CaseExpr.expected @@ -3,20 +3,20 @@ caseValues caseNoValues | cases.rb:18:1:22:3 | case ... | caseElseBranches -| cases.rb:8:1:15:3 | case ... | cases.rb:13:1:14:7 | 300 | +| cases.rb:8:1:15:3 | case ... | cases.rb:13:1:14:7 | else ... | caseNoElseBranches | cases.rb:18:1:22:3 | case ... | caseWhenBranches -| cases.rb:8:1:15:3 | case ... | cases.rb:9:1:10:7 | when ... | 0 | cases.rb:9:6:9:6 | b | cases.rb:9:7:10:7 | 100 | -| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 0 | cases.rb:11:6:11:6 | c | cases.rb:11:10:12:7 | 200 | -| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 1 | cases.rb:11:9:11:9 | d | cases.rb:11:10:12:7 | 200 | -| cases.rb:18:1:22:3 | case ... | cases.rb:19:1:19:19 | when ... | 0 | cases.rb:19:6:19:10 | ... > ... | cases.rb:19:13:19:19 | 10 | -| cases.rb:18:1:22:3 | case ... | cases.rb:20:1:20:19 | when ... | 0 | cases.rb:20:6:20:11 | ... == ... | cases.rb:20:13:20:19 | 20 | -| cases.rb:18:1:22:3 | case ... | cases.rb:21:1:21:19 | when ... | 0 | cases.rb:21:6:21:10 | ... < ... | cases.rb:21:13:21:19 | 30 | +| cases.rb:8:1:15:3 | case ... | cases.rb:9:1:10:7 | when ... | 0 | cases.rb:9:6:9:6 | b | cases.rb:9:7:10:7 | then ... | +| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 0 | cases.rb:11:6:11:6 | c | cases.rb:11:10:12:7 | then ... | +| cases.rb:8:1:15:3 | case ... | cases.rb:11:1:12:7 | when ... | 1 | cases.rb:11:9:11:9 | d | cases.rb:11:10:12:7 | then ... | +| cases.rb:18:1:22:3 | case ... | cases.rb:19:1:19:19 | when ... | 0 | cases.rb:19:6:19:10 | ... > ... | cases.rb:19:13:19:19 | then ... | +| cases.rb:18:1:22:3 | case ... | cases.rb:20:1:20:19 | when ... | 0 | cases.rb:20:6:20:11 | ... == ... | cases.rb:20:13:20:19 | then ... | +| cases.rb:18:1:22:3 | case ... | cases.rb:21:1:21:19 | when ... | 0 | cases.rb:21:6:21:10 | ... < ... | cases.rb:21:13:21:19 | then ... | caseAllBranches | cases.rb:8:1:15:3 | case ... | 0 | cases.rb:9:1:10:7 | when ... | | cases.rb:8:1:15:3 | case ... | 1 | cases.rb:11:1:12:7 | when ... | -| cases.rb:8:1:15:3 | case ... | 2 | cases.rb:13:1:14:7 | 300 | +| cases.rb:8:1:15:3 | case ... | 2 | cases.rb:13:1:14:7 | else ... | | cases.rb:18:1:22:3 | case ... | 0 | cases.rb:19:1:19:19 | when ... | | cases.rb:18:1:22:3 | case ... | 1 | cases.rb:20:1:20:19 | when ... | | cases.rb:18:1:22:3 | case ... | 2 | cases.rb:21:1:21:19 | when ... | diff --git a/ql/test/library-tests/ast/control/ConditionalExpr.expected b/ql/test/library-tests/ast/control/ConditionalExpr.expected index ce3c57f3471..3d78655dbbb 100644 --- a/ql/test/library-tests/ast/control/ConditionalExpr.expected +++ b/ql/test/library-tests/ast/control/ConditionalExpr.expected @@ -1,34 +1,40 @@ conditionalExprs -| conditionals.rb:10:1:12:3 | if ... | IfExpr | conditionals.rb:10:4:10:8 | ... > ... | conditionals.rb:10:10:11:5 | c | true | -| conditionals.rb:15:1:19:3 | if ... | IfExpr | conditionals.rb:15:4:15:9 | ... == ... | conditionals.rb:15:10:16:5 | c | true | -| conditionals.rb:15:1:19:3 | if ... | IfExpr | conditionals.rb:15:4:15:9 | ... == ... | conditionals.rb:17:1:18:5 | d | false | -| conditionals.rb:22:1:30:3 | if ... | IfExpr | conditionals.rb:22:4:22:9 | ... == ... | conditionals.rb:22:11:23:5 | c | true | +| conditionals.rb:10:1:12:3 | if ... | IfExpr | conditionals.rb:10:4:10:8 | ... > ... | conditionals.rb:10:10:11:5 | then ... | true | +| conditionals.rb:15:1:19:3 | if ... | IfExpr | conditionals.rb:15:4:15:9 | ... == ... | conditionals.rb:15:10:16:5 | then ... | true | +| conditionals.rb:15:1:19:3 | if ... | IfExpr | conditionals.rb:15:4:15:9 | ... == ... | conditionals.rb:17:1:18:5 | else ... | false | +| conditionals.rb:22:1:30:3 | if ... | IfExpr | conditionals.rb:22:4:22:9 | ... == ... | conditionals.rb:22:11:23:5 | then ... | true | | conditionals.rb:22:1:30:3 | if ... | IfExpr | conditionals.rb:22:4:22:9 | ... == ... | conditionals.rb:24:1:29:5 | elsif ... | false | -| conditionals.rb:24:1:29:5 | elsif ... | IfExpr | conditionals.rb:24:7:24:12 | ... == ... | conditionals.rb:24:14:25:5 | d | true | +| conditionals.rb:24:1:29:5 | elsif ... | IfExpr | conditionals.rb:24:7:24:12 | ... == ... | conditionals.rb:24:14:25:5 | then ... | true | | conditionals.rb:24:1:29:5 | elsif ... | IfExpr | conditionals.rb:24:7:24:12 | ... == ... | conditionals.rb:26:1:29:5 | elsif ... | false | -| conditionals.rb:26:1:29:5 | elsif ... | IfExpr | conditionals.rb:26:7:26:12 | ... == ... | conditionals.rb:26:14:27:5 | e | true | -| conditionals.rb:26:1:29:5 | elsif ... | IfExpr | conditionals.rb:26:7:26:12 | ... == ... | conditionals.rb:28:1:29:5 | f | false | -| conditionals.rb:33:1:37:3 | if ... | IfExpr | conditionals.rb:33:4:33:9 | ... == ... | conditionals.rb:33:10:34:5 | b | true | +| conditionals.rb:26:1:29:5 | elsif ... | IfExpr | conditionals.rb:26:7:26:12 | ... == ... | conditionals.rb:26:14:27:5 | then ... | true | +| conditionals.rb:26:1:29:5 | elsif ... | IfExpr | conditionals.rb:26:7:26:12 | ... == ... | conditionals.rb:28:1:29:5 | else ... | false | +| conditionals.rb:33:1:37:3 | if ... | IfExpr | conditionals.rb:33:4:33:9 | ... == ... | conditionals.rb:33:10:34:5 | then ... | true | | conditionals.rb:33:1:37:3 | if ... | IfExpr | conditionals.rb:33:4:33:9 | ... == ... | conditionals.rb:35:1:36:5 | elsif ... | false | -| conditionals.rb:35:1:36:5 | elsif ... | IfExpr | conditionals.rb:35:7:35:12 | ... == ... | conditionals.rb:35:13:36:5 | c | true | -| conditionals.rb:40:1:42:3 | unless ... | UnlessExpr | conditionals.rb:40:8:40:12 | ... > ... | conditionals.rb:40:14:41:5 | c | false | -| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:45:14:46:5 | c | false | -| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:47:1:48:5 | d | true | +| conditionals.rb:35:1:36:5 | elsif ... | IfExpr | conditionals.rb:35:7:35:12 | ... == ... | conditionals.rb:35:13:36:5 | then ... | true | +| conditionals.rb:40:1:42:3 | unless ... | UnlessExpr | conditionals.rb:40:8:40:12 | ... > ... | conditionals.rb:40:14:41:5 | then ... | false | +| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:45:14:46:5 | then ... | false | +| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:47:1:48:5 | else ... | true | | conditionals.rb:52:1:52:14 | ... if ... | IfModifierExpr | conditionals.rb:52:10:52:14 | ... > ... | conditionals.rb:52:1:52:5 | ... = ... | true | | conditionals.rb:55:1:55:18 | ... unless ... | UnlessModifierExpr | conditionals.rb:55:14:55:18 | ... < ... | conditionals.rb:55:1:55:5 | ... = ... | false | | conditionals.rb:58:5:58:25 | ... ? ... : ... | TernaryIfExpr | conditionals.rb:58:5:58:9 | ... > ... | conditionals.rb:58:13:58:17 | ... + ... | true | | conditionals.rb:58:5:58:25 | ... ? ... : ... | TernaryIfExpr | conditionals.rb:58:5:58:9 | ... > ... | conditionals.rb:58:21:58:25 | ... - ... | false | +| conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:61:10:62:5 | then ... | true | +| conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:63:1:63:4 | else ... | false | +| conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:67:10:67:13 | then ... | true | +| conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:68:1:69:5 | else ... | false | ifExprs -| conditionals.rb:10:1:12:3 | if ... | IfExpr | conditionals.rb:10:4:10:8 | ... > ... | conditionals.rb:10:10:11:5 | c | (none) | false | -| conditionals.rb:15:1:19:3 | if ... | IfExpr | conditionals.rb:15:4:15:9 | ... == ... | conditionals.rb:15:10:16:5 | c | d | false | -| conditionals.rb:22:1:30:3 | if ... | IfExpr | conditionals.rb:22:4:22:9 | ... == ... | conditionals.rb:22:11:23:5 | c | elsif ... | false | -| conditionals.rb:24:1:29:5 | elsif ... | IfExpr | conditionals.rb:24:7:24:12 | ... == ... | conditionals.rb:24:14:25:5 | d | elsif ... | true | -| conditionals.rb:26:1:29:5 | elsif ... | IfExpr | conditionals.rb:26:7:26:12 | ... == ... | conditionals.rb:26:14:27:5 | e | f | true | -| conditionals.rb:33:1:37:3 | if ... | IfExpr | conditionals.rb:33:4:33:9 | ... == ... | conditionals.rb:33:10:34:5 | b | elsif ... | false | -| conditionals.rb:35:1:36:5 | elsif ... | IfExpr | conditionals.rb:35:7:35:12 | ... == ... | conditionals.rb:35:13:36:5 | c | (none) | true | +| conditionals.rb:10:1:12:3 | if ... | IfExpr | conditionals.rb:10:4:10:8 | ... > ... | conditionals.rb:10:10:11:5 | then ... | (none) | false | +| conditionals.rb:15:1:19:3 | if ... | IfExpr | conditionals.rb:15:4:15:9 | ... == ... | conditionals.rb:15:10:16:5 | then ... | else ... | false | +| conditionals.rb:22:1:30:3 | if ... | IfExpr | conditionals.rb:22:4:22:9 | ... == ... | conditionals.rb:22:11:23:5 | then ... | elsif ... | false | +| conditionals.rb:24:1:29:5 | elsif ... | IfExpr | conditionals.rb:24:7:24:12 | ... == ... | conditionals.rb:24:14:25:5 | then ... | elsif ... | true | +| conditionals.rb:26:1:29:5 | elsif ... | IfExpr | conditionals.rb:26:7:26:12 | ... == ... | conditionals.rb:26:14:27:5 | then ... | else ... | true | +| conditionals.rb:33:1:37:3 | if ... | IfExpr | conditionals.rb:33:4:33:9 | ... == ... | conditionals.rb:33:10:34:5 | then ... | elsif ... | false | +| conditionals.rb:35:1:36:5 | elsif ... | IfExpr | conditionals.rb:35:7:35:12 | ... == ... | conditionals.rb:35:13:36:5 | then ... | (none) | true | +| conditionals.rb:61:1:64:3 | if ... | IfExpr | conditionals.rb:61:4:61:8 | ... > ... | conditionals.rb:61:10:62:5 | then ... | else ... | false | +| conditionals.rb:67:1:70:3 | if ... | IfExpr | conditionals.rb:67:4:67:8 | ... > ... | conditionals.rb:67:10:67:13 | then ... | else ... | false | unlessExprs -| conditionals.rb:40:1:42:3 | unless ... | UnlessExpr | conditionals.rb:40:8:40:12 | ... > ... | conditionals.rb:40:14:41:5 | c | (none) | -| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:45:14:46:5 | c | d | +| conditionals.rb:40:1:42:3 | unless ... | UnlessExpr | conditionals.rb:40:8:40:12 | ... > ... | conditionals.rb:40:14:41:5 | then ... | (none) | +| conditionals.rb:45:1:49:3 | unless ... | UnlessExpr | conditionals.rb:45:8:45:13 | ... == ... | conditionals.rb:45:14:46:5 | then ... | else ... | ifModifierExprs | conditionals.rb:52:1:52:14 | ... if ... | IfModifierExpr | conditionals.rb:52:10:52:14 | ... > ... | conditionals.rb:52:1:52:5 | ... = ... | unlessModifierExprs diff --git a/ql/test/library-tests/ast/control/ControlExpr.expected b/ql/test/library-tests/ast/control/ControlExpr.expected index 3273ce0c6a4..9088fd6ed14 100644 --- a/ql/test/library-tests/ast/control/ControlExpr.expected +++ b/ql/test/library-tests/ast/control/ControlExpr.expected @@ -12,6 +12,8 @@ | conditionals.rb:52:1:52:14 | ... if ... | IfModifierExpr | | conditionals.rb:55:1:55:18 | ... unless ... | UnlessModifierExpr | | conditionals.rb:58:5:58:25 | ... ? ... : ... | TernaryIfExpr | +| conditionals.rb:61:1:64:3 | if ... | IfExpr | +| conditionals.rb:67:1:70:3 | if ... | IfExpr | | loops.rb:9:1:12:3 | for ... in ... | ForExpr | | loops.rb:16:1:19:3 | for ... in ... | ForExpr | | loops.rb:22:1:25:3 | for ... in ... | ForExpr | @@ -22,3 +24,4 @@ | loops.rb:51:1:54:3 | until ... | UntilExpr | | loops.rb:57:1:60:3 | until ... | UntilExpr | | loops.rb:63:1:63:19 | ... until ... | UntilModifierExpr | +| loops.rb:66:1:67:3 | while ... | WhileExpr | diff --git a/ql/test/library-tests/ast/control/Loop.expected b/ql/test/library-tests/ast/control/Loop.expected index 6ed5a497ec4..02bde8f9e36 100644 --- a/ql/test/library-tests/ast/control/Loop.expected +++ b/ql/test/library-tests/ast/control/Loop.expected @@ -1,48 +1,50 @@ loops -| loops.rb:9:1:12:3 | for ... in ... | ForExpr | loops.rb:9:15:12:3 | ...; ... | StmtSequence | -| loops.rb:16:1:19:3 | for ... in ... | ForExpr | loops.rb:16:15:19:3 | ...; ... | StmtSequence | -| loops.rb:22:1:25:3 | for ... in ... | ForExpr | loops.rb:22:35:25:3 | ...; ... | StmtSequence | -| loops.rb:28:1:32:3 | for ... in ... | ForExpr | loops.rb:28:37:32:3 | ...; ... | StmtSequence | -| loops.rb:35:1:39:3 | while ... | WhileExpr | loops.rb:35:12:39:3 | ...; ... | StmtSequence | -| loops.rb:42:1:45:3 | while ... | WhileExpr | loops.rb:42:13:45:3 | ...; ... | StmtSequence | +| loops.rb:9:1:12:3 | for ... in ... | ForExpr | loops.rb:9:15:12:3 | do ... | StmtSequence | +| loops.rb:16:1:19:3 | for ... in ... | ForExpr | loops.rb:16:15:19:3 | do ... | StmtSequence | +| loops.rb:22:1:25:3 | for ... in ... | ForExpr | loops.rb:22:35:25:3 | do ... | StmtSequence | +| loops.rb:28:1:32:3 | for ... in ... | ForExpr | loops.rb:28:37:32:3 | do ... | StmtSequence | +| loops.rb:35:1:39:3 | while ... | WhileExpr | loops.rb:35:12:39:3 | do ... | StmtSequence | +| loops.rb:42:1:45:3 | while ... | WhileExpr | loops.rb:42:13:45:3 | do ... | StmtSequence | | loops.rb:48:1:48:19 | ... while ... | WhileModifierExpr | loops.rb:48:1:48:6 | ... += ... | AssignAddExpr | -| loops.rb:51:1:54:3 | until ... | UntilExpr | loops.rb:51:13:54:3 | ...; ... | StmtSequence | -| loops.rb:57:1:60:3 | until ... | UntilExpr | loops.rb:57:13:60:3 | ...; ... | StmtSequence | +| loops.rb:51:1:54:3 | until ... | UntilExpr | loops.rb:51:13:54:3 | do ... | StmtSequence | +| loops.rb:57:1:60:3 | until ... | UntilExpr | loops.rb:57:13:60:3 | do ... | StmtSequence | | loops.rb:63:1:63:19 | ... until ... | UntilModifierExpr | loops.rb:63:1:63:6 | ... -= ... | AssignSubExpr | +| loops.rb:66:1:67:3 | while ... | WhileExpr | loops.rb:66:13:67:3 | do ... | StmtSequence | conditionalLoops -| loops.rb:35:1:39:3 | while ... | WhileExpr | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | ...; ... | StmtSequence | -| loops.rb:42:1:45:3 | while ... | WhileExpr | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | ...; ... | StmtSequence | +| loops.rb:35:1:39:3 | while ... | WhileExpr | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | do ... | StmtSequence | +| loops.rb:42:1:45:3 | while ... | WhileExpr | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | do ... | StmtSequence | | loops.rb:48:1:48:19 | ... while ... | WhileModifierExpr | loops.rb:48:14:48:19 | ... >= ... | loops.rb:48:1:48:6 | ... += ... | AssignAddExpr | -| loops.rb:51:1:54:3 | until ... | UntilExpr | loops.rb:51:7:51:12 | ... == ... | loops.rb:51:13:54:3 | ...; ... | StmtSequence | -| loops.rb:57:1:60:3 | until ... | UntilExpr | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | ...; ... | StmtSequence | +| loops.rb:51:1:54:3 | until ... | UntilExpr | loops.rb:51:7:51:12 | ... == ... | loops.rb:51:13:54:3 | do ... | StmtSequence | +| loops.rb:57:1:60:3 | until ... | UntilExpr | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | do ... | StmtSequence | | loops.rb:63:1:63:19 | ... until ... | UntilModifierExpr | loops.rb:63:14:63:19 | ... == ... | loops.rb:63:1:63:6 | ... -= ... | AssignSubExpr | +| loops.rb:66:1:67:3 | while ... | WhileExpr | loops.rb:66:7:66:11 | ... < ... | loops.rb:66:13:67:3 | do ... | StmtSequence | forExprs -| loops.rb:9:1:12:3 | for ... in ... | loops.rb:9:5:9:5 | n | loops.rb:9:15:12:3 | ...; ... | 0 | loops.rb:10:5:10:12 | ... += ... | -| loops.rb:9:1:12:3 | for ... in ... | loops.rb:9:5:9:5 | n | loops.rb:9:15:12:3 | ...; ... | 1 | loops.rb:11:5:11:11 | ... = ... | -| loops.rb:16:1:19:3 | for ... in ... | loops.rb:16:5:16:5 | n | loops.rb:16:15:19:3 | ...; ... | 0 | loops.rb:17:5:17:12 | ... += ... | -| loops.rb:16:1:19:3 | for ... in ... | loops.rb:16:5:16:5 | n | loops.rb:16:15:19:3 | ...; ... | 1 | loops.rb:18:5:18:12 | ... -= ... | -| loops.rb:22:1:25:3 | for ... in ... | loops.rb:22:5:22:14 | (..., ...) | loops.rb:22:35:25:3 | ...; ... | 0 | loops.rb:23:3:23:14 | ... += ... | -| loops.rb:22:1:25:3 | for ... in ... | loops.rb:22:5:22:14 | (..., ...) | loops.rb:22:35:25:3 | ...; ... | 1 | loops.rb:24:3:24:14 | ... *= ... | -| loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | loops.rb:28:37:32:3 | ...; ... | 0 | loops.rb:29:3:29:14 | ... += ... | -| loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | loops.rb:28:37:32:3 | ...; ... | 1 | loops.rb:30:3:30:14 | ... /= ... | -| loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | loops.rb:28:37:32:3 | ...; ... | 2 | loops.rb:31:3:31:7 | break | +| loops.rb:9:1:12:3 | for ... in ... | loops.rb:9:5:9:5 | n | loops.rb:9:15:12:3 | do ... | 0 | loops.rb:10:5:10:12 | ... += ... | +| loops.rb:9:1:12:3 | for ... in ... | loops.rb:9:5:9:5 | n | loops.rb:9:15:12:3 | do ... | 1 | loops.rb:11:5:11:11 | ... = ... | +| loops.rb:16:1:19:3 | for ... in ... | loops.rb:16:5:16:5 | n | loops.rb:16:15:19:3 | do ... | 0 | loops.rb:17:5:17:12 | ... += ... | +| loops.rb:16:1:19:3 | for ... in ... | loops.rb:16:5:16:5 | n | loops.rb:16:15:19:3 | do ... | 1 | loops.rb:18:5:18:12 | ... -= ... | +| loops.rb:22:1:25:3 | for ... in ... | loops.rb:22:5:22:14 | (..., ...) | loops.rb:22:35:25:3 | do ... | 0 | loops.rb:23:3:23:14 | ... += ... | +| loops.rb:22:1:25:3 | for ... in ... | loops.rb:22:5:22:14 | (..., ...) | loops.rb:22:35:25:3 | do ... | 1 | loops.rb:24:3:24:14 | ... *= ... | +| loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | loops.rb:28:37:32:3 | do ... | 0 | loops.rb:29:3:29:14 | ... += ... | +| loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | loops.rb:28:37:32:3 | do ... | 1 | loops.rb:30:3:30:14 | ... /= ... | +| loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | loops.rb:28:37:32:3 | do ... | 2 | loops.rb:31:3:31:7 | break | forExprsTuplePatterns | loops.rb:22:1:25:3 | for ... in ... | loops.rb:22:5:22:14 | (..., ...) | 0 | loops.rb:22:5:22:7 | key | | loops.rb:22:1:25:3 | for ... in ... | loops.rb:22:5:22:14 | (..., ...) | 1 | loops.rb:22:10:22:14 | value | | loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | 0 | loops.rb:28:6:28:8 | key | | loops.rb:28:1:32:3 | for ... in ... | loops.rb:28:5:28:16 | (..., ...) | 1 | loops.rb:28:11:28:15 | value | whileExprs -| loops.rb:35:1:39:3 | while ... | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | ...; ... | 0 | loops.rb:36:3:36:8 | ... += ... | -| loops.rb:35:1:39:3 | while ... | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | ...; ... | 1 | loops.rb:37:3:37:8 | ... += ... | -| loops.rb:35:1:39:3 | while ... | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | ...; ... | 2 | loops.rb:38:3:38:6 | next | -| loops.rb:42:1:45:3 | while ... | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | ...; ... | 0 | loops.rb:43:3:43:8 | ... += ... | -| loops.rb:42:1:45:3 | while ... | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | ...; ... | 1 | loops.rb:44:3:44:8 | ... += ... | +| loops.rb:35:1:39:3 | while ... | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | do ... | 0 | loops.rb:36:3:36:8 | ... += ... | +| loops.rb:35:1:39:3 | while ... | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | do ... | 1 | loops.rb:37:3:37:8 | ... += ... | +| loops.rb:35:1:39:3 | while ... | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | do ... | 2 | loops.rb:38:3:38:6 | next | +| loops.rb:42:1:45:3 | while ... | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | do ... | 0 | loops.rb:43:3:43:8 | ... += ... | +| loops.rb:42:1:45:3 | while ... | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | do ... | 1 | loops.rb:44:3:44:8 | ... += ... | whileModifierExprs | loops.rb:48:1:48:19 | ... while ... | loops.rb:48:14:48:19 | ... >= ... | loops.rb:48:1:48:6 | ... += ... | untilExprs -| loops.rb:51:1:54:3 | until ... | loops.rb:51:7:51:12 | ... == ... | loops.rb:51:13:54:3 | ...; ... | 0 | loops.rb:52:3:52:8 | ... += ... | -| loops.rb:51:1:54:3 | until ... | loops.rb:51:7:51:12 | ... == ... | loops.rb:51:13:54:3 | ...; ... | 1 | loops.rb:53:3:53:8 | ... -= ... | -| loops.rb:57:1:60:3 | until ... | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | ...; ... | 0 | loops.rb:58:3:58:8 | ... += ... | -| loops.rb:57:1:60:3 | until ... | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | ...; ... | 1 | loops.rb:59:3:59:8 | ... -= ... | +| loops.rb:51:1:54:3 | until ... | loops.rb:51:7:51:12 | ... == ... | loops.rb:51:13:54:3 | do ... | 0 | loops.rb:52:3:52:8 | ... += ... | +| loops.rb:51:1:54:3 | until ... | loops.rb:51:7:51:12 | ... == ... | loops.rb:51:13:54:3 | do ... | 1 | loops.rb:53:3:53:8 | ... -= ... | +| loops.rb:57:1:60:3 | until ... | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | do ... | 0 | loops.rb:58:3:58:8 | ... += ... | +| loops.rb:57:1:60:3 | until ... | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | do ... | 1 | loops.rb:59:3:59:8 | ... -= ... | untilModifierExprs | loops.rb:63:1:63:19 | ... until ... | loops.rb:63:14:63:19 | ... == ... | loops.rb:63:1:63:6 | ... -= ... | diff --git a/ql/test/library-tests/ast/control/conditionals.rb b/ql/test/library-tests/ast/control/conditionals.rb index 946a2d6659f..85e008f5c1d 100644 --- a/ql/test/library-tests/ast/control/conditionals.rb +++ b/ql/test/library-tests/ast/control/conditionals.rb @@ -55,4 +55,16 @@ a = b if c > d a = b unless c < d # Ternary if expr -a = b > c ? d + 1 : e - 2 \ No newline at end of file +a = b > c ? d + 1 : e - 2 + +# If expr with empty else (treated as no else) +if a > b then + c +else +end + +# If expr with empty then (treated as no then) +if a > b then +else + c +end \ No newline at end of file diff --git a/ql/test/library-tests/ast/control/loops.rb b/ql/test/library-tests/ast/control/loops.rb index e6bead6c401..b00a61e348b 100644 --- a/ql/test/library-tests/ast/control/loops.rb +++ b/ql/test/library-tests/ast/control/loops.rb @@ -60,4 +60,8 @@ until x > y do end # Until-modified expression -x -= 1 until x == 0 \ No newline at end of file +x -= 1 until x == 0 + +# While loop with empty `do` block +while x < y do +end diff --git a/ql/test/library-tests/controlflow/graph/Cfg.expected b/ql/test/library-tests/controlflow/graph/Cfg.expected index b585b8ac4f0..d4f66c8e830 100644 --- a/ql/test/library-tests/controlflow/graph/Cfg.expected +++ b/ql/test/library-tests/controlflow/graph/Cfg.expected @@ -25,7 +25,7 @@ break_ensure.rb: #-----| -> ensure ... # 2| element -#-----| -> element +#-----| -> do ... # 2| In #-----| empty -> for ... in ... @@ -34,11 +34,14 @@ break_ensure.rb: # 2| elements #-----| -> In +# 2| do ... +#-----| -> element + # 3| if ... #-----| -> In # 3| ... > ... -#-----| true -> break +#-----| true -> then ... #-----| false -> if ... # 3| element @@ -47,6 +50,9 @@ break_ensure.rb: # 3| 0 #-----| -> ... > ... +# 3| then ... +#-----| -> break + # 4| break #-----| break -> for ... in ... @@ -57,12 +63,15 @@ break_ensure.rb: #-----| -> exit m1 (normal) # 8| call to nil? -#-----| true -> "elements nil" +#-----| true -> then ... #-----| false -> if ... # 8| elements #-----| -> call to nil? +# 8| then ... +#-----| -> "elements nil" + # 9| call to puts #-----| -> if ... @@ -87,7 +96,7 @@ break_ensure.rb: #-----| -> exit m2 (normal) # 14| element -#-----| -> element +#-----| -> do ... # 14| In #-----| empty -> for ... in ... @@ -96,11 +105,14 @@ break_ensure.rb: # 14| elements #-----| -> In +# 14| do ... +#-----| -> element + # 16| if ... #-----| -> ensure ... # 16| ... > ... -#-----| true -> break +#-----| true -> then ... #-----| false -> if ... # 16| element @@ -109,6 +121,9 @@ break_ensure.rb: # 16| 0 #-----| -> ... > ... +# 16| then ... +#-----| -> break + # 17| break #-----| break -> [ensure: break] ensure ... @@ -125,11 +140,11 @@ break_ensure.rb: #-----| break -> for ... in ... # 20| call to nil? -#-----| true -> "elements nil" +#-----| true -> then ... #-----| false -> if ... # 20| [ensure: break] call to nil? -#-----| true -> [ensure: break] "elements nil" +#-----| true -> [ensure: break] then ... #-----| false -> [ensure: break] if ... # 20| elements @@ -138,6 +153,12 @@ break_ensure.rb: # 20| [ensure: break] elements #-----| -> [ensure: break] call to nil? +# 20| then ... +#-----| -> "elements nil" + +# 20| [ensure: break] then ... +#-----| -> [ensure: break] "elements nil" + # 21| call to puts #-----| -> if ... @@ -168,12 +189,15 @@ break_ensure.rb: #-----| -> ensure ... # 29| call to nil? -#-----| true -> return +#-----| true -> then ... #-----| false -> if ... # 29| elements #-----| -> call to nil? +# 29| then ... +#-----| -> return + # 30| return #-----| return -> [ensure: return] ensure ... @@ -190,10 +214,10 @@ break_ensure.rb: #-----| return -> exit m3 (normal) # 33| element -#-----| -> call to x +#-----| -> do ... # 33| [ensure: return] element -#-----| -> [ensure: return] call to x +#-----| -> [ensure: return] do ... # 33| In #-----| empty -> for ... in ... @@ -209,6 +233,12 @@ break_ensure.rb: # 33| [ensure: return] elements #-----| -> [ensure: return] In +# 33| do ... +#-----| -> call to x + +# 33| [ensure: return] do ... +#-----| -> [ensure: return] call to x + # 35| if ... #-----| -> In @@ -216,11 +246,11 @@ break_ensure.rb: #-----| -> [ensure: return] In # 35| ... > ... -#-----| true -> break +#-----| true -> then ... #-----| false -> if ... # 35| [ensure: return] ... > ... -#-----| true -> [ensure: return] break +#-----| true -> [ensure: return] then ... #-----| false -> [ensure: return] if ... # 35| call to x @@ -235,6 +265,12 @@ break_ensure.rb: # 35| [ensure: return] 0 #-----| -> [ensure: return] ... > ... +# 35| then ... +#-----| -> break + +# 35| [ensure: return] then ... +#-----| -> [ensure: return] break + # 36| break #-----| break -> for ... in ... @@ -265,7 +301,7 @@ break_ensure.rb: #-----| -> exit m4 (normal) # 45| element -#-----| -> element +#-----| -> do ... # 45| In #-----| empty -> for ... in ... @@ -274,11 +310,14 @@ break_ensure.rb: # 45| elements #-----| -> In +# 45| do ... +#-----| -> element + # 47| if ... #-----| -> ensure ... # 47| ... > ... -#-----| true -> "" +#-----| true -> then ... #-----| false -> if ... # 47| element @@ -287,6 +326,9 @@ break_ensure.rb: # 47| 1 #-----| -> ... > ... +# 47| then ... +#-----| -> "" + # 48| call to raise #-----| raise -> [ensure: raise] ensure ... @@ -306,11 +348,11 @@ break_ensure.rb: #-----| raise -> for ... in ... # 51| ... > ... -#-----| true -> 10 +#-----| true -> then ... #-----| false -> if ... # 51| [ensure: raise] ... > ... -#-----| true -> [ensure: raise] 10 +#-----| true -> [ensure: raise] then ... #-----| false -> [ensure: raise] if ... # 51| element @@ -325,6 +367,12 @@ break_ensure.rb: # 51| [ensure: raise] 0 #-----| -> [ensure: raise] ... > ... +# 51| then ... +#-----| -> 10 + +# 51| [ensure: raise] then ... +#-----| -> [ensure: raise] 10 + # 52| break #-----| break -> for ... in ... @@ -367,19 +415,25 @@ case.rb: #-----| -> 1 # 3| 1 -#-----| match -> call to x2 +#-----| match -> then ... #-----| no-match -> when ... -# 3| (if ...) +# 3| then ... +#-----| -> call to x2 + +# 3| ( ... ) #-----| -> exit if_in_case (normal) # 3| if ... -#-----| -> (if ...) +#-----| -> ( ... ) # 3| call to x2 -#-----| true -> "x2" +#-----| true -> then ... #-----| false -> if ... +# 3| then ... +#-----| -> "x2" + # 3| call to puts #-----| -> if ... @@ -390,9 +444,12 @@ case.rb: #-----| -> 2 # 4| 2 -#-----| match -> "2" +#-----| match -> then ... #-----| no-match -> exit if_in_case (normal) +# 4| then ... +#-----| -> "2" + # 4| call to puts #-----| -> exit if_in_case (normal) @@ -565,7 +622,10 @@ cfg.rb: #-----| -> false # 31| true -#-----| true -> 1 +#-----| true -> do ... + +# 31| do ... +#-----| -> 1 # 32| break #-----| break -> while ... @@ -598,9 +658,12 @@ cfg.rb: #-----| -> 1 # 42| 1 -#-----| match -> "one" +#-----| match -> then ... #-----| no-match -> when ... +# 42| then ... +#-----| -> "one" + # 42| call to puts #-----| -> case ... @@ -611,16 +674,19 @@ cfg.rb: #-----| -> 2 # 43| 2 -#-----| match -> "some" +#-----| match -> then ... #-----| no-match -> 3 # 43| 3 -#-----| match -> "some" +#-----| match -> then ... #-----| no-match -> 4 # 43| 4 -#-----| match -> "some" -#-----| no-match -> "many" +#-----| match -> then ... +#-----| no-match -> else ... + +# 43| then ... +#-----| -> "some" # 43| call to puts #-----| -> case ... @@ -628,6 +694,9 @@ cfg.rb: # 43| "some" #-----| -> call to puts +# 44| else ... +#-----| -> "many" + # 44| call to puts #-----| -> case ... @@ -641,7 +710,7 @@ cfg.rb: #-----| -> b # 48| ... == ... -#-----| true -> "one" +#-----| true -> then ... #-----| false -> when ... # 48| b @@ -650,6 +719,9 @@ cfg.rb: # 48| 1 #-----| -> ... == ... +# 48| then ... +#-----| -> "one" + # 48| call to puts #-----| -> chained @@ -660,7 +732,7 @@ cfg.rb: #-----| -> b # 49| ... == ... -#-----| true -> "some" +#-----| true -> then ... #-----| false -> b # 49| b @@ -670,7 +742,7 @@ cfg.rb: #-----| -> ... == ... # 49| ... > ... -#-----| true -> "some" +#-----| true -> then ... #-----| false -> chained # 49| b @@ -679,6 +751,9 @@ cfg.rb: # 49| 1 #-----| -> ... > ... +# 49| then ... +#-----| -> "some" + # 49| call to puts #-----| -> chained @@ -889,7 +964,7 @@ cfg.rb: #-----| -> ; # 75| ... < ... -#-----| true -> 0 +#-----| true -> then ... #-----| false -> x # 75| x @@ -898,6 +973,9 @@ cfg.rb: # 75| 0 #-----| -> ... < ... +# 75| then ... +#-----| -> 0 + # 75| 0 #-----| -> if ... @@ -905,8 +983,8 @@ cfg.rb: #-----| -> if ... # 75| ... > ... -#-----| true -> 10 -#-----| false -> x +#-----| true -> then ... +#-----| false -> else ... # 75| x #-----| -> 10 @@ -914,13 +992,22 @@ cfg.rb: # 75| 10 #-----| -> ... > ... +# 75| then ... +#-----| -> 10 + # 75| 10 #-----| -> elsif ... +# 75| else ... +#-----| -> x + # 75| x #-----| -> elsif ... # 78| ; +#-----| -> else ... + +# 82| else ... #-----| -> "ok" # 83| call to puts @@ -957,7 +1044,7 @@ cfg.rb: #-----| -> $global # 90| x -#-----| -> x +#-----| -> do ... # 90| In #-----| empty -> for ... in ... @@ -975,11 +1062,14 @@ cfg.rb: # 90| 3.4e5 #-----| -> [...] +# 90| do ... +#-----| -> x + # 91| if ... #-----| -> x # 91| ... > ... -#-----| true -> next +#-----| true -> then ... #-----| false -> if ... # 91| x @@ -988,6 +1078,9 @@ cfg.rb: # 91| 3 #-----| -> ... > ... +# 91| then ... +#-----| -> next + # 91| next #-----| next -> In @@ -1135,7 +1228,7 @@ cfg.rb: # 108| call to puts #-----| -> b -# 108| (< call to puts # 108| < #{...} # 110| #{...} -#-----| -> (< ( ... ) # 110| call to type #-----| -> #{...} @@ -1264,7 +1357,7 @@ cfg.rb: # 126| last #-----| -> 2 -# 126| (...; ...) +# 126| ( ... ) #-----| -> ... = ... # 126| 2 @@ -1274,7 +1367,7 @@ cfg.rb: #-----| -> 7 # 126| 7 -#-----| -> (...; ...) +#-----| -> ( ... ) # 127| ... = ... #-----| -> half @@ -1596,8 +1689,8 @@ cfg.rb: #-----| -> x # 172| ... == ... -#-----| false -> "hi" -#-----| true -> "bye" +#-----| false -> then ... +#-----| true -> else ... # 172| x #-----| -> 10 @@ -1605,12 +1698,18 @@ cfg.rb: # 172| 10 #-----| -> ... == ... +# 172| then ... +#-----| -> "hi" + # 172| call to puts #-----| -> unless ... # 172| "hi" #-----| -> call to puts +# 172| else ... +#-----| -> "bye" + # 172| call to puts #-----| -> unless ... @@ -1640,8 +1739,8 @@ cfg.rb: #-----| -> i # 176| ... > ... +#-----| false -> do ... #-----| true -> until ... -#-----| false -> x # 176| x #-----| -> 10 @@ -1649,6 +1748,9 @@ cfg.rb: # 176| 10 #-----| -> ... > ... +# 176| do ... +#-----| -> x + # 176| ... += ... #-----| -> "hello" @@ -1673,7 +1775,7 @@ cfg.rb: # 178| 0 #-----| -> ... = ... -# 179| (...; ...) +# 179| ( ... ) #-----| -> i # 179| ... until ... @@ -1686,7 +1788,7 @@ cfg.rb: #-----| -> call to puts # 179| ... += ... -#-----| -> (...; ...) +#-----| -> ( ... ) # 179| i #-----| -> 1 @@ -1717,7 +1819,7 @@ cfg.rb: #-----| -> i # 182| ... < ... -#-----| true -> x +#-----| true -> do ... #-----| false -> while ... # 182| x @@ -1726,6 +1828,9 @@ cfg.rb: # 182| 10 #-----| -> ... < ... +# 182| do ... +#-----| -> x + # 183| ... += ... #-----| -> x @@ -1739,7 +1844,7 @@ cfg.rb: #-----| -> x # 184| ... == ... -#-----| true -> redo +#-----| true -> then ... #-----| false -> if ... # 184| x @@ -1748,8 +1853,11 @@ cfg.rb: # 184| 5 #-----| -> ... == ... +# 184| then ... +#-----| -> redo + # 184| redo -#-----| redo -> x +#-----| redo -> do ... # 185| call to puts #-----| -> x @@ -1757,7 +1865,7 @@ cfg.rb: # 185| x #-----| -> call to puts -# 188| (...; ...) +# 188| ( ... ) #-----| -> i # 188| ... while ... @@ -1770,7 +1878,7 @@ cfg.rb: #-----| -> call to puts # 188| ... -= ... -#-----| -> (...; ...) +#-----| -> ( ... ) # 188| i #-----| -> 1 @@ -1858,7 +1966,7 @@ exit.rb: #-----| -> "x <= 2" # 2| ... > ... -#-----| true -> 1 +#-----| true -> then ... #-----| false -> if ... # 2| x @@ -1867,6 +1975,9 @@ exit.rb: # 2| 2 #-----| -> ... > ... +# 2| then ... +#-----| -> 1 + # 3| call to exit #-----| exit -> exit m1 (abnormal) @@ -1900,7 +2011,7 @@ exit.rb: #-----| -> "x <= 2" # 9| ... > ... -#-----| true -> "abort!" +#-----| true -> then ... #-----| false -> if ... # 9| x @@ -1909,6 +2020,9 @@ exit.rb: # 9| 2 #-----| -> ... > ... +# 9| then ... +#-----| -> "abort!" + # 10| call to abort #-----| exit -> exit m2 (abnormal) @@ -1977,7 +2091,7 @@ ifs.rb: #-----| -> exit m1 (normal) # 2| ... > ... -#-----| true -> "x is greater than 2" +#-----| true -> then ... #-----| false -> x # 2| x @@ -1986,6 +2100,9 @@ ifs.rb: # 2| 2 #-----| -> ... > ... +# 2| then ... +#-----| -> "x is greater than 2" + # 3| call to puts #-----| -> if ... @@ -1996,10 +2113,10 @@ ifs.rb: #-----| -> if ... # 4| [false] ... and ... -#-----| false -> "I can't guess the number" +#-----| false -> else ... # 4| [true] ... and ... -#-----| true -> "x is 1" +#-----| true -> then ... # 4| [false] ... and ... #-----| false -> [false] ... and ... @@ -2033,15 +2150,15 @@ ifs.rb: # 4| [true] ! ... #-----| true -> [true] ... and ... -# 4| [false] (... == ...) +# 4| [false] ( ... ) #-----| false -> [true] ! ... -# 4| [true] (... == ...) +# 4| [true] ( ... ) #-----| true -> [false] ! ... # 4| ... == ... -#-----| false -> [false] (... == ...) -#-----| true -> [true] (... == ...) +#-----| false -> [false] ( ... ) +#-----| true -> [true] ( ... ) # 4| x #-----| -> 5 @@ -2049,12 +2166,18 @@ ifs.rb: # 4| 5 #-----| -> ... == ... +# 4| then ... +#-----| -> "x is 1" + # 5| call to puts #-----| -> elsif ... # 5| "x is 1" #-----| -> call to puts +# 6| else ... +#-----| -> "I can't guess the number" + # 7| call to puts #-----| -> elsif ... @@ -2079,9 +2202,12 @@ ifs.rb: #-----| -> 1 # 12| b -#-----| true -> 0 +#-----| true -> then ... #-----| false -> if ... +# 12| then ... +#-----| -> 0 + # 13| return #-----| return -> exit m2 (normal) @@ -2112,8 +2238,8 @@ ifs.rb: #-----| -> x # 19| ... < ... +#-----| true -> then ... #-----| false -> if ... -#-----| true -> x # 19| x #-----| -> 0 @@ -2121,6 +2247,9 @@ ifs.rb: # 19| 0 #-----| -> ... < ... +# 19| then ... +#-----| -> x + # 20| ... = ... #-----| -> x @@ -2137,8 +2266,8 @@ ifs.rb: #-----| -> if ... # 21| ... > ... +#-----| true -> then ... #-----| false -> if ... -#-----| true -> x # 21| x #-----| -> 10 @@ -2146,6 +2275,9 @@ ifs.rb: # 21| 10 #-----| -> ... > ... +# 21| then ... +#-----| -> x + # 22| ... = ... #-----| -> if ... @@ -2193,17 +2325,17 @@ ifs.rb: # 29| ... ? ... : ... #-----| -> return -# 29| [false] (... ? ... : ...) +# 29| [false] ( ... ) #-----| false -> "!b2 || !b3" -# 29| [true] (... ? ... : ...) +# 29| [true] ( ... ) #-----| true -> "b2 || b3" # 29| [false] ... ? ... : ... -#-----| false -> [false] (... ? ... : ...) +#-----| false -> [false] ( ... ) # 29| [true] ... ? ... : ... -#-----| true -> [true] (... ? ... : ...) +#-----| true -> [true] ( ... ) # 29| b1 #-----| true -> b2 @@ -2252,22 +2384,25 @@ ifs.rb: # 33| if ... #-----| -> exit m5 (normal) -# 33| [false] (if ...) -#-----| false -> "!b2 || !b4 || !b5" +# 33| [false] ( ... ) +#-----| false -> else ... -# 33| [true] (if ...) -#-----| true -> "b2 || b4 || b5" +# 33| [true] ( ... ) +#-----| true -> then ... # 33| [false] if ... -#-----| false -> [false] (if ...) +#-----| false -> [false] ( ... ) # 33| [true] if ... -#-----| true -> [true] (if ...) +#-----| true -> [true] ( ... ) # 33| b1 -#-----| true -> b2 +#-----| true -> then ... #-----| false -> b3 +# 33| then ... +#-----| -> b2 + # 33| b2 #-----| false -> [false] if ... #-----| true -> [true] if ... @@ -2279,20 +2414,32 @@ ifs.rb: #-----| true -> [true] if ... # 33| b3 -#-----| true -> b4 -#-----| false -> b5 +#-----| true -> then ... +#-----| false -> else ... + +# 33| then ... +#-----| -> b4 # 33| b4 #-----| false -> [false] elsif ... #-----| true -> [true] elsif ... +# 33| else ... +#-----| -> b5 + # 33| b5 #-----| false -> [false] elsif ... #-----| true -> [true] elsif ... +# 33| then ... +#-----| -> "b2 || b4 || b5" + # 33| "b2 || b4 || b5" #-----| -> if ... +# 33| else ... +#-----| -> "!b2 || !b4 || !b5" + # 33| "!b2 || !b4 || !b5" #-----| -> if ... @@ -2330,7 +2477,7 @@ ifs.rb: #-----| -> true # 40| constant_condition -#-----| -> exit ifs.rb (normal) +#-----| -> empty_else # 40| exit constant_condition @@ -2346,6 +2493,45 @@ ifs.rb: # 41| true #-----| true -> [false] ! ... +# 46| enter empty_else +#-----| -> b + +# 46| empty_else +#-----| -> exit ifs.rb (normal) + +# 46| exit empty_else + +# 46| exit empty_else (normal) +#-----| -> exit empty_else + +# 46| b +#-----| -> b + +# 47| if ... +#-----| -> "done" + +# 47| b +#-----| true -> then ... +#-----| false -> else ... + +# 47| then ... +#-----| -> "true" + +# 48| call to puts +#-----| -> if ... + +# 48| "true" +#-----| -> call to puts + +# 49| else ... +#-----| -> if ... + +# 51| call to puts +#-----| -> exit empty_else (normal) + +# 51| "done" +#-----| -> call to puts + loops.rb: # 1| enter m1 #-----| -> x @@ -2373,7 +2559,7 @@ loops.rb: #-----| -> exit m1 (normal) # 2| ... >= ... -#-----| true -> x +#-----| true -> do ... #-----| false -> while ... # 2| x @@ -2382,6 +2568,9 @@ loops.rb: # 2| 0 #-----| -> ... >= ... +# 2| do ... +#-----| -> x + # 3| call to puts #-----| -> x @@ -2415,7 +2604,7 @@ loops.rb: #-----| -> "Done" # 9| ... >= ... -#-----| true -> x +#-----| true -> do ... #-----| false -> while ... # 9| x @@ -2424,6 +2613,9 @@ loops.rb: # 9| 0 #-----| -> ... >= ... +# 9| do ... +#-----| -> x + # 10| call to puts #-----| -> x @@ -2443,7 +2635,7 @@ loops.rb: #-----| -> "Iter" # 12| ... > ... -#-----| true -> break +#-----| true -> then ... #-----| false -> x # 12| x @@ -2452,6 +2644,9 @@ loops.rb: # 12| 100 #-----| -> ... > ... +# 12| then ... +#-----| -> break + # 13| break #-----| break -> while ... @@ -2459,7 +2654,7 @@ loops.rb: #-----| -> if ... # 14| ... > ... -#-----| true -> next +#-----| true -> then ... #-----| false -> x # 14| x @@ -2468,6 +2663,9 @@ loops.rb: # 14| 50 #-----| -> ... > ... +# 14| then ... +#-----| -> next + # 15| next #-----| next -> x @@ -2475,7 +2673,7 @@ loops.rb: #-----| -> elsif ... # 16| ... > ... -#-----| true -> redo +#-----| true -> then ... #-----| false -> elsif ... # 16| x @@ -2484,8 +2682,11 @@ loops.rb: # 16| 10 #-----| -> ... > ... +# 16| then ... +#-----| -> redo + # 17| redo -#-----| redo -> x +#-----| redo -> do ... # 19| call to puts #-----| -> x @@ -2503,7 +2704,7 @@ loops.rb: #-----| -> 1 # 24| m3 -#-----| -> exit loops.rb (normal) +#-----| -> m4 # 24| exit m3 @@ -2545,6 +2746,39 @@ loops.rb: # 26| x #-----| -> call to puts +# 30| enter m4 +#-----| -> x + +# 30| m4 +#-----| -> exit loops.rb (normal) + +# 30| exit m4 + +# 30| exit m4 (normal) +#-----| -> exit m4 + +# 30| x +#-----| -> y + +# 30| y +#-----| -> x + +# 31| while ... +#-----| -> exit m4 (normal) + +# 31| ... < ... +#-----| true -> do ... +#-----| false -> while ... + +# 31| x +#-----| -> y + +# 31| y +#-----| -> ... < ... + +# 31| do ... +#-----| -> x + raise.rb: # 1| enter raise.rb #-----| -> ExceptionA @@ -2587,7 +2821,7 @@ raise.rb: #-----| -> "x <= 2" # 8| ... > ... -#-----| true -> "x > 2" +#-----| true -> then ... #-----| false -> if ... # 8| x @@ -2596,6 +2830,9 @@ raise.rb: # 8| 2 #-----| -> ... > ... +# 8| then ... +#-----| -> "x > 2" + # 9| call to raise #-----| raise -> exit m1 (abnormal) @@ -2629,8 +2866,11 @@ raise.rb: #-----| -> "End m2" # 16| b +#-----| true -> then ... #-----| false -> if ... -#-----| true -> ExceptionA + +# 16| then ... +#-----| -> ExceptionA # 17| call to raise #-----| raise -> rescue ... @@ -2642,9 +2882,12 @@ raise.rb: #-----| -> ExceptionA # 19| ExceptionA -#-----| match -> "Rescued" +#-----| match -> then ... #-----| raise -> exit m2 (abnormal) +# 19| then ... +#-----| -> "Rescued" + # 20| call to puts #-----| -> "End m2" @@ -2675,8 +2918,11 @@ raise.rb: #-----| -> "End m3" # 27| b +#-----| true -> then ... #-----| false -> if ... -#-----| true -> ExceptionA + +# 27| then ... +#-----| -> ExceptionA # 28| call to raise #-----| raise -> rescue ... @@ -2685,6 +2931,9 @@ raise.rb: #-----| -> call to raise # 30| rescue ... +#-----| -> then ... + +# 30| then ... #-----| -> "Rescued" # 31| call to puts @@ -2717,8 +2966,11 @@ raise.rb: #-----| -> "End m4" # 38| b +#-----| true -> then ... #-----| false -> if ... -#-----| true -> ExceptionA + +# 38| then ... +#-----| -> ExceptionA # 39| call to raise #-----| raise -> rescue ... @@ -2730,6 +2982,9 @@ raise.rb: #-----| -> e # 41| e +#-----| -> then ... + +# 41| then ... #-----| -> "Rescued {e}" # 42| call to puts @@ -2762,8 +3017,11 @@ raise.rb: #-----| -> "End m5" # 49| b +#-----| true -> then ... #-----| false -> if ... -#-----| true -> ExceptionA + +# 49| then ... +#-----| -> ExceptionA # 50| call to raise #-----| raise -> rescue ... @@ -2804,8 +3062,11 @@ raise.rb: #-----| -> "End m6" # 59| b +#-----| true -> then ... #-----| false -> if ... -#-----| true -> ExceptionA + +# 59| then ... +#-----| -> ExceptionA # 60| call to raise #-----| raise -> rescue ... @@ -2825,6 +3086,9 @@ raise.rb: #-----| raise -> exit m6 (abnormal) # 62| e +#-----| -> then ... + +# 62| then ... #-----| -> "Rescued {e}" # 63| call to puts @@ -2860,7 +3124,7 @@ raise.rb: #-----| -> "0 <= x <= 2" # 69| ... > ... -#-----| true -> "x > 2" +#-----| true -> then ... #-----| false -> x # 69| x @@ -2869,6 +3133,9 @@ raise.rb: # 69| 2 #-----| -> ... > ... +# 69| then ... +#-----| -> "x > 2" + # 70| call to raise #-----| raise -> [ensure: raise] ensure ... @@ -2879,7 +3146,7 @@ raise.rb: #-----| -> if ... # 71| ... < ... -#-----| true -> "x < 0" +#-----| true -> then ... #-----| false -> elsif ... # 71| x @@ -2888,6 +3155,9 @@ raise.rb: # 71| 0 #-----| -> ... < ... +# 71| then ... +#-----| -> "x < 0" + # 72| return #-----| return -> [ensure: return] ensure ... @@ -2954,7 +3224,7 @@ raise.rb: #-----| -> "0 <= x <= 2" # 82| ... > ... -#-----| true -> "x > 2" +#-----| true -> then ... #-----| false -> x # 82| x @@ -2963,6 +3233,9 @@ raise.rb: # 82| 2 #-----| -> ... > ... +# 82| then ... +#-----| -> "x > 2" + # 83| call to raise #-----| raise -> [ensure: raise] ensure ... @@ -2973,7 +3246,7 @@ raise.rb: #-----| -> if ... # 84| ... < ... -#-----| true -> "x < 0" +#-----| true -> then ... #-----| false -> elsif ... # 84| x @@ -2982,6 +3255,9 @@ raise.rb: # 84| 0 #-----| -> ... < ... +# 84| then ... +#-----| -> "x < 0" + # 85| return #-----| return -> [ensure: return] ensure ... @@ -3060,7 +3336,7 @@ raise.rb: #-----| -> "0 <= x <= 2" # 97| ... > ... -#-----| true -> "x > 2" +#-----| true -> then ... #-----| false -> x # 97| x @@ -3069,6 +3345,9 @@ raise.rb: # 97| 2 #-----| -> ... > ... +# 97| then ... +#-----| -> "x > 2" + # 98| call to raise #-----| raise -> [ensure: raise] ensure ... @@ -3079,7 +3358,7 @@ raise.rb: #-----| -> if ... # 99| ... < ... -#-----| true -> "x < 0" +#-----| true -> then ... #-----| false -> elsif ... # 99| x @@ -3088,6 +3367,9 @@ raise.rb: # 99| 0 #-----| -> ... < ... +# 99| then ... +#-----| -> "x < 0" + # 100| return #-----| return -> [ensure: return] ensure ... @@ -3137,17 +3419,26 @@ raise.rb: #-----| -> [ensure: raise] ensure ... # 106| b1 -#-----| true -> "b1 is true" +#-----| true -> then ... #-----| false -> if ... # 106| [ensure: return] b1 -#-----| true -> [ensure: return] "b1 is true" +#-----| true -> [ensure: return] then ... #-----| false -> [ensure: return] if ... # 106| [ensure: raise] b1 -#-----| true -> [ensure: raise] "b1 is true" +#-----| true -> [ensure: raise] then ... #-----| false -> [ensure: raise] if ... +# 106| then ... +#-----| -> "b1 is true" + +# 106| [ensure: return] then ... +#-----| -> [ensure: return] "b1 is true" + +# 106| [ensure: raise] then ... +#-----| -> [ensure: raise] "b1 is true" + # 107| call to raise #-----| raise -> [ensure(1): raise] ensure ... @@ -3263,17 +3554,26 @@ raise.rb: #-----| raise -> exit m9 (abnormal) # 116| b2 -#-----| true -> "b2 is true" +#-----| true -> then ... #-----| false -> if ... # 116| [ensure: return] b2 -#-----| true -> [ensure: return] "b2 is true" +#-----| true -> [ensure: return] then ... #-----| false -> [ensure: return] if ... # 116| [ensure: raise] b2 -#-----| true -> [ensure: raise] "b2 is true" +#-----| true -> [ensure: raise] then ... #-----| false -> [ensure: raise] if ... +# 116| then ... +#-----| -> "b2 is true" + +# 116| [ensure: return] then ... +#-----| -> [ensure: return] "b2 is true" + +# 116| [ensure: raise] then ... +#-----| -> [ensure: raise] "b2 is true" + # 117| call to raise #-----| raise -> exit m9 (abnormal) @@ -3346,8 +3646,11 @@ raise.rb: #-----| -> ensure ... # 130| b +#-----| true -> then ... #-----| false -> if ... -#-----| true -> ExceptionA + +# 130| then ... +#-----| -> ExceptionA # 131| call to raise #-----| raise -> rescue ... @@ -3366,9 +3669,12 @@ raise.rb: #-----| -> ExceptionB # 134| ExceptionB -#-----| match -> "ExceptionB" +#-----| match -> then ... #-----| raise -> [ensure: raise] ensure ... +# 134| then ... +#-----| -> "ExceptionB" + # 135| call to puts #-----| -> ensure ... @@ -3417,9 +3723,12 @@ raise.rb: #-----| -> ensure ... # 143| b -#-----| true -> "" +#-----| true -> then ... #-----| false -> if ... +# 143| then ... +#-----| -> "" + # 144| call to raise #-----| raise -> [ensure: raise] ensure ... diff --git a/ql/test/library-tests/controlflow/graph/ifs.rb b/ql/test/library-tests/controlflow/graph/ifs.rb index aa8ac8a342b..30a3f169a5d 100644 --- a/ql/test/library-tests/controlflow/graph/ifs.rb +++ b/ql/test/library-tests/controlflow/graph/ifs.rb @@ -42,3 +42,11 @@ def constant_condition() puts "Impossible" end end + +def empty_else b + if b then + puts "true" + else + end + puts "done" +end \ No newline at end of file diff --git a/ql/test/library-tests/controlflow/graph/loops.rb b/ql/test/library-tests/controlflow/graph/loops.rb index 01222db77e1..b3f1c60557a 100644 --- a/ql/test/library-tests/controlflow/graph/loops.rb +++ b/ql/test/library-tests/controlflow/graph/loops.rb @@ -25,4 +25,9 @@ def m3 [1,2,3].each do |x| puts x end -end \ No newline at end of file +end + +def m4(x, y) + while x < y do + end +end diff --git a/ql/test/library-tests/dataflow/local/DataflowStep.expected b/ql/test/library-tests/dataflow/local/DataflowStep.expected index e8b542731fe..a41b0df807f 100644 --- a/ql/test/library-tests/dataflow/local/DataflowStep.expected +++ b/ql/test/library-tests/dataflow/local/DataflowStep.expected @@ -3,20 +3,20 @@ | local_dataflow.rb:2:7:2:7 | a | local_dataflow.rb:2:3:2:7 | ... = ... | | local_dataflow.rb:2:7:2:7 | a | local_dataflow.rb:2:3:2:7 | ... = ... | | local_dataflow.rb:2:7:2:7 | a | local_dataflow.rb:3:10:3:10 | a | -| local_dataflow.rb:3:7:3:14 | (...; ...) | local_dataflow.rb:3:3:3:14 | ... = ... | +| local_dataflow.rb:3:7:3:14 | ( ... ) | local_dataflow.rb:3:3:3:14 | ... = ... | | local_dataflow.rb:3:10:3:10 | [post] a | local_dataflow.rb:4:11:4:11 | a | | local_dataflow.rb:3:10:3:10 | a | local_dataflow.rb:4:11:4:11 | a | -| local_dataflow.rb:3:13:3:13 | b | local_dataflow.rb:3:7:3:14 | (...; ...) | +| local_dataflow.rb:3:13:3:13 | b | local_dataflow.rb:3:7:3:14 | ( ... ) | | local_dataflow.rb:3:13:3:13 | b | local_dataflow.rb:6:13:6:13 | b | | local_dataflow.rb:4:7:4:11 | ... = ... | local_dataflow.rb:4:3:4:11 | ... = ... | | local_dataflow.rb:4:11:4:11 | a | local_dataflow.rb:4:7:4:11 | ... = ... | | local_dataflow.rb:4:11:4:11 | a | local_dataflow.rb:5:12:5:12 | a | -| local_dataflow.rb:5:7:5:13 | (... = ...) | local_dataflow.rb:5:3:5:13 | ... = ... | -| local_dataflow.rb:5:8:5:12 | ... = ... | local_dataflow.rb:5:7:5:13 | (... = ...) | +| local_dataflow.rb:5:7:5:13 | ( ... ) | local_dataflow.rb:5:3:5:13 | ... = ... | +| local_dataflow.rb:5:8:5:12 | ... = ... | local_dataflow.rb:5:7:5:13 | ( ... ) | | local_dataflow.rb:5:12:5:12 | a | local_dataflow.rb:5:8:5:12 | ... = ... | | local_dataflow.rb:5:12:5:12 | a | local_dataflow.rb:6:8:6:8 | a | -| local_dataflow.rb:6:7:6:14 | (... += ...) | local_dataflow.rb:6:3:6:14 | ... = ... | -| local_dataflow.rb:6:8:6:13 | ... += ... | local_dataflow.rb:6:7:6:14 | (... += ...) | +| local_dataflow.rb:6:7:6:14 | ( ... ) | local_dataflow.rb:6:3:6:14 | ... = ... | +| local_dataflow.rb:6:8:6:13 | ... += ... | local_dataflow.rb:6:7:6:14 | ( ... ) | | local_dataflow.rb:9:1:9:15 | ... = ... | local_dataflow.rb:10:14:10:18 | array | | local_dataflow.rb:9:9:9:15 | [...] | local_dataflow.rb:9:1:9:15 | ... = ... | | local_dataflow.rb:9:9:9:15 | [...] | local_dataflow.rb:9:1:9:15 | ... = ... | @@ -24,12 +24,15 @@ | local_dataflow.rb:10:9:10:9 | x | local_dataflow.rb:12:5:12:5 | x | | local_dataflow.rb:10:14:10:18 | array | local_dataflow.rb:10:5:13:3 | for ... in ... | | local_dataflow.rb:10:14:10:18 | array | local_dataflow.rb:15:10:15:14 | array | +| local_dataflow.rb:12:3:12:5 | call to p | local_dataflow.rb:10:19:13:3 | do ... | | local_dataflow.rb:15:10:15:14 | array | local_dataflow.rb:15:1:17:3 | for ... in ... | | local_dataflow.rb:15:10:15:14 | array | local_dataflow.rb:19:10:19:14 | array | | local_dataflow.rb:16:3:16:10 | break | local_dataflow.rb:15:1:17:3 | for ... in ... | | local_dataflow.rb:16:9:16:10 | 10 | local_dataflow.rb:16:3:16:10 | break | | local_dataflow.rb:19:5:19:5 | x | local_dataflow.rb:20:6:20:6 | x | | local_dataflow.rb:19:10:19:14 | array | local_dataflow.rb:19:1:21:3 | for ... in ... | +| local_dataflow.rb:20:3:20:25 | if ... | local_dataflow.rb:19:16:21:3 | do ... | +| local_dataflow.rb:20:12:20:21 | then ... | local_dataflow.rb:20:3:20:25 | if ... | | local_dataflow.rb:20:17:20:21 | break | local_dataflow.rb:19:1:21:3 | for ... in ... | | local_dataflow.rb:24:2:24:8 | break | local_dataflow.rb:23:1:25:3 | while ... | | local_dataflow.rb:24:8:24:8 | 5 | local_dataflow.rb:24:2:24:8 | break | @@ -40,8 +43,10 @@ | local_dataflow.rb:32:5:32:25 | bar | local_dataflow.rb:32:1:32:25 | ... = ... | | local_dataflow.rb:32:5:32:25 | bar | local_dataflow.rb:32:1:32:25 | ... = ... | | local_dataflow.rb:34:7:34:7 | x | local_dataflow.rb:35:6:35:6 | x | +| local_dataflow.rb:35:12:36:13 | then ... | local_dataflow.rb:35:3:37:5 | if ... | | local_dataflow.rb:36:13:36:13 | 7 | local_dataflow.rb:36:6:36:13 | return | | local_dataflow.rb:41:7:41:7 | x | local_dataflow.rb:42:6:42:6 | x | +| local_dataflow.rb:42:12:43:13 | then ... | local_dataflow.rb:42:3:44:5 | if ... | | local_dataflow.rb:43:13:43:13 | 7 | local_dataflow.rb:43:6:43:13 | return | | local_dataflow.rb:45:10:45:10 | 6 | local_dataflow.rb:45:3:45:10 | return | | local_dataflow.rb:49:3:53:3 | | local_dataflow.rb:50:18:50:18 | x |