1
1
private import ql
2
2
private import codeql_ql.ast.internal.TreeSitter
3
+ private import experimental.RA
3
4
4
5
/** Gets a timestamp corresponding to the number of seconds since the date Semmle was founded. */
5
6
bindingset[d, h, m, s, ms]
@@ -67,6 +68,8 @@ class Array extends JSON::Array {
67
68
float getFloat(int i) { result = this.getChild(i).(JSON::Number).getValue().toFloat() }
68
69
69
70
Array getArray(int i) { result = this.getChild(i) }
71
+
72
+ int getLength() { result = count(this.getChild(_)) }
70
73
}
71
74
72
75
/**
@@ -78,6 +81,10 @@ private float getRanked(Array a, int i) {
78
81
result = rank[i + 1](int j, float f | f = a.getFloat(j) and f >= 0 | f order by j)
79
82
}
80
83
84
+ private string getRankedLine(Array a, int i) {
85
+ result = rank[i + 1](int j, string s | s = a.getString(j) and s != "" | s order by j)
86
+ }
87
+
81
88
module EvaluatorLog {
82
89
class Entry extends Object { }
83
90
@@ -274,7 +281,32 @@ module KindPredicatesLog {
274
281
else result = "<Summary event>"
275
282
}
276
283
277
- Array getRA(string ordering) { result = this.getObject("ra").getArray(ordering) }
284
+ RA getRA() { result = this.getObject("ra") }
285
+ }
286
+
287
+ class PipeLine extends Array {
288
+ RA ra;
289
+ string raReference;
290
+
291
+ RA getRA() { result = ra }
292
+
293
+ string getRAReference() { result = raReference }
294
+
295
+ PipeLine() { this = ra.getArray(raReference) }
296
+
297
+ string getLineOfRA(int n) { result = getRankedLine(this, n) }
298
+
299
+ RAExpr getExpr(int n) { result.getPredicate() = this and result.getLine() = n }
300
+ }
301
+
302
+ class RA extends Object {
303
+ SummaryEvent evt;
304
+
305
+ SummaryEvent getEvent() { result = evt }
306
+
307
+ RA() { evt.getObject("ra") = this }
308
+
309
+ PipeLine getPipeLine(string name) { result = this.getArray(name) }
278
310
}
279
311
280
312
class SentinelEmpty extends SummaryEvent {
@@ -290,6 +322,23 @@ module KindPredicatesLog {
290
322
291
323
string getRAReference() { result = this.getString("raReference") }
292
324
325
+ PipeLine getPipeLine() {
326
+ exists(SummaryEvent evt | runs.getEvent() = evt |
327
+ result = evt.getRA().getPipeLine(pragma[only_bind_into](this.getRAReference()))
328
+ )
329
+ }
330
+
331
+ float getCount(int i, string raLine) {
332
+ result = this.getCount(i) and
333
+ raLine = this.getPipeLine().getLineOfRA(pragma[only_bind_into](i))
334
+ }
335
+
336
+ float getCountAndExpr(int i, RAExpr raExpr) {
337
+ result = this.getCount(i) and
338
+ raExpr.getPredicate() = this.getPipeLine() and
339
+ raExpr.getLine() = i
340
+ }
341
+
293
342
Array getCounts() { result = this.getArray("counts") }
294
343
295
344
float getCount(int i) { result = getRanked(this.getArray("counts"), i) }
@@ -338,7 +387,7 @@ module KindPredicatesLog {
338
387
* Gets the RA for this event. Unlike recursive predicates, a COMPUTE_SIMPLE
339
388
* event only has one pipeline ordering (and it's named "pipeline").
340
389
*/
341
- Array getRA () { result = this.getObject("ra").getArray("pipeline") }
390
+ PipeLine getPipeLine () { result = this.getObject("ra").getArray("pipeline") }
342
391
}
343
392
344
393
/** Gets the `index`'th event that's evaluated by `recursive`. */
@@ -481,4 +530,6 @@ module KindPredicatesLog {
481
530
class Extensional extends SummaryEvent {
482
531
Extensional() { evaluationStrategy = "EXTENSIONAL" }
483
532
}
533
+
534
+ class RAExpr = RAParser<PipeLine>::RAExpr;
484
535
}
0 commit comments