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
@@ -11,9 +11,9 @@ import org.jetbrains.kotlin.backend.common.ir.Symbols
import org.jetbrains.kotlin.backend.common.ir.createTemporaryVariableWithWrappedDescriptor
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
import org.jetbrains.kotlin.config.languageVersionSettings
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.IrElement
import org.jetbrains.kotlin.ir.IrStatement
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import org.jetbrains.kotlin.ir.UNDEFINED_OFFSET
import org.jetbrains.kotlin.ir.builders.irReturn
import org.jetbrains.kotlin.ir.declarations.*
@@ -509,13 +509,14 @@ class FunctionInlining(
}
private class IrGetValueWithoutLocation(
symbol: IrValueSymbol,
override val symbol: IrValueSymbol,
override val origin: IrStatementOrigin? = null
) : IrTerminalDeclarationReferenceBase<IrValueSymbol>(
UNDEFINED_OFFSET, UNDEFINED_OFFSET,
symbol.owner.type,
symbol
), IrGetValue {
) : IrTerminalDeclarationReferenceBase<IrValueSymbol>(), IrGetValue {
override val startOffset: Int get() = UNDEFINED_OFFSET
override val endOffset: Int get() = UNDEFINED_OFFSET
override val type: IrType get() = symbol.owner.type
override fun <R, D> accept(visitor: IrElementVisitor<R, D>, data: D) =
visitor.visitGetValue(this, data)