Minor. Reformat

This commit is contained in:
Mikhael Bogdanov
2018-05-03 11:12:30 +02:00
parent eefc49a617
commit b4853d9293
2 changed files with 133 additions and 108 deletions
@@ -52,11 +52,13 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
private fun createOuterThisField() { private fun createOuterThisField() {
outerThisFieldDescriptor = context.descriptorsFactory.getOuterThisFieldDescriptor(irClass.descriptor) outerThisFieldDescriptor = context.descriptorsFactory.getOuterThisFieldDescriptor(irClass.descriptor)
irClass.declarations.add(IrFieldImpl( irClass.declarations.add(
irClass.startOffset, irClass.endOffset, IrFieldImpl(
FIELD_FOR_OUTER_THIS, irClass.startOffset, irClass.endOffset,
outerThisFieldDescriptor FIELD_FOR_OUTER_THIS,
)) outerThisFieldDescriptor
)
)
} }
private fun lowerConstructors() { private fun lowerConstructors() {
@@ -100,14 +102,13 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
IrGetValueImpl(startOffset, endOffset, outerThisValueParameter) IrGetValueImpl(startOffset, endOffset, outerThisValueParameter)
) )
) )
} } else {
else {
// Delegating constructor: invoke old constructor with dispatch receiver '$outer' // Delegating constructor: invoke old constructor with dispatch receiver '$outer'
val delegatingConstructorCall = (blockBody.statements.find { it is IrDelegatingConstructorCall } ?: val delegatingConstructorCall = (blockBody.statements.find { it is IrDelegatingConstructorCall }
throw AssertionError("Delegating constructor call expected: ${irConstructor.dump()}") ?: throw AssertionError("Delegating constructor call expected: ${irConstructor.dump()}")
) as IrDelegatingConstructorCall ) as IrDelegatingConstructorCall
delegatingConstructorCall.dispatchReceiver = IrGetValueImpl( delegatingConstructorCall.dispatchReceiver = IrGetValueImpl(
delegatingConstructorCall.startOffset, delegatingConstructorCall.endOffset, outerThisValueParameter delegatingConstructorCall.startOffset, delegatingConstructorCall.endOffset, outerThisValueParameter
) )
} }
@@ -124,14 +125,13 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
override fun visitClass(declaration: IrClass): IrStatement = override fun visitClass(declaration: IrClass): IrStatement =
//TODO: maybe add another transformer that skips specified elements //TODO: maybe add another transformer that skips specified elements
declaration declaration
override fun visitGetValue(expression: IrGetValue): IrExpression { override fun visitGetValue(expression: IrGetValue): IrExpression {
expression.transformChildrenVoid(this) expression.transformChildrenVoid(this)
val implicitThisClass = expression.descriptor.getClassDescriptorForImplicitThis() ?: val implicitThisClass = expression.descriptor.getClassDescriptorForImplicitThis() ?: return expression
return expression
if (implicitThisClass == classDescriptor) return expression if (implicitThisClass == classDescriptor) return expression
@@ -154,7 +154,7 @@ class InnerClassesLowering(val context: BackendContext) : ClassLoweringPass {
val outer = innerClass.containingDeclaration val outer = innerClass.containingDeclaration
innerClass = outer as? ClassDescriptor ?: innerClass = outer as? ClassDescriptor ?:
throw AssertionError("Unexpected containing declaration for inner class $innerClass: $outer") throw AssertionError("Unexpected containing declaration for inner class $innerClass: $outer")
} }
return irThis return irThis
@@ -186,13 +186,13 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe
val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(callee) val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(callee)
val newCall = IrCallImpl( val newCall = IrCallImpl(
expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor, expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor,
null, // TODO type arguments map null, // TODO type arguments map
expression.origin expression.origin
) )
newCall.putValueArgument(0, dispatchReceiver) newCall.putValueArgument(0, dispatchReceiver)
for (i in 1 .. newCallee.descriptor.valueParameters.lastIndex) { for (i in 1..newCallee.descriptor.valueParameters.lastIndex) {
newCall.putValueArgument(i, expression.getValueArgument(i - 1)) newCall.putValueArgument(i, expression.getValueArgument(i - 1))
} }
@@ -208,12 +208,12 @@ class InnerClassConstructorCallsLowering(val context: BackendContext) : BodyLowe
val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(callee) val newCallee = context.descriptorsFactory.getInnerClassConstructorWithOuterThisParameter(callee)
val newCall = IrDelegatingConstructorCallImpl( val newCall = IrDelegatingConstructorCallImpl(
expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor, expression.startOffset, expression.endOffset, newCallee, newCallee.descriptor,
null // TODO type arguments map null // TODO type arguments map
) )
newCall.putValueArgument(0, dispatchReceiver) newCall.putValueArgument(0, dispatchReceiver)
for (i in 1 .. newCallee.descriptor.valueParameters.lastIndex) { for (i in 1..newCallee.descriptor.valueParameters.lastIndex) {
newCall.putValueArgument(i, expression.getValueArgument(i - 1)) newCall.putValueArgument(i, expression.getValueArgument(i - 1))
} }
@@ -51,7 +51,7 @@ import java.util.*
open class ExpressionInfo(val expression: IrExpression) open class ExpressionInfo(val expression: IrExpression)
class LoopInfo(val loop: IrLoop, val continueLabel: Label, val breakLabel: Label): ExpressionInfo(loop) class LoopInfo(val loop: IrLoop, val continueLabel: Label, val breakLabel: Label) : ExpressionInfo(loop)
class TryInfo(val tryBlock: IrTry) : ExpressionInfo(tryBlock) { class TryInfo(val tryBlock: IrTry) : ExpressionInfo(tryBlock) {
val gaps = mutableListOf<Label>() val gaps = mutableListOf<Label>()
@@ -71,7 +71,7 @@ class BlockInfo private constructor(val parent: BlockInfo?) {
} }
fun removeInfo(info: ExpressionInfo) { fun removeInfo(info: ExpressionInfo) {
assert (peek() == info) assert(peek() == info)
pop() pop()
} }
@@ -92,10 +92,10 @@ class VariableInfo(val declaration: IrVariable, val index: Int, val type: Type,
@Suppress("IMPLICIT_CAST_TO_ANY") @Suppress("IMPLICIT_CAST_TO_ANY")
class ExpressionCodegen( class ExpressionCodegen(
val irFunction: IrFunction, val irFunction: IrFunction,
val frame: IrFrameMap, val frame: IrFrameMap,
val mv: InstructionAdapter, val mv: InstructionAdapter,
val classCodegen: ClassCodegen val classCodegen: ClassCodegen
) : IrElementVisitor<StackValue, BlockInfo>, BaseExpressionCodegen { ) : IrElementVisitor<StackValue, BlockInfo>, BaseExpressionCodegen {
/*TODO*/ /*TODO*/
@@ -118,8 +118,7 @@ class ExpressionCodegen(
if (returnType == Type.VOID_TYPE) { if (returnType == Type.VOID_TYPE) {
//for implicit return //for implicit return
mv.areturn(Type.VOID_TYPE) mv.areturn(Type.VOID_TYPE)
} } else if (irFunction.body is IrExpressionBody) {
else if (irFunction.body is IrExpressionBody) {
mv.areturn(returnType) mv.areturn(returnType)
} }
writeLocalVariablesInTable(info) writeLocalVariablesInTable(info)
@@ -127,8 +126,7 @@ class ExpressionCodegen(
} }
override fun visitBlockBody(body: IrBlockBody, data: BlockInfo): StackValue { override fun visitBlockBody(body: IrBlockBody, data: BlockInfo): StackValue {
return body.statements.fold(none()) { return body.statements.fold(none()) { _, exp ->
_, exp ->
exp.accept(this, data) exp.accept(this, data)
} }
} }
@@ -138,8 +136,7 @@ class ExpressionCodegen(
return super.visitBlock(expression, info).apply { return super.visitBlock(expression, info).apply {
if (!expression.isTransparentScope) { if (!expression.isTransparentScope) {
writeLocalVariablesInTable(info) writeLocalVariablesInTable(info)
} } else {
else {
info.variables.forEach { info.variables.forEach {
data.variables.add(it) data.variables.add(it)
} }
@@ -159,8 +156,7 @@ class ExpressionCodegen(
} }
override fun visitContainerExpression(expression: IrContainerExpression, data: BlockInfo): StackValue { override fun visitContainerExpression(expression: IrContainerExpression, data: BlockInfo): StackValue {
val result = expression.statements.fold(none()) { val result = expression.statements.fold(none()) { _, exp ->
_, exp ->
//coerceNotToUnit(r.type, Type.VOID_TYPE) //coerceNotToUnit(r.type, Type.VOID_TYPE)
exp.accept(this, data) exp.accept(this, data)
} }
@@ -192,7 +188,7 @@ class ExpressionCodegen(
} }
fun generateNewArray( fun generateNewArray(
expression: IrCall, data: BlockInfo expression: IrCall, data: BlockInfo
): StackValue { ): StackValue {
val args = expression.descriptor.valueParameters val args = expression.descriptor.valueParameters
assert(args.size == 1 || args.size == 2) { "Unknown constructor called: " + args.size + " arguments" } assert(args.size == 1 || args.size == 2) { "Unknown constructor called: " + args.size + " arguments" }
@@ -223,9 +219,9 @@ class ExpressionCodegen(
val receiver = expression.dispatchReceiver val receiver = expression.dispatchReceiver
receiver?.apply { receiver?.apply {
callGenerator.genValueAndPut( callGenerator.genValueAndPut(
null, this, null, this,
if (isSuperCall) receiver.asmType else callable.dispatchReceiverType!!, if (isSuperCall) receiver.asmType else callable.dispatchReceiverType!!,
-1, this@ExpressionCodegen, data -1, this@ExpressionCodegen, data
) )
} }
@@ -243,7 +239,13 @@ class ExpressionCodegen(
callGenerator.genValueAndPut(parameterDescriptor, arg, parameterType, i, this@ExpressionCodegen, data) callGenerator.genValueAndPut(parameterDescriptor, arg, parameterType, i, this@ExpressionCodegen, data)
} }
parameterDescriptor.hasDefaultValue() -> { parameterDescriptor.hasDefaultValue() -> {
callGenerator.putValueIfNeeded(parameterType, StackValue.createDefaultValue(parameterType), ValueKind.DEFAULT_PARAMETER, i, this@ExpressionCodegen) callGenerator.putValueIfNeeded(
parameterType,
StackValue.createDefaultValue(parameterType),
ValueKind.DEFAULT_PARAMETER,
i,
this@ExpressionCodegen
)
defaultMask.mark(i) defaultMask.mark(i)
} }
else -> { else -> {
@@ -254,21 +256,22 @@ class ExpressionCodegen(
// while its lower bound may be Nothing-typed after approximation // while its lower bound may be Nothing-typed after approximation
val type = typeMapper.mapType(parameterDescriptor.type.upperIfFlexible()) val type = typeMapper.mapType(parameterDescriptor.type.upperIfFlexible())
callGenerator.putValueIfNeeded( callGenerator.putValueIfNeeded(
parameterType, parameterType,
StackValue.operation(type) { StackValue.operation(type) {
it.aconst(0) it.aconst(0)
it.newarray(correctElementType(type)) it.newarray(correctElementType(type))
}, },
ValueKind.GENERAL_VARARG, i, this@ExpressionCodegen) ValueKind.GENERAL_VARARG, i, this@ExpressionCodegen
)
} }
} }
} }
callGenerator.genCall( callGenerator.genCall(
callable, callable,
defaultMask.generateOnStackIfNeeded(callGenerator, expression.descriptor is ConstructorDescriptor, this), defaultMask.generateOnStackIfNeeded(callGenerator, expression.descriptor is ConstructorDescriptor, this),
this, this,
expression expression
) )
val returnType = expression.descriptor.returnType val returnType = expression.descriptor.returnType
@@ -302,10 +305,10 @@ class ExpressionCodegen(
} }
val info = VariableInfo( val info = VariableInfo(
declaration, declaration,
index, index,
varType, varType,
markNewLabel() markNewLabel()
) )
data.variables.add(info) data.variables.add(info)
@@ -435,8 +438,7 @@ class ExpressionCodegen(
if (arrayOfReferences) { if (arrayOfReferences) {
mv.checkcast(type) mv.checkcast(type)
} }
} } else {
else {
val owner: String val owner: String
val addDescriptor: String val addDescriptor: String
val toArrayDescriptor: String val toArrayDescriptor: String
@@ -444,9 +446,9 @@ class ExpressionCodegen(
owner = "kotlin/jvm/internal/SpreadBuilder" owner = "kotlin/jvm/internal/SpreadBuilder"
addDescriptor = "(Ljava/lang/Object;)V" addDescriptor = "(Ljava/lang/Object;)V"
toArrayDescriptor = "([Ljava/lang/Object;)[Ljava/lang/Object;" toArrayDescriptor = "([Ljava/lang/Object;)[Ljava/lang/Object;"
} } else {
else { val spreadBuilderClassName =
val spreadBuilderClassName = AsmUtil.asmPrimitiveTypeToLangPrimitiveType(elementType)!!.typeName.identifier + "SpreadBuilder" AsmUtil.asmPrimitiveTypeToLangPrimitiveType(elementType)!!.typeName.identifier + "SpreadBuilder"
owner = "kotlin/jvm/internal/" + spreadBuilderClassName owner = "kotlin/jvm/internal/" + spreadBuilderClassName
addDescriptor = "(" + elementType.descriptor + ")V" addDescriptor = "(" + elementType.descriptor + ")V"
toArrayDescriptor = "()" + type.descriptor toArrayDescriptor = "()" + type.descriptor
@@ -461,8 +463,7 @@ class ExpressionCodegen(
if (argument is IrSpreadElement) { if (argument is IrSpreadElement) {
gen(argument.expression, OBJECT_TYPE, data) gen(argument.expression, OBJECT_TYPE, data)
mv.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V", false) mv.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V", false)
} } else {
else {
gen(argument, elementType, data) gen(argument, elementType, data)
mv.invokevirtual(owner, "add", addDescriptor, false) mv.invokevirtual(owner, "add", addDescriptor, false)
} }
@@ -473,22 +474,25 @@ class ExpressionCodegen(
newArrayInstruction(outType) newArrayInstruction(outType)
mv.invokevirtual(owner, "toArray", toArrayDescriptor, false) mv.invokevirtual(owner, "toArray", toArrayDescriptor, false)
mv.checkcast(type) mv.checkcast(type)
} } else {
else {
mv.invokevirtual(owner, "toArray", toArrayDescriptor, false) mv.invokevirtual(owner, "toArray", toArrayDescriptor, false)
} }
} }
} } else {
else {
mv.iconst(size) mv.iconst(size)
newArrayInstruction(expression.type) newArrayInstruction(expression.type)
val elementKotlinType = outType.constructor.builtIns.getArrayElementType(outType) val elementKotlinType = outType.constructor.builtIns.getArrayElementType(outType)
for ((i, element) in expression.elements.withIndex()) { for ((i, element) in expression.elements.withIndex()) {
mv.dup() mv.dup()
StackValue.constant(i, Type.INT_TYPE).put(Type.INT_TYPE, mv) StackValue.constant(i, Type.INT_TYPE).put(Type.INT_TYPE, mv)
val rightSide = gen(element, elementType, data) val rightSide = gen(element, elementType, data)
StackValue StackValue
.arrayElement(elementType, elementKotlinType, StackValue.onStack(elementType, outType), StackValue.onStack(Type.INT_TYPE)) .arrayElement(
elementType,
elementKotlinType,
StackValue.onStack(elementType, outType),
StackValue.onStack(Type.INT_TYPE)
)
.store(rightSide, mv) .store(rightSide, mv)
} }
} }
@@ -503,8 +507,7 @@ class ExpressionCodegen(
// ReifiedTypeInliner.OperationKind.NEW_ARRAY // ReifiedTypeInliner.OperationKind.NEW_ARRAY
// ) // )
mv.newarray(boxType(elementJetType.asmType)) mv.newarray(boxType(elementJetType.asmType))
} } else {
else {
val type = typeMapper.mapType(arrayType) val type = typeMapper.mapType(arrayType)
mv.newarray(correctElementType(type)) mv.newarray(correctElementType(type))
} }
@@ -602,8 +605,10 @@ class ExpressionCodegen(
gen(expression.argument, asmType, data) gen(expression.argument, asmType, data)
mv.dup() mv.dup()
mv.visitLdcInsn("TODO provide message for IMPLICIT_NOTNULL") /*TODO*/ mv.visitLdcInsn("TODO provide message for IMPLICIT_NOTNULL") /*TODO*/
mv.invokestatic("kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull", mv.invokestatic(
"(Ljava/lang/Object;Ljava/lang/String;)V", false) "kotlin/jvm/internal/Intrinsics", "checkExpressionValueIsNotNull",
"(Ljava/lang/Object;Ljava/lang/String;)V", false
)
} }
IrTypeOperator.IMPLICIT_INTEGER_COERCION -> { IrTypeOperator.IMPLICIT_INTEGER_COERCION -> {
@@ -663,9 +668,9 @@ class ExpressionCodegen(
} }
private fun generateBreakOrContinueExpression( private fun generateBreakOrContinueExpression(
expression: IrBreakContinue, expression: IrBreakContinue,
afterBreakContinueLabel: Label, afterBreakContinueLabel: Label,
data: BlockInfo data: BlockInfo
) { ) {
if (data.isEmpty()) { if (data.isEmpty()) {
throw UnsupportedOperationException("Target label for break/continue not found") throw UnsupportedOperationException("Target label for break/continue not found")
@@ -732,7 +737,7 @@ class ExpressionCodegen(
val tryRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, tryBlockEnd) val tryRegions = getCurrentTryIntervals(tryInfo, tryBlockStart, tryBlockEnd)
val tryCatchBlockEnd = Label() val tryCatchBlockEnd = Label()
genFinallyBlockOrGoto(tryInfo, tryCatchBlockEnd, null, data) genFinallyBlockOrGoto(tryInfo, tryCatchBlockEnd, null, data)
val catches = aTry.catches val catches = aTry.catches
for (clause in catches) { for (clause in catches) {
@@ -749,10 +754,17 @@ class ExpressionCodegen(
val clauseEnd = markNewLabel() val clauseEnd = markNewLabel()
mv.visitLocalVariable(descriptor.name.asString(), descriptorType.descriptor, null, clauseStart, clauseEnd, mv.visitLocalVariable(
index) descriptor.name.asString(), descriptorType.descriptor, null, clauseStart, clauseEnd,
index
)
genFinallyBlockOrGoto(tryInfo, if (clause != catches.last() || finallyExpression != null) tryCatchBlockEnd else null, null, data) genFinallyBlockOrGoto(
tryInfo,
if (clause != catches.last() || finallyExpression != null) tryCatchBlockEnd else null,
null,
data
)
generateExceptionTable(clauseStart, tryRegions, descriptorType.internalName) generateExceptionTable(clauseStart, tryRegions, descriptorType.internalName)
} }
@@ -790,9 +802,9 @@ class ExpressionCodegen(
} }
private fun getCurrentTryIntervals( private fun getCurrentTryIntervals(
finallyBlockStackElement: TryInfo?, finallyBlockStackElement: TryInfo?,
blockStart: Label, blockStart: Label,
blockEnd: Label blockEnd: Label
): List<Label> { ): List<Label> {
val gapsInBlock = if (finallyBlockStackElement != null) ArrayList<Label>(finallyBlockStackElement.gaps) else emptyList<Label>() val gapsInBlock = if (finallyBlockStackElement != null) ArrayList<Label>(finallyBlockStackElement.gaps) else emptyList<Label>()
assert(gapsInBlock.size % 2 == 0) assert(gapsInBlock.size % 2 == 0)
@@ -814,10 +826,10 @@ class ExpressionCodegen(
} }
private fun genFinallyBlockOrGoto( private fun genFinallyBlockOrGoto(
tryInfo: TryInfo?, tryInfo: TryInfo?,
tryCatchBlockEnd: Label?, tryCatchBlockEnd: Label?,
afterJumpLabel: Label?, afterJumpLabel: Label?,
data: BlockInfo data: BlockInfo
) { ) {
if (tryInfo != null) { if (tryInfo != null) {
assert(tryInfo.gaps.size % 2 == 0) { "Finally block gaps are inconsistent" } assert(tryInfo.gaps.size % 2 == 0) { "Finally block gaps are inconsistent" }
@@ -857,8 +869,7 @@ class ExpressionCodegen(
doFinallyOnReturn(afterReturnLabel, data) doFinallyOnReturn(afterReturnLabel, data)
localForReturnValue.put(returnType, mv) localForReturnValue.put(returnType, mv)
frame.leaveTemp(returnType) frame.leaveTemp(returnType)
} } else {
else {
doFinallyOnReturn(afterReturnLabel, data) doFinallyOnReturn(afterReturnLabel, data)
} }
} }
@@ -906,8 +917,7 @@ class ExpressionCodegen(
if (classReference !is IrClassReference /* && DescriptorUtils.isObjectQualifier(classReference.descriptor)*/) { if (classReference !is IrClassReference /* && DescriptorUtils.isObjectQualifier(classReference.descriptor)*/) {
assert(classReference is IrGetClass) assert(classReference is IrGetClass)
JavaClassProperty.generateImpl(mv, gen((classReference as IrGetClass).argument, data)) JavaClassProperty.generateImpl(mv, gen((classReference as IrGetClass).argument, data))
} } else {
else {
val type = classReference.classType val type = classReference.classType
if (TypeUtils.isTypeParameter(type)) { if (TypeUtils.isTypeParameter(type)) {
assert(TypeUtils.isReifiedTypeParameter(type)) { "Non-reified type parameter under ::class should be rejected by type checker: " + type } assert(TypeUtils.isReifiedTypeParameter(type)) { "Non-reified type parameter under ::class should be rejected by type checker: " + type }
@@ -940,7 +950,11 @@ class ExpressionCodegen(
private fun resolveToCallable(irCall: IrMemberAccessExpression, isSuper: Boolean): Callable { private fun resolveToCallable(irCall: IrMemberAccessExpression, isSuper: Boolean): Callable {
val intrinsic = intrinsics.getIntrinsic(irCall.descriptor.original as CallableMemberDescriptor) val intrinsic = intrinsics.getIntrinsic(irCall.descriptor.original as CallableMemberDescriptor)
if (intrinsic != null) { if (intrinsic != null) {
return intrinsic.toCallable(irCall, typeMapper.mapSignatureSkipGeneric(irCall.descriptor as FunctionDescriptor), classCodegen.context) return intrinsic.toCallable(
irCall,
typeMapper.mapSignatureSkipGeneric(irCall.descriptor as FunctionDescriptor),
classCodegen.context
)
} }
var descriptor = irCall.descriptor var descriptor = irCall.descriptor
@@ -955,8 +969,7 @@ class ExpressionCodegen(
val propertyDescriptor = JvmCodegenUtil.getDirectMember(descriptor) as SyntheticJavaPropertyDescriptor val propertyDescriptor = JvmCodegenUtil.getDirectMember(descriptor) as SyntheticJavaPropertyDescriptor
descriptor = if (descriptor is PropertyGetterDescriptor) { descriptor = if (descriptor is PropertyGetterDescriptor) {
propertyDescriptor.getMethod propertyDescriptor.getMethod
} } else {
else {
propertyDescriptor.setMethod!! propertyDescriptor.setMethod!!
} }
} }
@@ -971,10 +984,10 @@ class ExpressionCodegen(
private fun getOrCreateCallGenerator( private fun getOrCreateCallGenerator(
descriptor: CallableDescriptor, descriptor: CallableDescriptor,
element: IrMemberAccessExpression?, element: IrMemberAccessExpression?,
typeParameterMappings: TypeParameterMappings?, typeParameterMappings: TypeParameterMappings?,
isDefaultCompilation: Boolean isDefaultCompilation: Boolean
): IrCallGenerator { ): IrCallGenerator {
if (element == null) return IrCallGenerator.DefaultCallGenerator if (element == null) return IrCallGenerator.DefaultCallGenerator
@@ -987,13 +1000,15 @@ class ExpressionCodegen(
val original = unwrapInitialSignatureDescriptor(DescriptorUtils.unwrapFakeOverride(descriptor.original as FunctionDescriptor)) val original = unwrapInitialSignatureDescriptor(DescriptorUtils.unwrapFakeOverride(descriptor.original as FunctionDescriptor))
return if (isDefaultCompilation) { return if (isDefaultCompilation) {
TODO() TODO()
} } else {
else {
IrInlineCodegen(this, state, original, typeParameterMappings!!, IrSourceCompilerForInline(state, element, this)) IrInlineCodegen(this, state, original, typeParameterMappings!!, IrSourceCompilerForInline(state, element, this))
} }
} }
internal fun getOrCreateCallGenerator(memberAccessExpression: IrMemberAccessExpression, descriptor: CallableDescriptor): IrCallGenerator { internal fun getOrCreateCallGenerator(
memberAccessExpression: IrMemberAccessExpression,
descriptor: CallableDescriptor
): IrCallGenerator {
val typeArguments = descriptor.original.typeParameters.keysToMap { memberAccessExpression.getTypeArgumentOrDefault(it) } val typeArguments = descriptor.original.typeParameters.keysToMap { memberAccessExpression.getTypeArgumentOrDefault(it) }
val mappings = TypeParameterMappings() val mappings = TypeParameterMappings()
@@ -1011,12 +1026,11 @@ class ExpressionCodegen(
val asmType = typeMapper.mapTypeParameter(approximatedType, signatureWriter) val asmType = typeMapper.mapTypeParameter(approximatedType, signatureWriter)
mappings.addParameterMappingToType( mappings.addParameterMappingToType(
key.name.identifier, approximatedType, asmType, signatureWriter.toString(), isReified key.name.identifier, approximatedType, asmType, signatureWriter.toString(), isReified
) )
} } else {
else {
mappings.addParameterMappingForFurtherReification( mappings.addParameterMappingForFurtherReification(
key.name.identifier, type, typeParameterAndReificationArgument.second, isReified key.name.identifier, type, typeParameterAndReificationArgument.second, isReified
) )
} }
} }
@@ -1041,7 +1055,12 @@ class ExpressionCodegen(
//TODO //TODO
} }
override fun pushClosureOnStack(classDescriptor: ClassDescriptor, putThis: Boolean, callGenerator: CallGenerator, functionReferenceReceiver: StackValue?) { override fun pushClosureOnStack(
classDescriptor: ClassDescriptor,
putThis: Boolean,
callGenerator: CallGenerator,
functionReferenceReceiver: StackValue?
) {
//TODO //TODO
} }
@@ -1063,7 +1082,13 @@ fun DefaultCallArgs.generateOnStackIfNeeded(callGenerator: IrCallGenerator, isCo
} }
val parameterType = if (isConstructor) AsmTypes.DEFAULT_CONSTRUCTOR_MARKER else AsmTypes.OBJECT_TYPE val parameterType = if (isConstructor) AsmTypes.DEFAULT_CONSTRUCTOR_MARKER else AsmTypes.OBJECT_TYPE
callGenerator.putValueIfNeeded(parameterType, StackValue.constant(null, parameterType), ValueKind.METHOD_HANDLE_IN_DEFAULT, -1, codegen) callGenerator.putValueIfNeeded(
parameterType,
StackValue.constant(null, parameterType),
ValueKind.METHOD_HANDLE_IN_DEFAULT,
-1,
codegen
)
} }
return toInts.isNotEmpty() return toInts.isNotEmpty()
} }