Move default inline flag to JVM back-end
- other back-ends are likely to have its own value of this flag - get rid of DEFAULT_INLINE_FLAG_FOR_TEST - the main goal was to simplify the default GenerationState constructor, which now always uses default inline flag value
This commit is contained in:
+11
-17
@@ -19,27 +19,21 @@ package org.jetbrains.jet.cli.common.arguments;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class CompilerArgumentsUtil {
|
||||
public static final boolean DEFAULT_INLINE_FLAG = true;
|
||||
public static final boolean DEFAULT_INLINE_FLAG_FOR_TEST = true;
|
||||
|
||||
public static boolean optionToInlineFlag(@Nullable String option) {
|
||||
boolean enableInline = "on".equalsIgnoreCase(option) || "true".equalsIgnoreCase(option);
|
||||
return (enableInline || "off".equalsIgnoreCase(option) || "false".equalsIgnoreCase(option)) ? enableInline : DEFAULT_INLINE_FLAG;
|
||||
public static boolean optionToBooleanFlag(@Nullable String option, boolean defaultValue) {
|
||||
boolean enabled = "on".equalsIgnoreCase(option) || "true".equalsIgnoreCase(option);
|
||||
boolean disabled = "off".equalsIgnoreCase(option) || "false".equalsIgnoreCase(option);
|
||||
return (enabled || disabled) ? enabled : defaultValue;
|
||||
}
|
||||
|
||||
public static boolean checkInlineOption(@Nullable String option) {
|
||||
if (option == null ||
|
||||
"on".equalsIgnoreCase(option) ||
|
||||
"off".equalsIgnoreCase(option) ||
|
||||
"true".equalsIgnoreCase(option) ||
|
||||
"false".equalsIgnoreCase(option)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
public static boolean checkOption(@Nullable String option) {
|
||||
return option == null ||
|
||||
"on".equalsIgnoreCase(option) ||
|
||||
"off".equalsIgnoreCase(option) ||
|
||||
"true".equalsIgnoreCase(option) ||
|
||||
"false".equalsIgnoreCase(option);
|
||||
}
|
||||
|
||||
public static String getWrongOptionErrorMessage(@Nullable String inline) {
|
||||
public static String getWrongInlineOptionErrorMessage(@Nullable String inline) {
|
||||
return "Wrong value for inline option: '" + inline + "'. Should be 'on'/'off' or 'true'/'false'";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.jet.cli.common.messages.*;
|
||||
import org.jetbrains.jet.cli.jvm.compiler.*;
|
||||
import org.jetbrains.jet.cli.jvm.repl.ReplFromTerminal;
|
||||
import org.jetbrains.jet.codegen.CompilationException;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
import org.jetbrains.jet.config.CompilerConfiguration;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzerScriptParameter;
|
||||
@@ -108,7 +109,8 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
|
||||
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, arguments.notNullAssertions);
|
||||
configuration.put(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, arguments.notNullParamAssertions);
|
||||
configuration.put(JVMConfigurationKeys.ENABLE_INLINE, CompilerArgumentsUtil.optionToInlineFlag(arguments.inline));
|
||||
configuration.put(JVMConfigurationKeys.ENABLE_INLINE,
|
||||
CompilerArgumentsUtil.optionToBooleanFlag(arguments.inline, InlineCodegenUtil.DEFAULT_INLINE_FLAG));
|
||||
|
||||
configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, messageCollector);
|
||||
|
||||
@@ -197,8 +199,8 @@ public class K2JVMCompiler extends CLICompiler<K2JVMCompilerArguments> {
|
||||
protected void checkArguments(@NotNull K2JVMCompilerArguments argument) {
|
||||
super.checkArguments(argument);
|
||||
|
||||
if (!CompilerArgumentsUtil.checkInlineOption(argument.inline)) {
|
||||
throw new IllegalArgumentException(CompilerArgumentsUtil.getWrongOptionErrorMessage(argument.inline));
|
||||
if (!CompilerArgumentsUtil.checkOption(argument.inline)) {
|
||||
throw new IllegalArgumentException(CompilerArgumentsUtil.getWrongInlineOptionErrorMessage(argument.inline));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -29,13 +29,13 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||
import org.jetbrains.jet.cli.common.CompilerPlugin;
|
||||
import org.jetbrains.jet.cli.common.CompilerPluginContext;
|
||||
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
|
||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.common.output.OutputDirector;
|
||||
import org.jetbrains.jet.cli.common.output.SingleDirectoryDirector;
|
||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||
import org.jetbrains.jet.codegen.*;
|
||||
import org.jetbrains.jet.codegen.inline.InlineCodegenUtil;
|
||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||
import org.jetbrains.jet.codegen.state.Progress;
|
||||
import org.jetbrains.jet.config.CommonConfigurationKeys;
|
||||
@@ -309,7 +309,7 @@ public class KotlinToJVMBytecodeCompiler {
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_ASSERTIONS, false),
|
||||
configuration.get(JVMConfigurationKeys.GENERATE_NOT_NULL_PARAMETER_ASSERTIONS, false),
|
||||
GenerationState.GenerateClassFilter.GENERATE_ALL,
|
||||
configuration.get(JVMConfigurationKeys.ENABLE_INLINE, CompilerArgumentsUtil.DEFAULT_INLINE_FLAG)
|
||||
configuration.get(JVMConfigurationKeys.ENABLE_INLINE, InlineCodegenUtil.DEFAULT_INLINE_FLAG)
|
||||
);
|
||||
KotlinCodegenFacade.compileCorrectFiles(generationState, CompilationErrorHandler.THROW_EXCEPTION);
|
||||
return generationState;
|
||||
|
||||
@@ -29,10 +29,8 @@ import com.intellij.psi.impl.PsiFileFactoryImpl;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
import org.jetbrains.jet.OutputFile;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil;
|
||||
import org.jetbrains.jet.cli.common.messages.AnalyzerWithCompilerReport;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||
import org.jetbrains.jet.cli.common.messages.MessageCollectorToString;
|
||||
@@ -63,6 +61,7 @@ import org.jetbrains.jet.plugin.JetLanguage;
|
||||
import org.jetbrains.jet.storage.ExceptionTracker;
|
||||
import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
import org.jetbrains.jet.utils.UtilsPackage;
|
||||
import org.jetbrains.org.objectweb.asm.Type;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.PrintWriter;
|
||||
@@ -249,7 +248,7 @@ public class ReplInterpreter {
|
||||
|
||||
BindingContext bindingContext = AnalyzeExhaust.success(trace.getBindingContext(), module).getBindingContext();
|
||||
GenerationState generationState = new GenerationState(psiFile.getProject(), ClassBuilderFactories.BINARIES,
|
||||
bindingContext, Collections.singletonList(psiFile), CompilerArgumentsUtil.DEFAULT_INLINE_FLAG);
|
||||
bindingContext, Collections.singletonList(psiFile));
|
||||
|
||||
compileScript(psiFile.getScript(), scriptClassType, earlierScripts, generationState,
|
||||
CompilationErrorHandler.THROW_EXCEPTION);
|
||||
|
||||
Reference in New Issue
Block a user