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:
+4
-1
@@ -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)
|
||||
}
|
||||
|
||||
+3
-3
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user