1
+ class Location extends @location {
2
+ /** Gets the start line of this location */
3
+ int getStartLine ( ) {
4
+ locations_default ( this , _, result , _, _, _) or
5
+ locations_ast ( this , _, result , _, _, _)
6
+ }
7
+
8
+ /** Gets the start column of this location */
9
+ int getStartColumn ( ) {
10
+ locations_default ( this , _, _, result , _, _) or
11
+ locations_ast ( this , _, _, result , _, _)
12
+ }
13
+
14
+ string toString ( ) { result = "<some file>" + ":" + this .getStartLine ( ) .toString ( ) }
15
+ }
16
+
1
17
class Expr_ extends @py_expr {
2
18
string toString ( ) { result = "Expr" }
19
+
20
+ Location getLocation ( ) { py_locations ( result , this ) }
3
21
}
4
22
5
23
class ExprParent_ extends @py_expr_parent {
@@ -15,6 +33,8 @@ class ExprList_ extends @py_expr_list {
15
33
16
34
class Parameter_ extends @py_parameter {
17
35
string toString ( ) { result = "Parameter" }
36
+
37
+ Location getLocation ( ) { result = this .( Expr_ ) .getLocation ( ) }
18
38
}
19
39
20
40
class ParameterList extends @py_parameter_list {
@@ -68,8 +88,8 @@ class Function_ extends @py_Function {
68
88
string toString ( ) { result = "Function" }
69
89
}
70
90
71
-
72
- /* * This class servers the same purpose as CallableExpr. CallableExpr is defined in Function.qll
91
+ /**
92
+ * This class servers the same purpose as CallableExpr. CallableExpr is defined in Function.qll
73
93
* To ease the burden of number of classes that needs to be implemented here, I make the class
74
94
* hierarchy slightly different (that's why it's called Adjusted)
75
95
*/
@@ -85,7 +105,6 @@ abstract class CallableExprAdjusted extends Expr_ {
85
105
abstract Function_ getInnerScope ( ) ;
86
106
}
87
107
88
-
89
108
class Lambda_ extends @py_Lambda, CallableExprAdjusted , Expr_ {
90
109
/** Gets the arguments of this lambda expression. */
91
110
override Arguments_ getArgs ( ) { py_arguments ( result , this ) }
@@ -119,5 +138,19 @@ where
119
138
args .getDefault ( oldidx ) = id and
120
139
newidx = oldidx + count ( callable .getInnerScope ( ) .getArg ( _) ) - count ( args .getDefault ( _) )
121
140
)
141
+ or
142
+ exists ( Arguments_ args , CallableExprAdjusted callable |
143
+ callable .getArgs ( ) = args and
144
+ args .getKwDefault ( oldidx ) = id and
145
+ newidx =
146
+ max ( int i |
147
+ exists ( Parameter_ param | param = callable .getInnerScope ( ) .getKwonlyarg ( i ) |
148
+ param .getLocation ( ) .getStartLine ( ) < id .getLocation ( ) .getStartLine ( )
149
+ or
150
+ param .getLocation ( ) .getStartLine ( ) = id .getLocation ( ) .getStartLine ( ) and
151
+ param .getLocation ( ) .getStartColumn ( ) < id .getLocation ( ) .getStartColumn ( )
152
+ )
153
+ )
154
+ )
122
155
)
123
156
select id , kind , parent , newidx
0 commit comments