Minor, delete CapturedParamOwner

This commit is contained in:
Alexander Udalov
2016-06-04 13:40:27 +03:00
parent e148dcdee7
commit b370ac0b37
5 changed files with 12 additions and 57 deletions
@@ -365,14 +365,6 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
@NotNull final AnonymousObjectTransformationInfo transformationInfo,
@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
List<CapturedParamInfo> constructorAdditionalFakeParams = new ArrayList<CapturedParamInfo>();
Map<Integer, LambdaInfo> indexToLambda = transformationInfo.getLambdasToInline();
@@ -399,7 +391,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
? getNewFieldName(fieldName, true)
: fieldName;
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) {
info.setLambda(lambdaInfo);
@@ -488,15 +481,8 @@ public class AnonymousObjectTransformer extends ObjectTransformer<AnonymousObjec
//lambda with non InlinedLambdaRemapper already have outer
FieldRemapper parent = parentFieldRemapper.getParent();
assert parent instanceof RegeneratedLambdaFieldRemapper;
final Type ownerType = Type.getObjectType(parent.getLambdaInternalName());
CapturedParamDesc desc = new CapturedParamDesc(new CapturedParamOwner() {
@NotNull
@Override
public Type getType() {
return ownerType;
}
}, InlineCodegenUtil.THIS, ownerType);
Type ownerType = Type.getObjectType(parent.getLambdaInternalName());
CapturedParamDesc desc = new CapturedParamDesc(ownerType, InlineCodegenUtil.THIS, ownerType);
CapturedParamInfo recapturedParamInfo =
capturedParamBuilder.addCapturedParam(desc, InlineCodegenUtil.THIS$0/*outer lambda/object*/);
StackValue composed = StackValue.LOCAL_0;
@@ -20,19 +20,19 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.org.objectweb.asm.Type;
public class CapturedParamDesc {
private final CapturedParamOwner containingLambda;
private final Type containingLambdaType;
private final String fieldName;
private final Type type;
public CapturedParamDesc(@NotNull CapturedParamOwner containingLambda, @NotNull String fieldName, @NotNull Type type) {
this.containingLambda = containingLambda;
public CapturedParamDesc(@NotNull Type containingLambdaType, @NotNull String fieldName, @NotNull Type type) {
this.containingLambdaType = containingLambdaType;
this.fieldName = fieldName;
this.type = type;
}
@NotNull
public String getContainingLambdaName() {
return containingLambda.getType().getInternalName();
return containingLambdaType.getInternalName();
}
@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.*;
public class LambdaInfo implements CapturedParamOwner, LabelOwner {
public class LambdaInfo implements LabelOwner {
public final KtExpression expression;
private final KotlinTypeMapper typeMapper;
public final Set<String> labels;
@@ -139,7 +139,7 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
@NotNull
private CapturedParamDesc getCapturedParamInfo(@NotNull EnclosedValueDescriptor descriptor) {
return new CapturedParamDesc(this, descriptor.getFieldName(), descriptor.getType());
return new CapturedParamDesc(closureClassType, descriptor.getFieldName(), descriptor.getType());
}
@NotNull
@@ -161,12 +161,6 @@ public class LambdaInfo implements CapturedParamOwner, LabelOwner {
return builder.buildParameters();
}
@NotNull
@Override
public Type getType() {
return closureClassType;
}
@Override
public boolean isMyLabel(@NotNull String name) {
return labels.contains(name);
@@ -64,7 +64,7 @@ internal class ParametersBuilder private constructor() {
}
fun addCapturedParam(
containingLambda: CapturedParamOwner,
containingLambdaType: Type,
fieldName: String,
newFieldName: String,
type: Type,
@@ -72,7 +72,7 @@ internal class ParametersBuilder private constructor() {
original: ParameterInfo?
): 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) {
info.lambda = original.lambda