Skip to content

Commit 8372ad9

Browse files
authored
Merge pull request github#12169 from hvitved/util/numbers
Move `NumberUtils.qll` from Ruby into shared `util` pack
2 parents 4fa484d + 2113c3c commit 8372ad9

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

ruby/ql/lib/codeql/ruby/ast/internal/Literal.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ private import Constant
44
private import TreeSitter
55
private import codeql.ruby.ast.internal.Scope
66
private import codeql.ruby.controlflow.CfgNodes
7-
private import codeql.NumberUtils
7+
private import codeql.util.Numbers
88

99
int parseInteger(Ruby::Integer i) {
1010
exists(string s | s = i.getValue().toLowerCase().replaceAll("_", "") |

ruby/ql/lib/codeql/ruby/regexp/RegExpTreeView.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/** Provides a class hierarchy corresponding to a parse tree of regular expressions. */
22

33
private import internal.ParseRegExp
4-
private import codeql.NumberUtils
4+
private import codeql.util.Numbers
55
private import codeql.ruby.ast.Literal as Ast
66
private import codeql.Locations
77
private import codeql.regex.nfa.NfaUtils as NfaUtils

ruby/ql/lib/qlpack.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ dependencies:
99
codeql/regex: ${workspace}
1010
codeql/ssa: ${workspace}
1111
codeql/tutorial: ${workspace}
12+
codeql/util: ${workspace}
1213
dataExtensions:
1314
- codeql/ruby/frameworks/**/model.yml

ruby/ql/lib/codeql/NumberUtils.qll renamed to shared/util/codeql/util/Numbers.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ private int toHex(string hex) {
104104
* Gets the value of 16 to the power of `n`. Holds only for `n` in the range
105105
* 0..7 (inclusive).
106106
*/
107-
int sixteenToThe(int n) {
107+
private int sixteenToThe(int n) {
108108
// 16**7 is the largest power of 16 that fits in an int.
109109
n in [0 .. 7] and result = 1.bitShiftLeft(4 * n)
110110
}
@@ -113,7 +113,7 @@ int sixteenToThe(int n) {
113113
* Gets the value of 8 to the power of `n`. Holds only for `n` in the range
114114
* 0..10 (inclusive).
115115
*/
116-
int eightToThe(int n) {
116+
private int eightToThe(int n) {
117117
// 8**10 is the largest power of 8 that fits in an int.
118118
n in [0 .. 10] and result = 1.bitShiftLeft(3 * n)
119119
}
@@ -122,7 +122,7 @@ int eightToThe(int n) {
122122
* Gets the value of 2 to the power of `n`. Holds only for `n` in the range
123123
* 0..30 (inclusive).
124124
*/
125-
int twoToThe(int n) { n in [0 .. 30] and result = 1.bitShiftLeft(n) }
125+
private int twoToThe(int n) { n in [0 .. 30] and result = 1.bitShiftLeft(n) }
126126

127127
/** Gets `s` with any leading "0" characters removed. */
128128
bindingset[s]

0 commit comments

Comments
 (0)