kotlin-python
kotlin-python copied to clipboard
Remove unneeded lowerings and refactor needed ones
Lowerings are a big part of backend logic, so let's ensure we know what happens there and that we don't have anything surplus or weird.
- #95
- [x] analyze lowerings and dependencies between them
- [ ] iteratively remove lowerings to get a minimal list of needed ones
- [ ] remove unneeded Gradle module dependencies
- [ ] add unit tests for each lowering, if possible. It's to be able to understand what they really do, so it serves documentation purposes
- [ ] think outside the box: maybe for some case, the JS way is not the correct one? E. g. constructors, it may be a better way to lower them for Python. Now we base on JS version
Thanks to the below snippet I was able to generate a dependency diagram of lowerings:
(to be pasted in compiler/ir/backend.py/src/org/jetbrains/kotlin/ir/backend/py/JsLoweringPhases.kt
)
fun main() {
println("@startuml")
println("skinparam componentStyle rectangle")
println("left to right direction")
loweringList.forEach { lowering ->
println("component \"${lowering.modulePhase.name}\"")
lowering.modulePhase.prerequisite.forEach { prerequisite ->
println("component \"${prerequisite.name}\"")
println("[${lowering.modulePhase.name}] --> [${prerequisite.name}]")
}
}
println("@enduml")
}
The generated code can be rendered with any PlantUML renderer, e.g. http://www.plantuml.com/