method extracted to avoid duplicates
This commit is contained in:
@@ -197,22 +197,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitClass(JetClass klass, StackValue data) {
|
public StackValue visitClass(JetClass klass, StackValue data) {
|
||||||
ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, klass);
|
return visitClassOrObject(klass);
|
||||||
ObjectOrClosureCodegen closure = new LocalClassClosureCodegen(this, context, state, descriptor);
|
|
||||||
Pair<JvmClassName, ClassBuilder> nameAndVisitor = state.forAnonymousSubclass(klass);
|
|
||||||
|
|
||||||
closure.cv = nameAndVisitor.getSecond();
|
|
||||||
closure.name = nameAndVisitor.getFirst();
|
|
||||||
final CodegenContext objectContext = closure.context.intoAnonymousClass(
|
|
||||||
closure, descriptor, OwnerKind.IMPLEMENTATION,
|
|
||||||
typeMapper);
|
|
||||||
|
|
||||||
new ImplementationBodyCodegen(klass, objectContext, nameAndVisitor.getSecond(), state).generate();
|
|
||||||
return StackValue.none();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private StackValue visitClassOrObject(JetClassOrObject declaration) {
|
||||||
public StackValue visitObjectDeclaration(JetObjectDeclaration declaration, StackValue data) {
|
|
||||||
ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, declaration);
|
ClassDescriptor descriptor = bindingContext.get(BindingContext.CLASS, declaration);
|
||||||
ObjectOrClosureCodegen closure = new LocalClassClosureCodegen(this, context, state, descriptor);
|
ObjectOrClosureCodegen closure = new LocalClassClosureCodegen(this, context, state, descriptor);
|
||||||
Pair<JvmClassName, ClassBuilder> nameAndVisitor = state.forAnonymousSubclass(declaration);
|
Pair<JvmClassName, ClassBuilder> nameAndVisitor = state.forAnonymousSubclass(declaration);
|
||||||
@@ -227,6 +215,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
return StackValue.none();
|
return StackValue.none();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StackValue visitObjectDeclaration(JetObjectDeclaration declaration, StackValue data) {
|
||||||
|
return visitClassOrObject(declaration);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitExpression(JetExpression expression, StackValue receiver) {
|
public StackValue visitExpression(JetExpression expression, StackValue receiver) {
|
||||||
throw new UnsupportedOperationException("Codegen for " + expression + " is not yet implemented");
|
throw new UnsupportedOperationException("Codegen for " + expression + " is not yet implemented");
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class GenerationState {
|
|||||||
getInjector().getJetTypeMapper().mapType(aClass.getDefaultType(), MapTypeMode.TRAIT_IMPL).getInternalName() + ".class");
|
getInjector().getJetTypeMapper().mapType(aClass.getDefaultType(), MapTypeMode.TRAIT_IMPL).getInternalName() + ".class");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Pair<JvmClassName, ClassBuilder> forAnonymousSubclass(JetExpression expression) {
|
public Pair<JvmClassName, ClassBuilder> forAnonymousSubclass(JetElement expression) {
|
||||||
JvmClassName className = getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass(expression);
|
JvmClassName className = getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass(expression);
|
||||||
return Pair.create(className, getFactory().forAnonymousSubclass(className));
|
return Pair.create(className, getFactory().forAnonymousSubclass(className));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user