Remove useless parameter of FunctionCodegen.generateMethod
JvmMethodSignature can now be perfectly obtained by JetTypeMapper.mapSignature
This commit is contained in:
@@ -35,7 +35,6 @@ import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.psi.JetElement;
|
||||
import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature;
|
||||
import org.jetbrains.kotlin.types.JetType;
|
||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -161,10 +160,12 @@ public class ClosureCodegen extends MemberCodegen<JetElement> {
|
||||
erasedInterfaceFunction = samType.getAbstractMethod().getOriginal();
|
||||
}
|
||||
|
||||
JvmMethodSignature jvmMethodSignature = typeMapper.mapSignature(funDescriptor);
|
||||
generateBridge(typeMapper.mapSignature(erasedInterfaceFunction).getAsmMethod(), jvmMethodSignature.getAsmMethod());
|
||||
generateBridge(
|
||||
typeMapper.mapSignature(erasedInterfaceFunction).getAsmMethod(),
|
||||
typeMapper.mapSignature(funDescriptor).getAsmMethod()
|
||||
);
|
||||
|
||||
functionCodegen.generateMethod(OtherOrigin(element, funDescriptor), jvmMethodSignature, funDescriptor, strategy);
|
||||
functionCodegen.generateMethod(OtherOrigin(element, funDescriptor), funDescriptor, strategy);
|
||||
|
||||
//TODO: rewrite cause ugly hack
|
||||
if (samType != null) {
|
||||
|
||||
@@ -110,8 +110,7 @@ public class FunctionCodegen {
|
||||
JvmMethodSignature method = typeMapper.mapSignature(functionDescriptor, kind);
|
||||
|
||||
if (kind != OwnerKind.TRAIT_IMPL || function.hasBody()) {
|
||||
generateMethod(OtherOrigin(function, functionDescriptor),
|
||||
method, functionDescriptor,
|
||||
generateMethod(OtherOrigin(function, functionDescriptor), functionDescriptor,
|
||||
new FunctionGenerationStrategy.FunctionDefault(state, functionDescriptor, function));
|
||||
}
|
||||
|
||||
@@ -121,24 +120,23 @@ public class FunctionCodegen {
|
||||
|
||||
public void generateMethod(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
@NotNull JvmMethodSignature jvmSignature,
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull FunctionDescriptor descriptor,
|
||||
@NotNull FunctionGenerationStrategy strategy
|
||||
) {
|
||||
generateMethod(origin, jvmSignature, functionDescriptor, owner.intoFunction(functionDescriptor), strategy);
|
||||
generateMethod(origin, descriptor, owner.intoFunction(descriptor), strategy);
|
||||
}
|
||||
|
||||
public void generateMethod(
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
@NotNull JvmMethodSignature jvmSignature,
|
||||
@NotNull FunctionDescriptor functionDescriptor,
|
||||
@NotNull MethodContext methodContext,
|
||||
@NotNull FunctionGenerationStrategy strategy
|
||||
) {
|
||||
OwnerKind methodContextKind = methodContext.getContextKind();
|
||||
OwnerKind contextKind = methodContext.getContextKind();
|
||||
JvmMethodSignature jvmSignature = typeMapper.mapSignature(functionDescriptor, contextKind);
|
||||
Method asmMethod = jvmSignature.getAsmMethod();
|
||||
|
||||
int flags = getMethodAsmFlags(functionDescriptor, methodContextKind);
|
||||
int flags = getMethodAsmFlags(functionDescriptor, contextKind);
|
||||
boolean isNative = NativeDeclarationsPackage.hasNativeAnnotation(functionDescriptor);
|
||||
|
||||
if (isNative && owner instanceof PackageContext && !(owner instanceof PackageFacadeContext)) {
|
||||
@@ -176,7 +174,7 @@ public class FunctionCodegen {
|
||||
parentBodyCodegen.addAdditionalTask(new PlatformStaticGenerator(functionDescriptor, origin, state));
|
||||
}
|
||||
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES || isAbstractMethod(functionDescriptor, methodContextKind)) {
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.LIGHT_CLASSES || isAbstractMethod(functionDescriptor, contextKind)) {
|
||||
generateLocalVariableTable(
|
||||
mv,
|
||||
jvmSignature,
|
||||
@@ -184,7 +182,7 @@ public class FunctionCodegen {
|
||||
getThisTypeForFunction(functionDescriptor, methodContext, typeMapper),
|
||||
new Label(),
|
||||
new Label(),
|
||||
methodContextKind
|
||||
contextKind
|
||||
);
|
||||
|
||||
mv.visitEnd();
|
||||
@@ -851,10 +849,8 @@ public class FunctionCodegen {
|
||||
final ClassDescriptor toClass,
|
||||
final StackValue field
|
||||
) {
|
||||
final JvmMethodSignature jvmDelegateMethodSignature = typeMapper.mapSignature(delegateFunction);
|
||||
final JvmMethodSignature jvmDelegateToMethodSignature = typeMapper.mapSignature(delegatedTo);
|
||||
generateMethod(
|
||||
OtherOrigin(delegateFunction), jvmDelegateMethodSignature, delegateFunction,
|
||||
OtherOrigin(delegateFunction), delegateFunction,
|
||||
new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
public void generateBody(
|
||||
@@ -864,8 +860,8 @@ public class FunctionCodegen {
|
||||
@NotNull MethodContext context,
|
||||
@NotNull MemberCodegen<?> parentCodegen
|
||||
) {
|
||||
Method delegateToMethod = jvmDelegateToMethodSignature.getAsmMethod();
|
||||
Method delegateMethod = jvmDelegateMethodSignature.getAsmMethod();
|
||||
Method delegateToMethod = typeMapper.mapSignature(delegatedTo).getAsmMethod();
|
||||
Method delegateMethod = typeMapper.mapSignature(delegateFunction).getAsmMethod();
|
||||
|
||||
Type[] argTypes = delegateMethod.getArgumentTypes();
|
||||
Type[] originalArgTypes = delegateToMethod.getArgumentTypes();
|
||||
@@ -893,7 +889,8 @@ public class FunctionCodegen {
|
||||
TypesPackage.getApproximationTo(
|
||||
delegatedTo.getReturnType(),
|
||||
delegateFunction.getReturnType(),
|
||||
new Approximation.DataFlowExtras.OnlyMessage(delegatedTo.getName() + "(...)"))
|
||||
new Approximation.DataFlowExtras.OnlyMessage(delegatedTo.getName() + "(...)")
|
||||
)
|
||||
);
|
||||
|
||||
stackValue.put(delegateMethod.getReturnType(), iv);
|
||||
|
||||
@@ -681,7 +681,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
@Override
|
||||
public void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull final ValueParameterDescriptor parameter) {
|
||||
PsiElement originalElement = DescriptorToSourceUtils.descriptorToDeclaration(parameter);
|
||||
functionCodegen.generateMethod(OtherOrigin(originalElement, function), typeMapper.mapSignature(function), function, new FunctionGenerationStrategy() {
|
||||
functionCodegen.generateMethod(OtherOrigin(originalElement, function), function, new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
public void generateBody(
|
||||
@NotNull MethodVisitor mv,
|
||||
@@ -706,11 +706,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
@Override
|
||||
public void generateCopyFunction(@NotNull final FunctionDescriptor function, @NotNull List<JetParameter> constructorParameters) {
|
||||
JvmMethodSignature methodSignature = typeMapper.mapSignature(function);
|
||||
|
||||
final Type thisDescriptorType = typeMapper.mapType(descriptor);
|
||||
|
||||
functionCodegen.generateMethod(OtherOrigin(myClass, function), methodSignature, function, new FunctionGenerationStrategy() {
|
||||
functionCodegen.generateMethod(OtherOrigin(myClass, function), function, new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
public void generateBody(
|
||||
@NotNull MethodVisitor mv,
|
||||
@@ -755,7 +753,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
});
|
||||
|
||||
functionCodegen.generateDefaultIfNeeded(
|
||||
context.intoFunction(function), methodSignature, function, OwnerKind.IMPLEMENTATION,
|
||||
context.intoFunction(function), typeMapper.mapSignature(function), function, OwnerKind.IMPLEMENTATION,
|
||||
new DefaultParameterValueLoader() {
|
||||
@Override
|
||||
public StackValue genValue(ValueParameterDescriptor valueParameter, ExpressionCodegen codegen) {
|
||||
@@ -834,7 +832,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
FunctionDescriptor bridge = (FunctionDescriptor) entry.getValue();
|
||||
final FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
|
||||
functionCodegen.generateMethod(
|
||||
Synthetic(null, original), typeMapper.mapSignature(bridge), bridge,
|
||||
Synthetic(null, original), bridge,
|
||||
new FunctionGenerationStrategy.CodegenBased<FunctionDescriptor>(state, bridge) {
|
||||
@Override
|
||||
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
||||
@@ -889,9 +887,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
PropertyGetterDescriptor getter = bridge.getGetter();
|
||||
assert getter != null;
|
||||
functionCodegen.generateMethod(Synthetic(null, original.getGetter() != null ? original.getGetter() : original),
|
||||
typeMapper.mapSignature(getter),
|
||||
getter,
|
||||
new PropertyAccessorStrategy(getter));
|
||||
getter, new PropertyAccessorStrategy(getter));
|
||||
|
||||
|
||||
if (bridge.isVar()) {
|
||||
@@ -899,9 +895,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
assert setter != null;
|
||||
|
||||
functionCodegen.generateMethod(Synthetic(null, original.getSetter() != null ? original.getSetter() : original),
|
||||
typeMapper.mapSignature(setter),
|
||||
setter,
|
||||
new PropertyAccessorStrategy(setter));
|
||||
setter, new PropertyAccessorStrategy(setter));
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1053,9 +1047,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
lookupConstructorExpressionsInClosureIfPresent(constructorContext);
|
||||
}
|
||||
|
||||
JvmMethodSignature signature = typeMapper.mapSignature(constructorDescriptor);
|
||||
|
||||
functionCodegen.generateMethod(OtherOrigin(myClass, constructorDescriptor), signature, constructorDescriptor, constructorContext,
|
||||
functionCodegen.generateMethod(OtherOrigin(myClass, constructorDescriptor), constructorDescriptor, constructorContext,
|
||||
new FunctionGenerationStrategy.CodegenBased<ConstructorDescriptor>(state, constructorDescriptor) {
|
||||
@Override
|
||||
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
||||
@@ -1064,8 +1056,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
);
|
||||
|
||||
functionCodegen.generateDefaultIfNeeded(constructorContext, signature, constructorDescriptor, OwnerKind.IMPLEMENTATION,
|
||||
DefaultParameterValueLoader.DEFAULT, null);
|
||||
functionCodegen.generateDefaultIfNeeded(constructorContext, typeMapper.mapSignature(constructorDescriptor), constructorDescriptor,
|
||||
OwnerKind.IMPLEMENTATION, DefaultParameterValueLoader.DEFAULT, null);
|
||||
|
||||
CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructorDescriptor);
|
||||
FunctionCodegen.generateConstructorWithoutParametersIfNeeded(state, callableMethod, constructorDescriptor, v, myClass);
|
||||
@@ -1348,7 +1340,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generateDelegationToTraitImpl(@NotNull final FunctionDescriptor traitFun, @NotNull FunctionDescriptor inheritedFun) {
|
||||
functionCodegen.generateMethod(
|
||||
DelegationToTraitImpl(descriptorToDeclaration(traitFun), traitFun),
|
||||
typeMapper.mapSignature(inheritedFun),
|
||||
inheritedFun,
|
||||
new FunctionGenerationStrategy.CodegenBased<FunctionDescriptor>(state, inheritedFun) {
|
||||
@Override
|
||||
|
||||
@@ -174,8 +174,7 @@ public class PackageCodegen {
|
||||
|
||||
if (member instanceof DeserializedSimpleFunctionDescriptor) {
|
||||
DeserializedSimpleFunctionDescriptor function = (DeserializedSimpleFunctionDescriptor) member;
|
||||
JvmMethodSignature signature = state.getTypeMapper().mapSignature(function, OwnerKind.PACKAGE);
|
||||
memberCodegen.functionCodegen.generateMethod(OtherOrigin(function), signature, function,
|
||||
memberCodegen.functionCodegen.generateMethod(OtherOrigin(function), function,
|
||||
new FunctionGenerationStrategy() {
|
||||
@Override
|
||||
public void generateBody(
|
||||
@@ -191,9 +190,9 @@ public class PackageCodegen {
|
||||
);
|
||||
|
||||
memberCodegen.functionCodegen.generateDefaultIfNeeded(
|
||||
context.intoFunction(function), signature, function, OwnerKind.PACKAGE,
|
||||
DefaultParameterValueLoader.DEFAULT, null);
|
||||
|
||||
context.intoFunction(function), state.getTypeMapper().mapSignature(function, OwnerKind.PACKAGE),
|
||||
function, OwnerKind.PACKAGE, DefaultParameterValueLoader.DEFAULT, null
|
||||
);
|
||||
}
|
||||
else if (member instanceof DeserializedPropertyDescriptor) {
|
||||
memberCodegen.propertyCodegen.generateInPackageFacade((DeserializedPropertyDescriptor) member);
|
||||
|
||||
@@ -40,13 +40,10 @@ class PlatformStaticGenerator(
|
||||
override fun invoke(codegen: ImplementationBodyCodegen, classBuilder: ClassBuilder) {
|
||||
val staticFunctionDescriptor = createStaticFunctionDescriptor(descriptor)
|
||||
|
||||
val jvmMethodSignature = state.getTypeMapper().mapSignature(staticFunctionDescriptor)
|
||||
|
||||
codegen.functionCodegen.generateMethod(
|
||||
Synthetic(declarationOrigin.element, staticFunctionDescriptor),
|
||||
jvmMethodSignature,
|
||||
staticFunctionDescriptor,
|
||||
object: FunctionGenerationStrategy() {
|
||||
object : FunctionGenerationStrategy() {
|
||||
override fun generateBody(
|
||||
mv: MethodVisitor,
|
||||
frameMap: FrameMap,
|
||||
@@ -86,7 +83,7 @@ class PlatformStaticGenerator(
|
||||
val copies = CodegenUtil.copyFunctions(
|
||||
memberDescriptor,
|
||||
memberDescriptor,
|
||||
descriptor.getContainingDeclaration()?.getContainingDeclaration(),
|
||||
descriptor.getContainingDeclaration().getContainingDeclaration(),
|
||||
descriptor.getModality(),
|
||||
descriptor.getVisibility(),
|
||||
CallableMemberDescriptor.Kind.SYNTHESIZED,
|
||||
|
||||
@@ -341,8 +341,7 @@ public class PropertyCodegen {
|
||||
strategy = new FunctionGenerationStrategy.FunctionDefault(state, accessorDescriptor, accessor);
|
||||
}
|
||||
|
||||
JvmMethodSignature signature = typeMapper.mapSignature(accessorDescriptor, kind);
|
||||
functionCodegen.generateMethod(OtherOrigin(accessor != null ? accessor : p, accessorDescriptor), signature, accessorDescriptor, strategy);
|
||||
functionCodegen.generateMethod(OtherOrigin(accessor != null ? accessor : p, accessorDescriptor), accessorDescriptor, strategy);
|
||||
}
|
||||
|
||||
public static int indexOfDelegatedProperty(@NotNull JetProperty property) {
|
||||
|
||||
Reference in New Issue
Block a user