@@ -72,21 +72,24 @@ signature module InputSig1<LocationSig Location> {
72
72
73
73
module Make1< LocationSig Location, InputSig1< Location > Input1> {
74
74
private import Input1
75
- private import codeql.util.DenseRank
76
75
77
- private module DenseRankInput implements DenseRankInputSig {
78
- class Ranked = TypeParameter ;
76
+ private module TypeParameter {
77
+ private import codeql.util.DenseRank
79
78
80
- predicate getRank = getTypeParameterId / 1 ;
81
- }
79
+ private module DenseRankInput implements DenseRankInputSig {
80
+ class Ranked = TypeParameter ;
82
81
83
- private int getTypeParameterRank ( TypeParameter tp ) {
84
- tp = DenseRank< DenseRankInput > :: denseRank ( result )
85
- }
82
+ predicate getRank = getTypeParameterId / 1 ;
83
+ }
86
84
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 }
90
93
}
91
94
92
95
final private class String = string ;
@@ -123,10 +126,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
123
126
124
127
bindingset [ this ]
125
128
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 ) )
130
130
}
131
131
132
132
/** Gets a textual representation of this type path. */
@@ -159,13 +159,13 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
159
159
/** Holds if this path starts with `tp`, followed by `suffix`. */
160
160
bindingset [ this ]
161
161
predicate isCons ( TypeParameter tp , TypePath suffix ) {
162
- decodeTypePathComponent ( this , tp ) and
162
+ tp = TypeParameter :: decode ( this ) and
163
163
suffix .isEmpty ( )
164
164
or
165
165
exists ( int first |
166
166
first = min ( this .indexOf ( "." ) ) and
167
167
suffix = this .suffix ( first + 1 ) and
168
- decodeTypePathComponent ( this .prefix ( first ) , tp )
168
+ tp = TypeParameter :: decode ( this .prefix ( first ) )
169
169
)
170
170
}
171
171
}
@@ -176,7 +176,7 @@ module Make1<LocationSig Location, InputSig1<Location> Input1> {
176
176
TypePath nil ( ) { result .isEmpty ( ) }
177
177
178
178
/** Gets the singleton type path `tp`. */
179
- TypePath singleton ( TypeParameter tp ) { result = getTypeParameterRank ( tp ) . toString ( ) }
179
+ TypePath singleton ( TypeParameter tp ) { result = TypeParameter :: encode ( tp ) }
180
180
181
181
/**
182
182
* Gets the type path obtained by appending the singleton type path `tp`
0 commit comments