Skip to content

Commit 99ddfb4

Browse files
committed
Ruby: Rework getConstantValue implementation
1 parent 80fb021 commit 99ddfb4

File tree

7 files changed

+971
-764
lines changed

7 files changed

+971
-764
lines changed

ruby/ql/lib/codeql/ruby/ast/Constant.qll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,6 @@ class ConstantReadAccess extends ConstantAccess {
240240
result = lookupConst(resolveConstantReadAccess(this.getScopeExpr()), this.getName())
241241
}
242242

243-
final override ConstantValue getConstantValue() { result = this.getValue().getConstantValue() }
244-
245243
final override string getAPrimaryQlClass() { result = "ConstantReadAccess" }
246244
}
247245

ruby/ql/lib/codeql/ruby/ast/Expr.qll

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ private import codeql.ruby.AST
22
private import codeql.ruby.CFG
33
private import codeql.ruby.ast.Constant
44
private import internal.AST
5+
private import internal.Constant
56
private import internal.Expr
67
private import internal.TreeSitter
78

@@ -19,9 +20,7 @@ class Expr extends Stmt, TExpr {
1920
deprecated string getValueText() { result = this.getConstantValue().toString() }
2021

2122
/** Gets the constant value of this expression, if any. */
22-
ConstantValue getConstantValue() {
23-
forex(CfgNodes::ExprCfgNode n | n = this.getAControlFlowNode() | result = n.getConstantValue())
24-
}
23+
ConstantValue getConstantValue() { result = getConstantValueExpr(this) }
2524
}
2625

2726
/** DEPRECATED: Use `SelfVariableAccess` instead. */

0 commit comments

Comments
 (0)