Minor: formatted code

This commit is contained in:
Dmitriy Dolovov
2019-12-27 15:05:12 +07:00
parent e0d90ccf4b
commit 7ffb64ec57
8 changed files with 20 additions and 55 deletions
@@ -30,23 +30,13 @@ class DeclarationsBuilderCache(dimension: Int) {
check(dimension > 0) check(dimension > 0)
} }
private val modules = private val modules = CommonizedGroup<List<ModuleDescriptorImpl>>(dimension)
CommonizedGroup<List<ModuleDescriptorImpl>>(dimension) private val packageFragments = CommonizedGroupMap<Pair<Name, FqName>, CommonizedPackageFragmentDescriptor>(dimension)
private val packageFragments = private val classes = CommonizedGroupMap<FqName, CommonizedClassDescriptor>(dimension)
CommonizedGroupMap<Pair<Name, FqName>, CommonizedPackageFragmentDescriptor>( private val typeAliases = CommonizedGroupMap<FqName, CommonizedTypeAliasDescriptor>(dimension)
dimension
)
private val classes =
CommonizedGroupMap<FqName, CommonizedClassDescriptor>(dimension)
private val typeAliases =
CommonizedGroupMap<FqName, CommonizedTypeAliasDescriptor>(
dimension
)
private val forwardDeclarationsModules = private val forwardDeclarationsModules = CommonizedGroup<ModuleDescriptorImpl>(dimension)
CommonizedGroup<ModuleDescriptorImpl>(dimension) private val allModulesWithDependencies = CommonizedGroup<List<ModuleDescriptor>>(dimension)
private val allModulesWithDependencies =
CommonizedGroup<List<ModuleDescriptor>>(dimension)
fun getCachedPackageFragments(moduleName: Name, packageFqName: FqName): List<CommonizedPackageFragmentDescriptor?> = fun getCachedPackageFragments(moduleName: Name, packageFqName: FqName): List<CommonizedPackageFragmentDescriptor?> =
packageFragments.getOrFail(moduleName to packageFqName) packageFragments.getOrFail(moduleName to packageFqName)
@@ -89,8 +89,7 @@ internal class CommonizationVisitor(
} }
// find out common (and commonized) supertypes // find out common (and commonized) supertypes
val supertypesMap = val supertypesMap = CommonizedGroupMap<String, CirType>(node.target.size)
CommonizedGroupMap<String, CirType>(node.target.size)
node.target.forEachIndexed { index, clazz -> node.target.forEachIndexed { index, clazz ->
for (supertype in clazz!!.supertypes) { for (supertype in clazz!!.supertypes) {
supertypesMap[supertype.fqNameWithTypeParameters][index] = supertype supertypesMap[supertype.fqNameWithTypeParameters][index] = supertype
@@ -154,7 +154,7 @@ class NativeDistributionCommonizer(
""" """
library has incompatible metadata version ${metadataVersion ?: "\"unknown\""}: $location, library has incompatible metadata version ${metadataVersion ?: "\"unknown\""}: $location,
please make sure that all libraries passed to commonizer compatible metadata version ${KlibMetadataVersion.INSTANCE} please make sure that all libraries passed to commonizer compatible metadata version ${KlibMetadataVersion.INSTANCE}
""".trimIndent() """.trimIndent()
) )
return library return library
@@ -23,20 +23,10 @@ internal fun mergeClasses(
): CirClassNode { ): CirClassNode {
val node = buildClassNode(storageManager, cacheRW, containingDeclarationCommon, classes) val node = buildClassNode(storageManager, cacheRW, containingDeclarationCommon, classes)
val constructorsMap = val constructorsMap = CommonizedGroupMap<ConstructorApproximationKey, ClassConstructorDescriptor>(classes.size)
CommonizedGroupMap<ConstructorApproximationKey, ClassConstructorDescriptor>( val propertiesMap = CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(classes.size)
classes.size val functionsMap = CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(classes.size)
) val classesMap = CommonizedGroupMap<Name, ClassDescriptor>(classes.size)
val propertiesMap =
CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(
classes.size
)
val functionsMap =
CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(
classes.size
)
val classesMap =
CommonizedGroupMap<Name, ClassDescriptor>(classes.size)
classes.forEachIndexed { index, clazz -> classes.forEachIndexed { index, clazz ->
clazz?.constructors?.forEach { constructorsMap[ConstructorApproximationKey(it)][index] = it } clazz?.constructors?.forEach { constructorsMap[ConstructorApproximationKey(it)][index] = it }
@@ -24,8 +24,7 @@ internal fun mergeModules(
): CirModuleNode { ): CirModuleNode {
val node = buildModuleNode(storageManager, modules) val node = buildModuleNode(storageManager, modules)
val packageMemberScopesMap = val packageMemberScopesMap = CommonizedGroupMap<FqName, MemberScope>(modules.size)
CommonizedGroupMap<FqName, MemberScope>(modules.size)
modules.forEachIndexed { index, module -> modules.forEachIndexed { index, module ->
module?.collectNonEmptyPackageMemberScopes { packageFqName, memberScope -> module?.collectNonEmptyPackageMemberScopes { packageFqName, memberScope ->
@@ -27,19 +27,10 @@ internal fun mergePackages(
): CirPackageNode { ): CirPackageNode {
val node = buildPackageNode(storageManager, moduleName, packageFqName, packageMemberScopes) val node = buildPackageNode(storageManager, moduleName, packageFqName, packageMemberScopes)
val propertiesMap = val propertiesMap = CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>(packageMemberScopes.size)
CommonizedGroupMap<PropertyApproximationKey, PropertyDescriptor>( val functionsMap = CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(packageMemberScopes.size)
packageMemberScopes.size val classesMap = CommonizedGroupMap<Name, ClassDescriptor>(packageMemberScopes.size)
) val typeAliasesMap = CommonizedGroupMap<Name, TypeAliasDescriptor>(packageMemberScopes.size)
val functionsMap =
CommonizedGroupMap<FunctionApproximationKey, SimpleFunctionDescriptor>(
packageMemberScopes.size
)
val classesMap =
CommonizedGroupMap<Name, ClassDescriptor>(packageMemberScopes.size)
val typeAliasesMap = CommonizedGroupMap<Name, TypeAliasDescriptor>(
packageMemberScopes.size
)
packageMemberScopes.forEachIndexed { index, memberScope -> packageMemberScopes.forEachIndexed { index, memberScope ->
memberScope?.collectMembers( memberScope?.collectMembers(
@@ -19,8 +19,7 @@ internal fun mergeRoots(
): CirRootNode { ): CirRootNode {
val node = buildRootNode(storageManager, modulesByTargets.map { it.first }) val node = buildRootNode(storageManager, modulesByTargets.map { it.first })
val modulesMap = val modulesMap = CommonizedGroupMap<Name, ModuleDescriptor>(modulesByTargets.size)
CommonizedGroupMap<Name, ModuleDescriptor>(modulesByTargets.size)
modulesByTargets.forEachIndexed { index, (_, modules) -> modulesByTargets.forEachIndexed { index, (_, modules) ->
for (module in modules) { for (module in modules) {
@@ -41,11 +41,8 @@ internal class CommonizedGroup<T : Any>(
internal class CommonizedGroupMap<K, V : Any>(val size: Int) : Iterable<Map.Entry<K, CommonizedGroup<V>>> { internal class CommonizedGroupMap<K, V : Any>(val size: Int) : Iterable<Map.Entry<K, CommonizedGroup<V>>> {
private val wrapped: MutableMap<K, CommonizedGroup<V>> = HashMap() private val wrapped: MutableMap<K, CommonizedGroup<V>> = HashMap()
operator fun get(key: K): CommonizedGroup<V> = wrapped.getOrPut(key) { operator fun get(key: K): CommonizedGroup<V> = wrapped.getOrPut(key) { CommonizedGroup(size) }
CommonizedGroup(
size
)
}
fun getOrNull(key: K): CommonizedGroup<V>? = wrapped[key] fun getOrNull(key: K): CommonizedGroup<V>? = wrapped[key]
override fun iterator(): Iterator<Map.Entry<K, CommonizedGroup<V>>> = wrapped.iterator() override fun iterator(): Iterator<Map.Entry<K, CommonizedGroup<V>>> = wrapped.iterator()