IR: add module ir.tree.persistent, copy PIR implementation there
Use PersistentIrFactory in JS IR compiler entry points.
This commit is contained in:
@@ -12,6 +12,7 @@ dependencies {
|
||||
compile(project(":compiler:ir.backend.common"))
|
||||
compile(project(":compiler:ir.serialization.common"))
|
||||
compile(project(":compiler:ir.serialization.js"))
|
||||
compile(project(":compiler:ir.tree.persistent"))
|
||||
compile(project(":js:js.ast"))
|
||||
compile(project(":js:js.frontend"))
|
||||
|
||||
@@ -22,4 +23,3 @@ sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" {}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ import org.jetbrains.kotlin.ir.backend.js.utils.OperatorNames
|
||||
import org.jetbrains.kotlin.ir.builders.declarations.addFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFileImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||
import org.jetbrains.kotlin.ir.symbols.*
|
||||
import org.jetbrains.kotlin.ir.types.*
|
||||
@@ -55,7 +55,7 @@ class JsIrBackendContext(
|
||||
|
||||
override var inVerbosePhase: Boolean = false
|
||||
|
||||
override val irFactory: IrFactory = IrFactoryImpl
|
||||
override val irFactory: IrFactory = PersistentIrFactory
|
||||
|
||||
val devMode = configuration[JSConfigurationKeys.DEVELOPER_MODE] ?: false
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.ir.backend.js
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.ir.IrElement
|
||||
import org.jetbrains.kotlin.ir.declarations.*
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrDeclarationBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrBodyBase
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrDeclarationBase
|
||||
import org.jetbrains.kotlin.ir.expressions.IrBody
|
||||
import org.jetbrains.kotlin.ir.util.isLocal
|
||||
|
||||
@@ -18,7 +18,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
override var currentStage: Int = 0
|
||||
|
||||
override fun lazyLower(declaration: IrDeclaration) {
|
||||
if (declaration is IrDeclarationBase<*>) {
|
||||
if (declaration is PersistentIrDeclarationBase<*>) {
|
||||
while (declaration.loweredUpTo + 1 < currentStage) {
|
||||
val i = declaration.loweredUpTo + 1
|
||||
withStage(i) {
|
||||
@@ -44,7 +44,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
}
|
||||
|
||||
override fun lazyLower(body: IrBody) {
|
||||
if (body is IrBodyBase<*>) {
|
||||
if (body is PersistentIrBodyBase<*>) {
|
||||
for (i in (body.loweredUpTo + 1) until currentStage) {
|
||||
withStage(i) {
|
||||
if (body.container !in context.externalDeclarations) {
|
||||
@@ -63,7 +63,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
}
|
||||
|
||||
// Launches a lowering and applies it's results
|
||||
private fun DeclarationLowering.doApplyLoweringTo(declaration: IrDeclarationBase<*>) {
|
||||
private fun DeclarationLowering.doApplyLoweringTo(declaration: PersistentIrDeclarationBase<*>) {
|
||||
val parentBefore = declaration.parent
|
||||
val result = restrictTo(declaration) { this.declarationTransformer(context).transformFlat(declaration) }
|
||||
if (result != null) {
|
||||
@@ -184,4 +184,4 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
||||
declarationListsRestricted = wereDeclarationListsRestricted
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.IrModuleToJsTransf
|
||||
import org.jetbrains.kotlin.ir.backend.js.utils.NameTables
|
||||
import org.jetbrains.kotlin.ir.declarations.IrModuleFragment
|
||||
import org.jetbrains.kotlin.ir.declarations.StageController
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFactoryImpl
|
||||
import org.jetbrains.kotlin.ir.declarations.persistent.PersistentIrFactory
|
||||
import org.jetbrains.kotlin.ir.declarations.stageController
|
||||
import org.jetbrains.kotlin.ir.util.ExternalDependenciesGenerator
|
||||
import org.jetbrains.kotlin.ir.util.noUnboundLeft
|
||||
@@ -53,7 +53,7 @@ fun compile(
|
||||
stageController = StageController()
|
||||
|
||||
val (moduleFragment: IrModuleFragment, dependencyModules, irBuiltIns, symbolTable, deserializer) =
|
||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, IrFactoryImpl)
|
||||
loadIr(project, mainModule, analyzer, configuration, allDependencies, friendDependencies, PersistentIrFactory)
|
||||
|
||||
val moduleDescriptor = moduleFragment.descriptor
|
||||
|
||||
|
||||
Reference in New Issue
Block a user