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