JVM IR: build all needed stdlib symbols in JvmSymbols manually
This removes the mandatory dependency of all JVM IR tests on kotlin-stdlib (ConfigurationKind.ALL in all IR test cases) and speeds up tests which don't need kotiln-stdlib by about 20%. Another advantage of this method is that all required dependencies are listed in one file, are easy to grasp, and changes to the related code generation can be done independently of the corresponding changes in the actual library, which may help in bootstrapping the compiler
This commit is contained in:
+18
@@ -0,0 +1,18 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.builders.declarations
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
|
||||
class IrPropertyBuilder : IrDeclarationBuilder() {
|
||||
var modality: Modality = Modality.FINAL
|
||||
|
||||
var isVar: Boolean = false
|
||||
var isConst: Boolean = false
|
||||
var isLateinit: Boolean = false
|
||||
var isDelegated: Boolean = false
|
||||
var isExternal: Boolean = false
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.ir.builders.declarations
|
||||
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.utils.SmartList
|
||||
|
||||
class IrTypeParameterBuilder : IrDeclarationBuilder() {
|
||||
var index: Int = UNDEFINED_PARAMETER_INDEX
|
||||
var variance: Variance = Variance.INVARIANT
|
||||
var isReified: Boolean = false
|
||||
val superTypes: MutableList<IrType> = SmartList()
|
||||
}
|
||||
@@ -12,14 +12,12 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.TypeParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.descriptors.impl.ValueParameterDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.NoLookupLocation
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin
|
||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||
import org.jetbrains.kotlin.ir.declarations.impl.IrExternalPackageFragmentImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.toIrType
|
||||
import org.jetbrains.kotlin.ir.types.IrSimpleType
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl
|
||||
import org.jetbrains.kotlin.ir.types.toIrType
|
||||
import org.jetbrains.kotlin.ir.types.withHasQuestionMark
|
||||
import org.jetbrains.kotlin.ir.util.SymbolTable
|
||||
import org.jetbrains.kotlin.ir.util.TypeTranslator
|
||||
@@ -162,8 +160,24 @@ class IrBuiltIns(
|
||||
|
||||
val primitiveIrTypes by lazy { listOf(booleanType, charType, byteType, shortType, intType, floatType, longType, doubleType) }
|
||||
|
||||
val kCallableClass = builtIns.getBuiltInClassByFqName(KotlinBuiltIns.FQ_NAMES.kCallable.toSafe()).toIrSymbol()
|
||||
val kPropertyClass = builtIns.getBuiltInClassByFqName(KotlinBuiltIns.FQ_NAMES.kPropertyFqName.toSafe()).toIrSymbol()
|
||||
val kCallableClass = builtIns.kCallable.toIrSymbol()
|
||||
val kPropertyClass = builtIns.kProperty.toIrSymbol()
|
||||
val kDeclarationContainerClass = builtIns.kDeclarationContainer.toIrSymbol()
|
||||
val kClassClass = builtIns.kClass.toIrSymbol()
|
||||
|
||||
private val kProperty0Class = builtIns.kProperty0.toIrSymbol()
|
||||
private val kProperty1Class = builtIns.kProperty1.toIrSymbol()
|
||||
private val kProperty2Class = builtIns.kProperty2.toIrSymbol()
|
||||
private val kMutableProperty0Class = builtIns.kMutableProperty0.toIrSymbol()
|
||||
private val kMutableProperty1Class = builtIns.kMutableProperty1.toIrSymbol()
|
||||
private val kMutableProperty2Class = builtIns.kMutableProperty2.toIrSymbol()
|
||||
|
||||
fun getKPropertyClass(mutable: Boolean, n: Int): IrClassSymbol = when (n) {
|
||||
0 -> if (mutable) kMutableProperty0Class else kProperty0Class
|
||||
1 -> if (mutable) kMutableProperty1Class else kProperty1Class
|
||||
2 -> if (mutable) kMutableProperty2Class else kProperty2Class
|
||||
else -> error("No KProperty for n=$n mutable=$mutable")
|
||||
}
|
||||
|
||||
// TODO switch to IrType
|
||||
val primitiveTypes = listOf(bool, char, byte, short, int, long, float, double)
|
||||
|
||||
Reference in New Issue
Block a user