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);
|
||||
K2JVMCompileEnvironmentConfiguration
|
||||
env = new K2JVMCompileEnvironmentConfiguration(environment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR, false,
|
||||
BuiltinsScopeExtensionMode.ALL);
|
||||
BuiltinsScopeExtensionMode.ALL, false);
|
||||
|
||||
// lets register any compiler plugins
|
||||
env.getCompilerPlugins().addAll(getCompilerPlugins());
|
||||
|
||||
@@ -70,10 +70,11 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments, K2JVMComp
|
||||
}
|
||||
|
||||
JetCoreEnvironment environment = JetCoreEnvironment.createCoreEnvironmentForJVM(rootDisposable, compilerConfiguration, mode);
|
||||
boolean builtins = mode == CompilerSpecialMode.BUILTINS;
|
||||
K2JVMCompileEnvironmentConfiguration configuration = new K2JVMCompileEnvironmentConfiguration(
|
||||
environment, messageCollector, arguments.script, mode == CompilerSpecialMode.BUILTINS
|
||||
environment, messageCollector, arguments.script, builtins
|
||||
? BuiltinsScopeExtensionMode.ONLY_STANDARD_CLASSES
|
||||
: BuiltinsScopeExtensionMode.ALL);
|
||||
: BuiltinsScopeExtensionMode.ALL, builtins);
|
||||
|
||||
messageCollector.report(CompilerMessageSeverity.LOGGING, "Configuring the compilation environment",
|
||||
CompilerMessageLocation.NO_LOCATION);
|
||||
|
||||
@@ -148,7 +148,7 @@ public class CompileEnvironmentUtil {
|
||||
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(scriptEnvironment, messageCollector, false,
|
||||
BuiltinsScopeExtensionMode.ALL), false);
|
||||
BuiltinsScopeExtensionMode.ALL, false), false);
|
||||
if (generationState == null) {
|
||||
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 boolean script;
|
||||
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.
|
||||
*
|
||||
* @see Disposer
|
||||
*/
|
||||
public K2JVMCompileEnvironmentConfiguration(@NotNull JetCoreEnvironment environment,
|
||||
@NotNull MessageCollector messageCollector, boolean script, BuiltinsScopeExtensionMode builtinsScopeExtensionMode) {
|
||||
public K2JVMCompileEnvironmentConfiguration(@NotNull JetCoreEnvironment environment, @NotNull MessageCollector messageCollector,
|
||||
boolean script, BuiltinsScopeExtensionMode builtinsScopeExtensionMode, boolean stubs) {
|
||||
super(messageCollector);
|
||||
this.environment = environment;
|
||||
this.script = script;
|
||||
this.builtinsScopeExtensionMode = builtinsScopeExtensionMode;
|
||||
this.stubs = stubs;
|
||||
}
|
||||
|
||||
public JetCoreEnvironment getEnvironment() {
|
||||
@@ -55,4 +57,8 @@ public class K2JVMCompileEnvironmentConfiguration extends CompileEnvironmentConf
|
||||
public BuiltinsScopeExtensionMode getBuiltinsScopeExtensionMode() {
|
||||
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.cli.common.CompilerPlugin;
|
||||
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.CompilerMessageLocation;
|
||||
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.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.java.AnalyzerFacadeForJVM;
|
||||
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.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.plugin.JetMainDetector;
|
||||
@@ -259,7 +258,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(K2JVMCompileEnvironmentConfiguration configuration) {
|
||||
return analyzeAndGenerate(configuration, configuration.getEnvironment().getCompilerSpecialMode() == CompilerSpecialMode.BUILTINS);
|
||||
return analyzeAndGenerate(configuration, configuration.isStubs());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
|
||||
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.KotlinToJVMBytecodeCompiler;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.lang.BuiltinsScopeExtensionMode;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -29,7 +29,7 @@ public class CompileTextTest extends CodegenTestCase {
|
||||
createEnvironmentWithMockJdkAndIdeaAnnotations();
|
||||
String text = "import org.jetbrains.jet.codegen.CompileTextTest; fun x() = CompileTextTest()";
|
||||
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());
|
||||
ClassLoader classLoader = KotlinToJVMBytecodeCompiler.compileText(configuration, text);
|
||||
Class<?> namespace = classLoader.loadClass("namespace");
|
||||
|
||||
@@ -21,12 +21,11 @@ import gnu.trove.THashSet;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestCase;
|
||||
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.jvm.compiler.K2JVMCompileEnvironmentConfiguration;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler;
|
||||
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.psi.JetClass;
|
||||
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.types.JetType;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
import org.jetbrains.jet.utils.ExceptionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Constructor;
|
||||
@@ -86,7 +86,7 @@ public class TestlibTest extends CodegenTestCase {
|
||||
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler
|
||||
.analyzeAndGenerate(new K2JVMCompileEnvironmentConfiguration(myEnvironment, MessageCollector.PLAIN_TEXT_TO_SYSTEM_ERR,
|
||||
false, BuiltinsScopeExtensionMode.ALL), false);
|
||||
false, BuiltinsScopeExtensionMode.ALL, false), false);
|
||||
|
||||
if (generationState == null) {
|
||||
throw new RuntimeException("There were compilation errors");
|
||||
|
||||
Reference in New Issue
Block a user