@@ -106,10 +106,6 @@ private import codeql.mad.ModelValidation as SharedModelVal
106106private import codeql.util.Unit
107107private import codeql.mad.static.MaD as SharedMaD
108108
109- private module MaD = SharedMaD:: ModelsAsData< Extensions > ;
110-
111- import MaD
112-
113109/**
114110 * A unit class for adding additional source model rows.
115111 *
@@ -149,92 +145,80 @@ predicate sinkModel(string row) { any(SinkModelCsv s).row(row) }
149145/** Holds if `row` is a summary model. */
150146predicate summaryModel ( string row ) { any ( SummaryModelCsv s ) .row ( row ) }
151147
152- /** Holds if a source model exists for the given parameters. */
153- predicate sourceModel (
154- string namespace , string type , boolean subtypes , string name , string signature , string ext ,
155- string output , string kind , string provenance , string model
156- ) {
157- exists ( string row |
158- sourceModel ( row ) and
159- row .splitAt ( ";" , 0 ) = namespace and
160- row .splitAt ( ";" , 1 ) = type and
161- row .splitAt ( ";" , 2 ) = subtypes .toString ( ) and
162- subtypes = [ true , false ] and
163- row .splitAt ( ";" , 3 ) = name and
164- row .splitAt ( ";" , 4 ) = signature and
165- row .splitAt ( ";" , 5 ) = ext and
166- row .splitAt ( ";" , 6 ) = output and
167- row .splitAt ( ";" , 7 ) = kind
168- ) and
169- provenance = "manual" and
170- model = ""
171- or
172- exists ( QlBuiltins:: ExtensionId madId |
173- Extensions:: sourceModel ( namespace , type , subtypes , name , signature , ext , output , kind ,
174- provenance , madId ) and
175- model = "MaD:" + madId .toString ( )
176- )
177- }
148+ private module MadInput implements SharedMaD:: InputSig {
149+ /** Holds if a source model exists for the given parameters. */
150+ predicate additionalSourceModel (
151+ string namespace , string type , boolean subtypes , string name , string signature , string ext ,
152+ string output , string kind , string provenance , string model
153+ ) {
154+ exists ( string row |
155+ sourceModel ( row ) and
156+ row .splitAt ( ";" , 0 ) = namespace and
157+ row .splitAt ( ";" , 1 ) = type and
158+ row .splitAt ( ";" , 2 ) = subtypes .toString ( ) and
159+ subtypes = [ true , false ] and
160+ row .splitAt ( ";" , 3 ) = name and
161+ row .splitAt ( ";" , 4 ) = signature and
162+ row .splitAt ( ";" , 5 ) = ext and
163+ row .splitAt ( ";" , 6 ) = output and
164+ row .splitAt ( ";" , 7 ) = kind
165+ ) and
166+ provenance = "manual" and
167+ model = ""
168+ }
178169
179- /** Holds if a sink model exists for the given parameters. */
180- predicate sinkModel (
181- string namespace , string type , boolean subtypes , string name , string signature , string ext ,
182- string input , string kind , string provenance , string model
183- ) {
184- exists ( string row |
185- sinkModel ( row ) and
186- row .splitAt ( ";" , 0 ) = namespace and
187- row .splitAt ( ";" , 1 ) = type and
188- row .splitAt ( ";" , 2 ) = subtypes .toString ( ) and
189- subtypes = [ true , false ] and
190- row .splitAt ( ";" , 3 ) = name and
191- row .splitAt ( ";" , 4 ) = signature and
192- row .splitAt ( ";" , 5 ) = ext and
193- row .splitAt ( ";" , 6 ) = input and
194- row .splitAt ( ";" , 7 ) = kind
195- ) and
196- provenance = "manual" and
197- model = ""
198- or
199- exists ( QlBuiltins:: ExtensionId madId |
200- Extensions:: sinkModel ( namespace , type , subtypes , name , signature , ext , input , kind , provenance ,
201- madId ) and
202- model = "MaD:" + madId .toString ( )
203- )
204- }
170+ /** Holds if a sink model exists for the given parameters. */
171+ predicate additionalSinkModel (
172+ string namespace , string type , boolean subtypes , string name , string signature , string ext ,
173+ string input , string kind , string provenance , string model
174+ ) {
175+ exists ( string row |
176+ sinkModel ( row ) and
177+ row .splitAt ( ";" , 0 ) = namespace and
178+ row .splitAt ( ";" , 1 ) = type and
179+ row .splitAt ( ";" , 2 ) = subtypes .toString ( ) and
180+ subtypes = [ true , false ] and
181+ row .splitAt ( ";" , 3 ) = name and
182+ row .splitAt ( ";" , 4 ) = signature and
183+ row .splitAt ( ";" , 5 ) = ext and
184+ row .splitAt ( ";" , 6 ) = input and
185+ row .splitAt ( ";" , 7 ) = kind
186+ ) and
187+ provenance = "manual" and
188+ model = ""
189+ }
205190
206- /**
207- * Holds if a summary model exists for the given parameters.
208- *
209- * This predicate does not expand `@` to `*`s.
210- */
211- private predicate summaryModel0 (
212- string namespace , string type , boolean subtypes , string name , string signature , string ext ,
213- string input , string output , string kind , string provenance , string model
214- ) {
215- exists ( string row |
216- summaryModel ( row ) and
217- row .splitAt ( ";" , 0 ) = namespace and
218- row .splitAt ( ";" , 1 ) = type and
219- row .splitAt ( ";" , 2 ) = subtypes .toString ( ) and
220- subtypes = [ true , false ] and
221- row .splitAt ( ";" , 3 ) = name and
222- row .splitAt ( ";" , 4 ) = signature and
223- row .splitAt ( ";" , 5 ) = ext and
224- row .splitAt ( ";" , 6 ) = input and
225- row .splitAt ( ";" , 7 ) = output and
226- row .splitAt ( ";" , 8 ) = kind
227- ) and
228- provenance = "manual" and
229- model = ""
230- or
231- exists ( QlBuiltins:: ExtensionId madId |
232- Extensions:: summaryModel ( namespace , type , subtypes , name , signature , ext , input , output , kind ,
233- provenance , madId ) and
234- model = "MaD:" + madId .toString ( )
235- )
191+ /**
192+ * Holds if a summary model exists for the given parameters.
193+ *
194+ * This predicate does not expand `@` to `*`s.
195+ */
196+ predicate additionalSummaryModel (
197+ string namespace , string type , boolean subtypes , string name , string signature , string ext ,
198+ string input , string output , string kind , string provenance , string model
199+ ) {
200+ exists ( string row |
201+ summaryModel ( row ) and
202+ row .splitAt ( ";" , 0 ) = namespace and
203+ row .splitAt ( ";" , 1 ) = type and
204+ row .splitAt ( ";" , 2 ) = subtypes .toString ( ) and
205+ subtypes = [ true , false ] and
206+ row .splitAt ( ";" , 3 ) = name and
207+ row .splitAt ( ";" , 4 ) = signature and
208+ row .splitAt ( ";" , 5 ) = ext and
209+ row .splitAt ( ";" , 6 ) = input and
210+ row .splitAt ( ";" , 7 ) = output and
211+ row .splitAt ( ";" , 8 ) = kind
212+ ) and
213+ provenance = "manual" and
214+ model = ""
215+ }
236216}
237217
218+ private module MaD = SharedMaD:: ModelsAsData< Extensions , MadInput > ;
219+
220+ import MaD
221+
238222/**
239223 * Holds if `input` is `input0`, but with all occurrences of `@` replaced
240224 * by `n` repetitions of `*` (and similarly for `output` and `output0`).
@@ -256,7 +240,7 @@ predicate summaryModel(
256240 string input , string output , string kind , string provenance , string model
257241) {
258242 exists ( string input0 , string output0 |
259- summaryModel0 ( namespace , type , subtypes , name , signature , ext , input0 , output0 , kind ,
243+ MaD :: summaryModel ( namespace , type , subtypes , name , signature , ext , input0 , output0 , kind ,
260244 provenance , model ) and
261245 expandInputAndOutput ( input0 , input , output0 , output ,
262246 [ 0 .. Private:: getMaxElementContentIndirectionIndex ( ) - 1 ] )
0 commit comments