[light classes] analysis-api-fir: migrate from :compiler:backend to :compiler:backend.common.jvm
^KT-53097
This commit is contained in:
@@ -8,6 +8,7 @@ dependencies {
|
||||
api(project(":compiler:config.jvm"))
|
||||
api(commonDependency("org.jetbrains.intellij.deps:asm-all"))
|
||||
api(commonDependency("com.google.guava:guava"))
|
||||
compileOnly(intellijCore())
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
+258
@@ -0,0 +1,258 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.signature;
|
||||
|
||||
import com.intellij.util.containers.Stack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.name.Name;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.signature.SignatureVisitor;
|
||||
import org.jetbrains.org.objectweb.asm.signature.SignatureWriter;
|
||||
import org.jetbrains.org.objectweb.asm.util.CheckSignatureAdapter;
|
||||
|
||||
public class BothSignatureWriter extends JvmSignatureWriter {
|
||||
public enum Mode {
|
||||
METHOD(CheckSignatureAdapter.METHOD_SIGNATURE),
|
||||
CLASS(CheckSignatureAdapter.CLASS_SIGNATURE),
|
||||
TYPE(CheckSignatureAdapter.TYPE_SIGNATURE),
|
||||
// Expected to be used only from light classes for type mapping
|
||||
// It's needed because CheckSignatureAdapter.TYPE_SIGNATURE doesn't allow V (void) types.
|
||||
// They're only allowed with CheckSignatureAdapter.METHOD_SIGNATURE after calling `visitReturnType` while in light classes,
|
||||
// we only need to map distinct types
|
||||
SKIP_CHECKS(null);
|
||||
|
||||
private final Integer asmType;
|
||||
|
||||
Mode(Integer asmType) {
|
||||
this.asmType = asmType;
|
||||
}
|
||||
}
|
||||
|
||||
private final SignatureWriter signatureWriter = new SignatureWriter();
|
||||
private final SignatureVisitor signatureVisitor;
|
||||
|
||||
private boolean generic = false;
|
||||
|
||||
public BothSignatureWriter(@NotNull Mode mode) {
|
||||
this.signatureVisitor =
|
||||
mode.asmType != null
|
||||
? new CheckSignatureAdapter(mode.asmType, signatureWriter)
|
||||
: signatureWriter
|
||||
;
|
||||
}
|
||||
|
||||
private final Stack<SignatureVisitor> visitors = new Stack<>();
|
||||
|
||||
private void push(SignatureVisitor visitor) {
|
||||
visitors.push(visitor);
|
||||
}
|
||||
|
||||
private void pop() {
|
||||
visitors.pop();
|
||||
}
|
||||
|
||||
private SignatureVisitor signatureVisitor() {
|
||||
return !visitors.isEmpty() ? visitors.peek() : signatureVisitor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut
|
||||
*/
|
||||
@Override
|
||||
public void writeAsmType(@NotNull Type asmType) {
|
||||
if (asmType.getSort() != Type.OBJECT && asmType.getSort() != Type.ARRAY) {
|
||||
signatureVisitor().visitBaseType(asmType.getDescriptor().charAt(0));
|
||||
}
|
||||
super.writeAsmType(asmType);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void writeClassBegin(Type asmType) {
|
||||
signatureVisitor().visitClassType(asmType.getInternalName());
|
||||
super.writeClassBegin(asmType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeOuterClassBegin(Type resultingAsmType, String outerInternalName) {
|
||||
signatureVisitor().visitClassType(outerInternalName);
|
||||
super.writeOuterClassBegin(resultingAsmType, outerInternalName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInnerClass(String name) {
|
||||
signatureVisitor().visitInnerClassType(name);
|
||||
super.writeInnerClass(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeClassEnd() {
|
||||
signatureVisitor().visitEnd();
|
||||
super.writeClassEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeArrayType() {
|
||||
push(signatureVisitor().visitArrayType());
|
||||
super.writeArrayType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeArrayEnd() {
|
||||
pop();
|
||||
super.writeArrayEnd();
|
||||
}
|
||||
|
||||
private static char toJvmVariance(@NotNull Variance variance) {
|
||||
switch (variance) {
|
||||
case INVARIANT: return '=';
|
||||
case IN_VARIANCE: return '-';
|
||||
case OUT_VARIANCE: return '+';
|
||||
default: throw new IllegalStateException("Unknown variance: " + variance);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTypeArgument(@NotNull Variance projectionKind) {
|
||||
push(signatureVisitor().visitTypeArgument(toJvmVariance(projectionKind)));
|
||||
generic = true;
|
||||
super.writeTypeArgument(projectionKind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeUnboundedWildcard() {
|
||||
signatureVisitor().visitTypeArgument();
|
||||
generic = true;
|
||||
super.writeUnboundedWildcard();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTypeArgumentEnd() {
|
||||
pop();
|
||||
super.writeTypeArgumentEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTypeVariable(@NotNull Name name, @NotNull Type asmType) {
|
||||
signatureVisitor().visitTypeVariable(name.asString());
|
||||
generic = true;
|
||||
super.writeTypeVariable(name, asmType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeFormalTypeParameter(String name) {
|
||||
signatureVisitor().visitFormalTypeParameter(name);
|
||||
generic = true;
|
||||
super.writeFormalTypeParameter(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeClassBound() {
|
||||
push(signatureVisitor().visitClassBound());
|
||||
super.writeClassBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeClassBoundEnd() {
|
||||
pop();
|
||||
super.writeClassBoundEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInterfaceBound() {
|
||||
push(signatureVisitor().visitInterfaceBound());
|
||||
super.writeInterfaceBound();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInterfaceBoundEnd() {
|
||||
pop();
|
||||
super.writeInterfaceBoundEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeParametersStart() {
|
||||
super.writeParametersStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeParameterType(JvmMethodParameterKind parameterKind) {
|
||||
// This magic mimics the behavior of javac that enum constructor have these synthetic parameters in erased signature, but doesn't
|
||||
// have them in generic signature. IDEA, javac and their friends rely on this behavior.
|
||||
if (parameterKind.isSkippedInGenericSignature()) {
|
||||
generic = true;
|
||||
|
||||
// pushing dummy visitor, because we don't want these parameters to appear in generic JVM signature
|
||||
push(new SignatureWriter());
|
||||
}
|
||||
else {
|
||||
push(signatureVisitor().visitParameterType());
|
||||
}
|
||||
super.writeParameterType(parameterKind);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeParameterTypeEnd() {
|
||||
pop();
|
||||
super.writeParameterTypeEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeReturnType() {
|
||||
push(signatureVisitor().visitReturnType());
|
||||
super.writeReturnType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeReturnTypeEnd() {
|
||||
pop();
|
||||
super.writeReturnTypeEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSuperclass() {
|
||||
push(signatureVisitor().visitSuperclass());
|
||||
super.writeSuperclass();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSuperclassEnd() {
|
||||
pop();
|
||||
super.writeSuperclassEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInterface() {
|
||||
push(signatureVisitor().visitInterface());
|
||||
super.writeInterface();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeInterfaceEnd() {
|
||||
pop();
|
||||
super.writeInterfaceEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String makeJavaGenericSignature() {
|
||||
return generic ? signatureWriter.toString() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean skipGenericSignature() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return signatureWriter.toString();
|
||||
}
|
||||
}
|
||||
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.codegen.signature;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil;
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmDescriptorTypeWriter;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodGenericSignature;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterKind;
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodParameterSignature;
|
||||
import org.jetbrains.kotlin.types.Variance;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class JvmSignatureWriter extends JvmDescriptorTypeWriter<Type> {
|
||||
|
||||
private final List<JvmMethodParameterSignature> kotlinParameterTypes = new ArrayList<>();
|
||||
|
||||
private Type jvmReturnType;
|
||||
|
||||
private JvmMethodParameterKind currentParameterKind;
|
||||
|
||||
private int currentSignatureSize = 0;
|
||||
|
||||
public JvmSignatureWriter() {
|
||||
super(AsmTypeFactory.INSTANCE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeClass(@NotNull Type objectType) {
|
||||
writeClassBegin(objectType);
|
||||
writeClassEnd();
|
||||
}
|
||||
|
||||
public void writeAsmType(@NotNull Type asmType) {
|
||||
switch (asmType.getSort()) {
|
||||
case Type.OBJECT:
|
||||
writeClassBegin(asmType);
|
||||
writeClassEnd();
|
||||
return;
|
||||
case Type.ARRAY:
|
||||
writeArrayType();
|
||||
writeAsmType(AsmUtil.correctElementType(asmType));
|
||||
writeArrayEnd();
|
||||
return;
|
||||
default:
|
||||
writeJvmTypeAsIs(asmType);
|
||||
}
|
||||
}
|
||||
|
||||
public void writeClassBegin(Type asmType) {
|
||||
writeJvmTypeAsIs(asmType);
|
||||
}
|
||||
|
||||
public void writeOuterClassBegin(Type resultingAsmType, String outerInternalName) {
|
||||
writeJvmTypeAsIs(resultingAsmType);
|
||||
}
|
||||
|
||||
public void writeInnerClass(String name) {
|
||||
}
|
||||
|
||||
public void writeClassEnd() {
|
||||
}
|
||||
|
||||
public void writeTypeArgument(@NotNull Variance projectionKind) {
|
||||
}
|
||||
|
||||
public void writeUnboundedWildcard() {
|
||||
}
|
||||
|
||||
public void writeTypeArgumentEnd() {
|
||||
}
|
||||
|
||||
public void writeFormalTypeParameter(String name) {
|
||||
}
|
||||
|
||||
public void writeClassBound() {
|
||||
}
|
||||
|
||||
public void writeClassBoundEnd() {
|
||||
}
|
||||
|
||||
public void writeInterfaceBound() {
|
||||
}
|
||||
|
||||
public void writeInterfaceBoundEnd() {
|
||||
}
|
||||
|
||||
public void writeParametersStart() {
|
||||
// hacks
|
||||
clearCurrentType();
|
||||
}
|
||||
|
||||
public void writeParameterType(JvmMethodParameterKind parameterKind) {
|
||||
currentParameterKind = parameterKind;
|
||||
}
|
||||
|
||||
public void writeParameterTypeEnd() {
|
||||
//noinspection ConstantConditions
|
||||
kotlinParameterTypes.add(new JvmMethodParameterSignature(getJvmCurrentType(), currentParameterKind));
|
||||
currentSignatureSize += getJvmCurrentType().getSize();
|
||||
|
||||
currentParameterKind = null;
|
||||
clearCurrentType();
|
||||
}
|
||||
|
||||
public void writeReturnType() {
|
||||
}
|
||||
|
||||
public void writeReturnTypeEnd() {
|
||||
jvmReturnType = getJvmCurrentType();
|
||||
clearCurrentType();
|
||||
}
|
||||
|
||||
public void writeSuperclass() {
|
||||
}
|
||||
|
||||
public void writeSuperclassEnd() {
|
||||
}
|
||||
|
||||
public void writeInterface() {
|
||||
}
|
||||
|
||||
public void writeInterfaceEnd() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String makeJavaGenericSignature() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmMethodGenericSignature makeJvmMethodSignature(@NotNull String name) {
|
||||
List<Type> types = new ArrayList<>(kotlinParameterTypes.size());
|
||||
for (JvmMethodParameterSignature parameter : kotlinParameterTypes) {
|
||||
types.add(parameter.getAsmType());
|
||||
}
|
||||
Method asmMethod = new Method(name, jvmReturnType, types.toArray(new Type[types.size()]));
|
||||
return new JvmMethodGenericSignature(asmMethod, kotlinParameterTypes, makeJavaGenericSignature());
|
||||
}
|
||||
|
||||
public int getCurrentSignatureSize() {
|
||||
return currentSignatureSize;
|
||||
}
|
||||
|
||||
public boolean skipGenericSignature() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "empty";
|
||||
}
|
||||
}
|
||||
|
||||
+59
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
|
||||
fun TypeSystemCommonBackendContext.getOptimalModeForValueParameter(
|
||||
type: KotlinTypeMarker
|
||||
): TypeMappingMode = getOptimalModeForSignaturePart(type, canBeUsedInSupertypePosition = true)
|
||||
|
||||
fun TypeSystemCommonBackendContext.getOptimalModeForReturnType(
|
||||
type: KotlinTypeMarker,
|
||||
isAnnotationMethod: Boolean
|
||||
): TypeMappingMode {
|
||||
return if (isAnnotationMethod)
|
||||
TypeMappingMode.VALUE_FOR_ANNOTATION
|
||||
else
|
||||
getOptimalModeForSignaturePart(type, canBeUsedInSupertypePosition = false)
|
||||
}
|
||||
|
||||
@OptIn(TypeMappingModeInternals::class)
|
||||
private fun TypeSystemCommonBackendContext.getOptimalModeForSignaturePart(
|
||||
type: KotlinTypeMarker,
|
||||
canBeUsedInSupertypePosition: Boolean
|
||||
): TypeMappingMode {
|
||||
if (type.argumentsCount() == 0) return TypeMappingMode.DEFAULT
|
||||
|
||||
val isInlineClassType = type.typeConstructor().isInlineClass()
|
||||
if (isInlineClassType && shouldUseUnderlyingType(type)) {
|
||||
val underlyingType = computeUnderlyingType(type)
|
||||
if (underlyingType != null) {
|
||||
return getOptimalModeForSignaturePart(underlyingType, canBeUsedInSupertypePosition).dontWrapInlineClassesMode()
|
||||
}
|
||||
}
|
||||
|
||||
val contravariantArgumentMode =
|
||||
if (!canBeUsedInSupertypePosition)
|
||||
TypeMappingMode(skipDeclarationSiteWildcards = false, skipDeclarationSiteWildcardsIfPossible = true)
|
||||
else
|
||||
null
|
||||
|
||||
val invariantArgumentMode =
|
||||
if (canBeUsedInSupertypePosition)
|
||||
getOptimalModeForSignaturePart(type, canBeUsedInSupertypePosition = false)
|
||||
else
|
||||
null
|
||||
|
||||
return TypeMappingMode(
|
||||
skipDeclarationSiteWildcards = !canBeUsedInSupertypePosition,
|
||||
skipDeclarationSiteWildcardsIfPossible = true,
|
||||
genericContravariantArgumentMode = contravariantArgumentMode,
|
||||
genericInvariantArgumentMode = invariantArgumentMode,
|
||||
needInlineClassWrapping = !isInlineClassType
|
||||
)
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.load.kotlin
|
||||
|
||||
import org.jetbrains.kotlin.types.TypeSystemCommonBackendContext
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.SimpleTypeMarker
|
||||
|
||||
internal fun TypeSystemCommonBackendContext.computeUnderlyingType(inlineClassType: KotlinTypeMarker): KotlinTypeMarker? {
|
||||
if (!shouldUseUnderlyingType(inlineClassType)) return null
|
||||
|
||||
val underlyingType = inlineClassType.getUnsubstitutedUnderlyingType() ?: return null
|
||||
return underlyingType.typeConstructor().getTypeParameterClassifier()?.getRepresentativeUpperBound()
|
||||
?: inlineClassType.getSubstitutedUnderlyingType()
|
||||
}
|
||||
|
||||
internal fun TypeSystemCommonBackendContext.shouldUseUnderlyingType(inlineClassType: KotlinTypeMarker): Boolean {
|
||||
val underlyingType = inlineClassType.getUnsubstitutedUnderlyingType() ?: return false
|
||||
|
||||
return !inlineClassType.isMarkedNullable() ||
|
||||
!underlyingType.isNullableType() && !(underlyingType is SimpleTypeMarker && underlyingType.isPrimitiveType())
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.jvmSignature;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JvmClassSignature {
|
||||
private final String name;
|
||||
private final String superclassName;
|
||||
private final List<String> interfaces;
|
||||
private final String javaGenericSignature;
|
||||
|
||||
public JvmClassSignature(String name, String superclassName, List<String> interfaces, @Nullable String javaGenericSignature) {
|
||||
this.name = name;
|
||||
this.superclassName = superclassName;
|
||||
this.interfaces = interfaces;
|
||||
this.javaGenericSignature = javaGenericSignature;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public String getSuperclassName() {
|
||||
return superclassName;
|
||||
}
|
||||
|
||||
public List<String> getInterfaces() {
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
public String getJavaGenericSignature() {
|
||||
return javaGenericSignature;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.jvmSignature;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
public class JvmMethodGenericSignature extends JvmMethodSignature {
|
||||
private final String genericsSignature;
|
||||
|
||||
public JvmMethodGenericSignature(
|
||||
@NotNull Method asmMethod,
|
||||
@NotNull List<JvmMethodParameterSignature> valueParameters,
|
||||
@Nullable String genericsSignature
|
||||
) {
|
||||
super(asmMethod, valueParameters);
|
||||
this.genericsSignature = genericsSignature;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getGenericsSignature() {
|
||||
return genericsSignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof JvmMethodGenericSignature)) return false;
|
||||
|
||||
JvmMethodGenericSignature that = (JvmMethodGenericSignature) o;
|
||||
|
||||
return super.equals(that) && Objects.equals(genericsSignature, that.genericsSignature);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = super.hashCode();
|
||||
result = 31 * result + (genericsSignature != null ? genericsSignature.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.jvmSignature;
|
||||
|
||||
public enum JvmMethodParameterKind {
|
||||
VALUE,
|
||||
THIS,
|
||||
OUTER,
|
||||
RECEIVER,
|
||||
CONTEXT_RECEIVER,
|
||||
CAPTURED_LOCAL_VARIABLE,
|
||||
ENUM_NAME_OR_ORDINAL,
|
||||
SUPER_CALL_PARAM,
|
||||
CONSTRUCTOR_MARKER;
|
||||
|
||||
public boolean isSkippedInGenericSignature() {
|
||||
return this == OUTER || this == ENUM_NAME_OR_ORDINAL;
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.jvmSignature;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
public final class JvmMethodParameterSignature {
|
||||
private final Type asmType;
|
||||
private final JvmMethodParameterKind kind;
|
||||
|
||||
public JvmMethodParameterSignature(@NotNull Type asmType, @NotNull JvmMethodParameterKind kind) {
|
||||
this.asmType = asmType;
|
||||
this.kind = kind;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getAsmType() {
|
||||
return asmType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmMethodParameterKind getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof JvmMethodParameterSignature)) return false;
|
||||
|
||||
JvmMethodParameterSignature that = (JvmMethodParameterSignature) o;
|
||||
return asmType.equals(that.asmType) && kind == that.kind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return 31 * asmType.hashCode() + kind.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return kind + " " + asmType;
|
||||
}
|
||||
}
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.resolve.jvm.jvmSignature;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class JvmMethodSignature {
|
||||
private final Method asmMethod;
|
||||
private final List<JvmMethodParameterSignature> valueParameters;
|
||||
|
||||
public JvmMethodSignature(
|
||||
@NotNull Method asmMethod,
|
||||
@NotNull List<JvmMethodParameterSignature> valueParameters
|
||||
) {
|
||||
this.asmMethod = asmMethod;
|
||||
this.valueParameters = valueParameters;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Method getAsmMethod() {
|
||||
return asmMethod;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public List<JvmMethodParameterSignature> getValueParameters() {
|
||||
return valueParameters;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Type getReturnType() {
|
||||
return asmMethod.getReturnType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof JvmMethodSignature)) return false;
|
||||
|
||||
JvmMethodSignature that = (JvmMethodSignature) o;
|
||||
|
||||
return asmMethod.equals(that.asmMethod) &&
|
||||
valueParameters.equals(that.valueParameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = asmMethod.hashCode();
|
||||
result = 31 * result + valueParameters.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return asmMethod.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user