@@ -501,42 +501,41 @@ class Position extends TPosition {
501501 abstract string toString ( ) ;
502502}
503503
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 {
513505 int index ;
514506
515- Positional ( ) { this = TPositional ( index ) }
516-
517- string toString ( ) { result = index .toString ( ) }
507+ DirectPosition ( ) { this = TDirectPosition ( index ) }
518508
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 ( )
521515 }
516+
517+ int getIndex ( ) { result = index }
522518}
523519
524- class PositionalIndirection extends TPositionalIndirection {
520+ class IndirectionPosition extends TIndirectionPosition {
525521 int index ;
526522
527- PositionalIndirection ( ) { this = TPositionalIndirection ( index ) }
523+ IndirectionPosition ( ) { this = TIndirectionPosition ( index ) }
528524
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 ( )
532531 }
532+
533+ int getIndex ( ) { result = index }
533534}
534535
535536newtype 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 ) ) }
540539
541540/**
542541 * The value of a parameter at function entry, viewed as a node in a data
@@ -570,7 +569,7 @@ private class ExplicitParameterNode extends ParameterNode {
570569 ExplicitParameterNode ( ) { exists ( instr .getParameter ( ) ) }
571570
572571 override predicate isParameterOf ( Function f , ParameterPosition pos ) {
573- f .getParameter ( pos .( Positional ) .getIndex ( ) ) = instr .getParameter ( )
572+ f .getParameter ( pos .( DirectPosition ) .getIndex ( ) ) = instr .getParameter ( )
574573 }
575574
576575 /** Gets the `Parameter` associated with this node. */
@@ -586,7 +585,7 @@ class ThisParameterNode extends ParameterNode {
586585 ThisParameterNode ( ) { instr .getIRVariable ( ) instanceof IRThisVariable }
587586
588587 override predicate isParameterOf ( Function f , ParameterPosition pos ) {
589- pos instanceof ThisPosition and instr .getEnclosingFunction ( ) = f
588+ pos . ( DirectPosition ) . getIndex ( ) = - 1 and instr .getEnclosingFunction ( ) = f
590589 }
591590
592591 override string toString ( ) { result = "this" }
@@ -601,12 +600,8 @@ class ParameterIndirectionNode extends ParameterNode {
601600 instr .getEnclosingFunction ( ) = f and
602601 instr .hasIndex ( index )
603602 |
604- pos .( PositionalIndirection ) .getIndex ( ) = index
603+ pos .( IndirectionPosition ) .getIndex ( ) = index
605604 )
606- or
607- instr .getEnclosingFunction ( ) = f and
608- instr .hasIndex ( - 1 ) and
609- pos instanceof ThisIndirectionPosition
610605 }
611606
612607 override string toString ( ) { result = "*" + instr .getIRVariable ( ) .toString ( ) }
0 commit comments