Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- makeEnsureProgram :: MonadError Error m => (Program -> Bool) -> String -> Program -> m ()
- hasSubscriptionInLoopCounters :: Program -> Bool
- doesntHaveSubscriptionInLoopCounters :: Program -> Bool
- ensureDoesntHaveSubscriptionInLoopCounters :: MonadError Error m => Program -> m ()
- hasLeakOfLoopCounters :: Program -> Bool
- doesntHaveLeakOfLoopCounters :: Program -> Bool
- ensureDoesntHaveLeakOfLoopCounters :: MonadError Error m => Program -> m ()
- hasAssignmentToLoopCounters :: Program -> Bool
- doesntHaveAssignmentToLoopCounters :: Program -> Bool
- ensureDoesntHaveAssignmentToLoopCounters :: MonadError Error m => Program -> m ()
- hasAssignmentToLoopIterators :: Program -> Bool
- doesntHaveAssignmentToLoopIterators :: Program -> Bool
- ensureDoesntHaveAssignmentToLoopIterators :: MonadError Error m => Program -> m ()
- hasReturnInLoops :: Program -> Bool
- doesntHaveReturnInLoops :: Program -> Bool
- ensureDoesntHaveReturnInLoops :: MonadError Error m => Program -> m ()
- hasMixedAssignment :: Program -> Bool
- doesntHaveMixedAssignment :: Program -> Bool
- ensureDoesntHaveMixedAssignment :: MonadError Error m => Program -> m ()
- hasNonTrivialSubscriptedAssignmentInForLoops :: Program -> Bool
- doesntHaveNonTrivialSubscriptedAssignmentInForLoops :: Program -> Bool
- ensureDoesntHaveNonTrivialSubscriptedAssignmentInForLoops :: MonadError Error m => Program -> m ()
- hasAssignmentToBuiltin :: Program -> Bool
- doesntHaveAssignmentToBuiltin :: Program -> Bool
- ensureDoesntHaveAssignmentToBuiltin :: MonadError Error m => Program -> m ()
- hasNonResolvedBuiltin :: Program -> Bool
- doesntHaveNonResolvedBuiltin :: Program -> Bool
- ensureDoesntHaveNonResolvedBuiltin :: MonadError Error m => Program -> m ()
Documentation
makeEnsureProgram :: MonadError Error m => (Program -> Bool) -> String -> Program -> m () Source #
hasSubscriptionInLoopCounters :: Program -> Bool Source #
hasSubscriptionInLoopCounters
checks that there are SubscriptTrg
in loop counters of for-loops.
This includes loop counters of ListComp
.
For example, the followings has such subscriptions.
for a[0] in range(100): pass return a[0] # => 99
a = [0] b = [0 for a[0] in range(100)] return a[0] # => 99
NOTE: This is allowd in the standard Python.
ensureDoesntHaveSubscriptionInLoopCounters :: MonadError Error m => Program -> m () Source #
hasLeakOfLoopCounters :: Program -> Bool Source #
hasLeakOfLoopCounters
checks that there are leaks of loop counters of for-loops.
For example, the following has a leak.
for i in range(100): pass return i # => 100
ensureDoesntHaveLeakOfLoopCounters :: MonadError Error m => Program -> m () Source #
hasAssignmentToLoopCounters :: Program -> Bool Source #
hasAssignmentToLoopCounters
checks that there are assignments to loop counters of for-loops.
For example, the following has the assignment.
for i in range(100): i += 1
ensureDoesntHaveAssignmentToLoopCounters :: MonadError Error m => Program -> m () Source #
hasAssignmentToLoopIterators :: Program -> Bool Source #
hasAssignmentToLoopIterators
checks that there are assignments to loop iterators of for-loops.
For example, the followings have the assignments.
a = list(range(10)) for i in a: a[5] = i
a = 0 for i in f(a): a += i
ensureDoesntHaveAssignmentToLoopIterators :: MonadError Error m => Program -> m () Source #
hasReturnInLoops :: Program -> Bool Source #
hasReturnInLoops
checks that there are return-statements in for-loops.
For example, the following has such a return-statement.
a = list(range(10)) for i in a: return True
ensureDoesntHaveReturnInLoops :: MonadError Error m => Program -> m () Source #
hasMixedAssignment :: Program -> Bool Source #
hasMixedAssignment
checks that there are assignments which assign to both of bare variables and subscripted variables.
For example, the following is such an assignment.
a, b[0] = list(range(10))
ensureDoesntHaveMixedAssignment :: MonadError Error m => Program -> m () Source #
hasNonTrivialSubscriptedAssignmentInForLoops :: Program -> Bool Source #
hasNonTrivialSubscriptedAssignmentInForLoops
checks that there are assignments with non-trivial subscriptions in for-loops.
A trivial subscription is a sequence of subscriptions to a variable with constant indices and at most one trivial loop-counter indices for each loops.
A constant index is an expr which has a constant value in the loop.
A trivial loop-counter index is the loop counter from "range(n)", "range(n, m)" or "enumerate(a)" with optional post-addition with a positive int literal.
For example, the followings have such assignments.
x = 0 for i in range(10): x += 1 a[x] += 1
for i in range(10): j = i a[j] += 1
for i in range(10): a[2 * i] += 1
for i in range(10): a[1 + i] += 1
for i in range(10): a[i - 1] += 1
c = 1 for i in range(10): a[i + c] += 1
for i in range(10): a[i][i] += 1
for i in [1, 2, 3]: a[i] += 1
b = range(10) for i in b: a[i] += 1
for i in range(0, 10, 2): a[i] += 1
for i, b_i in enumerate(b): a[b_i] += i
For example, the followings don't have such assignments.
c = 0 for i in range(10): a[c] += 1
for i in range(10): a[i] += 1
for i in range(10): a[i + 1] += 1
for i in range(10): for j in range(10): a[i + 1][j] += 1
for i in range(1, 10): a[i] += 1
for i, b_i in enumerate(b): a[i] += b_i
ensureDoesntHaveNonTrivialSubscriptedAssignmentInForLoops :: MonadError Error m => Program -> m () Source #
hasAssignmentToBuiltin :: Program -> Bool Source #
hasAssginmentToBuiltin
checks that there are assignments to builtin functions.
For example, the followings have such assignments.
map = 3
return [range for range in range(10)]
ensureDoesntHaveAssignmentToBuiltin :: MonadError Error m => Program -> m () Source #
hasNonResolvedBuiltin :: Program -> Bool Source #
hasNonResolvedBuiltin
checks that there are not resolved builtin functions.
This always doesn't hold after ResolveBuiltin
.
ensureDoesntHaveNonResolvedBuiltin :: MonadError Error m => Program -> m () Source #