Minor, delete CapturedParamOwner
This commit is contained in:
+4
-18
@@ -365,14 +365,6 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
|||||||
@NotNull final AnonymousObjectTransformationInfo transformationInfo,
|
@NotNull final AnonymousObjectTransformationInfo transformationInfo,
|
||||||
@NotNull FieldRemapper parentFieldRemapper
|
@NotNull FieldRemapper parentFieldRemapper
|
||||||
) {
|
) {
|
||||||
CapturedParamOwner owner = new CapturedParamOwner() {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Type getType() {
|
|
||||||
return Type.getObjectType(transformationInfo.getOldClassName());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Set<LambdaInfo> capturedLambdas = new LinkedHashSet<LambdaInfo>(); //captured var of inlined parameter
|
Set<LambdaInfo> capturedLambdas = new LinkedHashSet<LambdaInfo>(); //captured var of inlined parameter
|
||||||
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<CapturedParamInfo>();
|
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<CapturedParamInfo>();
|
||||||
Map<Integer, LambdaInfo> indexToLambda = transformationInfo.getLambdasToInline();
|
Map<Integer, LambdaInfo> indexToLambda = transformationInfo.getLambdasToInline();
|
||||||
@@ -399,7 +391,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
|||||||
? getNewFieldName(fieldName, true)
|
? getNewFieldName(fieldName, true)
|
||||||
: fieldName;
|
: fieldName;
|
||||||
CapturedParamInfo info = capturedParamBuilder.addCapturedParam(
|
CapturedParamInfo info = capturedParamBuilder.addCapturedParam(
|
||||||
owner, fieldName, newFieldName, Type.getType(fieldNode.desc), lambdaInfo != null, null
|
Type.getObjectType(transformationInfo.getOldClassName()), fieldName, newFieldName,
|
||||||
|
Type.getType(fieldNode.desc), lambdaInfo != null, null
|
||||||
);
|
);
|
||||||
if (lambdaInfo != null) {
|
if (lambdaInfo != null) {
|
||||||
info.setLambda(lambdaInfo);
|
info.setLambda(lambdaInfo);
|
||||||
@@ -488,15 +481,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
|
|||||||
//lambda with non InlinedLambdaRemapper already have outer
|
//lambda with non InlinedLambdaRemapper already have outer
|
||||||
FieldRemapper parent = parentFieldRemapper.getParent();
|
FieldRemapper parent = parentFieldRemapper.getParent();
|
||||||
assert parent instanceof RegeneratedLambdaFieldRemapper;
|
assert parent instanceof RegeneratedLambdaFieldRemapper;
|
||||||
final Type ownerType = Type.getObjectType(parent.getLambdaInternalName());
|
Type ownerType = Type.getObjectType(parent.getLambdaInternalName());
|
||||||
|
CapturedParamDesc desc = new CapturedParamDesc(ownerType, InlineCodegenUtil.THIS, ownerType);
|
||||||
CapturedParamDesc desc = new CapturedParamDesc(new CapturedParamOwner() {
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Type getType() {
|
|
||||||
return ownerType;
|
|
||||||
}
|
|
||||||
}, InlineCodegenUtil.THIS, ownerType);
|
|
||||||
CapturedParamInfo recapturedParamInfo =
|
CapturedParamInfo recapturedParamInfo =
|
||||||
capturedParamBuilder.addCapturedParam(desc, InlineCodegenUtil.THIS$0/*outer lambda/object*/);
|
capturedParamBuilder.addCapturedParam(desc, InlineCodegenUtil.THIS$0/*outer lambda/object*/);
|
||||||
StackValue composed = StackValue.LOCAL_0;
|
StackValue composed = StackValue.LOCAL_0;
|
||||||
|
|||||||
@@ -20,19 +20,19 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.org.objectweb.asm.Type;
|
import org.jetbrains.org.objectweb.asm.Type;
|
||||||
|
|
||||||
public class CapturedParamDesc {
|
public class CapturedParamDesc {
|
||||||
private final CapturedParamOwner containingLambda;
|
private final Type containingLambdaType;
|
||||||
private final String fieldName;
|
private final String fieldName;
|
||||||
private final Type type;
|
private final Type type;
|
||||||
|
|
||||||
public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull String fieldName, @NotNull Type type) {
|
public CapturedParamDesc(@NotNull Type containingLambdaType, @NotNull String fieldName, @NotNull Type type) {
|
||||||
this.containingLambda = containingLambda;
|
this.containingLambdaType = containingLambdaType;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getContainingLambdaName() {
|
public String getContainingLambdaName() {
|
||||||
return containingLambda.getType().getInternalName();
|
return containingLambdaType.getInternalName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.codegen.inline;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.org.objectweb.asm.Type;
|
|
||||||
|
|
||||||
public interface CapturedParamOwner {
|
|
||||||
@NotNull
|
|
||||||
Type getType();
|
|
||||||
}
|
|
||||||
@@ -39,7 +39,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
|
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.*;
|
||||||
|
|
||||||
public class LambdaInfo implements CapturedParamOwner, LabelOwner {
|
public class LambdaInfo implements LabelOwner {
|
||||||
public final KtExpression expression;
|
public final KtExpression expression;
|
||||||
private final KotlinTypeMapper typeMapper;
|
private final KotlinTypeMapper typeMapper;
|
||||||
public final Set<String> labels;
|
public final Set<String> labels;
|
||||||
@@ -139,7 +139,7 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private CapturedParamDesc getCapturedParamInfo(@NotNull EnclosedValueDescriptor descriptor) {
|
private CapturedParamDesc getCapturedParamInfo(@NotNull EnclosedValueDescriptor descriptor) {
|
||||||
return new CapturedParamDesc(this, descriptor.getFieldName(), descriptor.getType());
|
return new CapturedParamDesc(closureClassType, descriptor.getFieldName(), descriptor.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -161,12 +161,6 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
|
|||||||
return builder.buildParameters();
|
return builder.buildParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Type getType() {
|
|
||||||
return closureClassType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isMyLabel(@NotNull String name) {
|
public boolean isMyLabel(@NotNull String name) {
|
||||||
return labels.contains(name);
|
return labels.contains(name);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ internal class ParametersBuilder private constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun addCapturedParam(
|
fun addCapturedParam(
|
||||||
containingLambda: CapturedParamOwner,
|
containingLambdaType: Type,
|
||||||
fieldName: String,
|
fieldName: String,
|
||||||
newFieldName: String,
|
newFieldName: String,
|
||||||
type: Type,
|
type: Type,
|
||||||
@@ -72,7 +72,7 @@ internal class ParametersBuilder private constructor() {
|
|||||||
original: ParameterInfo?
|
original: ParameterInfo?
|
||||||
): CapturedParamInfo {
|
): CapturedParamInfo {
|
||||||
val info = CapturedParamInfo(
|
val info = CapturedParamInfo(
|
||||||
CapturedParamDesc(containingLambda, fieldName, type), newFieldName, skipped, nextCapturedIndex(), original?.index ?: -1
|
CapturedParamDesc(containingLambdaType, fieldName, type), newFieldName, skipped, nextCapturedIndex(), original?.index ?: -1
|
||||||
)
|
)
|
||||||
if (original != null) {
|
if (original != null) {
|
||||||
info.lambda = original.lambda
|
info.lambda = original.lambda
|
||||||
|
|||||||
Reference in New Issue
Block a user