Passing "stubs" flag to K2JVMCompileEnvironmentConfiguration to avoid checking compiler special mode.
This commit is contained in:
@@ -74,7 +74,7 @@ public class BytecodeCompiler {
|
|||||||
CompilerSpecialMode.REGULAR);
|
CompilerSpecialMode.REGULAR);
|
||||||
K2JVMCompileEnvironmentConfiguration
|
K2JVMCompileEnvironmentConfiguration
|
||||||
env = new K2JVMCompileEnvironmentConfiguration(environment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false,
|
env = new K2JVMCompileEnvironmentConfiguration(environment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false,
|
||||||
BuiltinsScopeExtensionMode.ALL);
|
BuiltinsScopeExtensionMode.ALL, false);
|
||||||
|
|
||||||
// lets register any compiler plugins
|
// lets register any compiler plugins
|
||||||
env.getCompilerPlugins().addAll(getCompilerPlugins());
|
env.getCompilerPlugins().addAll(getCompilerPlugins());
|
||||||
|
|||||||
@@ -70,10 +70,11 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
|||||||
}
|
}
|
||||||
|
|
||||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration, mode);
|
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration, mode);
|
||||||
|
boolean builtins = mode == CompilerSpecialMode.BUILTINS;
|
||||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
||||||
environment, messageCollector, arguments.script, mode == CompilerSpecialMode.BUILTINS
|
environment, messageCollector, arguments.script, builtins
|
||||||
? BuiltinsScopeExtensionMode.ONLY_STANDARD_CLASSES
|
? BuiltinsScopeExtensionMode.ONLY_STANDARD_CLASSES
|
||||||
: BuiltinsScopeExtensionMode.ALL);
|
: BuiltinsScopeExtensionMode.ALL, builtins);
|
||||||
|
|
||||||
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
||||||
CompilerMessageLocation.NO_LOCATION);
|
CompilerMessageLocation.NO_LOCATION);
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ public class CompileEnvironmentUtil {
|
|||||||
|
|
||||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||||
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(scriptEnvironment, messageCollector, false,
|
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(scriptEnvironment, messageCollector, false,
|
||||||
BuiltinsScopeExtensionMode.ALL), false);
|
BuiltinsScopeExtensionMode.ALL, false), false);
|
||||||
if (generationState == null) {
|
if (generationState == null) {
|
||||||
throw new CompileEnvironmentException("Module script " + moduleScriptFile + " analyze failed");
|
throw new CompileEnvironmentException("Module script " + moduleScriptFile + " analyze failed");
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-2
@@ -29,18 +29,20 @@ public class K2JVMCompileEnvironmentConfiguration extends CompileEnvironmentConf
|
|||||||
private final JetCoreEnvironment environment;
|
private final JetCoreEnvironment environment;
|
||||||
private final boolean script;
|
private final boolean script;
|
||||||
private final BuiltinsScopeExtensionMode builtinsScopeExtensionMode;
|
private final BuiltinsScopeExtensionMode builtinsScopeExtensionMode;
|
||||||
|
private final boolean stubs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NOTE: It's very important to call dispose for every object of this class or there will be memory leaks.
|
* NOTE: It's very important to call dispose for every object of this class or there will be memory leaks.
|
||||||
*
|
*
|
||||||
* @see Disposer
|
* @see Disposer
|
||||||
*/
|
*/
|
||||||
public K2JVMCompileEnvironmentConfiguration(@NotNull JetCoreEnvironment environment,
|
public K2JVMCompileEnvironmentConfiguration(@NotNull JetCoreEnvironment environment, @NotNull MessageCollector messageCollector,
|
||||||
@NotNull MessageCollector messageCollector, boolean script, BuiltinsScopeExtensionMode builtinsScopeExtensionMode) {
|
boolean script, BuiltinsScopeExtensionMode builtinsScopeExtensionMode, boolean stubs) {
|
||||||
super(messageCollector);
|
super(messageCollector);
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
this.script = script;
|
this.script = script;
|
||||||
this.builtinsScopeExtensionMode = builtinsScopeExtensionMode;
|
this.builtinsScopeExtensionMode = builtinsScopeExtensionMode;
|
||||||
|
this.stubs = stubs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public JetCoreEnvironment getEnvironment() {
|
public JetCoreEnvironment getEnvironment() {
|
||||||
@@ -55,4 +57,8 @@ public class K2JVMCompileEnvironmentConfiguration extends CompileEnvironmentConf
|
|||||||
public BuiltinsScopeExtensionMode getBuiltinsScopeExtensionMode() {
|
public BuiltinsScopeExtensionMode getBuiltinsScopeExtensionMode() {
|
||||||
return builtinsScopeExtensionMode;
|
return builtinsScopeExtensionMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isStubs() {
|
||||||
|
return stubs;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -30,17 +30,16 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||||
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
||||||
import org.jetbrains.jet.cli.common.CompilerPluginContext;
|
import org.jetbrains.jet.cli.common.CompilerPluginContext;
|
||||||
import org.jetbrains.jet.codegen.*;
|
|
||||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
import org.jetbrains.jet.cli.common.messages.CompilerMessageLocation;
|
||||||
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
import org.jetbrains.jet.cli.common.messages.CompilerMessageSeverity;
|
||||||
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
import org.jetbrains.jet.lang.psi.JetPsiUtil;
|
||||||
import org.jetbrains.jet.lang.resolve.java.CompilerSpecialMode;
|
|
||||||
import org.jetbrains.jet.lang.resolve.name.FqName;
|
|
||||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.FqName;
|
||||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
import org.jetbrains.jet.plugin.JetLanguage;
|
import org.jetbrains.jet.plugin.JetLanguage;
|
||||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||||
@@ -259,7 +258,7 @@ public class KotlinToJVMBytecodeCompiler {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static GenerationState analyzeAndGenerate(K2JVMCompileEnvironmentConfiguration configuration) {
|
public static GenerationState analyzeAndGenerate(K2JVMCompileEnvironmentConfiguration configuration) {
|
||||||
return analyzeAndGenerate(configuration, configuration.getEnvironment().getCompilerSpecialMode() == CompilerSpecialMode.BUILTINS);
|
return analyzeAndGenerate(configuration, configuration.isStubs());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen;
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.K2JVMCompileEnvironmentConfiguration;
|
import org.jetbrains.jet.cli.jvm.compiler.K2JVMCompileEnvironmentConfiguration;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
||||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
|
||||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
@@ -29,7 +29,7 @@ public class CompileTextTest extends CodegenTestCase {
|
|||||||
createEnvironmentWithMockJdkAndIdeaAnnotations();
|
createEnvironmentWithMockJdkAndIdeaAnnotations();
|
||||||
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
||||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
||||||
myEnvironment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false, BuiltinsScopeExtensionMode.ALL);
|
myEnvironment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false, BuiltinsScopeExtensionMode.ALL, false);
|
||||||
configuration.getEnvironment().addToClasspathFromClassLoader(getClass().getClassLoader());
|
configuration.getEnvironment().addToClasspathFromClassLoader(getClass().getClassLoader());
|
||||||
ClassLoader classLoader = KotlinToJVMBytecodeCompiler.compileText(configuration, text);
|
ClassLoader classLoader = KotlinToJVMBytecodeCompiler.compileText(configuration, text);
|
||||||
Class<?> namespace = classLoader.loadClass("namespace");
|
Class<?> namespace = classLoader.loadClass("namespace");
|
||||||
|
|||||||
@@ -21,12 +21,11 @@ import gnu.trove.THashSet;
|
|||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
|
||||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
|
||||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.K2JVMCompileEnvironmentConfiguration;
|
import org.jetbrains.jet.cli.jvm.compiler.K2JVMCompileEnvironmentConfiguration;
|
||||||
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
||||||
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
import org.jetbrains.jet.codegen.forTestCompile.ForTestCompileRuntime;
|
||||||
|
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
import org.jetbrains.jet.lang.psi.JetClass;
|
import org.jetbrains.jet.lang.psi.JetClass;
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||||
@@ -35,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
|
|||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||||
|
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@@ -86,7 +86,7 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
|
|
||||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||||
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(myEnvironment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR,
|
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(myEnvironment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR,
|
||||||
false, BuiltinsScopeExtensionMode.ALL), false);
|
false, BuiltinsScopeExtensionMode.ALL, false), false);
|
||||||
|
|
||||||
if (generationState == null) {
|
if (generationState == null) {
|
||||||
throw new RuntimeException("There were compilation errors");
|
throw new RuntimeException("There were compilation errors");
|
||||||
|
|||||||
Reference in New Issue
Block a user