krzema12 / kotlin-python

Python target for the Kotlin Programming Language. See https://github.com/krzema12/kotlin-python/tree/python-backend/python
https://discuss.kotlinlang.org/t/idea-python-backend/19852
47 stars 1 forks source link

Support do-while loop fully #122

Open SerVB opened 2 years ago

SerVB commented 2 years ago

Now continue is unsupported. Probably we can support it by compiling do { <body> } while (<condition>) as follows:

firstIterationLoopName = true
while firstIterationLoopName or (<condition>):
    firstIterationLoopName = false
    <body>

We need to introduce loop name, but there is already some logic for it in PyGenerationContext – we can pick the missing parts inside js-ir. Or we could use a concept of tmpVariable, this can be even easier.