AST: rename getLhs/getRhs to getLeftOperand/getRightOperand

This commit is contained in:
Arthur Baars
2021-02-18 13:25:03 +01:00
parent 095eb803b3
commit c0b5ac760a
5 changed files with 18 additions and 16 deletions

View File

@@ -445,10 +445,10 @@ class Assignment extends Operation {
override Assignment::Range range;
/** Gets the left hand side of this assignment. */
final Expr getLhs() { result = range.getLhs() }
final Expr getLeftOperand() { result = range.getLeftOperand() }
/** Gets the right hand side of this assignment. */
final Expr getRhs() { result = range.getRhs() }
final Expr getRightOperand() { result = range.getRightOperand() }
}
/**

View File

@@ -156,7 +156,7 @@ class VariableReadAccess extends VariableAccess {
not this instanceof VariableWriteAccess
or
// `x` in `x += y` is considered both a read and a write
this = any(AssignOperation a).getLhs()
this = any(AssignOperation a).getLeftOperand()
}
}

View File

@@ -218,11 +218,13 @@ module NoRegexMatchExpr {
module Assignment {
abstract class Range extends Operation::Range {
abstract Expr getLhs();
abstract Pattern getLeftOperand();
abstract Expr getRhs();
abstract Expr getRightOperand();
final override Expr getAnOperand() { result = this.getLhs() or result = this.getRhs() }
final override Expr getAnOperand() {
result = this.getLeftOperand() or result = this.getRightOperand()
}
override string toString() { result = "... " + this.getOperator() + " ..." }
}
@@ -232,9 +234,9 @@ module AssignExpr {
class Range extends Assignment::Range, @assignment {
final override Generated::Assignment generated;
final override Expr getLhs() { result = generated.getLeft() }
final override Pattern getLeftOperand() { result = generated.getLeft() }
final override Expr getRhs() { result = generated.getRight() }
final override Expr getRightOperand() { result = generated.getRight() }
final override string getOperator() { result = "=" }
}
@@ -246,9 +248,9 @@ module AssignOperation {
final override string getOperator() { result = generated.getOperator() }
final override LhsExpr getLhs() { result = generated.getLeft() }
final override LhsExpr getLeftOperand() { result = generated.getLeft() }
final override Expr getRhs() { result = generated.getRight() }
final override Expr getRightOperand() { result = generated.getRight() }
}
}

View File

@@ -218,10 +218,10 @@ module ExprNodes {
final override Assignment getExpr() { result = ExprCfgNode.super.getExpr() }
/** Gets the LHS of this assignment. */
final ExprCfgNode getLhs() { e.hasCfgChild(e.getLhs(), this, result) }
final ExprCfgNode getLhs() { e.hasCfgChild(e.getLeftOperand(), this, result) }
/** Gets the RHS of this assignment. */
final ExprCfgNode getRhs() { e.hasCfgChild(e.getRhs(), this, result) }
final ExprCfgNode getRhs() { e.hasCfgChild(e.getRightOperand(), this, result) }
}
/** A control-flow node that wraps an `AssignExpr` AST expression. */

View File

@@ -2,8 +2,8 @@ import ruby
query predicate assignments(Assignment a, string operator, Expr left, Expr right, string pClass) {
operator = a.getOperator() and
left = a.getLhs() and
right = a.getRhs() and
left = a.getLeftOperand() and
right = a.getRightOperand() and
pClass = a.getAPrimaryQlClass()
}
@@ -11,8 +11,8 @@ query predicate assignOperations(
AssignOperation o, string operator, Expr left, Expr right, string pClass
) {
operator = o.getOperator() and
left = o.getLhs() and
right = o.getRhs() and
left = o.getLeftOperand() and
right = o.getRightOperand() and
pClass = o.getAPrimaryQlClass()
}