[IR] Add doc comments for KotlinMangleComputer and its inheritors

This commit is contained in:
Sergej Jaskiewicz
2022-12-14 19:17:08 +01:00
committed by Space Team
parent c447b91101
commit 1651199ed8
4 changed files with 32 additions and 4 deletions
@@ -25,6 +25,9 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
/**
* A mangle computer that generates a mangled name for a Kotlin declaration represented by [FirDeclaration].
*/
class FirJvmMangleComputer(
builder: StringBuilder,
mode: MangleMode,
@@ -5,9 +5,28 @@
package org.jetbrains.kotlin.backend.common.serialization.mangle
interface KotlinMangleComputer<D : Any> {
/**
* Something capable of producing a mangled name for a Kotlin declaration.
*
* @param Declaration A class representing a Kotlin declaration.
*/
interface KotlinMangleComputer<Declaration : Any> {
fun computeMangle(declaration: D): String
/**
* Computes the mangled name of [declaration].
*
* @param declaration The Kotlin declaration to compute a mangle name for.
* @return The mangled name of [declaration].
*/
fun computeMangle(declaration: Declaration): String
fun copy(newMode: MangleMode): KotlinMangleComputer<D>
}
/**
* Creates a copy of this mangle computer with a different mangle mode but otherwise the same state.
*
* Useful for temporarily switching the mangle mode.
*
* @param newMode The mangle mode to use in the new mangle computer.
* @return A copy of this mangle computer.
*/
fun copy(newMode: MangleMode): KotlinMangleComputer<Declaration>
}
@@ -15,6 +15,9 @@ import org.jetbrains.kotlin.types.checker.SimpleClassicTypeSystemContext
import org.jetbrains.kotlin.types.model.TypeSystemContext
import org.jetbrains.kotlin.types.typeUtil.isUnit
/**
* The descriptor-based mangle computer. Used to compute a mangled name for a declaration given its [DeclarationDescriptor].
*/
abstract class DescriptorMangleComputer(builder: StringBuilder, mode: MangleMode) :
BaseKotlinMangleComputer<
/*Declaration=*/DeclarationDescriptor,
@@ -16,6 +16,9 @@ import org.jetbrains.kotlin.ir.util.*
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptVoid
/**
* A mangle computer that generates a mangled name for a Kotlin declaration represented by [IrDeclaration].
*/
abstract class IrMangleComputer(
builder: StringBuilder,
mode: MangleMode,