Jikka-5.0.11.2: A transpiler from Python to C++ for competitive programming
Copyright(c) Kimiyuki Onaka 2021
LicenseApache License 2.0
Maintainerkimiyuki95@gmail.com
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Jikka.RestrictedPython.Convert.SplitLoops

Description

 
Synopsis

Documentation

run :: (MonadAlpha m, MonadError Error m) => Program -> m Program Source #

run does alpha conversion, check assumptions, and run`.

run' :: Program -> Program Source #

run` splits for-loops into many small for-loops as possible. This assumes that doesntHaveSubscriptionInLoopCounters, doesntHaveAssignmentToLoopCounters, and doesntHaveAssignmentToLoopIterators hold. This may introduce name conflicts.

For example, the following

a = 0
b = 0
for i in range(10):
    c = b
    a += i
    b += c

is split to

a = 0
b = 0
for i in range(10):
    c = b
    b += c
for i in range(10):
    a += i

runForLoop :: Target' -> Expr' -> [Statement] -> [Statement] Source #

runForLoop splits a for-loop to many for-loops as possible. This assumes that doesntHaveSubscriptionInLoopCounters, doesntHaveAssignmentToLoopCounters, and doesntHaveAssignmentToLoopIterators hold.

This function analyzes read-variables and write-variables in statements, and split statements into connected components.