@@ -130,20 +130,34 @@ abstract private class NonExprChildMapping extends ChildMapping {
130
130
abstract private class AbstractCallCfgNode extends AstCfgNode {
131
131
override string getAPrimaryQlClass ( ) { result = "CfgCall" }
132
132
133
+ /** Holds if this call invokes a function with the name `name`. */
133
134
final predicate hasName ( string name ) { this .getName ( ) = name }
134
135
136
+ /** Gets the name of the function that is invoked by this call. */
135
137
abstract string getName ( ) ;
136
138
139
+ /** Gets the qualifier of this call, if any. */
137
140
ExprCfgNode getQualifier ( ) { none ( ) }
138
141
142
+ /** Gets the i'th argument to this call. */
139
143
abstract ExprCfgNode getArgument ( int i ) ;
140
144
145
+ /** Gets the i'th positional argument to this call. */
141
146
abstract ExprCfgNode getPositionalArgument ( int i ) ;
142
147
148
+ /** Gets the argument with the name `name`, if any. */
143
149
abstract ExprCfgNode getNamedArgument ( string name ) ;
144
150
151
+ /**
152
+ * Gets any argument of this call.
153
+ *
154
+ * Note that this predicate doesn't get the pipeline argument, if any.
155
+ */
145
156
abstract ExprCfgNode getAnArgument ( ) ;
146
157
158
+ /**
159
+ * Gets the expression that provides the call target of this call, if any.
160
+ */
147
161
abstract ExprCfgNode getCommand ( ) ;
148
162
}
149
163
@@ -381,12 +395,12 @@ module ExprNodes {
381
395
}
382
396
383
397
module StmtNodes {
384
- private class CmdChildMapping extends NonExprChildMapping , Cmd {
398
+ private class CmdChildMapping extends CmdBaseChildMapping , Cmd {
385
399
override predicate relevantChild ( Ast n ) { n = this .getAnArgument ( ) or n = this .getCommand ( ) }
386
400
}
387
401
388
402
/** A control-flow node that wraps a `Cmd` AST expression. */
389
- class CmdCfgNode extends StmtCfgNode , AbstractCallCfgNode {
403
+ class CmdCfgNode extends CmdBaseCfgNode , AbstractCallCfgNode {
390
404
override string getAPrimaryQlClass ( ) { result = "CmdCfgNode" }
391
405
392
406
override CmdChildMapping s ;
@@ -410,14 +424,14 @@ module StmtNodes {
410
424
final override string getName ( ) { result = s .getCmdName ( ) .getValue ( ) .getValue ( ) }
411
425
}
412
426
413
- private class AssignStmtChildMapping extends NonExprChildMapping , AssignStmt {
427
+ private class AssignStmtChildMapping extends PipelineBaseChildMapping , AssignStmt {
414
428
override predicate relevantChild ( Ast n ) {
415
429
n = this .getLeftHandSide ( ) or n = this .getRightHandSide ( )
416
430
}
417
431
}
418
432
419
433
/** A control-flow node that wraps an `AssignStmt` AST expression. */
420
- class AssignStmtCfgNode extends StmtCfgNode {
434
+ class AssignStmtCfgNode extends PipelineBaseCfgNode {
421
435
override string getAPrimaryQlClass ( ) { result = "AssignCfgNode" }
422
436
423
437
override AssignStmtChildMapping s ;
@@ -431,12 +445,12 @@ module StmtNodes {
431
445
final StmtCfgNode getRightHandSide ( ) { s .hasCfgChild ( s .getRightHandSide ( ) , this , result ) }
432
446
}
433
447
434
- class CmdExprChildMapping extends NonExprChildMapping , CmdExpr {
448
+ class CmdExprChildMapping extends CmdBaseChildMapping , CmdExpr {
435
449
override predicate relevantChild ( Ast n ) { n = this .getExpr ( ) }
436
450
}
437
451
438
452
/** A control-flow node that wraps a `CmdExpr` expression. */
439
- class CmdExprCfgNode extends StmtCfgNode {
453
+ class CmdExprCfgNode extends CmdBaseCfgNode {
440
454
override string getAPrimaryQlClass ( ) { result = "CmdExprCfgNode" }
441
455
442
456
override CmdExprChildMapping s ;
@@ -445,4 +459,70 @@ module StmtNodes {
445
459
446
460
final ExprCfgNode getExpr ( ) { s .hasCfgChild ( s .getExpr ( ) , this , result ) }
447
461
}
462
+
463
+ class PipelineBaseChildMapping extends NonExprChildMapping , PipelineBase {
464
+ override predicate relevantChild ( Ast n ) { none ( ) }
465
+ }
466
+
467
+ class PipelineBaseCfgNode extends StmtCfgNode {
468
+ override string getAPrimaryQlClass ( ) { result = "PipelineBaseCfgNode" }
469
+
470
+ override PipelineBaseChildMapping s ;
471
+
472
+ override PipelineBase getStmt ( ) { result = super .getStmt ( ) }
473
+ }
474
+
475
+ class ChainableChildMapping extends PipelineBaseChildMapping , Chainable {
476
+ override predicate relevantChild ( Ast n ) { none ( ) }
477
+ }
478
+
479
+ class ChainableCfgNode extends PipelineBaseCfgNode {
480
+ override string getAPrimaryQlClass ( ) { result = "ChainableCfgNode" }
481
+
482
+ override ChainableChildMapping s ;
483
+
484
+ override Chainable getStmt ( ) { result = super .getStmt ( ) }
485
+ }
486
+
487
+ class PipelineChainChildMapping extends ChainableChildMapping , PipelineChain {
488
+ override predicate relevantChild ( Ast n ) { n = this .getLeft ( ) or n = this .getRight ( ) }
489
+ }
490
+
491
+ class PipelineChainCfgNode extends ChainableCfgNode {
492
+ override string getAPrimaryQlClass ( ) { result = "PipelineChainCfgNode" }
493
+
494
+ override PipelineChainChildMapping s ;
495
+
496
+ override PipelineChain getStmt ( ) { result = super .getStmt ( ) }
497
+
498
+ final ChainableCfgNode getLeft ( ) { s .hasCfgChild ( s .getLeft ( ) , this , result ) }
499
+
500
+ final ChainableCfgNode getRight ( ) { s .hasCfgChild ( s .getRight ( ) , this , result ) }
501
+ }
502
+
503
+ class CmdBaseChildMapping extends ChainableChildMapping , CmdBase { }
504
+
505
+ class CmdBaseCfgNode extends ChainableCfgNode {
506
+ override string getAPrimaryQlClass ( ) { result = "CmdBaseCfgNode" }
507
+
508
+ override CmdBaseChildMapping s ;
509
+
510
+ override CmdBase getStmt ( ) { result = super .getStmt ( ) }
511
+ }
512
+
513
+ class PipelineChildMapping extends ChainableChildMapping , Pipeline {
514
+ override predicate relevantChild ( Ast n ) { n = this .getAComponent ( ) }
515
+ }
516
+
517
+ class PipelineCfgNode extends ChainableCfgNode {
518
+ override string getAPrimaryQlClass ( ) { result = "PipelineCfgNode" }
519
+
520
+ override PipelineChildMapping s ;
521
+
522
+ override Pipeline getStmt ( ) { result = super .getStmt ( ) }
523
+
524
+ final CmdBaseCfgNode getComponent ( int i ) { s .hasCfgChild ( s .getComponent ( i ) , this , result ) }
525
+
526
+ final CmdBaseCfgNode getAComponent ( ) { s .hasCfgChild ( s .getAComponent ( ) , this , result ) }
527
+ }
448
528
}
0 commit comments