Add CompilerPhase and corresponding compiler keys

This commit is contained in:
Georgy Bronnikov
2018-10-16 17:55:16 +03:00
parent ecba313223
commit 32640750ee
35 changed files with 642 additions and 80 deletions
@@ -196,6 +196,48 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var allowResultReturnType: Boolean by FreezableVar(false)
@Argument(
value = "-Xlist-phases",
description = "List backend phases"
)
var listPhases: Boolean by FreezableVar(false)
@Argument(
value = "-Xdisable-phases",
description = "Disable backend phases"
)
var disablePhases: Array<String> by FreezableVar(emptyArray())
@Argument(
value = "-Xverbose-phases",
description = "Be verbose while performing these backend phases"
)
var verbosePhases: Array<String> by FreezableVar(emptyArray())
@Argument(
value = "-Xphases-to-dump-before",
description = "Dump backend state before these phases"
)
var phasesToDumpBefore: Array<String> by FreezableVar(emptyArray())
@Argument(
value = "-Xphases-to-dump-after",
description = "Dump backend state after these phases"
)
var phasesToDumpAfter: Array<String> by FreezableVar(emptyArray())
@Argument(
value = "-Xphases-to-dump",
description = "Dump backend state both before and after these phases"
)
var phasesToDump: Array<String> by FreezableVar(emptyArray())
@Argument(
value = "-Xprofile-phases",
description = "Profile backend phases"
)
var profilePhases: Boolean by FreezableVar(false)
open fun configureAnalysisFlags(collector: MessageCollector): MutableMap<AnalysisFlag<*>, Any> {
return HashMap<AnalysisFlag<*>, Any>().apply {
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.cli.common;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.util.Disposer;
import kotlin.collections.SetsKt;
import kotlin.jvm.functions.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -160,6 +161,14 @@ public abstract class CLICompiler<A extends CommonCompilerArguments> extends CLI
}
setupLanguageVersionSettings(configuration, arguments);
configuration.put(CommonConfigurationKeys.LIST_PHASES, arguments.getListPhases());
configuration.put(CommonConfigurationKeys.DISABLED_PHASES, SetsKt.setOf(arguments.getDisablePhases()));
configuration.put(CommonConfigurationKeys.VERBOSE_PHASES, SetsKt.setOf(arguments.getVerbosePhases()));
configuration.put(CommonConfigurationKeys.PHASES_TO_DUMP_STATE_BEFORE, SetsKt.setOf(arguments.getPhasesToDumpBefore()));
configuration.put(CommonConfigurationKeys.PHASES_TO_DUMP_STATE_AFTER, SetsKt.setOf(arguments.getPhasesToDumpAfter()));
configuration.put(CommonConfigurationKeys.PHASES_TO_DUMP_STATE, SetsKt.setOf(arguments.getPhasesToDump()));
configuration.put(CommonConfigurationKeys.PROFILE_PHASES, arguments.getProfilePhases());
}
@NotNull