@@ -72,21 +72,24 @@ signature module InputSig1<LocationSig Location> {
7272
7373module Make1< LocationSig Location, InputSig1< Location > Input1> {
7474 private import Input1
75- private import codeql.util.DenseRank
7675
77- private module DenseRankInput implements DenseRankInputSig {
78- class Ranked = TypeParameter ;
76+ private module TypeParameter {
77+ private import codeql.util.DenseRank
7978
80- predicate getRank = getTypeParameterId / 1 ;
81- }
79+ private module DenseRankInput implements DenseRankInputSig {
80+ class Ranked = TypeParameter ;
8281
83- private int getTypeParameterRank ( TypeParameter tp ) {
84- tp = DenseRank< DenseRankInput > :: denseRank ( result )
85- }
82+ predicate getRank = getTypeParameterId / 1 ;
83+ }
8684
87- bindingset [ s]
88- private predicate decodeTypePathComponent ( string s , TypeParameter tp ) {
89- getTypeParameterRank ( tp ) = s .toInt ( )
85+ private int getTypeParameterRank ( TypeParameter tp ) {
86+ tp = DenseRank< DenseRankInput > :: denseRank ( result )
87+ }
88+
89+ string encode ( TypeParameter tp ) { result = getTypeParameterRank ( tp ) .toString ( ) }
90+
91+ bindingset [ s]
92+ TypeParameter decode ( string s ) { encode ( result ) = s }
9093 }
9194
9295 final private class String = string ;
@@ -123,10 +126,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
123126
124127 bindingset [ this ]
125128 private TypeParameter getTypeParameter ( int i ) {
126- exists ( string s |
127- s = this .splitAt ( "." , i ) and
128- decodeTypePathComponent ( s , result )
129- )
129+ result = TypeParameter:: decode ( this .splitAt ( "." , i ) )
130130 }
131131
132132 /** Gets a textual representation of this type path. */
@@ -159,13 +159,13 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
159159 /** Holds if this path starts with `tp`, followed by `suffix`. */
160160 bindingset [ this ]
161161 predicate isCons ( TypeParameter tp , TypePath suffix ) {
162- decodeTypePathComponent ( this , tp ) and
162+ tp = TypeParameter :: decode ( this ) and
163163 suffix .isEmpty ( )
164164 or
165165 exists ( int first |
166166 first = min ( this .indexOf ( "." ) ) and
167167 suffix = this .suffix ( first + 1 ) and
168- decodeTypePathComponent ( this .prefix ( first ) , tp )
168+ tp = TypeParameter :: decode ( this .prefix ( first ) )
169169 )
170170 }
171171 }
@@ -176,7 +176,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
176176 TypePath nil ( ) { result .isEmpty ( ) }
177177
178178 /** Gets the singleton type path `tp`. */
179- TypePath singleton ( TypeParameter tp ) { result = getTypeParameterRank ( tp ) . toString ( ) }
179+ TypePath singleton ( TypeParameter tp ) { result = TypeParameter :: encode ( tp ) }
180180
181181 /**
182182 * Gets the type path obtained by appending the singleton type path `tp`
0 commit comments