IR: push down implementations of startOffset/endOffset/type/...

Do not store these as properties in IrElementBase, IrExpressionBase and
similar classes. This helps to reduce boilerplate in implementations
(just "override val" in the constructor, instead of taking a parameter
and passing it to the superclass), and also slightly optimizes memory in
cases where the value is trivial (UNDEFINED_OFFSET, 0, etc) and thus
does not need to be stored.
This commit is contained in:
Alexander Udalov
2020-07-22 18:41:14 +02:00
parent 03f804b1c5
commit e3dfd5fb49
57 changed files with 286 additions and 505 deletions
@@ -22,7 +22,10 @@ import org.jetbrains.kotlin.ir.declarations.IrFactory
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
class IrBlockBodyImpl(startOffset: Int, endOffset: Int) : IrElementBase(startOffset, endOffset), IrBlockBody {
class IrBlockBodyImpl(
override val startOffset: Int,
override val endOffset: Int
) : IrElementBase(), IrBlockBody {
constructor(startOffset: Int, endOffset: Int, statements: List<IrStatement>) : this(startOffset, endOffset) {
this.statements.addAll(statements)
}
@@ -23,10 +23,10 @@ import org.jetbrains.kotlin.ir.expressions.IrExpression
import org.jetbrains.kotlin.ir.expressions.IrExpressionBody
class IrExpressionBodyImpl(
startOffset: Int,
endOffset: Int,
override val startOffset: Int,
override val endOffset: Int,
initializer: (IrExpressionBody.() -> Unit)? = null
) : IrElementBase(startOffset, endOffset), IrExpressionBody {
) : IrElementBase(), IrExpressionBody {
init {
initializer?.invoke(this)
}