JvmDeclarationOrigin used in newVisitor()
This commit is contained in:
@@ -18,7 +18,6 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
@@ -28,7 +27,6 @@ import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jet.OutputFile;
|
||||
import org.jetbrains.jet.OutputFileCollection;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
@@ -51,23 +49,21 @@ public class ClassFileFactory implements OutputFileCollection {
|
||||
|
||||
@NotNull
|
||||
public ClassBuilder newVisitor(
|
||||
@Nullable PsiElement forElement,
|
||||
@Nullable DeclarationDescriptor forDescriptor,
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
@NotNull Type asmType,
|
||||
@NotNull PsiFile sourceFile) {
|
||||
return newVisitor(forElement == null ? sourceFile : forElement, forDescriptor, asmType, Collections.singletonList(sourceFile));
|
||||
return newVisitor(origin, asmType, Collections.singletonList(sourceFile));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public ClassBuilder newVisitor(
|
||||
@Nullable PsiElement forElement,
|
||||
@Nullable DeclarationDescriptor forDescriptor,
|
||||
@NotNull JvmDeclarationOrigin origin,
|
||||
@NotNull Type asmType,
|
||||
@NotNull Collection<? extends PsiFile> sourceFiles) {
|
||||
String outputFilePath = asmType.getInternalName() + ".class";
|
||||
List<File> ioSourceFiles = toIoFilesIgnoringNonPhysical(sourceFiles);
|
||||
state.getProgress().reportOutput(ioSourceFiles, new File(outputFilePath));
|
||||
ClassBuilder answer = builderFactory.newClassBuilder(forElement, forDescriptor);
|
||||
ClassBuilder answer = builderFactory.newClassBuilder(origin.getElement(), origin.getDescriptor());
|
||||
generators.put(outputFilePath, new ClassBuilderAndSourceFileList(answer, ioSourceFiles));
|
||||
return answer;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ClosureCodegen extends ParentCodegenAware {
|
||||
}
|
||||
|
||||
public void gen() {
|
||||
ClassBuilder cv = state.getFactory().newVisitor(fun, funDescriptor, asmType, fun.getContainingFile());
|
||||
ClassBuilder cv = state.getFactory().newVisitor(OtherOrigin(fun, funDescriptor), asmType, fun.getContainingFile());
|
||||
|
||||
FunctionDescriptor erasedInterfaceFunction;
|
||||
if (samType == null) {
|
||||
|
||||
@@ -67,6 +67,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.*;
|
||||
import static org.jetbrains.jet.codegen.CodegenPackage.OtherOrigin;
|
||||
import static org.jetbrains.jet.codegen.JvmCodegenUtil.*;
|
||||
import static org.jetbrains.jet.codegen.binding.CodegenBinding.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
@@ -175,7 +176,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert classDescriptor != null;
|
||||
|
||||
Type asmType = asmTypeForAnonymousClass(bindingContext, objectDeclaration);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(objectDeclaration, classDescriptor, asmType, literal.getContainingFile());
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(
|
||||
OtherOrigin(objectDeclaration, classDescriptor),
|
||||
asmType,
|
||||
literal.getContainingFile()
|
||||
);
|
||||
|
||||
|
||||
ClassContext objectContext = context.intoAnonymousClass(classDescriptor, this);
|
||||
@@ -264,7 +269,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
assert descriptor != null;
|
||||
|
||||
Type asmType = asmTypeForAnonymousClass(bindingContext, declaration);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(declaration, descriptor, asmType, declaration.getContainingFile());
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(OtherOrigin(declaration, descriptor), asmType, declaration.getContainingFile());
|
||||
|
||||
ClassContext objectContext = context.intoAnonymousClass(descriptor, this);
|
||||
new ImplementationBodyCodegen(declaration, objectContext, classBuilder, state, getParentCodegen()).generate();
|
||||
|
||||
@@ -164,13 +164,13 @@ public abstract class MemberCodegen<T extends JetElement/* TODO: & JetDeclaratio
|
||||
}
|
||||
|
||||
Type classType = state.getTypeMapper().mapClass(descriptor);
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(aClass, descriptor, classType, aClass.getContainingFile());
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(OtherOrigin(aClass, descriptor), classType, aClass.getContainingFile());
|
||||
ClassContext classContext = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION, state);
|
||||
new ImplementationBodyCodegen(aClass, classContext, classBuilder, state, parentCodegen).generate();
|
||||
|
||||
if (aClass instanceof JetClass && ((JetClass) aClass).isTrait()) {
|
||||
Type traitImplType = state.getTypeMapper().mapTraitImpl(descriptor);
|
||||
ClassBuilder traitImplBuilder = state.getFactory().newVisitor(aClass, descriptor, traitImplType, aClass.getContainingFile());
|
||||
ClassBuilder traitImplBuilder = state.getFactory().newVisitor(OtherOrigin(aClass, descriptor), traitImplType, aClass.getContainingFile());
|
||||
ClassContext traitImplContext = parentContext.intoClass(descriptor, OwnerKind.TRAIT_IMPL, state);
|
||||
new TraitImplBodyCodegen(aClass, traitImplContext, traitImplBuilder, state, parentCodegen).generate();
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ import org.jetbrains.org.objectweb.asm.Type;
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.asmDescByFqNameWithoutInnerClasses;
|
||||
import static org.jetbrains.jet.codegen.CodegenPackage.OtherOrigin;
|
||||
import static org.jetbrains.jet.descriptors.serialization.NameSerializationUtil.createNameResolver;
|
||||
import static org.jetbrains.jet.lang.resolve.java.PackageClassUtils.getPackageClassFqName;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
@@ -90,7 +91,7 @@ public class PackageCodegen {
|
||||
String className = AsmUtil.internalNameByFqNameWithoutInnerClasses(getPackageClassFqName(fqName));
|
||||
ClassBuilder v = PackageCodegen.this.state.getFactory()
|
||||
.newVisitor(
|
||||
null, packageFragment,
|
||||
OtherOrigin(packageFragment),
|
||||
Type.getObjectType(className), PackagePartClassUtils.getPackageFilesWithCallables(files));
|
||||
v.defineClass(sourceFile, V1_6,
|
||||
ACC_PUBLIC | ACC_FINAL,
|
||||
@@ -281,7 +282,7 @@ public class PackageCodegen {
|
||||
|
||||
if (!generatePackagePart) return null;
|
||||
|
||||
ClassBuilder builder = state.getFactory().newVisitor(file, packageFragment, packagePartType, file);
|
||||
ClassBuilder builder = state.getFactory().newVisitor(OtherOrigin(file, packageFragment), packagePartType, file);
|
||||
|
||||
new PackagePartCodegen(builder, file, packagePartType, packagePartContext, state).generate();
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public class SamWrapperCodegen {
|
||||
// e.g. compare(T, T)
|
||||
SimpleFunctionDescriptor erasedInterfaceFunction = samType.getAbstractMethod().getOriginal();
|
||||
|
||||
ClassBuilder cv = state.getFactory().newVisitor(null, erasedInterfaceFunction, asmType, file);
|
||||
ClassBuilder cv = state.getFactory().newVisitor(OtherOrigin(erasedInterfaceFunction), asmType, file);
|
||||
cv.defineClass(file,
|
||||
V1_6,
|
||||
ACC_FINAL,
|
||||
|
||||
@@ -60,7 +60,8 @@ public class ScriptCodegen extends MemberCodegen<JetScript> {
|
||||
Type className = state.getBindingContext().get(ASM_TYPE, classDescriptorForScript);
|
||||
assert className != null;
|
||||
|
||||
ClassBuilder builder = state.getFactory().newVisitor(declaration, classDescriptorForScript, className, declaration.getContainingFile());
|
||||
ClassBuilder builder = state.getFactory().newVisitor(OtherOrigin(declaration, classDescriptorForScript),
|
||||
className, declaration.getContainingFile());
|
||||
List<ScriptDescriptor> earlierScripts = state.getEarlierScriptsForReplInterpreter();
|
||||
ScriptContext scriptContext = parentContext.intoScript(
|
||||
scriptDescriptor,
|
||||
|
||||
+1
-1
@@ -296,7 +296,7 @@ public class AnonymousObjectTransformer {
|
||||
|
||||
@NotNull
|
||||
private ClassBuilder createClassBuilder() {
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(null, null, newLambdaType, inliningContext.getRoot().callElement.getContainingFile());
|
||||
ClassBuilder classBuilder = state.getFactory().newVisitor(NO_ORIGIN, newLambdaType, inliningContext.getRoot().callElement.getContainingFile());
|
||||
return new RemappingClassBuilder(classBuilder, new TypeRemapper(inliningContext.typeMapping));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user