Skip to content

Commit 06ec03d

Browse files
committed
Ruby: add convenience-accessors for ConstantValue
1 parent 046e669 commit 06ec03d

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,24 @@ module ConstantValue {
170170

171171
/** A constant `nil` value. */
172172
class ConstantNilValue extends ConstantValue, TNil { }
173+
174+
/** Gets the integer constant `x`. */
175+
ConstantValue getInt(int x) { result.getInt() = x }
176+
177+
/** Gets the float constant `x`. */
178+
ConstantValue getFloat(float x) { result.getFloat() = x }
179+
180+
/** Gets the string constant `x`. */
181+
ConstantValue getString(string x) { result.getString() = x }
182+
183+
/** Gets the symbol constant `x`. */
184+
ConstantValue getSymbol(string x) { result.getSymbol() = x }
185+
186+
/** Gets the regexp constant `x`. */
187+
ConstantValue getRegExp(string x) { result.getRegExp() = x }
188+
189+
/** Gets the string, symbol, or regexp constant `x`. */
190+
ConstantValue getStringlikeValue(string x) { result.getStringlikeValue() = x }
173191
}
174192

175193
/** An access to a constant. */

0 commit comments

Comments
 (0)