Delete JvmClassName.byType
Replace JvmClassName by ASM Type in many places of JVM codegen: it wasn't used to abstract anything, but there was a lot of useless conversions between the two
This commit is contained in:
@@ -17,8 +17,8 @@
|
||||
package org.jetbrains.jet.cli.jvm.repl;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.jet.lang.descriptors.ScriptDescriptor;
|
||||
import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
|
||||
public class EarlierLine {
|
||||
@NotNull
|
||||
@@ -30,14 +30,14 @@ public class EarlierLine {
|
||||
@NotNull
|
||||
private final Object scriptInstance;
|
||||
@NotNull
|
||||
private final JvmClassName className;
|
||||
private final Type classType;
|
||||
|
||||
public EarlierLine(@NotNull String code, @NotNull ScriptDescriptor scriptDescriptor, @NotNull Class<?> scriptClass, @NotNull Object scriptInstance, @NotNull JvmClassName className) {
|
||||
public EarlierLine(@NotNull String code, @NotNull ScriptDescriptor scriptDescriptor, @NotNull Class<?> scriptClass, @NotNull Object scriptInstance, @NotNull Type classType) {
|
||||
this.code = code;
|
||||
this.scriptDescriptor = scriptDescriptor;
|
||||
this.scriptClass = scriptClass;
|
||||
this.scriptInstance = scriptInstance;
|
||||
this.className = className;
|
||||
this.classType = classType;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -61,7 +61,7 @@ public class EarlierLine {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JvmClassName getClassName() {
|
||||
return className;
|
||||
public Type getClassType() {
|
||||
return classType;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.intellij.psi.impl.PsiFileFactoryImpl;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.asm4.Type;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
@@ -66,6 +67,8 @@ import java.net.URLClassLoader;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.codegen.AsmUtil.fqNameByAsmTypeUnsafe;
|
||||
|
||||
public class ReplInterpreter {
|
||||
|
||||
private int lineNumber = 0;
|
||||
@@ -181,7 +184,7 @@ public class ReplInterpreter {
|
||||
public LineResult eval(@NotNull String line) {
|
||||
++lineNumber;
|
||||
|
||||
JvmClassName scriptClassName = JvmClassName.byInternalName("Line" + lineNumber);
|
||||
Type scriptClassType = Type.getObjectType("Line" + lineNumber);
|
||||
|
||||
StringBuilder fullText = new StringBuilder();
|
||||
for (String prevLine : previousIncompleteLines) {
|
||||
@@ -219,16 +222,16 @@ public class ReplInterpreter {
|
||||
return LineResult.error(errorCollector.getString());
|
||||
}
|
||||
|
||||
List<Pair<ScriptDescriptor, JvmClassName>> earierScripts = Lists.newArrayList();
|
||||
List<Pair<ScriptDescriptor, Type>> earlierScripts = Lists.newArrayList();
|
||||
|
||||
for (EarlierLine earlierLine : earlierLines) {
|
||||
earierScripts.add(Pair.create(earlierLine.getScriptDescriptor(), earlierLine.getClassName()));
|
||||
earlierScripts.add(Pair.create(earlierLine.getScriptDescriptor(), earlierLine.getClassType()));
|
||||
}
|
||||
|
||||
BindingContext bindingContext = AnalyzeExhaust.success(trace.getBindingContext(), module).getBindingContext();
|
||||
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false),
|
||||
bindingContext, Collections.singletonList(psiFile));
|
||||
generationState.getScriptCodegen().compileScript(psiFile.getScript(), scriptClassName, earierScripts,
|
||||
generationState.getScriptCodegen().compileScript(psiFile.getScript(), scriptClassType, earlierScripts,
|
||||
CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
for (String file : generationState.getFactory().files()) {
|
||||
@@ -236,7 +239,7 @@ public class ReplInterpreter {
|
||||
}
|
||||
|
||||
try {
|
||||
Class<?> scriptClass = classLoader.loadClass(scriptClassName.getFqName().asString());
|
||||
Class<?> scriptClass = classLoader.loadClass(fqNameByAsmTypeUnsafe(scriptClassType).asString());
|
||||
|
||||
Class<?>[] constructorParams = new Class<?>[earlierLines.size()];
|
||||
Object[] constructorArgs = new Object[earlierLines.size()];
|
||||
@@ -257,7 +260,7 @@ public class ReplInterpreter {
|
||||
rvField.setAccessible(true);
|
||||
Object rv = rvField.get(scriptInstance);
|
||||
|
||||
earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassName));
|
||||
earlierLines.add(new EarlierLine(line, scriptDescriptor, scriptClass, scriptInstance, scriptClassType));
|
||||
|
||||
return LineResult.successful(rv, scriptDescriptor.getReturnType().equals(KotlinBuiltIns.getInstance().getUnitType()));
|
||||
} catch (Throwable e) {
|
||||
|
||||
Reference in New Issue
Block a user