Got rid of adding constant on each call site.
This commit is contained in:
@@ -51,8 +51,8 @@ public final class ClassFileFactory extends GenerationStateAware {
|
||||
this.builderFactory = builderFactory;
|
||||
}
|
||||
|
||||
ClassBuilder newVisitor(String outputFilePath, PsiFile sourceFile) {
|
||||
return newVisitor(outputFilePath, Collections.singletonList(sourceFile));
|
||||
ClassBuilder newVisitor(String internalClassName, PsiFile sourceFile) {
|
||||
return newVisitor(internalClassName + ".class", Collections.singletonList(sourceFile));
|
||||
}
|
||||
|
||||
private ClassBuilder newVisitor(String outputFilePath, Collection<? extends PsiFile> sourceFiles) {
|
||||
@@ -126,16 +126,16 @@ public final class ClassFileFactory extends GenerationStateAware {
|
||||
if (isPrimitive(type)) {
|
||||
throw new IllegalStateException("Codegen for primitive type is not possible: " + aClass);
|
||||
}
|
||||
return newVisitor(type.getInternalName() + ".class", sourceFile);
|
||||
return newVisitor(type.getInternalName(), sourceFile);
|
||||
}
|
||||
|
||||
public ClassBuilder forNamespacepart(String internalName, PsiFile sourceFile) {
|
||||
return newVisitor(internalName + ".class", sourceFile);
|
||||
return newVisitor(internalName, sourceFile);
|
||||
}
|
||||
|
||||
public ClassBuilder forTraitImplementation(ClassDescriptor aClass, GenerationState state, PsiFile sourceFile) {
|
||||
return newVisitor(
|
||||
state.getTypeMapper().mapType(aClass.getDefaultType(), JetTypeMapperMode.TRAIT_IMPL).getInternalName() + ".class",
|
||||
state.getTypeMapper().mapType(aClass.getDefaultType(), JetTypeMapperMode.TRAIT_IMPL).getInternalName(),
|
||||
sourceFile);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class ClosureCodegen extends GenerationStateAware {
|
||||
|
||||
public ClosureCodegen gen(JetDeclarationWithBody fun, CodegenContext context, ExpressionCodegen expressionCodegen) {
|
||||
name = classNameForAnonymousClass(state.getBindingContext(), fun);
|
||||
ClassBuilder cv = state.getFactory().newVisitor(name.getInternalName() + ".class", fun.getContainingFile());
|
||||
ClassBuilder cv = state.getFactory().newVisitor(name.getInternalName(), fun.getContainingFile());
|
||||
|
||||
FunctionDescriptor funDescriptor = bindingContext.get(BindingContext.FUNCTION, fun);
|
||||
assert funDescriptor != null;
|
||||
|
||||
@@ -109,11 +109,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
) {
|
||||
JetObjectDeclaration objectDeclaration = literal.getObjectDeclaration();
|
||||
|
||||
JvmClassName className =
|
||||
classNameForAnonymousClass(bindingContext, objectDeclaration);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(
|
||||
className.getInternalName() + ".class",
|
||||
literal.getContainingFile());
|
||||
JvmClassName className = classNameForAnonymousClass(bindingContext, objectDeclaration);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(className.getInternalName(), literal.getContainingFile());
|
||||
|
||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS, objectDeclaration);
|
||||
assert classDescriptor != null;
|
||||
@@ -278,9 +275,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
|
||||
JvmClassName className =
|
||||
classNameForAnonymousClass(bindingContext, declaration);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(
|
||||
className.getInternalName() + ".class",
|
||||
declaration.getContainingFile()
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(className.getInternalName(), declaration.getContainingFile()
|
||||
);
|
||||
|
||||
CodegenContext objectContext = context.intoAnonymousClass(descriptor, this);
|
||||
|
||||
@@ -75,9 +75,7 @@ public class ScriptCodegen extends MemberCodegen {
|
||||
JvmClassName className = bindingContext.get(FQN, classDescriptorForScript);
|
||||
assert className != null;
|
||||
|
||||
ClassBuilder classBuilder = classFileFactory.newVisitor(
|
||||
className.getInternalName() + ".class",
|
||||
scriptDeclaration.getContainingFile()
|
||||
ClassBuilder classBuilder = classFileFactory.newVisitor(className.getInternalName(), scriptDeclaration.getContainingFile()
|
||||
);
|
||||
classBuilder.defineClass(scriptDeclaration,
|
||||
V1_6,
|
||||
|
||||
Reference in New Issue
Block a user