Remove obsolete SCRIPT markers
This commit is contained in:
@@ -2579,7 +2579,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
}
|
||||
}
|
||||
else if (receiverValue instanceof ScriptReceiver) {
|
||||
// SCRIPT: generate script
|
||||
return generateScript((ScriptReceiver) receiverValue);
|
||||
}
|
||||
else if (receiverValue instanceof ExtensionReceiver) {
|
||||
@@ -2598,7 +2597,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
return context.generateReceiver(descriptor, state, false);
|
||||
}
|
||||
|
||||
// SCRIPT: generate script, move to ScriptingUtil
|
||||
private StackValue generateScript(@NotNull ScriptReceiver receiver) {
|
||||
CodegenContext cur = context;
|
||||
StackValue result = StackValue.LOCAL_0;
|
||||
@@ -3393,7 +3391,6 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
||||
Type varType = asmType(variableDescriptor.getType());
|
||||
|
||||
StackValue storeTo;
|
||||
// SCRIPT: Variable at the top of the script is generated as field
|
||||
if (KtPsiUtil.isScriptDeclaration(variableDeclaration)) {
|
||||
KtScript scriptPsi = KtPsiUtil.getScript(variableDeclaration);
|
||||
assert scriptPsi != null;
|
||||
|
||||
@@ -21,14 +21,16 @@ import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState;
|
||||
import org.jetbrains.kotlin.fileClasses.JvmFileClassInfo;
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||
import org.jetbrains.kotlin.name.FqName;
|
||||
import org.jetbrains.kotlin.progress.ProgressIndicatorAndCompilationCanceledStatus;
|
||||
import org.jetbrains.kotlin.psi.KtFile;
|
||||
import org.jetbrains.kotlin.psi.KtScript;
|
||||
import org.jetbrains.kotlin.resolve.ScriptNameUtil;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jetbrains.kotlin.codegen.binding.CodegenBinding.registerClassNameForScript;
|
||||
|
||||
@@ -37,7 +39,6 @@ public class KotlinCodegenFacade {
|
||||
public static void prepareForCompilation(@NotNull GenerationState state) {
|
||||
for (KtFile file : state.getFiles()) {
|
||||
if (file.isScript()) {
|
||||
// SCRIPT: register class name for scripting from this file, move outside of this function
|
||||
KtScript script = file.getScript();
|
||||
assert script != null;
|
||||
|
||||
|
||||
@@ -162,17 +162,14 @@ public class MultifileClassCodegen(
|
||||
val partContext = state.rootContext.intoMultifileClassPart(packageFragment, facadeClassType, partType, file)
|
||||
|
||||
for (declaration in file.declarations) {
|
||||
if (declaration is KtProperty || declaration is KtNamedFunction) {
|
||||
generatePart = true
|
||||
}
|
||||
else if (declaration is KtClassOrObject) {
|
||||
if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
|
||||
when (declaration) {
|
||||
is KtProperty, is KtNamedFunction -> {
|
||||
generatePart = true
|
||||
}
|
||||
is KtClassOrObject -> if (state.generateDeclaredClassFilter.shouldGenerateClass(declaration)) {
|
||||
generateClassOrObject(declaration, partContext)
|
||||
}
|
||||
}
|
||||
else if (declaration is KtScript) {
|
||||
// SCRIPT: generate script code, should be separate execution branch
|
||||
if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
|
||||
is KtScript -> if (state.generateDeclaredClassFilter.shouldGenerateScript(declaration)) {
|
||||
ScriptCodegen.createScriptCodegen(declaration, state, partContext).generate()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,6 @@ public class PackageCodegen {
|
||||
else if (declaration instanceof KtScript) {
|
||||
KtScript script = (KtScript) declaration;
|
||||
|
||||
// SCRIPT: generate script code, should be separate execution branch
|
||||
if (state.getGenerateDeclaredClassFilter().shouldGenerateScript(script)) {
|
||||
ScriptCodegen.createScriptCodegen(script, state, packagePartContext).generate();
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ import static org.jetbrains.kotlin.resolve.jvm.AsmTypes.OBJECT_TYPE;
|
||||
import static org.jetbrains.kotlin.resolve.jvm.diagnostics.JvmDeclarationOrigin.NO_ORIGIN;
|
||||
import static org.jetbrains.org.objectweb.asm.Opcodes.*;
|
||||
|
||||
// SCRIPT: script code generator
|
||||
public class ScriptCodegen extends MemberCodegen<KtScript> {
|
||||
|
||||
public static ScriptCodegen createScriptCodegen(
|
||||
|
||||
+1
-1
@@ -161,7 +161,7 @@ class CodegenAnnotatingVisitor extends KtVisitorVoid {
|
||||
@Override
|
||||
public void visitJetFile(@NotNull KtFile file) {
|
||||
if (file.isScript()) {
|
||||
// SCRIPT: should be replaced with VisitScript override
|
||||
// TODO: replace with visitScript override
|
||||
//noinspection ConstantConditions
|
||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS_FOR_SCRIPT, bindingContext.get(SCRIPT, file.getScript()));
|
||||
classStack.push(classDescriptor);
|
||||
|
||||
@@ -89,7 +89,6 @@ public class CodegenBinding {
|
||||
return Boolean.TRUE.equals(bindingContext.get(ENUM_ENTRY_CLASS_NEED_SUBCLASS, classDescriptor));
|
||||
}
|
||||
|
||||
// SCRIPT: Generate asmType for script, move to ScriptingUtil
|
||||
@NotNull
|
||||
public static Type asmTypeForScriptDescriptor(BindingContext bindingContext, @NotNull ScriptDescriptor scriptDescriptor) {
|
||||
ClassDescriptor classDescriptor = bindingContext.get(CLASS_FOR_SCRIPT, scriptDescriptor);
|
||||
@@ -97,7 +96,6 @@ public class CodegenBinding {
|
||||
return getAsmType(bindingContext, classDescriptor);
|
||||
}
|
||||
|
||||
// SCRIPT: Generate asmType for script, move to ScriptingUtil
|
||||
@NotNull
|
||||
public static Type asmTypeForScriptPsi(BindingContext bindingContext, @NotNull KtScript script) {
|
||||
ScriptDescriptor scriptDescriptor = bindingContext.get(SCRIPT, script);
|
||||
@@ -198,7 +196,6 @@ public class CodegenBinding {
|
||||
innerClasses.add(inner);
|
||||
}
|
||||
|
||||
// SCRIPT: register asmType for script, move to ScriptingUtil
|
||||
public static void registerClassNameForScript(
|
||||
@NotNull BindingTrace trace,
|
||||
@NotNull KtScript script,
|
||||
@@ -227,15 +224,14 @@ public class CodegenBinding {
|
||||
// todo: we use Set and add given files but ignoring other scripts because something non-clear kept in binding
|
||||
// for scripts especially in case of REPL
|
||||
|
||||
// SCRIPT: collect fq names for files that are not scripts
|
||||
HashSet<FqName> names = new HashSet<FqName>();
|
||||
Set<FqName> names = new HashSet<FqName>();
|
||||
for (KtFile file : files) {
|
||||
if (!file.isScript()) {
|
||||
names.add(file.getPackageFqName());
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<KtFile> answer = new HashSet<KtFile>();
|
||||
Set<KtFile> answer = new HashSet<KtFile>();
|
||||
answer.addAll(files);
|
||||
|
||||
for (FqName name : names) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils;
|
||||
import org.jetbrains.kotlin.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.kotlin.storage.NullableLazyValue;
|
||||
import org.jetbrains.kotlin.types.KotlinType;
|
||||
import org.jetbrains.kotlin.types.TypeUtils;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.util.*;
|
||||
@@ -312,7 +311,6 @@ public abstract class CodegenContext<T extends DeclarationDescriptor> {
|
||||
return new ConstructorContext(descriptor, getContextKind(), this, closure);
|
||||
}
|
||||
|
||||
// SCRIPT: generate into script, move to ScriptingUtil
|
||||
@NotNull
|
||||
public ScriptContext intoScript(
|
||||
@NotNull ScriptDescriptor script,
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.descriptors.ScriptDescriptor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
// SCRIPT: script as field owner context
|
||||
public class ScriptContext extends FieldOwnerContext<ClassDescriptor> {
|
||||
private final ScriptDescriptor scriptDescriptor;
|
||||
private final List<ScriptDescriptor> earlierScripts;
|
||||
|
||||
Reference in New Issue
Block a user