Inline methods.

This commit is contained in:
Peter Rybin
2014-05-06 03:01:43 +04:00
committed by Zalim Bashorov
parent 59a09c04af
commit 535cc3eed8
@@ -625,7 +625,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
new DataClassMethodGeneratorImpl(myClass, bindingContext).generate(); new DataClassMethodGeneratorImpl(myClass, bindingContext).generate();
} }
// A delegating class. Actual method implementations could easily move in.
private class DataClassMethodGeneratorImpl extends DataClassMethodGenerator { private class DataClassMethodGeneratorImpl extends DataClassMethodGenerator {
DataClassMethodGeneratorImpl( DataClassMethodGeneratorImpl(
JetClassOrObject klass, JetClassOrObject klass,
@@ -634,33 +633,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
super(klass, bindingContext); super(klass, bindingContext);
} }
@Override
public void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull ValueParameterDescriptor parameter) {
ImplementationBodyCodegen.this.generateComponentFunction(function, parameter);
}
@Override
public void generateCopyFunction(@NotNull FunctionDescriptor function, @NotNull List<JetParameter> constructorParameters) {
ImplementationBodyCodegen.this.generateCopyFunction(function);
}
@Override
public void generateToStringMethod(@NotNull List<PropertyDescriptor> properties) {
ImplementationBodyCodegen.this.generateDataClassToStringMethod(properties);
}
@Override
public void generateHashCodeMethod(@NotNull List<PropertyDescriptor> properties) {
ImplementationBodyCodegen.this.generateDataClassHashCodeMethod(properties);
}
@Override @Override
public void generateEqualsMethod(@NotNull List<PropertyDescriptor> properties) { public void generateEqualsMethod(@NotNull List<PropertyDescriptor> properties) {
ImplementationBodyCodegen.this.generateDataClassEqualsMethod(properties);
}
}
private void generateDataClassEqualsMethod(@NotNull List<PropertyDescriptor> properties) {
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null); MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "equals", "(Ljava/lang/Object;)Z", null, null);
InstructionAdapter iv = new InstructionAdapter(mv); InstructionAdapter iv = new InstructionAdapter(mv);
@@ -714,7 +688,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
FunctionCodegen.endVisit(mv, "equals", myClass); FunctionCodegen.endVisit(mv, "equals", myClass);
} }
private void generateDataClassHashCodeMethod(@NotNull List<PropertyDescriptor> properties) { @Override
public void generateHashCodeMethod(@NotNull List<PropertyDescriptor> properties) {
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "hashCode", "()I", null, null); MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "hashCode", "()I", null, null);
InstructionAdapter iv = new InstructionAdapter(mv); InstructionAdapter iv = new InstructionAdapter(mv);
@@ -760,7 +735,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
FunctionCodegen.endVisit(mv, "hashCode", myClass); FunctionCodegen.endVisit(mv, "hashCode", myClass);
} }
private void generateDataClassToStringMethod(@NotNull List<PropertyDescriptor> properties) { @Override
public void generateToStringMethod(@NotNull List<PropertyDescriptor> properties) {
MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null); MethodVisitor mv = v.getVisitor().visitMethod(ACC_PUBLIC, "toString", "()Ljava/lang/String;", null, null);
InstructionAdapter iv = new InstructionAdapter(mv); InstructionAdapter iv = new InstructionAdapter(mv);
@@ -814,13 +790,14 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
return method.getReturnType(); return method.getReturnType();
} }
private void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull final ValueParameterDescriptor parameter) { @Override
public void generateComponentFunction(@NotNull FunctionDescriptor function, @NotNull final ValueParameterDescriptor parameter) {
functionCodegen.generateMethod(myClass, typeMapper.mapSignature(function), function, new FunctionGenerationStrategy() { functionCodegen.generateMethod(myClass, typeMapper.mapSignature(function), function, new FunctionGenerationStrategy() {
@Override @Override
public void generateBody( public void generateBody(
@NotNull MethodVisitor mv, @NotNull MethodVisitor mv,
@NotNull JvmMethodSignature signature, @NotNull JvmMethodSignature signature,
@NotNull MethodContext context, @NotNull MethodContext context1,
@Nullable MemberCodegen<?> parentCodegen @Nullable MemberCodegen<?> parentCodegen
) { ) {
Type componentType = signature.getReturnType(); Type componentType = signature.getReturnType();
@@ -835,7 +812,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
}); });
} }
private void generateCopyFunction(@NotNull final FunctionDescriptor function) { @Override
public void generateCopyFunction(@NotNull final FunctionDescriptor function, @NotNull List<JetParameter> constructorParameters) {
JvmMethodSignature methodSignature = typeMapper.mapSignature(function); JvmMethodSignature methodSignature = typeMapper.mapSignature(function);
final Type thisDescriptorType = typeMapper.mapType(descriptor); final Type thisDescriptorType = typeMapper.mapType(descriptor);
@@ -845,7 +823,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
public void generateBody( public void generateBody(
@NotNull MethodVisitor mv, @NotNull MethodVisitor mv,
@NotNull JvmMethodSignature signature, @NotNull JvmMethodSignature signature,
@NotNull MethodContext context, @NotNull MethodContext context1,
@Nullable MemberCodegen<?> parentCodegen @Nullable MemberCodegen<?> parentCodegen
) { ) {
InstructionAdapter iv = new InstructionAdapter(mv); InstructionAdapter iv = new InstructionAdapter(mv);
@@ -896,6 +874,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
} }
); );
} }
}
private void generateEnumMethodsAndConstInitializers() { private void generateEnumMethodsAndConstInitializers() {
if (isEnumClass(descriptor)) { if (isEnumClass(descriptor)) {