(whileToken)
| 981 | |
| 982 | |
| 983 | def isFloatCounterInWhileLoop(whileToken): |
| 984 | if not simpleMatch(whileToken, 'while ('): |
| 985 | return False |
| 986 | lpar = whileToken.next |
| 987 | rpar = lpar.link |
| 988 | counterTokens = findCounterTokens(lpar.astOperand2) |
| 989 | tok_varid = tuple(tok.varId for tok in counterTokens if tok.varId) |
| 990 | whileBodyStart = None |
| 991 | if simpleMatch(rpar, ') {'): |
| 992 | whileBodyStart = rpar.next |
| 993 | elif simpleMatch(whileToken.previous, '} while') and simpleMatch(whileToken.previous.link.previous, 'do {'): |
| 994 | whileBodyStart = whileToken.previous.link |
| 995 | else: |
| 996 | return False |
| 997 | token = whileBodyStart |
| 998 | while token != whileBodyStart.link: |
| 999 | token = token.next |
| 1000 | if not token.varId: |
| 1001 | continue |
| 1002 | if token.varId not in tok_varid: |
| 1003 | continue |
| 1004 | if not token.astParent or not token.valueType or not token.valueType.isFloat(): |
| 1005 | continue |
| 1006 | parent = token.astParent |
| 1007 | if parent.str in ('++', '--'): |
| 1008 | return True |
| 1009 | while parent: |
| 1010 | if parent.isAssignmentOp and parent.str != "=" and parent.astOperand1 == token: |
| 1011 | return True |
| 1012 | if parent.str == "=" and parent.astOperand1.str == token.str and parent.astOperand1 != token: |
| 1013 | return True |
| 1014 | parent = parent.astParent |
| 1015 | return False |
| 1016 | |
| 1017 | |
| 1018 | def countSideEffectsRecursive(expr): |
no test coverage detected