@@ -501,42 +501,41 @@ class Position extends TPosition {
501
501
abstract string toString ( ) ;
502
502
}
503
503
504
- class ThisPosition extends TThisPosition {
505
- string toString ( ) { result = "this" }
506
- }
507
-
508
- class ThisIndirectionPosition extends TThisIndirectionPosition {
509
- string toString ( ) { result = "this" }
510
- }
511
-
512
- class Positional extends TPositional {
504
+ class DirectPosition extends TDirectPosition {
513
505
int index ;
514
506
515
- Positional ( ) { this = TPositional ( index ) }
516
-
517
- string toString ( ) { result = index .toString ( ) }
507
+ DirectPosition ( ) { this = TDirectPosition ( index ) }
518
508
519
- int getIndex ( ) {
520
- result = index
509
+ string toString ( ) {
510
+ index = - 1 and
511
+ result = "this"
512
+ or
513
+ index != - 1 and
514
+ result = index .toString ( )
521
515
}
516
+
517
+ int getIndex ( ) { result = index }
522
518
}
523
519
524
- class PositionalIndirection extends TPositionalIndirection {
520
+ class IndirectionPosition extends TIndirectionPosition {
525
521
int index ;
526
522
527
- PositionalIndirection ( ) { this = TPositionalIndirection ( index ) }
523
+ IndirectionPosition ( ) { this = TIndirectionPosition ( index ) }
528
524
529
- string toString ( ) { result = index .toString ( ) }
530
- int getIndex ( ) {
531
- result = index
525
+ string toString ( ) {
526
+ index = - 1 and
527
+ result = "this"
528
+ or
529
+ index != - 1 and
530
+ result = index .toString ( )
532
531
}
532
+
533
+ int getIndex ( ) { result = index }
533
534
}
534
535
535
536
newtype TPosition =
536
- TThisPosition ( ) or
537
- TThisIndirectionPosition ( ) or
538
- TPositional ( int index ) { exists ( any ( Call c ) .getArgument ( index ) ) } or
539
- TPositionalIndirection ( int index ) { exists ( any ( Call c ) .getArgument ( index ) ) }
537
+ TDirectPosition ( int index ) { exists ( any ( CallInstruction c ) .getArgument ( index ) ) } or
538
+ TIndirectionPosition ( int index ) { exists ( any ( CallInstruction c ) .getArgument ( index ) ) }
540
539
541
540
/**
542
541
* The value of a parameter at function entry, viewed as a node in a data
@@ -570,7 +569,7 @@ private class ExplicitParameterNode extends ParameterNode {
570
569
ExplicitParameterNode ( ) { exists ( instr .getParameter ( ) ) }
571
570
572
571
override predicate isParameterOf ( Function f , ParameterPosition pos ) {
573
- f .getParameter ( pos .( Positional ) .getIndex ( ) ) = instr .getParameter ( )
572
+ f .getParameter ( pos .( DirectPosition ) .getIndex ( ) ) = instr .getParameter ( )
574
573
}
575
574
576
575
/** Gets the `Parameter` associated with this node. */
@@ -586,7 +585,7 @@ class ThisParameterNode extends ParameterNode {
586
585
ThisParameterNode ( ) { instr .getIRVariable ( ) instanceof IRThisVariable }
587
586
588
587
override predicate isParameterOf ( Function f , ParameterPosition pos ) {
589
- pos instanceof ThisPosition and instr .getEnclosingFunction ( ) = f
588
+ pos . ( DirectPosition ) . getIndex ( ) = - 1 and instr .getEnclosingFunction ( ) = f
590
589
}
591
590
592
591
override string toString ( ) { result = "this" }
@@ -601,12 +600,8 @@ class ParameterIndirectionNode extends ParameterNode {
601
600
instr .getEnclosingFunction ( ) = f and
602
601
instr .hasIndex ( index )
603
602
|
604
- pos .( PositionalIndirection ) .getIndex ( ) = index
603
+ pos .( IndirectionPosition ) .getIndex ( ) = index
605
604
)
606
- or
607
- instr .getEnclosingFunction ( ) = f and
608
- instr .hasIndex ( - 1 ) and
609
- pos instanceof ThisIndirectionPosition
610
605
}
611
606
612
607
override string toString ( ) { result = "*" + instr .getIRVariable ( ) .toString ( ) }
0 commit comments