Minor.Reformat
This commit is contained in:
+29
-17
@@ -60,9 +60,11 @@ interface SourceCompilerForInline {
|
|||||||
|
|
||||||
val lazySourceMapper: DefaultSourceMapper
|
val lazySourceMapper: DefaultSourceMapper
|
||||||
|
|
||||||
fun generateLambdaBody(adapter: MethodVisitor,
|
fun generateLambdaBody(
|
||||||
|
adapter: MethodVisitor,
|
||||||
jvmMethodSignature: JvmMethodSignature,
|
jvmMethodSignature: JvmMethodSignature,
|
||||||
lambdaInfo: ExpressionLambda): SMAP
|
lambdaInfo: ExpressionLambda
|
||||||
|
): SMAP
|
||||||
|
|
||||||
fun doCreateMethodNodeFromSource(
|
fun doCreateMethodNodeFromSource(
|
||||||
callableDescriptor: FunctionDescriptor,
|
callableDescriptor: FunctionDescriptor,
|
||||||
@@ -91,7 +93,7 @@ interface SourceCompilerForInline {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, override val callElement: KtElement): SourceCompilerForInline {
|
class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, override val callElement: KtElement) : SourceCompilerForInline {
|
||||||
|
|
||||||
override val state = codegen.state
|
override val state = codegen.state
|
||||||
|
|
||||||
@@ -137,9 +139,11 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
|||||||
override val lazySourceMapper
|
override val lazySourceMapper
|
||||||
get() = codegen.parentCodegen.orCreateSourceMapper
|
get() = codegen.parentCodegen.orCreateSourceMapper
|
||||||
|
|
||||||
override fun generateLambdaBody(adapter: MethodVisitor,
|
override fun generateLambdaBody(
|
||||||
|
adapter: MethodVisitor,
|
||||||
jvmMethodSignature: JvmMethodSignature,
|
jvmMethodSignature: JvmMethodSignature,
|
||||||
lambdaInfo: ExpressionLambda): SMAP {
|
lambdaInfo: ExpressionLambda
|
||||||
|
): SMAP {
|
||||||
lambdaInfo as? PsiExpressionLambda ?: error("TODO")
|
lambdaInfo as? PsiExpressionLambda ?: error("TODO")
|
||||||
val invokeMethodDescriptor = lambdaInfo.invokeMethodDescriptor
|
val invokeMethodDescriptor = lambdaInfo.invokeMethodDescriptor
|
||||||
val closureContext =
|
val closureContext =
|
||||||
@@ -189,8 +193,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
|||||||
true, info!!.getFunction, info.target, asmType, receiverType,
|
true, info!!.getFunction, info.target, asmType, receiverType,
|
||||||
lambdaInfo.functionWithBodyOrCallableReference, state, true
|
lambdaInfo.functionWithBodyOrCallableReference, state, true
|
||||||
)
|
)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
FunctionReferenceGenerationStrategy(state, descriptor, resolvedCall, receiverType, null, true)
|
FunctionReferenceGenerationStrategy(state, descriptor, resolvedCall, receiverType, null, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,8 +255,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
|||||||
override fun addParentsToInnerClassesIfNeeded(innerClasses: MutableCollection<ClassDescriptor>) {
|
override fun addParentsToInnerClassesIfNeeded(innerClasses: MutableCollection<ClassDescriptor>) {
|
||||||
if (isInlineLambdaCodegen) {
|
if (isInlineLambdaCodegen) {
|
||||||
super.addParentsToInnerClassesIfNeeded(innerClasses)
|
super.addParentsToInnerClassesIfNeeded(innerClasses)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
innerClasses.addAll(parentAsInnerClasses)
|
innerClasses.addAll(parentAsInnerClasses)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,8 +302,7 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
|||||||
inliningFunction as KtNamedFunction?, parentCodegen, asmMethod
|
inliningFunction as KtNamedFunction?, parentCodegen, asmMethod
|
||||||
)
|
)
|
||||||
createSMAPWithDefaultMapping(inliningFunction, parentCodegen.orCreateSourceMapper.resultMappings)
|
createSMAPWithDefaultMapping(inliningFunction, parentCodegen.orCreateSourceMapper.resultMappings)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
generateMethodBody(maxCalcAdapter, callableDescriptor, methodContext, inliningFunction!!, jvmSignature, null)
|
generateMethodBody(maxCalcAdapter, callableDescriptor, methodContext, inliningFunction!!, jvmSignature, null)
|
||||||
}
|
}
|
||||||
maxCalcAdapter.visitMaxs(-1, -1)
|
maxCalcAdapter.visitMaxs(-1, -1)
|
||||||
@@ -340,8 +341,10 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
|||||||
val finallyNode = createEmptyMethodNode()
|
val finallyNode = createEmptyMethodNode()
|
||||||
finallyNode.visitLabel(start)
|
finallyNode.visitLabel(start)
|
||||||
|
|
||||||
val finallyCodegen = ExpressionCodegen(finallyNode, codegen.frameMap, codegen.returnType,
|
val finallyCodegen = ExpressionCodegen(
|
||||||
codegen.getContext(), codegen.state, codegen.parentCodegen)
|
finallyNode, codegen.frameMap, codegen.returnType,
|
||||||
|
codegen.getContext(), codegen.state, codegen.parentCodegen
|
||||||
|
)
|
||||||
finallyCodegen.addBlockStackElementsForNonLocalReturns(codegen.blockStackElements, curFinallyDepth)
|
finallyCodegen.addBlockStackElementsForNonLocalReturns(codegen.blockStackElements, curFinallyDepth)
|
||||||
|
|
||||||
val frameMap = finallyCodegen.frameMap
|
val frameMap = finallyCodegen.frameMap
|
||||||
@@ -394,19 +397,28 @@ class PsiSourceCompilerForInline(private val codegen: ExpressionCodegen, overrid
|
|||||||
val parentContext = context.parentContext
|
val parentContext = context.parentContext
|
||||||
val descriptor = if (parentContext is ClosureContext && parentContext.originalSuspendLambdaDescriptor != null) {
|
val descriptor = if (parentContext is ClosureContext && parentContext.originalSuspendLambdaDescriptor != null) {
|
||||||
parentContext.originalSuspendLambdaDescriptor!!
|
parentContext.originalSuspendLambdaDescriptor!!
|
||||||
}
|
} else context.contextDescriptor
|
||||||
else context.contextDescriptor
|
|
||||||
|
|
||||||
return InlineCodegen.getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
|
return InlineCodegen.getDeclarationLabels(DescriptorToSourceUtils.descriptorToDeclaration(descriptor), descriptor)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun initializeInlineFunctionContext(functionDescriptor: FunctionDescriptor) {
|
override fun initializeInlineFunctionContext(functionDescriptor: FunctionDescriptor) {
|
||||||
context = getContext(functionDescriptor, functionDescriptor, state, DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor)?.containingFile as? KtFile, additionalInnerClasses)
|
context = getContext(
|
||||||
|
functionDescriptor,
|
||||||
|
functionDescriptor,
|
||||||
|
state,
|
||||||
|
DescriptorToSourceUtils.descriptorToDeclaration(functionDescriptor)?.containingFile as? KtFile,
|
||||||
|
additionalInnerClasses
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun getContext(
|
fun getContext(
|
||||||
descriptor: DeclarationDescriptor, innerDescriptor: DeclarationDescriptor, state: GenerationState, sourceFile: KtFile?, additionalInners: MutableList<ClassDescriptor>
|
descriptor: DeclarationDescriptor,
|
||||||
|
innerDescriptor: DeclarationDescriptor,
|
||||||
|
state: GenerationState,
|
||||||
|
sourceFile: KtFile?,
|
||||||
|
additionalInners: MutableList<ClassDescriptor>
|
||||||
): CodegenContext<*> {
|
): CodegenContext<*> {
|
||||||
if (descriptor is PackageFragmentDescriptor) {
|
if (descriptor is PackageFragmentDescriptor) {
|
||||||
//no inners
|
//no inners
|
||||||
|
|||||||
Reference in New Issue
Block a user