[IR] KotlinLikeDumper: WIP
* rearrange some declarations * add space for before "BLOCK" * add comment for "RETURNABLE BLOCK"
This commit is contained in:
committed by
teamcityserver
parent
0294ff4f10
commit
6a1ab1b325
@@ -424,19 +424,6 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p(isNoinline, "noinline")
|
p(isNoinline, "noinline")
|
||||||
}
|
}
|
||||||
|
|
||||||
private val INAPPLICABLE = false
|
|
||||||
private val INAPPLICABLE_N = null
|
|
||||||
|
|
||||||
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
|
|
||||||
declaration.printSimpleFunction(
|
|
||||||
"fun ",
|
|
||||||
declaration.name.asString(),
|
|
||||||
printTypeParametersAndExtensionReceiver = true,
|
|
||||||
printSignatureAndBody = true
|
|
||||||
)
|
|
||||||
p.printlnWithNoIndent()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun IrValueParameter.printExtensionReceiverParameter() {
|
private fun IrValueParameter.printExtensionReceiverParameter() {
|
||||||
type.printTypeWithNoIndent()
|
type.printTypeWithNoIndent()
|
||||||
p.printWithNoIndent(".")
|
p.printWithNoIndent(".")
|
||||||
@@ -513,6 +500,16 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitSimpleFunction(declaration: IrSimpleFunction) {
|
||||||
|
declaration.printSimpleFunction(
|
||||||
|
"fun ",
|
||||||
|
declaration.name.asString(),
|
||||||
|
printTypeParametersAndExtensionReceiver = true,
|
||||||
|
printSignatureAndBody = true
|
||||||
|
)
|
||||||
|
p.printlnWithNoIndent()
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitConstructor(declaration: IrConstructor) {
|
override fun visitConstructor(declaration: IrConstructor) {
|
||||||
// TODO primary!!!
|
// TODO primary!!!
|
||||||
// TODO name?
|
// TODO name?
|
||||||
@@ -557,9 +554,6 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.printlnWithNoIndent()
|
p.printlnWithNoIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun commentBlock(text: String) = "/* $text */"
|
|
||||||
private fun commentBlockH(text: String) = "/* $text */"
|
|
||||||
|
|
||||||
override fun visitProperty(declaration: IrProperty) {
|
override fun visitProperty(declaration: IrProperty) {
|
||||||
if (options.printFakeOverridesStrategy == FakeOverridesStrategy.NONE && declaration.isFakeOverride) return
|
if (options.printFakeOverridesStrategy == FakeOverridesStrategy.NONE && declaration.isFakeOverride) return
|
||||||
|
|
||||||
@@ -792,7 +786,20 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
p.printlnWithNoIndent()
|
p.printlnWithNoIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun visitComposite(expression: IrComposite) {
|
||||||
|
expression.printStatementContainer("// COMPOSITE {", "// }", withIndentation = false)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun visitBlock(expression: IrBlock) {
|
||||||
|
// TODO special blocks using `origin`
|
||||||
|
// TODO inlineFunctionSymbol for IrReturnableBlock
|
||||||
|
// TODO no tests for IrReturnableBlock?
|
||||||
|
val kind = if (expression is IrReturnableBlock) "RETURNABLE BLOCK" else "BLOCK"
|
||||||
|
expression.printStatementContainer("{ // $kind", "}")
|
||||||
|
}
|
||||||
|
|
||||||
private fun IrStatementContainer.printStatementContainer(before: String, after: String, withIndentation: Boolean = true) {
|
private fun IrStatementContainer.printStatementContainer(before: String, after: String, withIndentation: Boolean = true) {
|
||||||
|
// TODO type for IrContainerExpression
|
||||||
p.printlnWithNoIndent(before)
|
p.printlnWithNoIndent(before)
|
||||||
if (withIndentation) p.pushIndent()
|
if (withIndentation) p.pushIndent()
|
||||||
|
|
||||||
@@ -876,12 +883,6 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
expression.function.printSimpleFunction("fun ", expression.function.name.asString(), printTypeParametersAndExtensionReceiver = true, printSignatureAndBody = true)
|
expression.function.printSimpleFunction("fun ", expression.function.name.asString(), printTypeParametersAndExtensionReceiver = true, printSignatureAndBody = true)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrFieldAccessExpression.printFieldAccess() {
|
|
||||||
// TODO receiver, superQualifierSymbol?
|
|
||||||
// TODO is not valid kotlin
|
|
||||||
p.printWithNoIndent("#" + symbol.owner.name.asString())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitGetField(expression: IrGetField) {
|
override fun visitGetField(expression: IrGetField) {
|
||||||
expression.printFieldAccess()
|
expression.printFieldAccess()
|
||||||
}
|
}
|
||||||
@@ -892,6 +893,12 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
expression.value.acceptVoid(this)
|
expression.value.acceptVoid(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrFieldAccessExpression.printFieldAccess() {
|
||||||
|
// TODO receiver, superQualifierSymbol?
|
||||||
|
// TODO is not valid kotlin
|
||||||
|
p.printWithNoIndent("#" + symbol.owner.name.asString())
|
||||||
|
}
|
||||||
|
|
||||||
override fun visitReturn(expression: IrReturn) {
|
override fun visitReturn(expression: IrReturn) {
|
||||||
p.printWithNoIndent("return ")
|
p.printWithNoIndent("return ")
|
||||||
expression.value.acceptVoid(this)
|
expression.value.acceptVoid(this)
|
||||||
@@ -902,14 +909,6 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
expression.value.acceptVoid(this)
|
expression.value.acceptVoid(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitComposite(expression: IrComposite) {
|
|
||||||
expression.printStatementContainer("// COMPOSITE {", "// }", withIndentation = false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitBlock(expression: IrBlock) {
|
|
||||||
expression.printStatementContainer("{ //BLOCK", "}")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitStringConcatenation(expression: IrStringConcatenation) {
|
override fun visitStringConcatenation(expression: IrStringConcatenation) {
|
||||||
// TODO escape? see IrTextTestCaseGenerated.Expressions#testStringTemplates
|
// TODO escape? see IrTextTestCaseGenerated.Expressions#testStringTemplates
|
||||||
expression.arguments.forEachIndexed { i, e ->
|
expression.arguments.forEachIndexed { i, e ->
|
||||||
@@ -1096,4 +1095,12 @@ private class KotlinLikeDumper(val p: Printer, val options: KotlinLikeDumpOption
|
|||||||
// TODO receiver, arguments
|
// TODO receiver, arguments
|
||||||
p.printWithNoIndent("error(\"\") /* ERROR CALL */")
|
p.printWithNoIndent("error(\"\") /* ERROR CALL */")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun commentBlock(text: String) = "/* $text */"
|
||||||
|
private fun commentBlockH(text: String) = "/* $text */"
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
private const val INAPPLICABLE = false
|
||||||
|
private val INAPPLICABLE_N = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user