11private import ql
22private import codeql_ql.ast.internal.TreeSitter
3+ private import experimental.RA
34
45/** Gets a timestamp corresponding to the number of seconds since the date Semmle was founded. */
56bindingset [ d, h, m, s, ms]
@@ -67,6 +68,8 @@ class Array extends JSON::Array {
6768 float getFloat ( int i ) { result = this .getChild ( i ) .( JSON:: Number ) .getValue ( ) .toFloat ( ) }
6869
6970 Array getArray ( int i ) { result = this .getChild ( i ) }
71+
72+ int getLength ( ) { result = count ( this .getChild ( _) ) }
7073}
7174
7275/**
@@ -78,6 +81,10 @@ private float getRanked(Array a, int i) {
7881 result = rank [ i + 1 ] ( int j , float f | f = a .getFloat ( j ) and f >= 0 | f order by j )
7982}
8083
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+
8188module EvaluatorLog {
8289 class Entry extends Object { }
8390
@@ -274,7 +281,32 @@ module KindPredicatesLog {
274281 else result = "<Summary event>"
275282 }
276283
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 ) }
278310 }
279311
280312 class SentinelEmpty extends SummaryEvent {
@@ -290,6 +322,23 @@ module KindPredicatesLog {
290322
291323 string getRAReference ( ) { result = this .getString ( "raReference" ) }
292324
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+
293342 Array getCounts ( ) { result = this .getArray ( "counts" ) }
294343
295344 float getCount ( int i ) { result = getRanked ( this .getArray ( "counts" ) , i ) }
@@ -338,7 +387,7 @@ module KindPredicatesLog {
338387 * Gets the RA for this event. Unlike recursive predicates, a COMPUTE_SIMPLE
339388 * event only has one pipeline ordering (and it's named "pipeline").
340389 */
341- Array getRA ( ) { result = this .getObject ( "ra" ) .getArray ( "pipeline" ) }
390+ PipeLine getPipeLine ( ) { result = this .getObject ( "ra" ) .getArray ( "pipeline" ) }
342391 }
343392
344393 /** Gets the `index`'th event that's evaluated by `recursive`. */
@@ -481,4 +530,6 @@ module KindPredicatesLog {
481530 class Extensional extends SummaryEvent {
482531 Extensional ( ) { evaluationStrategy = "EXTENSIONAL" }
483532 }
533+
534+ class RAExpr = RAParser< PipeLine > :: RAExpr ;
484535}
0 commit comments