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

Remove unneeded lowerings and refactor needed ones #94

Open krzema12 opened 2 years ago

krzema12 commented 2 years ago

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.

krzema12 commented 2 years ago

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/

image