From d42b6b651e16e50956755ccfe0f9a5a1699fc66e Mon Sep 17 00:00:00 2001 From: Arthur Baars Date: Thu, 11 Feb 2021 15:32:48 +0100 Subject: [PATCH] AST: rename ExprSequence to StmtSequence --- ql/src/codeql_ruby/ast/Control.qll | 26 ++++++------ ql/src/codeql_ruby/ast/Expr.qll | 32 +++++++------- ql/src/codeql_ruby/ast/Method.qll | 2 +- ql/src/codeql_ruby/ast/Module.qll | 6 +-- ql/src/codeql_ruby/ast/internal/Control.qll | 18 ++++---- ql/src/codeql_ruby/ast/internal/Expr.qll | 42 +++++++++---------- ql/src/codeql_ruby/ast/internal/Method.qll | 4 +- ql/src/codeql_ruby/controlflow/CfgNodes.qll | 17 ++++---- .../dataflow/internal/DataFlowPrivate.qll | 2 +- ql/test/library-tests/ast/control/CaseExpr.ql | 4 +- .../ast/control/ConditionalExpr.ql | 4 +- .../library-tests/ast/control/Loop.expected | 24 +++++------ ql/test/library-tests/ast/control/Loop.ql | 12 +++--- ql/test/library-tests/ast/modules/classes.ql | 2 +- ql/test/library-tests/ast/modules/modules.ql | 2 +- .../ast/modules/singleton_classes.ql | 2 +- 16 files changed, 98 insertions(+), 101 deletions(-) diff --git a/ql/src/codeql_ruby/ast/Control.qll b/ql/src/codeql_ruby/ast/Control.qll index 66110be14f3..6f5a7dbcded 100644 --- a/ql/src/codeql_ruby/ast/Control.qll +++ b/ql/src/codeql_ruby/ast/Control.qll @@ -57,11 +57,11 @@ class IfExpr extends ConditionalExpr { final predicate isElsif() { this instanceof @elsif } /** Gets the 'then' branch of this `if`/`elsif` expression. */ - final ExprSequence getThen() { result = range.getThen() } + final StmtSequence getThen() { result = range.getThen() } /** * Gets the `elsif`/`else` branch of this `if`/`elsif` expression, if any. In - * the following example, the result is an `ExprSequence` containing `b`. + * the following example, the result is a `StmtSequence` containing `b`. * ```rb * if foo * a @@ -77,7 +77,7 @@ class IfExpr extends ConditionalExpr { * ``` * There can be at most one result, since `elsif` branches nest. In the * following example, `ifExpr.getElse()` returns an `ElsifExpr`, and the - * `else` branch is nested inside that. To get the `ExprSequence` for the + * `else` branch is nested inside that. To get the `StmtSequence` for the * `else` branch, i.e. the one containing `c`, use * `getElse().(ElsifExpr).getElse()`. * ```rb @@ -108,7 +108,7 @@ class UnlessExpr extends ConditionalExpr, @unless { /** * Gets the 'then' branch of this `unless` expression. In the following - * example, the result is the `ExprSequence` containing `foo`. + * example, the result is the `StmtSequence` containing `foo`. * ```rb * unless a == b then * foo @@ -117,11 +117,11 @@ class UnlessExpr extends ConditionalExpr, @unless { * end * ``` */ - final ExprSequence getThen() { result = range.getThen() } + final StmtSequence getThen() { result = range.getThen() } /** * Gets the 'else' branch of this `unless` expression. In the following - * example, the result is the `ExprSequence` containing `bar`. + * example, the result is the `StmtSequence` containing `bar`. * ```rb * unless a == b then * foo @@ -130,7 +130,7 @@ class UnlessExpr extends ConditionalExpr, @unless { * end * ``` */ - final ExprSequence getElse() { result = range.getElse() } + final StmtSequence getElse() { result = range.getElse() } } /** @@ -220,8 +220,8 @@ class CaseExpr extends ControlExpr, @case__ { final Expr getValue() { result = range.getValue() } /** - * Gets the `n`th branch of this case expression, either a `WhenExpr` or an - * `ExprSequence`. + * Gets the `n`th branch of this case expression, either a `WhenExpr` or a + * `StmtSequence`. */ final Expr getBranch(int n) { result = range.getBranch(n) } @@ -235,7 +235,7 @@ class CaseExpr extends ControlExpr, @case__ { final WhenExpr getAWhenBranch() { result = getABranch() } /** Gets the `else` branch of this case expression, if any. */ - final ExprSequence getElseBranch() { result = getABranch() } + final StmtSequence getElseBranch() { result = getABranch() } /** * Gets the number of branches of this case expression. @@ -257,7 +257,7 @@ class WhenExpr extends Expr, @when { final override string getAPrimaryQlClass() { result = "WhenExpr" } /** Gets the body of this case-when expression. */ - final ExprSequence getBody() { result = range.getBody() } + final StmtSequence getBody() { result = range.getBody() } /** * Gets the `n`th pattern (or condition) in this case-when expression. In the @@ -320,7 +320,7 @@ class WhileExpr extends ConditionalLoop, @while { final override string getAPrimaryQlClass() { result = "WhileExpr" } /** Gets the body of this `while` loop. */ - final override ExprSequence getBody() { result = range.getBody() } + final override StmtSequence getBody() { result = range.getBody() } } /** @@ -338,7 +338,7 @@ class UntilExpr extends ConditionalLoop, @until { final override string getAPrimaryQlClass() { result = "UntilExpr" } /** Gets the body of this `until` loop. */ - final override ExprSequence getBody() { result = range.getBody() } + final override StmtSequence getBody() { result = range.getBody() } } /** diff --git a/ql/src/codeql_ruby/ast/Expr.qll b/ql/src/codeql_ruby/ast/Expr.qll index bad205bd99c..55ed61c0b0a 100644 --- a/ql/src/codeql_ruby/ast/Expr.qll +++ b/ql/src/codeql_ruby/ast/Expr.qll @@ -102,25 +102,25 @@ class SymbolLiteral extends Literal { } /** A sequence of expressions. */ -class ExprSequence extends Expr { - override ExprSequence::Range range; +class StmtSequence extends Expr { + override StmtSequence::Range range; - override string getAPrimaryQlClass() { result = "ExprSequence" } + override string getAPrimaryQlClass() { result = "StmtSequence" } - /** Gets the `n`th expression in this sequence. */ - final Expr getExpr(int n) { result = range.getExpr(n) } + /** Gets the `n`th statement in this sequence. */ + final Stmt getStmt(int n) { result = range.getStmt(n) } - /** Gets an expression in this sequence. */ - final Expr getAnExpr() { result = this.getExpr(_) } + /** Gets a statement in this sequence. */ + final Stmt getAStmt() { result = this.getStmt(_) } /** Gets the last expression in this sequence, if any. */ - final Expr getLastExpr() { result = this.getExpr(this.getNumberOfExpressions() - 1) } + final Expr getLastExpr() { result = this.getStmt(this.getNumberOfStatements() - 1) } - /** Gets the number of expressions in this sequence. */ - final int getNumberOfExpressions() { result = count(this.getAnExpr()) } + /** Gets the number of statements in this sequence. */ + final int getNumberOfStatements() { result = count(this.getAStmt()) } - /** Holds if this sequence has no expressions. */ - final predicate isEmpty() { this.getNumberOfExpressions() = 0 } + /** Holds if this sequence has no statements. */ + final predicate isEmpty() { this.getNumberOfStatements() = 0 } } /** @@ -128,14 +128,14 @@ class ExprSequence extends Expr { * or do-block. That is, any body that may also include rescue/ensure/else * statements. */ -class BodyStatement extends ExprSequence { +class BodyStatement extends StmtSequence { override BodyStatement::Range range; /** Gets the `else` block in this block, if any. */ - final ExprSequence getElse() { result = range.getElse() } + final StmtSequence getElse() { result = range.getElse() } /** Gets the `ensure` block in this block, if any. */ - final ExprSequence getEnsure() { result = range.getEnsure() } + final StmtSequence getEnsure() { result = range.getEnsure() } final predicate hasEnsure() { exists(this.getEnsure()) } } @@ -155,7 +155,7 @@ class BodyStatement extends ExprSequence { * () * ``` */ -class ParenthesizedExpr extends ExprSequence, @parenthesized_statements { +class ParenthesizedExpr extends StmtSequence, @parenthesized_statements { final override ParenthesizedExpr::Range range; final override string getAPrimaryQlClass() { result = "ParenthesizedExpr" } diff --git a/ql/src/codeql_ruby/ast/Method.qll b/ql/src/codeql_ruby/ast/Method.qll index 05245497fa5..28d4439f47d 100644 --- a/ql/src/codeql_ruby/ast/Method.qll +++ b/ql/src/codeql_ruby/ast/Method.qll @@ -63,7 +63,7 @@ class Lambda extends Callable, BodyStatement, @lambda { } /** A block. */ -class Block extends Callable, ExprSequence { +class Block extends Callable, StmtSequence { override Block::Range range; } diff --git a/ql/src/codeql_ruby/ast/Module.qll b/ql/src/codeql_ruby/ast/Module.qll index 8e03ee69c5b..96ee60d200a 100644 --- a/ql/src/codeql_ruby/ast/Module.qll +++ b/ql/src/codeql_ruby/ast/Module.qll @@ -9,19 +9,19 @@ class ModuleBase extends BodyStatement { override ModuleBase::Range range; /** Gets a method defined in this module/class. */ - Method getAMethod() { result = this.getAnExpr() } + Method getAMethod() { result = this.getAStmt() } /** Gets the method named `name` in this module/class, if any. */ Method getMethod(string name) { result = this.getAMethod() and result.getName() = name } /** Gets a class defined in this module/class. */ - Class getAClass() { result = this.getAnExpr() } + Class getAClass() { result = this.getAStmt() } /** Gets the class named `name` in this module/class, if any. */ Class getClass(string name) { result = this.getAClass() and result.getName() = name } /** Gets a module defined in this module/class. */ - Module getAModule() { result = this.getAnExpr() } + Module getAModule() { result = this.getAStmt() } /** Gets the module named `name` in this module/class, if any. */ Module getModule(string name) { result = this.getAModule() and result.getName() = name } diff --git a/ql/src/codeql_ruby/ast/internal/Control.qll b/ql/src/codeql_ruby/ast/internal/Control.qll index cfc98f5e3cb..518cb8e7505 100644 --- a/ql/src/codeql_ruby/ast/internal/Control.qll +++ b/ql/src/codeql_ruby/ast/internal/Control.qll @@ -17,7 +17,7 @@ module ConditionalExpr { module IfExpr { abstract class Range extends ConditionalExpr::Range { - abstract ExprSequence getThen(); + abstract StmtSequence getThen(); abstract Expr getElse(); @@ -31,7 +31,7 @@ module IfExpr { final override Expr getCondition() { result = generated.getCondition() } - final override ExprSequence getThen() { result = generated.getConsequence() } + final override StmtSequence getThen() { result = generated.getConsequence() } final override Expr getElse() { result = generated.getAlternative() } @@ -47,7 +47,7 @@ module IfExpr { final override Expr getCondition() { result = generated.getCondition() } - final override ExprSequence getThen() { result = generated.getConsequence() } + final override StmtSequence getThen() { result = generated.getConsequence() } final override Expr getElse() { result = generated.getAlternative() } @@ -65,9 +65,9 @@ module UnlessExpr { final override Expr getCondition() { result = generated.getCondition() } - final ExprSequence getThen() { result = generated.getConsequence() } + final StmtSequence getThen() { result = generated.getConsequence() } - final ExprSequence getElse() { result = generated.getAlternative() } + final StmtSequence getElse() { result = generated.getAlternative() } final override Expr getBranch(boolean cond) { cond = false and result = getThen() @@ -143,7 +143,7 @@ module WhenExpr { class Range extends Expr::Range, @when { final override Generated::When generated; - final ExprSequence getBody() { result = generated.getBody() } + final StmtSequence getBody() { result = generated.getBody() } final Expr getPattern(int n) { result = generated.getPattern(n).getChild() } @@ -167,7 +167,7 @@ module WhileExpr { class Range extends ConditionalLoop::Range, @while { final override Generated::While generated; - final override ExprSequence getBody() { result = generated.getBody() } + final override StmtSequence getBody() { result = generated.getBody() } final override Expr getCondition() { result = generated.getCondition() } @@ -179,7 +179,7 @@ module UntilExpr { class Range extends ConditionalLoop::Range, @until { final override Generated::Until generated; - final override ExprSequence getBody() { result = generated.getBody() } + final override StmtSequence getBody() { result = generated.getBody() } final override Expr getCondition() { result = generated.getCondition() } @@ -215,7 +215,7 @@ module ForExpr { class Range extends Loop::Range, @for { final override Generated::For generated; - final override ExprSequence getBody() { result = generated.getBody() } + final override StmtSequence getBody() { result = generated.getBody() } final Pattern getPattern() { result = generated.getPattern() } diff --git a/ql/src/codeql_ruby/ast/internal/Expr.qll b/ql/src/codeql_ruby/ast/internal/Expr.qll index bed8763cf36..c8ac64cf446 100644 --- a/ql/src/codeql_ruby/ast/internal/Expr.qll +++ b/ql/src/codeql_ruby/ast/internal/Expr.qll @@ -164,17 +164,17 @@ module SymbolLiteral { } } -module ExprSequence { +module StmtSequence { abstract class Range extends Expr::Range { - abstract Expr getExpr(int n); + abstract Stmt getStmt(int n); - int getNumberOfExpressions() { result = count(this.getExpr(_)) } + int getNumberOfStatements() { result = count(this.getStmt(_)) } override string toString() { - exists(int c | c = this.getNumberOfExpressions() | + exists(int c | c = this.getNumberOfStatements() | c = 0 and result = ";" or - c = 1 and result = this.getExpr(0).toString() + c = 1 and result = this.getStmt(0).toString() or c > 1 and result = "...; ..." ) @@ -183,8 +183,8 @@ module ExprSequence { } module BodyStatement { - abstract class Range extends ExprSequence::Range { - final override Expr getExpr(int n) { + abstract class Range extends StmtSequence::Range { + final override Stmt getStmt(int n) { result = rank[n + 1](Generated::AstNode node, int i | node = getChild(i) and @@ -196,59 +196,59 @@ module BodyStatement { ) } - final ExprSequence getElse() { result = unique(Generated::Else s | s = getChild(_)) } + final StmtSequence getElse() { result = unique(Generated::Else s | s = getChild(_)) } - final ExprSequence getEnsure() { result = unique(Generated::Ensure s | s = getChild(_)) } + final StmtSequence getEnsure() { result = unique(Generated::Ensure s | s = getChild(_)) } abstract Generated::AstNode getChild(int i); } } module ParenthesizedExpr { - class Range extends ExprSequence::Range, @parenthesized_statements { + class Range extends StmtSequence::Range, @parenthesized_statements { final override Generated::ParenthesizedStatements generated; - final override Expr getExpr(int n) { result = generated.getChild(n) } + final override Stmt getStmt(int n) { result = generated.getChild(n) } final override string toString() { - exists(int c | c = this.getNumberOfExpressions() | + exists(int c | c = this.getNumberOfStatements() | c = 0 and result = "()" or - c > 0 and result = "(" + ExprSequence::Range.super.toString() + ")" + c > 0 and result = "(" + StmtSequence::Range.super.toString() + ")" ) } } } module ThenExpr { - class Range extends ExprSequence::Range, @then { + class Range extends StmtSequence::Range, @then { final override Generated::Then generated; - final override Expr getExpr(int n) { result = generated.getChild(n) } + final override Stmt getStmt(int n) { result = generated.getChild(n) } } } module ElseExpr { - class Range extends ExprSequence::Range, @else { + class Range extends StmtSequence::Range, @else { final override Generated::Else generated; - final override Expr getExpr(int n) { result = generated.getChild(n) } + final override Stmt getStmt(int n) { result = generated.getChild(n) } } } module DoExpr { - class Range extends ExprSequence::Range, @do { + class Range extends StmtSequence::Range, @do { final override Generated::Do generated; - final override Expr getExpr(int n) { result = generated.getChild(n) } + final override Stmt getStmt(int n) { result = generated.getChild(n) } } } module Ensure { - class Range extends ExprSequence::Range, @ensure { + class Range extends StmtSequence::Range, @ensure { final override Generated::Ensure generated; - final override Expr getExpr(int n) { result = generated.getChild(n) } + final override Stmt getStmt(int n) { result = generated.getChild(n) } final override string toString() { result = "ensure ... end" } } diff --git a/ql/src/codeql_ruby/ast/internal/Method.qll b/ql/src/codeql_ruby/ast/internal/Method.qll index 331cf90f987..ae3462af950 100644 --- a/ql/src/codeql_ruby/ast/internal/Method.qll +++ b/ql/src/codeql_ruby/ast/internal/Method.qll @@ -65,7 +65,7 @@ module Lambda { } module Block { - abstract class Range extends Callable::Range, ExprSequence::Range { + abstract class Range extends Callable::Range, StmtSequence::Range { Range() { not generated.getParent() instanceof Generated::Lambda } } } @@ -92,7 +92,7 @@ module BraceBlock { result = generated.getParameters().getChild(n) } - final override Expr getExpr(int i) { result = generated.getChild(i) } + final override Stmt getStmt(int i) { result = generated.getChild(i) } final override string toString() { result = "{ ... }" } } diff --git a/ql/src/codeql_ruby/controlflow/CfgNodes.qll b/ql/src/codeql_ruby/controlflow/CfgNodes.qll index 4ab22541942..42466e3df20 100644 --- a/ql/src/codeql_ruby/controlflow/CfgNodes.qll +++ b/ql/src/codeql_ruby/controlflow/CfgNodes.qll @@ -292,21 +292,18 @@ module ExprNodes { final ExprCfgNode getBranch(boolean cond) { e.hasCfgChild(e.getBranch(cond), this, result) } } - private class ExprSequenceChildMapping extends ExprChildMapping, ExprSequence { - override predicate relevantChild(Expr e) { e = this.getAnExpr() } + private class StmtSequenceChildMapping extends ExprChildMapping, StmtSequence { + override predicate relevantChild(Expr e) { e = this.getLastExpr() } } - /** A control-flow node that wraps an `ExprSequence` AST expression. */ - class ExprSequenceCfgNode extends ExprCfgNode { - override ExprSequenceChildMapping e; + /** A control-flow node that wraps a `StmtSequence` AST expression. */ + class StmtSequenceCfgNode extends ExprCfgNode { + override StmtSequenceChildMapping e; - final override ExprSequence getExpr() { result = ExprCfgNode.super.getExpr() } + final override StmtSequence getExpr() { result = ExprCfgNode.super.getExpr() } /** Gets the last expression in this sequence, if any. */ final ExprCfgNode getLastExpr() { e.hasCfgChild(e.getLastExpr(), this, result) } - - /** Gets the 'n'th expression of this expression sequence. */ - final ExprCfgNode getExpr(int n) { e.hasCfgChild(e.getExpr(n), this, result) } } private class ForExprChildMapping extends ExprChildMapping, ForExpr { @@ -324,7 +321,7 @@ module ExprNodes { } /** A control-flow node that wraps a `ParenthesizedExpr` AST expression. */ - class ParenthesizedExprCfgNode extends ExprSequenceCfgNode { + class ParenthesizedExprCfgNode extends StmtSequenceCfgNode { ParenthesizedExprCfgNode() { this.getExpr() instanceof ParenthesizedExpr } } diff --git a/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll b/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll index 38669d32736..222fa8ac7bb 100644 --- a/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll +++ b/ql/src/codeql_ruby/dataflow/internal/DataFlowPrivate.qll @@ -126,7 +126,7 @@ private module Cached { or nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::AssignExprCfgNode).getRhs() or - nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::ExprSequenceCfgNode).getLastExpr() + nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::StmtSequenceCfgNode).getLastExpr() or nodeFrom.asExpr() = nodeTo.asExpr().(CfgNodes::ExprNodes::ConditionalExprCfgNode).getBranch(_) or diff --git a/ql/test/library-tests/ast/control/CaseExpr.ql b/ql/test/library-tests/ast/control/CaseExpr.ql index 297b6b3577c..eaef9359f55 100644 --- a/ql/test/library-tests/ast/control/CaseExpr.ql +++ b/ql/test/library-tests/ast/control/CaseExpr.ql @@ -4,13 +4,13 @@ query predicate caseValues(CaseExpr c, Expr value) { value = c.getValue() } query predicate caseNoValues(CaseExpr c) { not exists(c.getValue()) } -query predicate caseElseBranches(CaseExpr c, ExprSequence elseBranch) { +query predicate caseElseBranches(CaseExpr c, StmtSequence elseBranch) { elseBranch = c.getElseBranch() } query predicate caseNoElseBranches(CaseExpr c) { not exists(c.getElseBranch()) } -query predicate caseWhenBranches(CaseExpr c, WhenExpr when, int pIndex, Expr p, ExprSequence body) { +query predicate caseWhenBranches(CaseExpr c, WhenExpr when, int pIndex, Expr p, StmtSequence body) { when = c.getAWhenBranch() and p = when.getPattern(pIndex) and body = when.getBody() diff --git a/ql/test/library-tests/ast/control/ConditionalExpr.ql b/ql/test/library-tests/ast/control/ConditionalExpr.ql index 48c1e2630c9..6e209b2d3fc 100644 --- a/ql/test/library-tests/ast/control/ConditionalExpr.ql +++ b/ql/test/library-tests/ast/control/ConditionalExpr.ql @@ -9,7 +9,7 @@ query predicate conditionalExprs( } query predicate ifExprs( - IfExpr e, string pClass, Expr cond, ExprSequence thenExpr, string elseStr, boolean isElsif + IfExpr e, string pClass, Expr cond, StmtSequence thenExpr, string elseStr, boolean isElsif ) { pClass = e.getAPrimaryQlClass() and cond = e.getCondition() and @@ -19,7 +19,7 @@ query predicate ifExprs( } query predicate unlessExprs( - UnlessExpr e, string pClass, Expr cond, ExprSequence thenExpr, string elseStr + UnlessExpr e, string pClass, Expr cond, StmtSequence thenExpr, string elseStr ) { pClass = e.getAPrimaryQlClass() and cond = e.getCondition() and diff --git a/ql/test/library-tests/ast/control/Loop.expected b/ql/test/library-tests/ast/control/Loop.expected index 0da638e8b21..0c32647e0be 100644 --- a/ql/test/library-tests/ast/control/Loop.expected +++ b/ql/test/library-tests/ast/control/Loop.expected @@ -1,20 +1,20 @@ loops -| loops.rb:9:1:12:3 | for ... in ... | ForExpr | loops.rb:9:15:12:3 | ...; ... | ExprSequence | -| loops.rb:16:1:19:3 | for ... in ... | ForExpr | loops.rb:16:15:19:3 | ...; ... | ExprSequence | -| loops.rb:22:1:25:3 | for ... in ... | ForExpr | loops.rb:22:35:25:3 | ...; ... | ExprSequence | -| loops.rb:28:1:32:3 | for ... in ... | ForExpr | loops.rb:28:37:32:3 | ...; ... | ExprSequence | -| loops.rb:35:1:39:3 | while ... | WhileExpr | loops.rb:35:12:39:3 | ...; ... | ExprSequence | -| loops.rb:42:1:45:3 | while ... | WhileExpr | loops.rb:42:13:45:3 | ...; ... | ExprSequence | +| 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: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 | ...; ... | ExprSequence | -| loops.rb:57:1:60:3 | until ... | UntilExpr | loops.rb:57:13:60:3 | ...; ... | ExprSequence | +| 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:63:1:63:19 | ... until ... | UntilModifierExpr | loops.rb:63:1:63:6 | ... -= ... | AssignSubExpr | conditionalLoops -| loops.rb:35:1:39:3 | while ... | WhileExpr | loops.rb:35:7:35:11 | ... < ... | loops.rb:35:12:39:3 | ...; ... | ExprSequence | -| loops.rb:42:1:45:3 | while ... | WhileExpr | loops.rb:42:7:42:11 | ... < ... | loops.rb:42:13:45:3 | ...; ... | ExprSequence | +| 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: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 | ...; ... | ExprSequence | -| loops.rb:57:1:60:3 | until ... | UntilExpr | loops.rb:57:7:57:11 | ... > ... | loops.rb:57:13:60:3 | ...; ... | ExprSequence | +| 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:63:1:63:19 | ... until ... | UntilModifierExpr | loops.rb:63:14:63:19 | ... == ... | loops.rb:63:1:63:6 | ... -= ... | AssignSubExpr | 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 | ... += ... | diff --git a/ql/test/library-tests/ast/control/Loop.ql b/ql/test/library-tests/ast/control/Loop.ql index e8b2b30b107..6bae94fe352 100644 --- a/ql/test/library-tests/ast/control/Loop.ql +++ b/ql/test/library-tests/ast/control/Loop.ql @@ -13,10 +13,10 @@ query predicate conditionalLoops( cond = l.getCondition() } -query predicate forExprs(ForExpr f, Pattern p, ExprSequence body, int i, Expr bodyChild) { +query predicate forExprs(ForExpr f, Pattern p, StmtSequence body, int i, Expr bodyChild) { p = f.getPattern() and body = f.getBody() and - bodyChild = body.getExpr(i) + bodyChild = body.getStmt(i) } query predicate forExprsTuplePatterns(ForExpr f, TuplePattern tp, int i, Pattern cp) { @@ -24,10 +24,10 @@ query predicate forExprsTuplePatterns(ForExpr f, TuplePattern tp, int i, Pattern cp = tp.getElement(i) } -query predicate whileExprs(WhileExpr e, Expr cond, ExprSequence body, int i, Expr bodyChild) { +query predicate whileExprs(WhileExpr e, Expr cond, StmtSequence body, int i, Expr bodyChild) { cond = e.getCondition() and body = e.getBody() and - bodyChild = body.getExpr(i) + bodyChild = body.getStmt(i) } query predicate whileModifierExprs(WhileModifierExpr e, Expr cond, Expr body) { @@ -35,10 +35,10 @@ query predicate whileModifierExprs(WhileModifierExpr e, Expr cond, Expr body) { body = e.getBody() } -query predicate untilExprs(UntilExpr e, Expr cond, ExprSequence body, int i, Expr bodyChild) { +query predicate untilExprs(UntilExpr e, Expr cond, StmtSequence body, int i, Expr bodyChild) { cond = e.getCondition() and body = e.getBody() and - bodyChild = body.getExpr(i) + bodyChild = body.getStmt(i) } query predicate untilModifierExprs(UntilModifierExpr e, Expr cond, Expr body) { diff --git a/ql/test/library-tests/ast/modules/classes.ql b/ql/test/library-tests/ast/modules/classes.ql index 7293e193768..52d6ed21e51 100644 --- a/ql/test/library-tests/ast/modules/classes.ql +++ b/ql/test/library-tests/ast/modules/classes.ql @@ -9,7 +9,7 @@ query predicate classesWithNameScopeExprs(Class c, Expr se) { se = c.getScopeExp query predicate classesWithGlobalNameScopeExprs(Class c) { c.hasGlobalScope() } query predicate exprsInClasses(Class c, int i, Expr e, string eClass) { - e = c.getExpr(i) and eClass = e.getAPrimaryQlClass() + e = c.getStmt(i) and eClass = e.getAPrimaryQlClass() } query predicate methodsInClasses(Class c, Method m, string name) { m = c.getMethod(name) } diff --git a/ql/test/library-tests/ast/modules/modules.ql b/ql/test/library-tests/ast/modules/modules.ql index 8f7d7a952c5..cce336c8b5c 100644 --- a/ql/test/library-tests/ast/modules/modules.ql +++ b/ql/test/library-tests/ast/modules/modules.ql @@ -9,7 +9,7 @@ query predicate modulesWithScopeExprs(Module m, Expr se) { se = m.getScopeExpr() query predicate modulesWithGlobalNameScopeExprs(Module m) { m.hasGlobalScope() } query predicate exprsInModules(Module m, int i, Expr e, string eClass) { - e = m.getExpr(i) and eClass = e.getAPrimaryQlClass() + e = m.getStmt(i) and eClass = e.getAPrimaryQlClass() } query predicate methodsInModules(Module mod, Method method, string name) { diff --git a/ql/test/library-tests/ast/modules/singleton_classes.ql b/ql/test/library-tests/ast/modules/singleton_classes.ql index 83e0da59ce2..d02dd8cb68c 100644 --- a/ql/test/library-tests/ast/modules/singleton_classes.ql +++ b/ql/test/library-tests/ast/modules/singleton_classes.ql @@ -5,7 +5,7 @@ query predicate singletonClasses(SingletonClass sc, string pClass, Expr value) { } query predicate exprsInSingletonClasses(SingletonClass sc, int i, Expr e, string eClass) { - e = sc.getExpr(i) and eClass = e.getAPrimaryQlClass() + e = sc.getStmt(i) and eClass = e.getAPrimaryQlClass() } query predicate methodsInSingletonClasses(SingletonClass sc, Method m) { m = sc.getAMethod() }