Cleanup in compiler modules
This commit is contained in:
@@ -32,8 +32,8 @@ abstract class ArgumentGenerator {
|
||||
* @see kotlin.reflect.jvm.internal.KCallableImpl.callBy
|
||||
*/
|
||||
open fun generate(valueArgumentsByIndex: List<ResolvedValueArgument>, actualArgs: List<ResolvedValueArgument>): DefaultCallMask {
|
||||
assert(valueArgumentsByIndex.size() == actualArgs.size()) {
|
||||
"Value arguments collection should have same size, but ${valueArgumentsByIndex.size()} != ${actualArgs.size()}"
|
||||
assert(valueArgumentsByIndex.size == actualArgs.size) {
|
||||
"Value arguments collection should have same size, but ${valueArgumentsByIndex.size} != ${actualArgs.size}"
|
||||
}
|
||||
|
||||
val arg2Index = valueArgumentsByIndex.mapToIndex()
|
||||
@@ -48,7 +48,7 @@ abstract class ArgumentGenerator {
|
||||
}
|
||||
}
|
||||
|
||||
val masks = DefaultCallMask(valueArgumentsByIndex.size())
|
||||
val masks = DefaultCallMask(valueArgumentsByIndex.size)
|
||||
|
||||
for (argumentWithDeclIndex in actualArgsWithDeclIndex) {
|
||||
val argument = argumentWithDeclIndex.arg
|
||||
|
||||
@@ -214,7 +214,7 @@ class CollectionStubMethodGenerator(
|
||||
private fun Collection<KotlinType>.findMostSpecificTypeForClass(klass: ClassDescriptor): KotlinType {
|
||||
val types = this.filter { it.getConstructor().getDeclarationDescriptor() == klass }
|
||||
if (types.isEmpty()) error("No supertype of $klass in $this")
|
||||
if (types.size() == 1) return types.first()
|
||||
if (types.size == 1) return types.first()
|
||||
// Find the first type in the list such that it's a subtype of every other type in that list
|
||||
return types.first { type ->
|
||||
types.all { other -> KotlinTypeChecker.DEFAULT.isSubtypeOf(type, other) }
|
||||
@@ -227,7 +227,7 @@ class CollectionStubMethodGenerator(
|
||||
child.setModality(Modality.FINAL)
|
||||
child.setVisibility(Visibilities.PUBLIC)
|
||||
val typeParameters = descriptor.getTypeConstructor().getParameters()
|
||||
val newTypeParameters = ArrayList<TypeParameterDescriptor>(typeParameters.size())
|
||||
val newTypeParameters = ArrayList<TypeParameterDescriptor>(typeParameters.size)
|
||||
DescriptorSubstitutor.substituteTypeParameters(typeParameters, TypeSubstitution.EMPTY, child, newTypeParameters)
|
||||
child.setTypeParameterDescriptors(typeParameters)
|
||||
return Pair(child, newTypeParameters)
|
||||
|
||||
@@ -32,9 +32,9 @@ public class InlineCycleReporter(val diagnostics: DiagnosticSink) {
|
||||
if (call != null) {
|
||||
val callElement = call.getCall().getCallElement()
|
||||
if (processingFunctions.contains(callElement)) {
|
||||
val cycle = processingFunctions.asSequence().dropWhile { it.getKey() != callElement }
|
||||
val cycle = processingFunctions.asSequence().dropWhile { it.key != callElement }
|
||||
cycle.forEach {
|
||||
diagnostics.report(Errors.INLINE_CALL_CYCLE.on(it.getKey(), it.getValue()))
|
||||
diagnostics.report(Errors.INLINE_CALL_CYCLE.on(it.key, it.value))
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ public class InterfaceImplBodyCodegen(
|
||||
val myParameters = signature.getValueParameters()
|
||||
val calleeParameters = method.getValueParameters()
|
||||
|
||||
if (myParameters.size() != calleeParameters.size()) {
|
||||
if (myParameters.size != calleeParameters.size) {
|
||||
throw AssertionError(
|
||||
"Method from super interface has a different signature.\n" +
|
||||
"This method:\n%s\n%s\n%s\nSuper method:\n%s\n%s\n%s".format(
|
||||
|
||||
@@ -312,7 +312,7 @@ public class MultifileClassCodegen(
|
||||
fragments.add(fragment)
|
||||
}
|
||||
}
|
||||
if (fragments.size() > 1) {
|
||||
if (fragments.size > 1) {
|
||||
throw IllegalStateException("More than one package fragment, files: $files | fragments: $fragments")
|
||||
}
|
||||
return fragments.firstOrNull()
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ public abstract class SignatureCollectingClassBuilderFactory(
|
||||
|
||||
override fun done() {
|
||||
for ((signature, elementsAndDescriptors) in signatures.entrySet()) {
|
||||
if (elementsAndDescriptors.size() == 1) continue // no clash
|
||||
if (elementsAndDescriptors.size == 1) continue // no clash
|
||||
handleClashingSignatures(ConflictingJvmDeclarationsData(
|
||||
classInternalName,
|
||||
classCreatedFor,
|
||||
|
||||
@@ -47,7 +47,7 @@ private fun List<PackageParts>.addCompiledParts(state: GenerationState): List<Pa
|
||||
mapping.findPackageParts(qualifier)?.run { parts.remove(name) }
|
||||
}
|
||||
|
||||
return (this + mapping.packageFqName2Parts.values())
|
||||
return (this + mapping.packageFqName2Parts.values)
|
||||
.groupBy { it.packageFqName }
|
||||
.map {
|
||||
val (packageFqName, packageParts) = it
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ class DefaultImplsClassContext(
|
||||
override fun getAccessors(): Collection<AccessorForCallableDescriptor<*>> {
|
||||
val accessors = super.getAccessors()
|
||||
val alreadyExistKeys = accessors.map ({ Pair(it.calleeDescriptor, it.superCallTarget) })
|
||||
val filtered = interfaceContext.accessors.toMap ({ Pair(it.calleeDescriptor, it.superCallTarget) }, {it}) - alreadyExistKeys
|
||||
val filtered = interfaceContext.accessors.toMapBy({ Pair(it.calleeDescriptor, it.superCallTarget) }, { it }) - alreadyExistKeys
|
||||
return accessors + filtered.values
|
||||
}
|
||||
}
|
||||
@@ -54,10 +54,10 @@ internal class Parameters(val real: List<ParameterInfo>, val captured: List<Capt
|
||||
}
|
||||
|
||||
private fun get(index: Int): ParameterInfo {
|
||||
if (index < real.size()) {
|
||||
if (index < real.size) {
|
||||
return real.get(index)
|
||||
}
|
||||
return captured.get(index - real.size())
|
||||
return captured.get(index - real.size)
|
||||
}
|
||||
|
||||
override fun iterator(): Iterator<ParameterInfo> {
|
||||
|
||||
@@ -35,18 +35,18 @@ internal class ParametersBuilder private constructor(){
|
||||
private var nextCaptured = 0
|
||||
|
||||
fun addThis(type: Type, skipped: Boolean): ParameterInfo {
|
||||
val info = ParameterInfo(type, skipped, nextValueParameterIndex, -1, valueAndHiddenParams.size())
|
||||
val info = ParameterInfo(type, skipped, nextValueParameterIndex, -1, valueAndHiddenParams.size)
|
||||
addParameter(info)
|
||||
return info
|
||||
}
|
||||
|
||||
fun addNextParameter(type: Type, skipped: Boolean, remapValue: StackValue?): ParameterInfo {
|
||||
return addParameter(ParameterInfo(type, skipped, nextValueParameterIndex, remapValue, valueAndHiddenParams.size()))
|
||||
return addParameter(ParameterInfo(type, skipped, nextValueParameterIndex, remapValue, valueAndHiddenParams.size))
|
||||
}
|
||||
|
||||
fun addNextValueParameter(type: Type, skipped: Boolean, remapValue: StackValue?, parameterIndex: Int): ParameterInfo {
|
||||
return addParameter(ParameterInfo(type, skipped, nextValueParameterIndex, remapValue,
|
||||
if (parameterIndex == -1) valueAndHiddenParams.size() else { parameterIndex + valueParamStart }))
|
||||
if (parameterIndex == -1) valueAndHiddenParams.size else { parameterIndex + valueParamStart }))
|
||||
}
|
||||
|
||||
fun addCapturedParam(
|
||||
@@ -102,7 +102,7 @@ internal class ParametersBuilder private constructor(){
|
||||
}
|
||||
|
||||
fun markValueParametesStart(){
|
||||
this.valueParamStart = valueAndHiddenParams.size()
|
||||
this.valueParamStart = valueAndHiddenParams.size
|
||||
}
|
||||
|
||||
fun listCaptured(): List<CapturedParamInfo> {
|
||||
|
||||
@@ -202,7 +202,7 @@ public open class DefaultSourceMapper(val sourceInfo: SourceInfo, override val p
|
||||
private fun createKey(name: String, path: String) = "$name#$path"
|
||||
|
||||
override val resultMappings: List<FileMapping>
|
||||
get() = fileMappings.values().map { it.toFileMapping() }
|
||||
get() = fileMappings.values.map { it.toFileMapping() }
|
||||
|
||||
override fun visitSource(name: String, path: String) {
|
||||
lastVisited = fileMappings.getOrPut(createKey(name, path), { RawFileMapping(name, path) })
|
||||
|
||||
@@ -44,7 +44,7 @@ object SMAPParser {
|
||||
public fun parse(mappingInfo: String): SMAP {
|
||||
val fileMappings = linkedMapOf<Int, FileMapping>()
|
||||
|
||||
val fileSectionStart = mappingInfo.indexOf(SMAP.FILE_SECTION) + SMAP.FILE_SECTION.length()
|
||||
val fileSectionStart = mappingInfo.indexOf(SMAP.FILE_SECTION) + SMAP.FILE_SECTION.length
|
||||
val lineSectionAnchor = mappingInfo.indexOf(SMAP.LINE_SECTION)
|
||||
val files = mappingInfo.substring(fileSectionStart, lineSectionAnchor)
|
||||
|
||||
@@ -63,7 +63,7 @@ object SMAPParser {
|
||||
}
|
||||
|
||||
|
||||
val lines = mappingInfo.substring(lineSectionAnchor + SMAP.LINE_SECTION.length(), mappingInfo.indexOf(SMAP.END)).trim().split('\n')
|
||||
val lines = mappingInfo.substring(lineSectionAnchor + SMAP.LINE_SECTION.length, mappingInfo.indexOf(SMAP.END)).trim().split('\n')
|
||||
for (lineMapping in lines) {
|
||||
/*only simple mapping now*/
|
||||
val targetSplit = lineMapping.indexOf(':')
|
||||
@@ -79,6 +79,6 @@ object SMAPParser {
|
||||
fileMappings[fileIndex]!!.addRangeMapping(RangeMapping(originalIndex, targetIndex, range))
|
||||
}
|
||||
|
||||
return SMAP(fileMappings.values().toList())
|
||||
return SMAP(fileMappings.values.toList())
|
||||
}
|
||||
}
|
||||
@@ -97,5 +97,5 @@ fun <T : IntervalWithHandler> doClustering(blocks: List<T>): List<TryBlockCluste
|
||||
cluster.blocks.add(block)
|
||||
}
|
||||
|
||||
return clusters.values().toList()
|
||||
return clusters.values.toList()
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class BinaryOp(private val opcode: Int) : IntrinsicMethod() {
|
||||
|
||||
override fun toCallable(method: CallableMethod): Callable {
|
||||
val returnType = method.returnType
|
||||
assert(method.getValueParameters().size() == 1)
|
||||
assert(method.getValueParameters().size == 1)
|
||||
val operandType = numberFunctionOperandType(returnType)
|
||||
val paramType = if (shift()) Type.INT_TYPE else operandType
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ class IsArrayOf : IntrinsicMethod() {
|
||||
val method = typeMapper.mapToCallableMethod(fd, false)
|
||||
|
||||
val builtIns = fd.module.builtIns
|
||||
val elementType = typeArguments.values().first()
|
||||
val elementType = typeArguments.values.first()
|
||||
val arrayKtType = builtIns.getArrayType(Variance.INVARIANT, elementType)
|
||||
val arrayType = typeMapper.mapType(arrayKtType)
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter
|
||||
public class JavaClassFunction : IntrinsicMethod() {
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val javaClass = resolvedCall.getResultingDescriptor().getReturnType()!!.getArguments().first().getType()
|
||||
return object : IntrinsicCallable(getType(javaClass<Class<Any>>()), listOf(), null, null) {
|
||||
return object : IntrinsicCallable(getType(Class::class.java), listOf(), null, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
codegen.putReifiedOperationMarkerIfTypeIsReifiedParameter(javaClass, ReifiedTypeInliner.OperationKind.JAVA_CLASS)
|
||||
putJavaLangClassInstance(v, codegen.getState().typeMapper.mapType(javaClass))
|
||||
|
||||
@@ -54,12 +54,12 @@ public class JavaClassProperty : IntrinsicPropertyGetter() {
|
||||
v.invokevirtual("java/lang/Object", "getClass", "()Ljava/lang/Class;", false)
|
||||
}
|
||||
|
||||
return getType(javaClass<Class<Any>>())
|
||||
return getType(Class::class.java)
|
||||
}
|
||||
|
||||
override fun toCallable(fd: FunctionDescriptor, isSuper: Boolean, resolvedCall: ResolvedCall<*>, codegen: ExpressionCodegen): Callable {
|
||||
val classType = codegen.getState().typeMapper.mapType(resolvedCall.getCall().getDispatchReceiver()!!.getType())
|
||||
return object : IntrinsicCallable(getType(javaClass<Class<Any>>()), listOf(), classType, null) {
|
||||
return object : IntrinsicCallable(getType(Class::class.java), listOf(), classType, null) {
|
||||
override fun invokeIntrinsic(v: InstructionAdapter) {
|
||||
if (isPrimitive(classType)) {
|
||||
v.getstatic(boxType(classType).getInternalName(), "TYPE", "Ljava/lang/Class;")
|
||||
|
||||
+2
-2
@@ -110,10 +110,10 @@ public open class MethodAnalyzer<V : Value>(
|
||||
|
||||
}
|
||||
catch (e: AnalyzerException) {
|
||||
throw AnalyzerException(e.node, "Error at instruction " + insn + ": " + e.getMessage(), e)
|
||||
throw AnalyzerException(e.node, "Error at instruction " + insn + ": " + e.message, e)
|
||||
}
|
||||
catch (e: Exception) {
|
||||
throw AnalyzerException(insnNode, "Error at instruction " + insn + ": " + e.getMessage(), e)
|
||||
throw AnalyzerException(insnNode, "Error at instruction " + insn + ": " + e.message, e)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ private fun insertSaveRestoreStackMarkers(
|
||||
val doneTryStartLabels = hashSetOf<LabelNode>()
|
||||
val doneHandlerLabels = hashSetOf<LabelNode>()
|
||||
|
||||
for (decompiledTryDescriptor in decompiledTryDescriptorForStart.values()) {
|
||||
for (decompiledTryDescriptor in decompiledTryDescriptorForStart.values) {
|
||||
with(decompiledTryDescriptor) {
|
||||
if (!doneTryStartLabels.contains(tryStartLabel)) {
|
||||
doneTryStartLabels.add(tryStartLabel)
|
||||
|
||||
+1
-1
@@ -96,7 +96,7 @@ internal class FixStackAnalyzer(
|
||||
}
|
||||
else {
|
||||
extraStack.add(value)
|
||||
maxExtraStackSize = Math.max(maxExtraStackSize, extraStack.size())
|
||||
maxExtraStackSize = Math.max(maxExtraStackSize, extraStack.size)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -107,7 +107,7 @@ internal class FixStackContext(val methodNode: MethodNode) {
|
||||
if (saveNodes.isEmpty()) {
|
||||
throw AssertionError("${indexOf(insnNode)}: in handler ${indexOf(restoreLabel)} restore is not matched with save")
|
||||
}
|
||||
else if (saveNodes.size() > 1) {
|
||||
else if (saveNodes.size > 1) {
|
||||
throw AssertionError("${indexOf(insnNode)}: in handler ${indexOf(restoreLabel)} restore is matched with several saves")
|
||||
}
|
||||
val saveNode = saveNodes.first()
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
}
|
||||
|
||||
fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List<BasicValue>): SavedStackDescriptor {
|
||||
val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker]!!.size()
|
||||
val numRestoreStackMarkers = context.restoreStackMarkersForSaveMarker[saveStackMarker]!!.size
|
||||
return allocateNewHandle(numRestoreStackMarkers, saveStackMarker, savedStackValues)
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod
|
||||
}
|
||||
|
||||
private fun getFirstUnusedLocalVariableIndex(): Int =
|
||||
allocatedHandles.values().fold(initialMaxLocals) {
|
||||
allocatedHandles.values.fold(initialMaxLocals) {
|
||||
index, handle -> Math.max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex)
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ class JvmStringTable(private val typeMapper: JetTypeMapper) : StringTable {
|
||||
|
||||
override fun getStringIndex(string: String): Int =
|
||||
map.getOrPut(string) {
|
||||
strings.size().apply {
|
||||
strings.size.apply {
|
||||
strings.add(string)
|
||||
|
||||
val lastRecord = records.lastOrNull()
|
||||
@@ -78,7 +78,7 @@ class JvmStringTable(private val typeMapper: JetTypeMapper) : StringTable {
|
||||
}
|
||||
}
|
||||
|
||||
val index = strings.size()
|
||||
val index = strings.size
|
||||
if (classId.isLocal) {
|
||||
localNames.add(index)
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ val CallableDescriptor?.isMethodWithDeclarationSiteWildcards: Boolean
|
||||
get() {
|
||||
if (this !is CallableMemberDescriptor) return false
|
||||
return firstOverridden {
|
||||
METHODS_WITH_DECLARATION_SITE_WILDCARDS.containsRaw(it.propertyIfAccessor.fqNameOrNull())
|
||||
METHODS_WITH_DECLARATION_SITE_WILDCARDS.contains(it.propertyIfAccessor.fqNameOrNull())
|
||||
} != null
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user