Phaser: Implement dumper and verifier as general actions

This commit is contained in:
Svyatoslav Kuzmich
2019-05-13 15:19:23 +03:00
parent 0702b88bf3
commit b07690fccf
12 changed files with 208 additions and 78 deletions
@@ -238,6 +238,18 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
)
var namesExcludedFromDumping: Array<String>? by FreezableVar(null)
@Argument(
value = "-Xdump-directory",
description = "Dump backend state into directory"
)
var dumpDirectory: String? by FreezableVar(null)
@Argument(
value = "-Xdump-fqname",
description = "FqName of declaration that should be dumped"
)
var dumpOnlyFqName: String? by FreezableVar(null)
@Argument(
value = "-Xphases-to-validate-before",
description = "Validate backend state before these phases"
@@ -29,8 +29,9 @@ import org.jetbrains.kotlin.incremental.components.LookupTracker
import org.jetbrains.kotlin.incremental.js.IncrementalDataProvider
import org.jetbrains.kotlin.incremental.js.IncrementalResultsConsumer
import org.jetbrains.kotlin.ir.backend.js.KlibModuleRef
import org.jetbrains.kotlin.ir.backend.js.generateKLib
import org.jetbrains.kotlin.ir.backend.js.compile
import org.jetbrains.kotlin.ir.backend.js.generateKLib
import org.jetbrains.kotlin.ir.backend.js.jsPhases
import org.jetbrains.kotlin.js.config.EcmaVersion
import org.jetbrains.kotlin.js.config.JSConfigurationKeys
import org.jetbrains.kotlin.js.config.JsConfig
@@ -223,10 +224,13 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
}
if (produceKind == ProduceKind.JS || produceKind == ProduceKind.DEFAULT) {
val phaseConfig = createPhaseConfig(jsPhases, arguments, messageCollector)
val compiledModule = compile(
project,
sourcesFiles,
configuration,
phaseConfig,
immediateDependencies = dependencies,
allDependencies = dependencies,
friendDependencies = friendDependencies,
@@ -29,6 +29,8 @@ fun createPhaseConfig(
val bothDumpSet = phaseSetFromArguments(phases, arguments.phasesToDump, ::report)
val toDumpStateBefore = beforeDumpSet + bothDumpSet
val toDumpStateAfter = afterDumpSet + bothDumpSet
val dumpDirectory = arguments.dumpDirectory
val dumpOnlyFqName = arguments.dumpOnlyFqName
val beforeValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateBefore, ::report)
val afterValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidateAfter, ::report)
val bothValidateSet = phaseSetFromArguments(phases, arguments.phasesToValidate, ::report)
@@ -42,9 +44,20 @@ fun createPhaseConfig(
val checkStickyConditions = arguments.checkStickyPhaseConditions
return PhaseConfig(
compoundPhase, phases, enabled, verbose, toDumpStateBefore, toDumpStateAfter, toValidateStateBefore, toValidateStateAfter,
compoundPhase,
phases,
enabled,
verbose,
toDumpStateBefore,
toDumpStateAfter,
dumpDirectory,
dumpOnlyFqName,
toValidateStateBefore,
toValidateStateAfter,
namesOfElementsExcludedFromDumping,
needProfiling, checkConditions, checkStickyConditions
needProfiling,
checkConditions,
checkStickyConditions
).also {
if (arguments.listPhases) {
it.list()