Minor cleanup in FunctionGenerationStrategy and inheritors
This commit is contained in:
@@ -19,7 +19,6 @@ package org.jetbrains.jet.codegen;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.asm4.MethodVisitor;
|
import org.jetbrains.asm4.MethodVisitor;
|
||||||
import org.jetbrains.asm4.Type;
|
|
||||||
import org.jetbrains.jet.codegen.context.MethodContext;
|
import org.jetbrains.jet.codegen.context.MethodContext;
|
||||||
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;
|
||||||
@@ -31,9 +30,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public abstract class FunctionGenerationStrategy {
|
public abstract class FunctionGenerationStrategy {
|
||||||
|
|
||||||
private final Collection<String> localVariableNames = new ArrayList<String>();
|
private final Collection<String> localVariableNames = new ArrayList<String>();
|
||||||
|
|
||||||
private FrameMap frameMap;
|
private FrameMap frameMap;
|
||||||
|
|
||||||
public abstract void generateBody(
|
public abstract void generateBody(
|
||||||
@@ -66,7 +63,6 @@ public abstract class FunctionGenerationStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class FunctionDefault extends CodegenBased<CallableDescriptor> {
|
public static class FunctionDefault extends CodegenBased<CallableDescriptor> {
|
||||||
|
|
||||||
private final JetDeclarationWithBody declaration;
|
private final JetDeclarationWithBody declaration;
|
||||||
|
|
||||||
public FunctionDefault(
|
public FunctionDefault(
|
||||||
@@ -85,18 +81,16 @@ public abstract class FunctionGenerationStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract static class CodegenBased<T extends CallableDescriptor> extends FunctionGenerationStrategy {
|
public abstract static class CodegenBased<T extends CallableDescriptor> extends FunctionGenerationStrategy {
|
||||||
|
|
||||||
protected final GenerationState state;
|
protected final GenerationState state;
|
||||||
|
|
||||||
protected final T callableDescriptor;
|
protected final T callableDescriptor;
|
||||||
|
|
||||||
public CodegenBased(@NotNull GenerationState state, T callableDescriptor) {
|
public CodegenBased(@NotNull GenerationState state, @NotNull T callableDescriptor) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.callableDescriptor = callableDescriptor;
|
this.callableDescriptor = callableDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateBody(
|
public final void generateBody(
|
||||||
@NotNull MethodVisitor mv,
|
@NotNull MethodVisitor mv,
|
||||||
@NotNull JvmMethodSignature signature,
|
@NotNull JvmMethodSignature signature,
|
||||||
@NotNull MethodContext context,
|
@NotNull MethodContext context,
|
||||||
@@ -108,9 +102,9 @@ public abstract class FunctionGenerationStrategy {
|
|||||||
generateLocalVarNames(codegen);
|
generateLocalVarNames(codegen);
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature);
|
public abstract void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature);
|
||||||
|
|
||||||
public void generateLocalVarNames(@NotNull ExpressionCodegen codegen) {
|
private void generateLocalVarNames(@NotNull ExpressionCodegen codegen) {
|
||||||
for (String name : codegen.getLocalVariableNamesForExpression()) {
|
for (String name : codegen.getLocalVariableNamesForExpression()) {
|
||||||
addLocalVariableName(name);
|
addLocalVariableName(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1139,7 +1139,6 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
functionCodegen.generateMethod(null, constructorSignature, constructorDescriptor, constructorContext,
|
functionCodegen.generateMethod(null, constructorSignature, constructorDescriptor, constructorContext,
|
||||||
new FunctionGenerationStrategy.CodegenBased<ConstructorDescriptor>(state, constructorDescriptor) {
|
new FunctionGenerationStrategy.CodegenBased<ConstructorDescriptor>(state, constructorDescriptor) {
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
protected FrameMap createFrameMap(@NotNull JetTypeMapper typeMapper, @NotNull MethodContext context) {
|
protected FrameMap createFrameMap(@NotNull JetTypeMapper typeMapper, @NotNull MethodContext context) {
|
||||||
|
|||||||
@@ -311,18 +311,12 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
|
|
||||||
|
|
||||||
private static class DefaultPropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased<PropertyAccessorDescriptor> {
|
private static class DefaultPropertyAccessorStrategy extends FunctionGenerationStrategy.CodegenBased<PropertyAccessorDescriptor> {
|
||||||
|
public DefaultPropertyAccessorStrategy(@NotNull GenerationState state, @NotNull PropertyAccessorDescriptor descriptor) {
|
||||||
public DefaultPropertyAccessorStrategy(
|
super(state, descriptor);
|
||||||
@NotNull GenerationState state,
|
|
||||||
@NotNull PropertyAccessorDescriptor callableDescriptor
|
|
||||||
) {
|
|
||||||
super(state, callableDescriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGenerateBody(
|
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
||||||
ExpressionCodegen codegen, JvmMethodSignature signature
|
|
||||||
) {
|
|
||||||
generateDefaultAccessor(callableDescriptor, codegen.v, codegen);
|
generateDefaultAccessor(callableDescriptor, codegen.v, codegen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,9 +365,7 @@ public class PropertyCodegen extends GenerationStateAware {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doGenerateBody(
|
public void doGenerateBody(@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature) {
|
||||||
@NotNull ExpressionCodegen codegen, @NotNull JvmMethodSignature signature
|
|
||||||
) {
|
|
||||||
JetTypeMapper typeMapper = codegen.typeMapper;
|
JetTypeMapper typeMapper = codegen.typeMapper;
|
||||||
OwnerKind kind = codegen.context.getContextKind();
|
OwnerKind kind = codegen.context.getContextKind();
|
||||||
InstructionAdapter iv = codegen.v;
|
InstructionAdapter iv = codegen.v;
|
||||||
|
|||||||
Reference in New Issue
Block a user