Support for "builtins/stubs" mode removed from cli
This commit is contained in:
@@ -82,35 +82,33 @@ public class ClassBuilderFactories {
|
||||
}
|
||||
};
|
||||
|
||||
public static ClassBuilderFactory BINARIES = new ClassBuilderFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ClassBuilderMode getClassBuilderMode() {
|
||||
return ClassBuilderMode.FULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassBuilder newClassBuilder() {
|
||||
return new ClassBuilder.Concrete(new BinaryClassWriter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asText(ClassBuilder builder) {
|
||||
throw new UnsupportedOperationException("BINARIES generator asked for text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] asBytes(ClassBuilder builder) {
|
||||
ClassWriter visitor = (ClassWriter) builder.getVisitor();
|
||||
return visitor.toByteArray();
|
||||
}
|
||||
};
|
||||
|
||||
private ClassBuilderFactories() {
|
||||
}
|
||||
|
||||
public static ClassBuilderFactory binaries(final boolean stubs) {
|
||||
return new ClassBuilderFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public ClassBuilderMode getClassBuilderMode() {
|
||||
return stubs ? ClassBuilderMode.STUBS : ClassBuilderMode.FULL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClassBuilder newClassBuilder() {
|
||||
return new ClassBuilder.Concrete(new BinaryClassWriter());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String asText(ClassBuilder builder) {
|
||||
throw new UnsupportedOperationException("BINARIES generator asked for text");
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] asBytes(ClassBuilder builder) {
|
||||
ClassWriter visitor = (ClassWriter) builder.getVisitor();
|
||||
return visitor.toByteArray();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private static class BinaryClassWriter extends ClassWriter {
|
||||
public BinaryClassWriter() {
|
||||
super(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
|
||||
|
||||
@@ -31,7 +31,6 @@ public class JVMConfigurationKeys {
|
||||
public static final CompilerConfigurationKey<List<File>> ANNOTATIONS_PATH_KEY = CompilerConfigurationKey.create("annotations path");
|
||||
|
||||
public static final CompilerConfigurationKey<List<AnalyzerScriptParameter>> SCRIPT_PARAMETERS = CompilerConfigurationKey.create("script");
|
||||
public static final CompilerConfigurationKey<Boolean> STUBS = CompilerConfigurationKey.create("stubs");
|
||||
public static final CompilerConfigurationKey<BuiltinToJavaTypesMapping> BUILTIN_TO_JAVA_TYPES_MAPPING_KEY =
|
||||
CompilerConfigurationKey.create("builtin to java types mapping");
|
||||
|
||||
|
||||
@@ -112,14 +112,10 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
}
|
||||
}
|
||||
|
||||
boolean builtins = arguments.builtins;
|
||||
|
||||
configuration.put(JVMConfigurationKeys.SCRIPT_PARAMETERS, arguments.script
|
||||
? CommandLineScriptUtils.scriptParameters()
|
||||
: Collections.<AnalyzerScriptParameter>emptyList());
|
||||
configuration.put(JVMConfigurationKeys.STUBS, builtins);
|
||||
configuration.put(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY,
|
||||
builtins ? BuiltinToJavaTypesMapping.DISABLED : BuiltinToJavaTypesMapping.ENABLED);
|
||||
configuration.put(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED);
|
||||
|
||||
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions);
|
||||
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions);
|
||||
|
||||
@@ -70,9 +70,6 @@ public class K2JVMCompilerArguments extends CommonCompilerArguments {
|
||||
@Argument(value = "notNullParamAssertions", description = "generate not-null assertions on parameters of methods accessible from Java")
|
||||
public boolean notNullParamAssertions;
|
||||
|
||||
@Argument(value = "builtins", description = "compile builtin classes (internal)")
|
||||
public boolean builtins;
|
||||
|
||||
@Argument(value = "output", description = "output directory")
|
||||
public String outputDir;
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public class CompileEnvironmentUtil {
|
||||
List<Module> modules;
|
||||
try {
|
||||
JetCoreEnvironment scriptEnvironment = new JetCoreEnvironment(disposable, configuration);
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment, false);
|
||||
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment);
|
||||
if (generationState == null) {
|
||||
throw new CompileEnvironmentException("Module script " + moduleScriptFile + " analyze failed:\n" +
|
||||
loadModuleScriptText(moduleScriptFile));
|
||||
|
||||
+9
-22
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.cli.jvm.compiler;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Predicates;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -270,26 +269,16 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(JetCoreEnvironment environment) {
|
||||
return analyzeAndGenerate(environment, environment.getConfiguration().get(JVMConfigurationKeys.STUBS, false),
|
||||
return analyzeAndGenerate(environment,
|
||||
environment.getConfiguration().getList(JVMConfigurationKeys.SCRIPT_PARAMETERS));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(
|
||||
JetCoreEnvironment environment,
|
||||
boolean stubs
|
||||
) {
|
||||
return analyzeAndGenerate(environment, stubs,
|
||||
environment.getConfiguration().getList(JVMConfigurationKeys.SCRIPT_PARAMETERS));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static GenerationState analyzeAndGenerate(
|
||||
JetCoreEnvironment environment,
|
||||
boolean stubs,
|
||||
List<AnalyzerScriptParameter> scriptParameters
|
||||
) {
|
||||
AnalyzeExhaust exhaust = analyze(environment, scriptParameters, stubs);
|
||||
AnalyzeExhaust exhaust = analyze(environment, scriptParameters);
|
||||
|
||||
if (exhaust == null) {
|
||||
return null;
|
||||
@@ -297,18 +286,16 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
|
||||
exhaust.throwIfError();
|
||||
|
||||
return generate(environment, exhaust, stubs);
|
||||
return generate(environment, exhaust);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static AnalyzeExhaust analyze(
|
||||
final JetCoreEnvironment environment,
|
||||
final List<AnalyzerScriptParameter> scriptParameters,
|
||||
boolean stubs) {
|
||||
final List<AnalyzerScriptParameter> scriptParameters
|
||||
) {
|
||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
|
||||
environment.getConfiguration().get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY));
|
||||
final Predicate<PsiFile> filesToAnalyzeCompletely =
|
||||
stubs ? Predicates.<PsiFile>alwaysFalse() : Predicates.<PsiFile>alwaysTrue();
|
||||
analyzerWithCompilerReport.analyzeAndReport(
|
||||
new Function0<AnalyzeExhaust>() {
|
||||
@NotNull
|
||||
@@ -320,7 +307,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
environment.getSourceFiles(),
|
||||
sharedTrace,
|
||||
scriptParameters,
|
||||
filesToAnalyzeCompletely,
|
||||
Predicates.<PsiFile>alwaysTrue(),
|
||||
false
|
||||
);
|
||||
}
|
||||
@@ -333,8 +320,8 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
@NotNull
|
||||
private static GenerationState generate(
|
||||
JetCoreEnvironment environment,
|
||||
AnalyzeExhaust exhaust,
|
||||
boolean stubs) {
|
||||
AnalyzeExhaust exhaust
|
||||
) {
|
||||
Project project = environment.getProject();
|
||||
final CompilerConfiguration configuration = environment.getConfiguration();
|
||||
Progress backendProgress = new Progress() {
|
||||
@@ -352,7 +339,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
};
|
||||
GenerationState generationState = new GenerationState(
|
||||
project, ClassBuilderFactories.binaries(stubs), backendProgress, exhaust.getBindingContext(), environment.getSourceFiles(),
|
||||
project, ClassBuilderFactories.BINARIES, backendProgress, exhaust.getBindingContext(), environment.getSourceFiles(),
|
||||
configuration.get(JVMConfigurationKeys.BUILTIN_TO_JAVA_TYPES_MAPPING_KEY, BuiltinToJavaTypesMapping.ENABLED),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false),
|
||||
|
||||
@@ -230,7 +230,7 @@ public class ReplInterpreter {
|
||||
}
|
||||
|
||||
BindingContext bindingContext = AnalyzeExhaust.success(trace.getBindingContext(), module).getBindingContext();
|
||||
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.binaries(false),
|
||||
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.BINARIES,
|
||||
bindingContext, Collections.singletonList(psiFile));
|
||||
generationState.getScriptCodegen().compileScript(psiFile.getScript(), scriptClassType, earlierScripts,
|
||||
CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
@@ -9,7 +9,6 @@ Usage: org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
|
||||
-noJdkAnnotations [flag] don't include JDK external annotations into classpath
|
||||
-notNullAssertions [flag] generate not-null assertion after each invokation of method returning not-null
|
||||
-notNullParamAssertions [flag] generate not-null assertions on parameters of methods accessible from Java
|
||||
-builtins [flag] compile builtin classes (internal)
|
||||
-output [String] output directory
|
||||
-module [String] module to compile
|
||||
-script [flag] evaluate script
|
||||
|
||||
@@ -10,7 +10,6 @@ Usage: org.jetbrains.jet.cli.jvm.K2JVMCompilerArguments
|
||||
-noJdkAnnotations [flag] don't include JDK external annotations into classpath
|
||||
-notNullAssertions [flag] generate not-null assertion after each invokation of method returning not-null
|
||||
-notNullParamAssertions [flag] generate not-null assertions on parameters of methods accessible from Java
|
||||
-builtins [flag] compile builtin classes (internal)
|
||||
-output [String] output directory
|
||||
-module [String] module to compile
|
||||
-script [flag] evaluate script
|
||||
|
||||
@@ -100,7 +100,7 @@ public class TestlibTest extends UsefulTestCase {
|
||||
|
||||
myEnvironment = new JetCoreEnvironment(getTestRootDisposable(), configuration);
|
||||
|
||||
generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(myEnvironment, false);
|
||||
generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(myEnvironment);
|
||||
if (generationState == null) {
|
||||
throw new RuntimeException("There were compilation errors");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user