prepare anonymous classes also when generating namespace

This commit is contained in:
Dmitry Jemerov
2011-06-29 17:59:27 +02:00
parent 796b815897
commit e09f4afd17
3 changed files with 18 additions and 18 deletions
@@ -17,7 +17,7 @@ public class ClassCodegen {
}
public void generate(JetClassOrObject aClass) {
prepareAnonymousClasses(aClass);
state.prepareAnonymousClasses((JetElement) aClass);
if (aClass instanceof JetObjectDeclaration) {
generateImplementation(aClass, OwnerKind.IMPLEMENTATION);
@@ -35,21 +35,6 @@ public class ClassCodegen {
}
}
private void prepareAnonymousClasses(JetClassOrObject aClass) {
aClass.acceptChildren(new JetVisitor() {
@Override
public void visitJetElement(JetElement element) {
super.visitJetElement(element);
element.acceptChildren(this);
}
@Override
public void visitObjectLiteralExpression(JetObjectLiteralExpression expression) {
state.getTypeMapper().classNameForAnonymousClass(expression.getObjectDeclaration());
}
});
}
private void generateInterface(JetClassOrObject aClass) {
final ClassVisitor visitor = state.forClassInterface(state.getBindingContext().getClassDescriptor(aClass));
new InterfaceBodyCodegen(aClass, visitor, state).generate();
@@ -116,4 +116,19 @@ public class GenerationState {
final ClosureCodegen top = closureContexts.peek();
return top != null ? top.lookupInContext(d) : null;
}
void prepareAnonymousClasses(JetElement aClass) {
aClass.acceptChildren(new JetVisitor() {
@Override
public void visitJetElement(JetElement element) {
super.visitJetElement(element);
element.acceptChildren(this);
}
@Override
public void visitObjectLiteralExpression(JetObjectLiteralExpression expression) {
getTypeMapper().classNameForAnonymousClass(expression.getObjectDeclaration());
}
});
}
}
@@ -3,7 +3,6 @@ package org.jetbrains.jet.codegen;
import com.intellij.openapi.project.Project;
import org.jetbrains.jet.lang.descriptors.PropertyDescriptor;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.types.JetStandardLibrary;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
@@ -34,11 +33,12 @@ public class NamespaceCodegen {
}
public void generate(JetNamespace namespace) {
final JetStandardLibrary standardLibrary = JetStandardLibrary.getJetStandardLibrary(project);
final FunctionCodegen functionCodegen = new FunctionCodegen(namespace, v, state);
final PropertyCodegen propertyCodegen = new PropertyCodegen(v, functionCodegen, state);
final ClassCodegen classCodegen = state.forClass();
state.prepareAnonymousClasses(namespace);
if (hasNonConstantPropertyInitializers(namespace)) {
generateStaticInitializers(namespace);
}