Partial code cleanup: can be private and some others applied
This commit is contained in:
@@ -22,7 +22,7 @@ import java.util.*
|
||||
|
||||
class DefaultCallArgs(val size: Int) {
|
||||
|
||||
val bits: BitSet = BitSet(size)
|
||||
private val bits: BitSet = BitSet(size)
|
||||
|
||||
fun mark(index: Int) {
|
||||
assert (index < size) {
|
||||
@@ -39,7 +39,7 @@ class DefaultCallArgs(val size: Int) {
|
||||
val masks = ArrayList<Int>(1)
|
||||
|
||||
var mask = 0
|
||||
for (i in 0..size - 1) {
|
||||
for (i in 0 until size) {
|
||||
if (i != 0 && i % Integer.SIZE == 0) {
|
||||
masks.add(mask)
|
||||
mask = 0
|
||||
|
||||
@@ -23,9 +23,9 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticSink
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
||||
|
||||
class InlineCycleReporter(val diagnostics: DiagnosticSink) {
|
||||
class InlineCycleReporter(private val diagnostics: DiagnosticSink) {
|
||||
|
||||
val processingFunctions = linkedMapOf<PsiElement, CallableDescriptor>()
|
||||
private val processingFunctions = linkedMapOf<PsiElement, CallableDescriptor>()
|
||||
|
||||
fun enterIntoInlining(call: ResolvedCall<*>?): Boolean {
|
||||
//null call for default method inlining
|
||||
|
||||
+3
-3
@@ -25,9 +25,9 @@ import org.jetbrains.kotlin.resolve.jvm.diagnostics.Synthetic
|
||||
import org.jetbrains.kotlin.resolve.jvm.jvmSignature.JvmMethodSignature
|
||||
|
||||
class JvmStaticInCompanionObjectGenerator(
|
||||
val descriptor: FunctionDescriptor,
|
||||
val declarationOrigin: JvmDeclarationOrigin,
|
||||
val state: GenerationState,
|
||||
private val descriptor: FunctionDescriptor,
|
||||
private val declarationOrigin: JvmDeclarationOrigin,
|
||||
private val state: GenerationState,
|
||||
parentBodyCodegen: ImplementationBodyCodegen
|
||||
) : Function2<ImplementationBodyCodegen, ClassBuilder, Unit> {
|
||||
private val typeMapper = state.typeMapper
|
||||
|
||||
@@ -62,7 +62,7 @@ class PropertyReferenceCodegen(
|
||||
|
||||
private val isLocalDelegatedProperty = target is LocalVariableDescriptor
|
||||
|
||||
val getFunction =
|
||||
private val getFunction =
|
||||
if (isLocalDelegatedProperty)
|
||||
(localVariableDescriptorForReference as VariableDescriptorWithAccessors).getter!!
|
||||
else
|
||||
@@ -250,13 +250,13 @@ class PropertyReferenceCodegen(
|
||||
|
||||
class PropertyReferenceGenerationStrategy(
|
||||
val isGetter: Boolean,
|
||||
val originalFunctionDesc: FunctionDescriptor,
|
||||
private val originalFunctionDesc: FunctionDescriptor,
|
||||
val target: VariableDescriptor,
|
||||
val asmType: Type,
|
||||
val receiverType: Type?,
|
||||
val expression: KtElement,
|
||||
state: GenerationState,
|
||||
val isInliningStrategy: Boolean
|
||||
private val isInliningStrategy: Boolean
|
||||
) :
|
||||
FunctionGenerationStrategy.CodegenBased(state) {
|
||||
override fun doGenerateBody(codegen: ExpressionCodegen, signature: JvmMethodSignature) {
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
|
||||
class CoercionValue(
|
||||
val value: StackValue,
|
||||
val castType: Type
|
||||
private val castType: Type
|
||||
) : StackValue(castType, value.canHaveSideEffects()) {
|
||||
|
||||
override fun putSelector(type: Type, v: InstructionAdapter) {
|
||||
|
||||
+2
-4
@@ -28,12 +28,10 @@ class DefaultImplsClassContext(
|
||||
contextKind: OwnerKind,
|
||||
parentContext: CodegenContext<*>?,
|
||||
localLookup: ((DeclarationDescriptor) -> Boolean)?,
|
||||
val interfaceContext: ClassContext
|
||||
private val interfaceContext: ClassContext
|
||||
) : ClassContext(typeMapper, contextDescriptor, contextKind, parentContext, localLookup) {
|
||||
|
||||
override fun getCompanionObjectContext(): CodegenContext<*>? {
|
||||
return interfaceContext.companionObjectContext
|
||||
}
|
||||
override fun getCompanionObjectContext(): CodegenContext<*>? = interfaceContext.companionObjectContext
|
||||
|
||||
override fun getAccessors(): Collection<AccessorForCallableDescriptor<*>> {
|
||||
val accessors = super.getAccessors()
|
||||
|
||||
@@ -25,8 +25,8 @@ class InlineLambdaContext(
|
||||
contextKind: OwnerKind,
|
||||
parentContext: CodegenContext<*>,
|
||||
closure: MutableClosure?,
|
||||
val isCrossInline: Boolean,
|
||||
val isPropertyReference: Boolean
|
||||
private val isCrossInline: Boolean,
|
||||
private val isPropertyReference: Boolean
|
||||
) : MethodContext(functionDescriptor, contextKind, parentContext, closure, false) {
|
||||
|
||||
override fun getFirstCrossInlineOrNonInlineContext(): CodegenContext<*> {
|
||||
|
||||
+1
-1
@@ -141,7 +141,7 @@ class IntervalMetaInfo<T : SplittableInterval<T>> {
|
||||
return splitPair
|
||||
}
|
||||
|
||||
fun getInterval(curIns: LabelNode, isOpen: Boolean) =
|
||||
private fun getInterval(curIns: LabelNode, isOpen: Boolean) =
|
||||
if (isOpen) intervalStarts.get(curIns) else intervalEnds.get(curIns)
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
|
||||
class DeferredMethodVisitor(
|
||||
val intermediate: MethodNode,
|
||||
val resultNode: () -> MethodVisitor
|
||||
private val resultNode: () -> MethodVisitor
|
||||
) : MethodVisitor(API, intermediate) {
|
||||
|
||||
override fun visitEnd() {
|
||||
|
||||
@@ -24,7 +24,7 @@ class InlinedLambdaRemapper(
|
||||
originalLambdaInternalName: String,
|
||||
parent: FieldRemapper,
|
||||
methodParams: Parameters,
|
||||
val isDefaultBoundCallableReference: Boolean
|
||||
private val isDefaultBoundCallableReference: Boolean
|
||||
) : FieldRemapper(originalLambdaInternalName, parent, methodParams) {
|
||||
|
||||
public override fun canProcess(fieldOwner: String, fieldName: String, isFolding: Boolean) =
|
||||
|
||||
@@ -84,7 +84,7 @@ abstract class LambdaInfo(@JvmField val isCrossInline: Boolean) : LabelOwner {
|
||||
|
||||
class DefaultLambda(
|
||||
override val lambdaClassType: Type,
|
||||
val capturedArgs: Array<Type>,
|
||||
private val capturedArgs: Array<Type>,
|
||||
val parameterDescriptor: ValueParameterDescriptor,
|
||||
val offset: Int,
|
||||
val needReification: Boolean
|
||||
|
||||
@@ -53,7 +53,7 @@ abstract class ObjectTransformer<out T : TransformationInfo>(@JvmField val trans
|
||||
|
||||
class WhenMappingTransformer(
|
||||
whenObjectRegenerationInfo: WhenMappingTransformationInfo,
|
||||
val inliningContext: InliningContext
|
||||
private val inliningContext: InliningContext
|
||||
) : ObjectTransformer<WhenMappingTransformationInfo>(whenObjectRegenerationInfo, inliningContext.state) {
|
||||
|
||||
override fun doTransform(parentRemapper: FieldRemapper): InlineResult {
|
||||
|
||||
@@ -16,13 +16,11 @@
|
||||
|
||||
package org.jetbrains.kotlin.codegen.inline
|
||||
|
||||
import org.jetbrains.kotlin.codegen.AsmUtil
|
||||
import org.jetbrains.kotlin.codegen.context.MethodContext
|
||||
import org.jetbrains.kotlin.codegen.generateAsCast
|
||||
import org.jetbrains.kotlin.codegen.generateIsCheck
|
||||
import org.jetbrains.kotlin.codegen.intrinsics.IntrinsicMethods
|
||||
import org.jetbrains.kotlin.codegen.optimization.common.intConstant
|
||||
import org.jetbrains.kotlin.codegen.optimization.removeNodeGetNext
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
@@ -34,7 +32,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
import org.jetbrains.org.objectweb.asm.tree.*
|
||||
|
||||
class ReificationArgument(
|
||||
val parameterName: String, val nullable: Boolean, val arrayDepth: Int
|
||||
val parameterName: String, val nullable: Boolean, private val arrayDepth: Int
|
||||
) {
|
||||
fun asString() = "[".repeat(arrayDepth) + parameterName + (if (nullable) "?" else "")
|
||||
fun combine(replacement: ReificationArgument) =
|
||||
@@ -302,7 +300,7 @@ class TypeParameterMapping(
|
||||
)
|
||||
|
||||
class ReifiedTypeParametersUsages {
|
||||
val usedTypeParameters: MutableSet<String> = hashSetOf()
|
||||
private val usedTypeParameters: MutableSet<String> = hashSetOf()
|
||||
|
||||
fun wereUsedReifiedParameters(): Boolean = usedTypeParameters.isNotEmpty()
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug"
|
||||
class SMAPBuilder(
|
||||
val source: String,
|
||||
val path: String,
|
||||
val fileMappings: List<FileMapping>
|
||||
private val fileMappings: List<FileMapping>
|
||||
) {
|
||||
private val header = "SMAP\n$source\nKotlin"
|
||||
|
||||
@@ -91,9 +91,9 @@ open class NestedSourceMapper(
|
||||
override val parent: SourceMapper, val ranges: List<RangeMapping>, sourceInfo: SourceInfo
|
||||
) : DefaultSourceMapper(sourceInfo) {
|
||||
|
||||
val visitedLines = TIntIntHashMap()
|
||||
private val visitedLines = TIntIntHashMap()
|
||||
|
||||
var lastVisitedRange: RangeMapping? = null
|
||||
private var lastVisitedRange: RangeMapping? = null
|
||||
|
||||
override fun mapLineNumber(lineNumber: Int): Int {
|
||||
val mappedLineNumber = visitedLines.get(lineNumber)
|
||||
@@ -115,7 +115,7 @@ open class NestedSourceMapper(
|
||||
}
|
||||
}
|
||||
|
||||
fun findMappingIfExists(lineNumber: Int): RangeMapping? {
|
||||
private fun findMappingIfExists(lineNumber: Int): RangeMapping? {
|
||||
val index = ranges.binarySearch(RangeMapping(lineNumber, lineNumber, 1), Comparator {
|
||||
value, key ->
|
||||
if (key.dest in value) 0 else RangeMapping.Comparator.compare(value, key)
|
||||
|
||||
@@ -40,7 +40,7 @@ interface TransformationInfo {
|
||||
class WhenMappingTransformationInfo(
|
||||
override val oldClassName: String,
|
||||
parentNameGenerator: NameGenerator,
|
||||
val alreadyRegenerated: Boolean,
|
||||
private val alreadyRegenerated: Boolean,
|
||||
val fieldNode: FieldInsnNode
|
||||
) : TransformationInfo {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class TypeParameter(val oldName: String, val newName: String?, val isReified: Bo
|
||||
class TypeRemapper private constructor(
|
||||
private val typeMapping: MutableMap<String, String>,
|
||||
val parent: TypeRemapper? = null,
|
||||
val isRootInlineLambda: Boolean = false
|
||||
private val isRootInlineLambda: Boolean = false
|
||||
) {
|
||||
private val additionalMappings = hashMapOf<String, String>()
|
||||
private val typeParametersMapping = hashMapOf<String, TypeParameter>()
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ class DeadCodeEliminationMethodTransformer : MethodTransformer() {
|
||||
return true
|
||||
}
|
||||
|
||||
class Result(val removedNodes: Set<AbstractInsnNode>) {
|
||||
class Result(private val removedNodes: Set<AbstractInsnNode>) {
|
||||
fun hasRemovedAnything() = removedNodes.isNotEmpty()
|
||||
fun isRemoved(node: AbstractInsnNode) = removedNodes.contains(node)
|
||||
fun isAlive(node: AbstractInsnNode) = !isRemoved(node)
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ class CleanBoxedValue(
|
||||
}
|
||||
|
||||
|
||||
class TaintedBoxedValue(val boxedBasicValue: CleanBoxedValue) : BoxedBasicValue(boxedBasicValue.type) {
|
||||
class TaintedBoxedValue(private val boxedBasicValue: CleanBoxedValue) : BoxedBasicValue(boxedBasicValue.type) {
|
||||
override val descriptor get() = boxedBasicValue.descriptor
|
||||
|
||||
override fun taint(): BoxedBasicValue = this
|
||||
@@ -53,7 +53,7 @@ class TaintedBoxedValue(val boxedBasicValue: CleanBoxedValue) : BoxedBasicValue(
|
||||
|
||||
|
||||
class BoxedValueDescriptor(
|
||||
val boxedType: Type,
|
||||
private val boxedType: Type,
|
||||
val boxingInsn: AbstractInsnNode,
|
||||
val progressionIterator: ProgressionIteratorBasicValue?
|
||||
) {
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ open class MethodAnalyzer<V : Value>(
|
||||
protected val interpreter: Interpreter<V>
|
||||
) {
|
||||
val instructions: InsnList = method.instructions
|
||||
val nInsns: Int = instructions.size()
|
||||
private val nInsns: Int = instructions.size()
|
||||
|
||||
val frames: Array<Frame<V>?> = arrayOfNulls(nInsns)
|
||||
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ class SavedStackDescriptor(
|
||||
val savedValues: List<BasicValue>,
|
||||
val firstLocalVarIndex: Int
|
||||
) {
|
||||
val savedValuesSize = savedValues.fold(0, { size, value -> size + value.size })
|
||||
private val savedValuesSize = savedValues.fold(0, { size, value -> size + value.size })
|
||||
val firstUnusedLocalVarIndex = firstLocalVarIndex + savedValuesSize
|
||||
|
||||
override fun toString(): String =
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@ package org.jetbrains.kotlin.codegen.optimization.transformer
|
||||
|
||||
import org.jetbrains.org.objectweb.asm.tree.MethodNode
|
||||
|
||||
open class CompositeMethodTransformer(vararg val transformers: MethodTransformer) : MethodTransformer() {
|
||||
open class CompositeMethodTransformer(private vararg val transformers: MethodTransformer) : MethodTransformer() {
|
||||
override fun transform(internalClassName: String, methodNode: MethodNode) {
|
||||
transformers.forEach { it.transform(internalClassName, methodNode) }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user