Review fix: add TODO comments
This commit is contained in:
@@ -78,6 +78,8 @@ private fun removeUselessDeclarations(module: IrModuleFragment, usefulDeclaratio
|
|||||||
process(declaration)
|
process(declaration)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO bring back the primary constructor fix
|
||||||
|
|
||||||
private fun process(container: IrDeclarationContainer) {
|
private fun process(container: IrDeclarationContainer) {
|
||||||
container.declarations.transformFlat { member ->
|
container.declarations.transformFlat { member ->
|
||||||
if (member !in usefulDeclarations) {
|
if (member !in usefulDeclarations) {
|
||||||
@@ -143,6 +145,7 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
|||||||
while (queue.isNotEmpty()) {
|
while (queue.isNotEmpty()) {
|
||||||
val declaration = queue.pollFirst()
|
val declaration = queue.pollFirst()
|
||||||
|
|
||||||
|
// TODO remove?
|
||||||
stageController.lazyLower(declaration)
|
stageController.lazyLower(declaration)
|
||||||
|
|
||||||
if (declaration is IrClass) {
|
if (declaration is IrClass) {
|
||||||
@@ -188,6 +191,7 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO remove?
|
||||||
(body as? IrBody)?.let { stageController.lazyLower(it) }
|
(body as? IrBody)?.let { stageController.lazyLower(it) }
|
||||||
|
|
||||||
body?.acceptVoid(object : IrElementVisitorVoid {
|
body?.acceptVoid(object : IrElementVisitorVoid {
|
||||||
@@ -285,6 +289,7 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO is this needed?
|
||||||
for (declaration in ArrayList(klass.declarations)) {
|
for (declaration in ArrayList(klass.declarations)) {
|
||||||
// TODO this is a hack.
|
// TODO this is a hack.
|
||||||
if (declaration is IrProperty) {
|
if (declaration is IrProperty) {
|
||||||
@@ -293,6 +298,7 @@ fun usefulDeclarations(roots: Iterable<IrDeclaration>, context: JsIrBackendConte
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO deduplicate
|
||||||
// Special hack for `IntrinsicsJs.kt` support
|
// Special hack for `IntrinsicsJs.kt` support
|
||||||
if (klass.superTypes.any { it.isSuspendFunctionTypeOrSubtype() }) {
|
if (klass.superTypes.any { it.isSuspendFunctionTypeOrSubtype() }) {
|
||||||
ArrayList(klass.declarations).forEach {
|
ArrayList(klass.declarations).forEach {
|
||||||
|
|||||||
@@ -356,4 +356,5 @@ class JsIrBackendContext(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: investigate if it could be removed
|
||||||
fun <T> lazy2(fn: () -> T) = lazy { stageController.withInitialIr(fn) }
|
fun <T> lazy2(fn: () -> T) = lazy { stageController.withInitialIr(fn) }
|
||||||
@@ -641,8 +641,10 @@ val loweringList = listOf<Lowering>(
|
|||||||
validateIrAfterLowering
|
validateIrAfterLowering
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// TODO comment? Eliminate MouduleLowering's? Don't filter them here?
|
||||||
val pirLowerings = loweringList.filter { it is DeclarationLowering || it is BodyLowering } + staticMembersLoweringPhase
|
val pirLowerings = loweringList.filter { it is DeclarationLowering || it is BodyLowering } + staticMembersLoweringPhase
|
||||||
|
|
||||||
|
// TODO `fold` -> `reduce`
|
||||||
val jsPhases = namedIrModulePhase(
|
val jsPhases = namedIrModulePhase(
|
||||||
name = "IrModuleLowering",
|
name = "IrModuleLowering",
|
||||||
description = "IR module lowering",
|
description = "IR module lowering",
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ open class MutableController(val context: JsIrBackendContext, val lowerings: Lis
|
|||||||
|
|
||||||
override fun canModify(element: IrElement): Boolean {
|
override fun canModify(element: IrElement): Boolean {
|
||||||
return true
|
return true
|
||||||
|
// TODO fix and enable
|
||||||
// return !restricted || restrictedToDeclaration === element || element is IrPersistingElementBase<*> && element.createdOn == currentStage
|
// return !restricted || restrictedToDeclaration === element || element is IrPersistingElementBase<*> && element.createdOn == currentStage
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,6 +97,7 @@ fun compile(
|
|||||||
|
|
||||||
eliminateDeadDeclarations(moduleFragment, context, mainFunction)
|
eliminateDeadDeclarations(moduleFragment, context, mainFunction)
|
||||||
|
|
||||||
|
// TODO investigate whether this is needed anymore
|
||||||
stageController = object : StageController {
|
stageController = object : StageController {
|
||||||
override val currentStage: Int = controller.currentStage
|
override val currentStage: Int = controller.currentStage
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ class IrFileToJsTransformer : BaseIrElementToJsNodeTransformer<JsBlock, JsGenera
|
|||||||
val fileContext = data.newDeclaration()
|
val fileContext = data.newDeclaration()
|
||||||
val block = JsGlobalBlock()
|
val block = JsGlobalBlock()
|
||||||
|
|
||||||
ArrayList(declaration.declarations).forEach {
|
declaration.declarations.forEach {
|
||||||
block.statements.add(it.accept(IrDeclarationToJsTransformer(), fileContext))
|
block.statements.add(it.accept(IrDeclarationToJsTransformer(), fileContext))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -199,8 +199,7 @@ class NameTables(
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (p in packages) {
|
for (p in packages) {
|
||||||
// TODO
|
for (declaration in p.declarations) {
|
||||||
for (declaration in ArrayList(p.declarations)) {
|
|
||||||
acceptDeclaration(declaration)
|
acceptDeclaration(declaration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -333,6 +332,7 @@ class NameTables(
|
|||||||
val signature = fieldSignature(field)
|
val signature = fieldSignature(field)
|
||||||
val name = memberNames.names[signature] ?: mappedNames[mapToKey(signature)]
|
val name = memberNames.names[signature] ?: mappedNames[mapToKey(signature)]
|
||||||
|
|
||||||
|
// TODO investigate
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return sanitizeName(field.name.asString()) + "__error"
|
return sanitizeName(field.name.asString()) + "__error"
|
||||||
}
|
}
|
||||||
@@ -352,10 +352,13 @@ class NameTables(
|
|||||||
if (name == null && signature is ParameterTypeBasedSignature && signature.suggestedName.startsWith("invoke"))
|
if (name == null && signature is ParameterTypeBasedSignature && signature.suggestedName.startsWith("invoke"))
|
||||||
return signature.suggestedName
|
return signature.suggestedName
|
||||||
|
|
||||||
|
// TODO Add a compiler flag, which enables this behaviour
|
||||||
|
// TODO remove in DCE
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
return sanitizeName(function.name.asString()) + "__error" // TODO one case is a virtual method of an abstract class with no implementation
|
return sanitizeName(function.name.asString()) + "__error" // TODO one case is a virtual method of an abstract class with no implementation
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO report backend error
|
||||||
require(name != null) {
|
require(name != null) {
|
||||||
"Can't find name for member function ${function.render()}"
|
"Can't find name for member function ${function.render()}"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.ir.expressions.IrBody
|
|||||||
// TODO make a IrDeclarationBase field? (requires IR factory)
|
// TODO make a IrDeclarationBase field? (requires IR factory)
|
||||||
var stageController: StageController = object : StageController {}
|
var stageController: StageController = object : StageController {}
|
||||||
|
|
||||||
|
// TODO make a class
|
||||||
interface StageController {
|
interface StageController {
|
||||||
val currentStage: Int get() = 0
|
val currentStage: Int get() = 0
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ abstract class IrDeclarationBase<T : DeclarationCarrier<T>>(
|
|||||||
|
|
||||||
override var parentField: IrDeclarationParent? = null
|
override var parentField: IrDeclarationParent? = null
|
||||||
|
|
||||||
|
// TODO reduce boilerplate
|
||||||
override var parent: IrDeclarationParent
|
override var parent: IrDeclarationParent
|
||||||
get() = getCarrier().parentField ?: throw UninitializedPropertyAccessException("Parent not initialized: $this")
|
get() = getCarrier().parentField ?: throw UninitializedPropertyAccessException("Parent not initialized: $this")
|
||||||
set(p) {
|
set(p) {
|
||||||
@@ -84,6 +85,7 @@ abstract class IrPersistingElementBase<T : Carrier<T>>(
|
|||||||
|
|
||||||
var loweredUpTo = stageController.currentStage
|
var loweredUpTo = stageController.currentStage
|
||||||
|
|
||||||
|
// TODO Array<T>?
|
||||||
private var values: Array<Any?>? = null
|
private var values: Array<Any?>? = null
|
||||||
|
|
||||||
val createdOn: Int = stageController.currentStage
|
val createdOn: Int = stageController.currentStage
|
||||||
@@ -120,6 +122,7 @@ abstract class IrPersistingElementBase<T : Carrier<T>>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO naming? e.g. `mutableCarrier`
|
||||||
protected fun setCarrier(): T {
|
protected fun setCarrier(): T {
|
||||||
val stage = stageController.currentStage
|
val stage = stageController.currentStage
|
||||||
|
|
||||||
@@ -133,6 +136,7 @@ abstract class IrPersistingElementBase<T : Carrier<T>>(
|
|||||||
error("retrospective modification")
|
error("retrospective modification")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO move up? i.e. fast path
|
||||||
if (stage == lastModified) {
|
if (stage == lastModified) {
|
||||||
return this as T
|
return this as T
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
package org.jetbrains.kotlin.ir.declarations.impl.carriers
|
||||||
|
|
||||||
|
// TODO degenerify
|
||||||
|
// TODO degenerify
|
||||||
interface Carrier<in T : Carrier<T>> {
|
interface Carrier<in T : Carrier<T>> {
|
||||||
val lastModified: Int
|
val lastModified: Int
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
// TARGET_BACKEND: JS_IR
|
// TARGET_BACKEND: JS_IR
|
||||||
// SKIP_DCE_DRIVEN
|
|
||||||
// CHECK_TYPESCRIPT_DECLARATIONS
|
// CHECK_TYPESCRIPT_DECLARATIONS
|
||||||
// RUN_PLAIN_BOX_FUNCTION
|
// RUN_PLAIN_BOX_FUNCTION
|
||||||
|
|
||||||
|
// TODO fix statics export in DCE-driven mode
|
||||||
|
// SKIP_DCE_DRIVEN
|
||||||
|
|
||||||
@file:JsExport
|
@file:JsExport
|
||||||
|
|
||||||
internal val internalVal = 10
|
internal val internalVal = 10
|
||||||
|
|||||||
Reference in New Issue
Block a user