@@ -2,7 +2,7 @@ import python
2
2
3
3
import Testing.Mox
4
4
5
- private int varargs_length ( Call call ) {
5
+ private int varargs_length_objectapi ( Call call ) {
6
6
not exists ( call .getStarargs ( ) ) and result = 0
7
7
or
8
8
exists ( TupleObject t |
@@ -14,7 +14,7 @@ private int varargs_length(Call call) {
14
14
}
15
15
16
16
/** Gets a keyword argument that is not a keyword-only parameter. */
17
- private Keyword not_keyword_only_arg ( Call call , FunctionObject func ) {
17
+ private Keyword not_keyword_only_arg_objectapi ( Call call , FunctionObject func ) {
18
18
func .getACall ( ) .getNode ( ) = call and
19
19
result = call .getAKeyword ( ) and
20
20
not func .getFunction ( ) .getAKeywordOnlyArg ( ) .getId ( ) = result .getArg ( )
@@ -26,54 +26,54 @@ private Keyword not_keyword_only_arg(Call call, FunctionObject func) {
26
26
* plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
27
27
*/
28
28
29
- private int positional_arg_count_for_call ( Call call , Object callable ) {
30
- call = get_a_call ( callable ) .getNode ( ) and
29
+ private int positional_arg_count_objectapi_for_call_objectapi ( Call call , Object callable ) {
30
+ call = get_a_call_objectapi ( callable ) .getNode ( ) and
31
31
exists ( int positional_keywords |
32
- exists ( FunctionObject func | func = get_function_or_initializer ( callable ) |
32
+ exists ( FunctionObject func | func = get_function_or_initializer_objectapi ( callable ) |
33
33
not func .getFunction ( ) .hasKwArg ( ) and
34
- positional_keywords = count ( not_keyword_only_arg ( call , func ) )
34
+ positional_keywords = count ( not_keyword_only_arg_objectapi ( call , func ) )
35
35
or
36
36
func .getFunction ( ) .hasKwArg ( ) and positional_keywords = 0
37
37
)
38
38
|
39
- result = count ( call .getAnArg ( ) ) + varargs_length ( call ) + positional_keywords
39
+ result = count ( call .getAnArg ( ) ) + varargs_length_objectapi ( call ) + positional_keywords
40
40
)
41
41
}
42
42
43
- int arg_count ( Call call ) {
44
- result = count ( call .getAnArg ( ) ) + varargs_length ( call ) + count ( call .getAKeyword ( ) )
43
+ int arg_count_objectapi ( Call call ) {
44
+ result = count ( call .getAnArg ( ) ) + varargs_length_objectapi ( call ) + count ( call .getAKeyword ( ) )
45
45
}
46
46
47
47
/* Gets a call corresponding to the given class or function*/
48
- private ControlFlowNode get_a_call ( Object callable ) {
48
+ private ControlFlowNode get_a_call_objectapi ( Object callable ) {
49
49
result = callable .( ClassObject ) .getACall ( )
50
50
or
51
51
result = callable .( FunctionObject ) .getACall ( )
52
52
}
53
53
54
54
/* Gets the function object corresponding to the given class or function*/
55
- FunctionObject get_function_or_initializer ( Object func_or_cls ) {
55
+ FunctionObject get_function_or_initializer_objectapi ( Object func_or_cls ) {
56
56
result = func_or_cls .( FunctionObject )
57
57
or
58
58
result = func_or_cls .( ClassObject ) .declaredAttribute ( "__init__" )
59
59
}
60
60
61
61
62
62
/**Whether there is an illegally named parameter called `name` in the `call` to `func` */
63
- predicate illegally_named_parameter ( Call call , Object func , string name ) {
63
+ predicate illegally_named_parameter_objectapi ( Call call , Object func , string name ) {
64
64
not func .isC ( ) and
65
65
name = call .getANamedArgumentName ( ) and
66
- call .getAFlowNode ( ) = get_a_call ( func ) and
67
- not get_function_or_initializer ( func ) .isLegalArgumentName ( name )
66
+ call .getAFlowNode ( ) = get_a_call_objectapi ( func ) and
67
+ not get_function_or_initializer_objectapi ( func ) .isLegalArgumentName ( name )
68
68
}
69
69
70
70
/**Whether there are too few arguments in the `call` to `callable` where `limit` is the lowest number of legal arguments */
71
- predicate too_few_args ( Call call , Object callable , int limit ) {
71
+ predicate too_few_args_objectapi ( Call call , Object callable , int limit ) {
72
72
// Exclude cases where an incorrect name is used as that is covered by 'Wrong name for an argument in a call'
73
- not illegally_named_parameter ( call , callable , _) and
73
+ not illegally_named_parameter_objectapi ( call , callable , _) and
74
74
not exists ( call .getStarargs ( ) ) and not exists ( call .getKwargs ( ) ) and
75
- arg_count ( call ) < limit and
76
- exists ( FunctionObject func | func = get_function_or_initializer ( callable ) |
75
+ arg_count_objectapi ( call ) < limit and
76
+ exists ( FunctionObject func | func = get_function_or_initializer_objectapi ( callable ) |
77
77
call = func .getAFunctionCall ( ) .getNode ( ) and limit = func .minParameters ( ) and
78
78
/* The combination of misuse of `mox.Mox().StubOutWithMock()`
79
79
* and a bug in mox's implementation of methods results in having to
@@ -84,47 +84,47 @@ predicate too_few_args(Call call, Object callable, int limit) {
84
84
call = func .getAMethodCall ( ) .getNode ( ) and limit = func .minParameters ( ) - 1
85
85
or
86
86
callable instanceof ClassObject and
87
- call .getAFlowNode ( ) = get_a_call ( callable ) and limit = func .minParameters ( ) - 1
87
+ call .getAFlowNode ( ) = get_a_call_objectapi ( callable ) and limit = func .minParameters ( ) - 1
88
88
)
89
89
}
90
90
91
91
/**Whether there are too many arguments in the `call` to `func` where `limit` is the highest number of legal arguments */
92
- predicate too_many_args ( Call call , Object callable , int limit ) {
92
+ predicate too_many_args_objectapi ( Call call , Object callable , int limit ) {
93
93
// Exclude cases where an incorrect name is used as that is covered by 'Wrong name for an argument in a call'
94
- not illegally_named_parameter ( call , callable , _) and
94
+ not illegally_named_parameter_objectapi ( call , callable , _) and
95
95
exists ( FunctionObject func |
96
- func = get_function_or_initializer ( callable ) and
96
+ func = get_function_or_initializer_objectapi ( callable ) and
97
97
not func .getFunction ( ) .hasVarArg ( ) and limit >= 0
98
98
|
99
99
call = func .getAFunctionCall ( ) .getNode ( ) and limit = func .maxParameters ( )
100
100
or
101
101
call = func .getAMethodCall ( ) .getNode ( ) and limit = func .maxParameters ( ) - 1
102
102
or
103
103
callable instanceof ClassObject and
104
- call .getAFlowNode ( ) = get_a_call ( callable ) and limit = func .maxParameters ( ) - 1
104
+ call .getAFlowNode ( ) = get_a_call_objectapi ( callable ) and limit = func .maxParameters ( ) - 1
105
105
) and
106
- positional_arg_count_for_call ( call , callable ) > limit
106
+ positional_arg_count_objectapi_for_call_objectapi ( call , callable ) > limit
107
107
}
108
108
109
109
/** Holds if `call` has too many or too few arguments for `func` */
110
- predicate wrong_args ( Call call , FunctionObject func , int limit , string too ) {
111
- too_few_args ( call , func , limit ) and too = "too few"
110
+ predicate wrong_args_objectapi ( Call call , FunctionObject func , int limit , string too ) {
111
+ too_few_args_objectapi ( call , func , limit ) and too = "too few"
112
112
or
113
- too_many_args ( call , func , limit ) and too = "too many"
113
+ too_many_args_objectapi ( call , func , limit ) and too = "too many"
114
114
}
115
115
116
116
/** Holds if `call` has correct number of arguments for `func`.
117
117
* Implies nothing about whether `call` could call `func`.
118
118
*/
119
119
bindingset [ call, func]
120
- predicate correct_args_if_called_as_method ( Call call , FunctionObject func ) {
121
- arg_count ( call ) + 1 >= func .minParameters ( )
120
+ predicate correct_args_if_called_as_method_objectapi ( Call call , FunctionObject func ) {
121
+ arg_count_objectapi ( call ) + 1 >= func .minParameters ( )
122
122
and
123
- arg_count ( call ) < func .maxParameters ( )
123
+ arg_count_objectapi ( call ) < func .maxParameters ( )
124
124
}
125
125
126
126
/** Holds if `call` is a call to `overriding`, which overrides `func`. */
127
- predicate overridden_call ( FunctionObject func , FunctionObject overriding , Call call ) {
127
+ predicate overridden_call_objectapi ( FunctionObject func , FunctionObject overriding , Call call ) {
128
128
overriding .overrides ( func ) and
129
129
overriding .getACall ( ) .getNode ( ) = call
130
130
}
0 commit comments