Refactor JvmMethodSignature
Rename kotlinParameterTypes -> valueParameters. Inline some other methods
This commit is contained in:
@@ -22,12 +22,14 @@ import org.jetbrains.asm4.Type;
|
|||||||
import org.jetbrains.asm4.commons.InstructionAdapter;
|
import org.jetbrains.asm4.commons.InstructionAdapter;
|
||||||
import org.jetbrains.asm4.commons.Method;
|
import org.jetbrains.asm4.commons.Method;
|
||||||
import org.jetbrains.asm4.util.Printer;
|
import org.jetbrains.asm4.util.Printer;
|
||||||
|
import org.jetbrains.jet.codegen.signature.JvmMethodParameterKind;
|
||||||
import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
import org.jetbrains.jet.codegen.signature.JvmMethodParameterSignature;
|
||||||
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
import org.jetbrains.jet.codegen.signature.JvmMethodSignature;
|
||||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static org.jetbrains.asm4.Opcodes.INVOKESPECIAL;
|
import static org.jetbrains.asm4.Opcodes.INVOKESPECIAL;
|
||||||
@@ -70,12 +72,19 @@ public class CallableMethod implements Callable {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JvmMethodParameterSignature> getValueParameters() {
|
public List<JvmMethodParameterSignature> getValueParameters() {
|
||||||
return signature.getKotlinParameterTypes();
|
return signature.getValueParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<Type> getValueParameterTypes() {
|
public List<Type> getValueParameterTypes() {
|
||||||
return signature.getValueParameterTypes();
|
List<JvmMethodParameterSignature> valueParameters = signature.getValueParameters();
|
||||||
|
List<Type> result = new ArrayList<Type>(valueParameters.size());
|
||||||
|
for (JvmMethodParameterSignature parameter : valueParameters) {
|
||||||
|
if (parameter.getKind() == JvmMethodParameterKind.VALUE) {
|
||||||
|
result.add(parameter.getAsmType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class ConstructorFrameMap extends FrameMap {
|
|||||||
public ConstructorFrameMap(@NotNull JvmMethodSignature signature) {
|
public ConstructorFrameMap(@NotNull JvmMethodSignature signature) {
|
||||||
enterTemp(OBJECT_TYPE); // this
|
enterTemp(OBJECT_TYPE); // this
|
||||||
|
|
||||||
for (JvmMethodParameterSignature parameterType : signature.getKotlinParameterTypes()) {
|
for (JvmMethodParameterSignature parameterType : signature.getValueParameters()) {
|
||||||
if (parameterType.getKind() == JvmMethodParameterKind.OUTER) {
|
if (parameterType.getKind() == JvmMethodParameterKind.OUTER) {
|
||||||
myOuterThisIndex = enterTemp(OBJECT_TYPE); // this0
|
myOuterThisIndex = enterTemp(OBJECT_TYPE); // this0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
|||||||
@NotNull JvmMethodSignature jvmSignature
|
@NotNull JvmMethodSignature jvmSignature
|
||||||
) {
|
) {
|
||||||
Iterator<ValueParameterDescriptor> iterator = functionDescriptor.getValueParameters().iterator();
|
Iterator<ValueParameterDescriptor> iterator = functionDescriptor.getValueParameters().iterator();
|
||||||
List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getKotlinParameterTypes();
|
List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getValueParameters();
|
||||||
|
|
||||||
for (int i = 0; i < kotlinParameterTypes.size(); i++) {
|
for (int i = 0; i < kotlinParameterTypes.size(); i++) {
|
||||||
JvmMethodParameterKind kind = kotlinParameterTypes.get(i).getKind();
|
JvmMethodParameterKind kind = kotlinParameterTypes.get(i).getKind();
|
||||||
@@ -178,7 +178,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
|||||||
@NotNull JvmMethodSignature jvmSignature
|
@NotNull JvmMethodSignature jvmSignature
|
||||||
) {
|
) {
|
||||||
Iterator<ValueParameterDescriptor> descriptors = functionDescriptor.getValueParameters().iterator();
|
Iterator<ValueParameterDescriptor> descriptors = functionDescriptor.getValueParameters().iterator();
|
||||||
List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getKotlinParameterTypes();
|
List<JvmMethodParameterSignature> kotlinParameterTypes = jvmSignature.getValueParameters();
|
||||||
|
|
||||||
for (int i = 0; i < kotlinParameterTypes.size(); i++) {
|
for (int i = 0; i < kotlinParameterTypes.size(); i++) {
|
||||||
JvmMethodParameterKind kind = kotlinParameterTypes.get(i).getKind();
|
JvmMethodParameterKind kind = kotlinParameterTypes.get(i).getKind();
|
||||||
@@ -305,7 +305,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
|||||||
@NotNull OwnerKind ownerKind
|
@NotNull OwnerKind ownerKind
|
||||||
) {
|
) {
|
||||||
Iterator<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters().iterator();
|
Iterator<ValueParameterDescriptor> valueParameters = functionDescriptor.getValueParameters().iterator();
|
||||||
List<JvmMethodParameterSignature> params = jvmMethodSignature.getKotlinParameterTypes();
|
List<JvmMethodParameterSignature> params = jvmMethodSignature.getValueParameters();
|
||||||
int shift = 0;
|
int shift = 0;
|
||||||
|
|
||||||
boolean isStatic = AsmUtil.isStaticMethod(ownerKind, functionDescriptor);
|
boolean isStatic = AsmUtil.isStaticMethod(ownerKind, functionDescriptor);
|
||||||
@@ -563,7 +563,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
|||||||
|
|
||||||
int countOfExtraVarsInMethodArgs = 0;
|
int countOfExtraVarsInMethodArgs = 0;
|
||||||
|
|
||||||
for (JvmMethodParameterSignature parameterSignature : signature.getKotlinParameterTypes()) {
|
for (JvmMethodParameterSignature parameterSignature : signature.getValueParameters()) {
|
||||||
if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
|
if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
|
||||||
countOfExtraVarsInMethodArgs++;
|
countOfExtraVarsInMethodArgs++;
|
||||||
frameMap.enterTemp(parameterSignature.getAsmType());
|
frameMap.enterTemp(parameterSignature.getAsmType());
|
||||||
@@ -629,7 +629,7 @@ public class FunctionCodegen extends ParentCodegenAwareImpl {
|
|||||||
var += ownerType.getSize();
|
var += ownerType.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (JvmMethodParameterSignature parameterSignature : signature.getKotlinParameterTypes()) {
|
for (JvmMethodParameterSignature parameterSignature : signature.getValueParameters()) {
|
||||||
if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
|
if (parameterSignature.getKind() != JvmMethodParameterKind.VALUE) {
|
||||||
Type type = parameterSignature.getAsmType();
|
Type type = parameterSignature.getAsmType();
|
||||||
iv.load(var, type);
|
iv.load(var, type);
|
||||||
|
|||||||
@@ -21,25 +21,21 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.asm4.Type;
|
import org.jetbrains.asm4.Type;
|
||||||
import org.jetbrains.asm4.commons.Method;
|
import org.jetbrains.asm4.commons.Method;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class JvmMethodSignature {
|
public class JvmMethodSignature {
|
||||||
@NotNull
|
|
||||||
private final Method asmMethod;
|
private final Method asmMethod;
|
||||||
@Nullable
|
|
||||||
private final String genericsSignature;
|
private final String genericsSignature;
|
||||||
@NotNull
|
private final List<JvmMethodParameterSignature> valueParameters;
|
||||||
private final List<JvmMethodParameterSignature> kotlinParameterTypes;
|
|
||||||
|
|
||||||
protected JvmMethodSignature(
|
protected JvmMethodSignature(
|
||||||
@NotNull Method asmMethod,
|
@NotNull Method asmMethod,
|
||||||
@Nullable String genericsSignature,
|
@Nullable String genericsSignature,
|
||||||
@NotNull List<JvmMethodParameterSignature> kotlinParameterTypes
|
@NotNull List<JvmMethodParameterSignature> valueParameters
|
||||||
) {
|
) {
|
||||||
this.asmMethod = asmMethod;
|
this.asmMethod = asmMethod;
|
||||||
this.genericsSignature = genericsSignature;
|
this.genericsSignature = genericsSignature;
|
||||||
this.kotlinParameterTypes = kotlinParameterTypes;
|
this.valueParameters = valueParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -53,8 +49,8 @@ public class JvmMethodSignature {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<JvmMethodParameterSignature> getKotlinParameterTypes() {
|
public List<JvmMethodParameterSignature> getValueParameters() {
|
||||||
return kotlinParameterTypes;
|
return valueParameters;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -62,27 +58,11 @@ public class JvmMethodSignature {
|
|||||||
return asmMethod.getReturnType();
|
return asmMethod.getReturnType();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public List<Type> getValueParameterTypes() {
|
|
||||||
List<Type> r = new ArrayList<Type>(kotlinParameterTypes.size());
|
|
||||||
for (JvmMethodParameterSignature p : kotlinParameterTypes) {
|
|
||||||
if (p.getKind() == JvmMethodParameterKind.VALUE) {
|
|
||||||
r.add(p.getAsmType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public JvmMethodSignature replaceName(@NotNull String newName) {
|
public JvmMethodSignature replaceName(@NotNull String newName) {
|
||||||
return newName.equals(asmMethod.getName()) ?
|
return newName.equals(asmMethod.getName()) ?
|
||||||
this :
|
this :
|
||||||
new JvmMethodSignature(new Method(newName, asmMethod.getDescriptor()), genericsSignature, kotlinParameterTypes);
|
new JvmMethodSignature(new Method(newName, asmMethod.getDescriptor()), genericsSignature, valueParameters);
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public String getName() {
|
|
||||||
return asmMethod.getName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -767,10 +767,9 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
.get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression());
|
.get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression());
|
||||||
|
|
||||||
if (superDescriptor instanceof ConstructorDescriptor && isAnonymousObject(descriptor.getContainingDeclaration())) {
|
if (superDescriptor instanceof ConstructorDescriptor && isAnonymousObject(descriptor.getContainingDeclaration())) {
|
||||||
List<JvmMethodParameterSignature> types = mapSignature((ConstructorDescriptor) superDescriptor).getKotlinParameterTypes();
|
for (JvmMethodParameterSignature parameter : mapSignature((ConstructorDescriptor) superDescriptor).getValueParameters()) {
|
||||||
for (JvmMethodParameterSignature type : types) {
|
|
||||||
signatureWriter.writeParameterType(JvmMethodParameterKind.SUPER_CALL_PARAM);
|
signatureWriter.writeParameterType(JvmMethodParameterKind.SUPER_CALL_PARAM);
|
||||||
signatureWriter.writeAsmType(type.getAsmType());
|
signatureWriter.writeAsmType(parameter.getAsmType());
|
||||||
signatureWriter.writeParameterTypeEnd();
|
signatureWriter.writeParameterTypeEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user