ClassCodegen is stateless, put it into context
This commit is contained in:
@@ -50,7 +50,7 @@ public class ClassCodegen {
|
|||||||
generate(contextForInners, (JetClass) declaration);
|
generate(contextForInners, (JetClass) declaration);
|
||||||
}
|
}
|
||||||
if(declaration instanceof JetClassObject) {
|
if(declaration instanceof JetClassObject) {
|
||||||
state.forClass().generate(contextForInners, ((JetClassObject)declaration).getObjectDeclaration());
|
state.getInjector().getClassCodegen().generate(contextForInners, ((JetClassObject)declaration).getObjectDeclaration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,10 +91,6 @@ public class GenerationState {
|
|||||||
return classBuilderMode;
|
return classBuilderMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassCodegen forClass() {
|
|
||||||
return new ClassCodegen(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ClassBuilder forClassImplementation(ClassDescriptor aClass) {
|
public ClassBuilder forClassImplementation(ClassDescriptor aClass) {
|
||||||
return getFactory().newVisitor(getInjector().getJetTypeMapper().mapType(aClass.getDefaultType(), MapTypeMode.IMPL).getInternalName() + ".class");
|
return getFactory().newVisitor(getInjector().getJetTypeMapper().mapType(aClass.getDefaultType(), MapTypeMode.IMPL).getInternalName() + ".class");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,7 +61,6 @@ public class NamespaceCodegen {
|
|||||||
|
|
||||||
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
|
final FunctionCodegen functionCodegen = new FunctionCodegen(context, v, state);
|
||||||
final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, state);
|
final PropertyCodegen propertyCodegen = new PropertyCodegen(context, v, functionCodegen, state);
|
||||||
final ClassCodegen classCodegen = state.forClass();
|
|
||||||
|
|
||||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||||
if (declaration instanceof JetProperty) {
|
if (declaration instanceof JetProperty) {
|
||||||
@@ -79,7 +78,7 @@ public class NamespaceCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (declaration instanceof JetClassOrObject) {
|
else if (declaration instanceof JetClassOrObject) {
|
||||||
classCodegen.generate(context, (JetClassOrObject) declaration);
|
state.getInjector().getClassCodegen().generate(context, (JetClassOrObject) declaration);
|
||||||
}
|
}
|
||||||
// else if (declaration instanceof JetFile) {
|
// else if (declaration instanceof JetFile) {
|
||||||
// JetFile childNamespace = (JetFile) declaration;
|
// JetFile childNamespace = (JetFile) declaration;
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ import org.jetbrains.jet.codegen.ClassBuilderMode;
|
|||||||
import org.jetbrains.jet.codegen.GenerationState;
|
import org.jetbrains.jet.codegen.GenerationState;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
||||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||||
|
import org.jetbrains.jet.codegen.ClassCodegen;
|
||||||
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||||
import org.jetbrains.jet.codegen.ClosureAnnotator;
|
import org.jetbrains.jet.codegen.ClosureAnnotator;
|
||||||
@@ -54,6 +55,7 @@ public class InjectorForJvmCodegen {
|
|||||||
private final GenerationState generationState;
|
private final GenerationState generationState;
|
||||||
private final ClassBuilderFactory classBuilderFactory;
|
private final ClassBuilderFactory classBuilderFactory;
|
||||||
private JetTypeMapper jetTypeMapper;
|
private JetTypeMapper jetTypeMapper;
|
||||||
|
private ClassCodegen classCodegen;
|
||||||
private IntrinsicMethods intrinsics;
|
private IntrinsicMethods intrinsics;
|
||||||
private ClassFileFactory classFileFactory;
|
private ClassFileFactory classFileFactory;
|
||||||
private ClosureAnnotator closureAnnotator;
|
private ClosureAnnotator closureAnnotator;
|
||||||
@@ -77,6 +79,7 @@ public class InjectorForJvmCodegen {
|
|||||||
this.generationState = generationState;
|
this.generationState = generationState;
|
||||||
this.classBuilderFactory = classBuilderFactory;
|
this.classBuilderFactory = classBuilderFactory;
|
||||||
this.jetTypeMapper = new JetTypeMapper();
|
this.jetTypeMapper = new JetTypeMapper();
|
||||||
|
this.classCodegen = new ClassCodegen(getGenerationState());
|
||||||
this.intrinsics = new IntrinsicMethods();
|
this.intrinsics = new IntrinsicMethods();
|
||||||
this.classFileFactory = new ClassFileFactory();
|
this.classFileFactory = new ClassFileFactory();
|
||||||
this.closureAnnotator = new ClosureAnnotator();
|
this.closureAnnotator = new ClosureAnnotator();
|
||||||
@@ -120,6 +123,10 @@ public class InjectorForJvmCodegen {
|
|||||||
return this.jetTypeMapper;
|
return this.jetTypeMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassCodegen getClassCodegen() {
|
||||||
|
return this.classCodegen;
|
||||||
|
}
|
||||||
|
|
||||||
public IntrinsicMethods getIntrinsics() {
|
public IntrinsicMethods getIntrinsics() {
|
||||||
return this.intrinsics;
|
return this.intrinsics;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ package org.jetbrains.jet.di;
|
|||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderMode;
|
import org.jetbrains.jet.codegen.ClassBuilderMode;
|
||||||
|
import org.jetbrains.jet.codegen.ClassCodegen;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||||
import org.jetbrains.jet.codegen.GenerationState;
|
import org.jetbrains.jet.codegen.GenerationState;
|
||||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||||
@@ -154,6 +155,7 @@ public class AllInjectorsGenerator {
|
|||||||
generator.addPublicParameter(GenerationState.class);
|
generator.addPublicParameter(GenerationState.class);
|
||||||
generator.addParameter(ClassBuilderFactory.class);
|
generator.addParameter(ClassBuilderFactory.class);
|
||||||
generator.addPublicField(JetTypeMapper.class);
|
generator.addPublicField(JetTypeMapper.class);
|
||||||
|
generator.addPublicField(ClassCodegen.class);
|
||||||
generator.addField(true, IntrinsicMethods.class, "intrinsics", null);
|
generator.addField(true, IntrinsicMethods.class, "intrinsics", null);
|
||||||
generator.addPublicField(ClassFileFactory.class);
|
generator.addPublicField(ClassFileFactory.class);
|
||||||
generator.generate("compiler/backend/src", "org.jetbrains.jet.di", "InjectorForJvmCodegen");
|
generator.generate("compiler/backend/src", "org.jetbrains.jet.di", "InjectorForJvmCodegen");
|
||||||
|
|||||||
Reference in New Issue
Block a user