@@ -2,7 +2,7 @@ import python
22
33import Testing.Mox
44
5- private int varargs_length ( Call call ) {
5+ private int varargs_length_objectapi ( Call call ) {
66 not exists ( call .getStarargs ( ) ) and result = 0
77 or
88 exists ( TupleObject t |
@@ -14,7 +14,7 @@ private int varargs_length(Call call) {
1414}
1515
1616/** 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 ) {
1818 func .getACall ( ) .getNode ( ) = call and
1919 result = call .getAKeyword ( ) and
2020 not func .getFunction ( ) .getAKeywordOnlyArg ( ) .getId ( ) = result .getArg ( )
@@ -26,54 +26,54 @@ private Keyword not_keyword_only_arg(Call call, FunctionObject func) {
2626 * plus the number of keyword arguments that do not match keyword-only arguments (if the function does not take **kwargs).
2727 */
2828
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
3131 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 ) |
3333 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 ) )
3535 or
3636 func .getFunction ( ) .hasKwArg ( ) and positional_keywords = 0
3737 )
3838 |
39- result = count ( call .getAnArg ( ) ) + varargs_length ( call ) + positional_keywords
39+ result = count ( call .getAnArg ( ) ) + varargs_length_objectapi ( call ) + positional_keywords
4040 )
4141}
4242
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 ( ) )
4545}
4646
4747/* 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 ) {
4949 result = callable .( ClassObject ) .getACall ( )
5050 or
5151 result = callable .( FunctionObject ) .getACall ( )
5252}
5353
5454/* 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 ) {
5656 result = func_or_cls .( FunctionObject )
5757 or
5858 result = func_or_cls .( ClassObject ) .declaredAttribute ( "__init__" )
5959}
6060
6161
6262/**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 ) {
6464 not func .isC ( ) and
6565 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 )
6868}
6969
7070/**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 ) {
7272 // 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
7474 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 ) |
7777 call = func .getAFunctionCall ( ) .getNode ( ) and limit = func .minParameters ( ) and
7878 /* The combination of misuse of `mox.Mox().StubOutWithMock()`
7979 * 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) {
8484 call = func .getAMethodCall ( ) .getNode ( ) and limit = func .minParameters ( ) - 1
8585 or
8686 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
8888 )
8989}
9090
9191/**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 ) {
9393 // 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
9595 exists ( FunctionObject func |
96- func = get_function_or_initializer ( callable ) and
96+ func = get_function_or_initializer_objectapi ( callable ) and
9797 not func .getFunction ( ) .hasVarArg ( ) and limit >= 0
9898 |
9999 call = func .getAFunctionCall ( ) .getNode ( ) and limit = func .maxParameters ( )
100100 or
101101 call = func .getAMethodCall ( ) .getNode ( ) and limit = func .maxParameters ( ) - 1
102102 or
103103 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
105105 ) and
106- positional_arg_count_for_call ( call , callable ) > limit
106+ positional_arg_count_objectapi_for_call_objectapi ( call , callable ) > limit
107107}
108108
109109/** 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"
112112 or
113- too_many_args ( call , func , limit ) and too = "too many"
113+ too_many_args_objectapi ( call , func , limit ) and too = "too many"
114114}
115115
116116/** Holds if `call` has correct number of arguments for `func`.
117117 * Implies nothing about whether `call` could call `func`.
118118 */
119119 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 ( )
122122 and
123- arg_count ( call ) < func .maxParameters ( )
123+ arg_count_objectapi ( call ) < func .maxParameters ( )
124124}
125125
126126/** 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 ) {
128128 overriding .overrides ( func ) and
129129 overriding .getACall ( ) .getNode ( ) = call
130130}
0 commit comments