IR: create IrBlockBody via IrFactory

This commit is contained in:
Alexander Udalov
2020-07-14 19:57:17 +02:00
parent 9ad4a754ce
commit 0d605a6b7f
39 changed files with 137 additions and 82 deletions
@@ -582,7 +582,7 @@ class Fir2IrVisitor(
internal fun convertToIrBlockBody(block: FirBlock): IrBlockBody {
return block.convertWithOffsets { startOffset, endOffset ->
val irStatements = block.mapToIrStatements()
IrBlockBodyImpl(
irFactory.createBlockBody(
startOffset, endOffset,
if (irStatements.isNotEmpty()) {
irStatements.filterNotNull().takeIf { it.isNotEmpty() }
@@ -127,7 +127,7 @@ internal class ClassMemberGenerator(
annotationGenerator.generate(irFunction, firFunction)
}
if (firFunction is FirConstructor && irFunction is IrConstructor && !parentAsClass.isAnnotationClass && !firFunction.isExpect) {
val body = IrBlockBodyImpl(startOffset, endOffset)
val body = factory.createBlockBody(startOffset, endOffset)
val delegatedConstructor = firFunction.delegatedConstructor
if (delegatedConstructor != null) {
val irDelegatingConstructorCall = delegatedConstructor.toIrDelegatingConstructorCall()
@@ -250,7 +250,7 @@ internal class ClassMemberGenerator(
val fieldSymbol = backingField?.symbol
val declaration = this
if (fieldSymbol != null) {
body = IrBlockBodyImpl(
body = factory.createBlockBody(
startOffset, endOffset,
listOf(
if (isSetter) {
@@ -27,7 +27,10 @@ import org.jetbrains.kotlin.ir.descriptors.WrappedPropertyDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedSimpleFunctionDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedTypeParameterDescriptor
import org.jetbrains.kotlin.ir.descriptors.WrappedValueParameterDescriptor
import org.jetbrains.kotlin.ir.expressions.impl.*
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetFieldImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrGetValueImpl
import org.jetbrains.kotlin.ir.expressions.impl.IrReturnImpl
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol
import org.jetbrains.kotlin.ir.types.*
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
@@ -212,7 +215,7 @@ internal class DelegatedMemberGenerator(
}
}
val body = IrBlockBodyImpl(startOffset, endOffset)
val body = irFactory.createBlockBody(startOffset, endOffset)
val irCall = IrCallImpl(
startOffset,
endOffset,