IR: minor, avoid usages of IrBlockBodyImpl/IrExpressionBodyImpl
This commit is contained in:
+3
-3
@@ -11,8 +11,8 @@ import org.jetbrains.kotlin.ir.backend.js.JsIrBackendContext
|
||||
import org.jetbrains.kotlin.ir.backend.js.ir.JsIrBuilder
|
||||
import org.jetbrains.kotlin.ir.declarations.IrConstructor
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockBodyImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.IrRawFunctionReferenceImpl
|
||||
import org.jetbrains.kotlin.ir.util.isSubclassOf
|
||||
import org.jetbrains.kotlin.ir.util.parentAsClass
|
||||
@@ -30,7 +30,7 @@ class CaptureStackTraceInThrowables(val context: JsIrBackendContext) : BodyLower
|
||||
if (!klass.isSubclassOf(context.irBuiltIns.throwableClass.owner))
|
||||
return
|
||||
|
||||
(irBody as IrBlockBodyImpl).statements += JsIrBuilder.buildCall(context.intrinsics.captureStack).also { call ->
|
||||
(irBody as IrBlockBody).statements += JsIrBuilder.buildCall(context.intrinsics.captureStack).also { call ->
|
||||
call.putValueArgument(0, JsIrBuilder.buildGetValue(klass.thisReceiver!!.symbol))
|
||||
call.putValueArgument(
|
||||
1,
|
||||
@@ -38,4 +38,4 @@ class CaptureStackTraceInThrowables(val context: JsIrBackendContext) : BodyLower
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||
import org.jetbrains.kotlin.ir.expressions.*
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.util.referenceFunction
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.pureEndOffset
|
||||
@@ -143,7 +142,7 @@ class BodyGenerator(
|
||||
return irBlockBody
|
||||
}
|
||||
|
||||
private fun generateDelegatingConstructorCall(irBlockBody: IrBlockBodyImpl, ktConstructor: KtSecondaryConstructor) {
|
||||
private fun generateDelegatingConstructorCall(irBlockBody: IrBlockBody, ktConstructor: KtSecondaryConstructor) {
|
||||
val constructorDescriptor = scopeOwner as ClassConstructorDescriptor
|
||||
|
||||
val statementGenerator = createStatementGenerator()
|
||||
@@ -215,15 +214,15 @@ class BodyGenerator(
|
||||
return irBlockBody
|
||||
}
|
||||
|
||||
private fun generateSuperConstructorCall(irBlockBody: IrBlockBodyImpl, ktClassOrObject: KtPureClassOrObject) {
|
||||
private fun generateSuperConstructorCall(body: IrBlockBody, ktClassOrObject: KtPureClassOrObject) {
|
||||
val classDescriptor = ktClassOrObject.findClassDescriptor(context.bindingContext)
|
||||
|
||||
when (classDescriptor.kind) {
|
||||
// enums can't be synthetic
|
||||
ClassKind.ENUM_CLASS -> generateEnumSuperConstructorCall(irBlockBody, ktClassOrObject as KtClassOrObject, classDescriptor)
|
||||
ClassKind.ENUM_CLASS -> generateEnumSuperConstructorCall(body, ktClassOrObject as KtClassOrObject, classDescriptor)
|
||||
|
||||
ClassKind.ENUM_ENTRY -> {
|
||||
irBlockBody.statements.add(
|
||||
body.statements.add(
|
||||
generateEnumEntrySuperConstructorCall(ktClassOrObject as KtEnumEntry, classDescriptor)
|
||||
)
|
||||
}
|
||||
@@ -239,7 +238,7 @@ class BodyGenerator(
|
||||
val irSuperConstructorCall = CallGenerator(statementGenerator).generateDelegatingConstructorCall(
|
||||
ktSuperTypeListEntry.startOffsetSkippingComments, ktSuperTypeListEntry.endOffset, superConstructorCall
|
||||
)
|
||||
irBlockBody.statements.add(irSuperConstructorCall)
|
||||
body.statements.add(irSuperConstructorCall)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -251,14 +250,14 @@ class BodyGenerator(
|
||||
assert(KotlinBuiltIns.isAny(superClass)) {
|
||||
"$classDescriptor: Super class should be any: $superClass"
|
||||
}
|
||||
generateAnySuperConstructorCall(irBlockBody, ktClassOrObject)
|
||||
generateAnySuperConstructorCall(body, ktClassOrObject)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateAnySuperConstructorCall(irBlockBody: IrBlockBodyImpl, ktElement: KtPureElement) {
|
||||
private fun generateAnySuperConstructorCall(body: IrBlockBody, ktElement: KtPureElement) {
|
||||
val anyConstructor = context.builtIns.any.constructors.single()
|
||||
irBlockBody.statements.add(
|
||||
body.statements.add(
|
||||
IrDelegatingConstructorCallImpl(
|
||||
ktElement.pureStartOffset, ktElement.pureEndOffset,
|
||||
context.irBuiltIns.unitType,
|
||||
@@ -267,13 +266,9 @@ class BodyGenerator(
|
||||
)
|
||||
}
|
||||
|
||||
private fun generateEnumSuperConstructorCall(
|
||||
irBlockBody: IrBlockBodyImpl,
|
||||
ktElement: KtElement,
|
||||
classDescriptor: ClassDescriptor
|
||||
) {
|
||||
private fun generateEnumSuperConstructorCall(body: IrBlockBody, ktElement: KtElement, classDescriptor: ClassDescriptor) {
|
||||
val enumConstructor = context.builtIns.enum.constructors.single()
|
||||
irBlockBody.statements.add(
|
||||
body.statements.add(
|
||||
IrEnumConstructorCallImpl(
|
||||
ktElement.startOffsetSkippingComments, ktElement.endOffset,
|
||||
context.irBuiltIns.unitType,
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrImplementingDelegateDescriptorImpl
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBlockBody
|
||||
import org.jetbrains.kotlin.ir.expressions.impl.*
|
||||
import org.jetbrains.kotlin.ir.expressions.mapValueParameters
|
||||
import org.jetbrains.kotlin.ir.expressions.putTypeArguments
|
||||
@@ -319,7 +320,7 @@ class ClassGenerator(
|
||||
delegatedDescriptor: FunctionDescriptor,
|
||||
delegateToDescriptor: FunctionDescriptor,
|
||||
irDelegatedFunction: IrSimpleFunction
|
||||
): IrBlockBodyImpl {
|
||||
): IrBlockBody {
|
||||
val startOffset = irDelegate.startOffset
|
||||
val endOffset = irDelegate.endOffset
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.util.*
|
||||
class IrBlockBodyImpl(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
initializer: (IrBlockBodyImpl.() -> Unit)? = null
|
||||
initializer: (IrBlockBody.() -> Unit)? = null
|
||||
) :
|
||||
IrBodyBase<IrBlockBodyImpl>(startOffset, endOffset, initializer),
|
||||
IrBlockBody {
|
||||
@@ -53,4 +53,4 @@ class IrBlockBodyImpl(
|
||||
statements[i] = irStatement.transform(transformer, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-3
@@ -26,7 +26,7 @@ class IrExpressionBodyImpl private constructor(
|
||||
startOffset: Int,
|
||||
endOffset: Int,
|
||||
private var expressionField: IrExpression? = null,
|
||||
initializer: (IrExpressionBodyImpl.() -> Unit)? = null
|
||||
initializer: (IrExpressionBody.() -> Unit)? = null
|
||||
) :
|
||||
IrBodyBase<IrExpressionBodyImpl>(startOffset, endOffset, initializer),
|
||||
IrExpressionBody {
|
||||
@@ -35,7 +35,8 @@ class IrExpressionBodyImpl private constructor(
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, expression: IrExpression) : this(startOffset, endOffset, expression, null)
|
||||
|
||||
constructor(startOffset: Int, endOffset: Int, initializer: IrExpressionBodyImpl.() -> Unit) : this(startOffset, endOffset, null, initializer)
|
||||
constructor(startOffset: Int, endOffset: Int, initializer: IrExpressionBody.() -> Unit) :
|
||||
this(startOffset, endOffset, null, initializer)
|
||||
|
||||
override var expression: IrExpression
|
||||
get() = checkEnabled { expressionField!! }
|
||||
@@ -53,4 +54,4 @@ class IrExpressionBodyImpl private constructor(
|
||||
override fun <D> transformChildren(transformer: IrElementTransformer<D>, data: D) {
|
||||
expression = expression.transform(transformer, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user