[kotlin compiler][update] 1.3.70-dev-1526
*9a55f418fa- (tag: build-1.3.70-dev-1526) IR: extract StaticInitializersLowering out of InitializersLowering (15 hours ago) <Alexander Udalov> *098561dd5f- IR: cleanup InitializersLowering.kt (15 hours ago) <Alexander Udalov> *9772de0088- JVM IR: generate kotlin.Metadata.packageName value for JvmPackageName files (16 hours ago) <Alexander Udalov> *808000e458- (tag: build-1.3.70-dev-1525) Implement warning when non-abstract classes containing abstract members invisible from that classes (16 hours ago) <Ilya Chernikov> *eae3688c61- (tag: build-1.3.70-dev-1524) [FIR] Fix collecting approved data flow info from rhs of boolean operator (16 hours ago) <Dmitriy Novozhilov> *8d6cfdf0b1- [FIR] Fix passing data flow info from while loop condition (16 hours ago) <Dmitriy Novozhilov> *7ef13caa33- [FIR] Add test for ambiguity in nested class constructor call (16 hours ago) <Dmitriy Novozhilov> *e9551e2022- [FIR] Don't generate setter by delegate for vals (16 hours ago) <Dmitriy Novozhilov> *2f2aa4ae83- [FIR] Create error type instead of implicit type for incorrect functional types (16 hours ago) <Dmitriy Novozhilov> *cf61a6c30f- [FIR] Add support of multiple condition branches to exhaustiveness checker (16 hours ago) <Dmitriy Novozhilov> *86570a2f91- [KLIB] Promote ABI version (16 hours ago) <Roman Artemev> *63110ab636- [IR] Remove deprecated `correspondingProperty` from IrField (16 hours ago) <Roman Artemev> *646df8d40a- [IR BE] Get rid of descriptor usage in KCallable name property lowering (16 hours ago) <Roman Artemev> *ec1c2eb42d- [IR] Remove deprecated `correspondingProperty` from IrSimpleFunction (16 hours ago) <Roman Artemev> *a343a57207- [IR] Refactor ir infrastructure - Remove range-based uniq id indexes using to link built ins - Limit KotlinType usages, replace them with corresponding IrType (16 hours ago) <Roman Artemev> *90d07eee53- [IR] Move wrapped descriptors from `backend.common` to `ir.descriptors` (16 hours ago) <Roman Artemev> *ed79ab68ab- [IR] Remove DeclarationDescriptor from IrExpression* tree API (16 hours ago) <Roman Artemev> *d4fc7fcd96- [IR] Get rid of substituted descriptor from IrMemberAccessExpression interface (16 hours ago) <Roman Artemev> *b391c066d6- [IR] Pass class Type Parameters into IrConstructorCall factory explicitly to avoid unexpected crash on uninitialized parent in psi2ir phase (16 hours ago) <Roman Artemev> *ba373c67d7- [IR] Remove FunctionDescriptor from IrCall-like node's constructor interface (16 hours ago) <Roman Artemev> *bf367003f9- [IR] Make IrMemberAccessExpression be IrDeclarationReference (16 hours ago) <Roman Artemev> *eee594101a- [IR] Remove superQualifier property from IrCall (16 hours ago) <Roman Artemev> *ea5b529d19- (tag: build-1.3.70-dev-1522) Check default parameters of expect suspend functions on original (17 hours ago) <Ilmir Usmanov> *633d1c9ea3- (tag: build-1.3.70-dev-1518) Merge pull request #2773 from t-kameyama/KT-28607 (18 hours ago) <igoriakovlev> |\ | *d04f88ff66- (origin/rr/Alefas/KT-28607) Extract/Introduce variable: fix to work correctly if caret is before right parenthesis or comment (31 hours ago) <Toshiaki Kameyama> * |42c4591df8- (tag: build-1.3.70-dev-1510) [JS IR] Add -Xgenerate-dts CLI argument (18 hours ago) <Svyatoslav Kuzmich> * |e81fbe0a05- (tag: build-1.3.70-dev-1501) Folding: fold function with expression body (KT-6316) (21 hours ago) <Toshiaki Kameyama> * |58fb1dede3- Multiline string enter handler: do not insert 'trimIndent()' in const (KT-34785) (21 hours ago) <Toshiaki Kameyama> * |ce0fb662c0- (tag: build-1.3.70-dev-1497) JVM_IR: fold inline lambdas when computing OUTERCLASS (22 hours ago) <pyos> * |f906524d76- (tag: build-1.3.70-dev-1495) Mark a SAM conversion test as JVM-only (22 hours ago) <pyos> * |c66b6b6a3a- (tag: build-1.3.70-dev-1485, tag: build-1.3.70-dev-1481) FIR visibility check: support companion private members correctly (25 hours ago) <Mikhail Glukhikh> * |e96aeb77a6- FIR visibility check: support private class members (25 hours ago) <Mikhail Glukhikh> * |a5ad05083a- Add some stubs for FIR visibility checking (25 hours ago) <Mikhail Glukhikh> * |7e07b88eab- (tag: build-1.3.70-dev-1480) Code cleanup: FirCallResolver (26 hours ago) <Mikhail Glukhikh> * |ac13a8c8b2- Cone conflict resolver: extract JVM equivalent call filtering to a separate class (26 hours ago) <Mikhail Glukhikh> * |96c5003a13- Cone conflict resolver: filter equivalent top-level callables (26 hours ago) <Mikhail Glukhikh> * |dc10d25661- (tag: build-1.3.70-dev-1479) Ensure ForLoopsLowering only handles the CharSequence.iterator() extension function from the standard library (kotlin.text.iterator()). (27 hours ago) <Mark Punzalan> |/ *1bd861c5eb- (tag: build-1.3.70-dev-1471) Save use_ni key state to log (2 days ago) <Simon Ogorodnik> *57a674e9e6- (tag: build-1.3.70-dev-1468) Make fast class files reading mode default in compiler tests (2 days ago) <Alexander Udalov> *dde2d08cfc- (tag: build-1.3.70-dev-1460) FIR resolve: add extra test for generic with bounds in Java (2 days ago) <Mikhail Glukhikh> *f66b2ca772- FIR resolve: add forgotten constraint subsystem from generic qualified access (2 days ago) <Mikhail Glukhikh> *26281bfe89- FIR Java: use different names for anonymous parameters (p0, p1, p2, ...) (2 days ago) <Mikhail Glukhikh> *c657d46437- FIR Java: add nullable (instead of not-null) type parameter bounds (2 days ago) <Mikhail Glukhikh> *db11c14fee- FIR Java: don't add type parameter bounds multiple times (2 days ago) <Mikhail Glukhikh> *a18da68171- (tag: build-1.3.70-dev-1457) Remove redundant `toList` call in `LazyJavaPackageScope` (2 days ago) <Roman Golyshev> *82fb5c4d19- (tag: build-1.3.70-dev-1456) JVM_IR: move lambda captures to end of signature when inlining (2 days ago) <pyos> *433e0e4740- (tag: build-1.3.70-dev-1455) JVM_IR: remember facade fqnames of imported classes (2 days ago) <pyos> *42cb53a380- (tag: build-1.3.70-dev-1454) Always apply new script configuration in tests (2 days ago) <Natalia Selezneva> *423f1909fa- Disable script configuration update in AbstractInspectionTest (2 days ago) <Natalia Selezneva> *698d675efe- Scripting: fix saving to file attributes (2 days ago) <Sergey Rostov> *05e8acffa7- Scripting: restore reports for applied configuration in case of previous error (2 days ago) <Sergey Rostov> *96b4ceb067- scripting: skip loading when reverting to applied configuration (2 days ago) <Sergey Rostov> *2499c42ac4- scripting: PsiModificationStamp add virtual file modification stamp (2 days ago) <Sergey Rostov> *789ad23e8d- Minor: isScriptDependenciesUpdaterDisabled -> isScriptChangesNotifierDisabled (2 days ago) <Sergey Rostov> *61b17de625- Minor: change ScriptConfigurationCache.kt declarations order for better readability, more docs (2 days ago) <Sergey Rostov> *fbb2b260dd- Split script configuration state into applied and loaded to make markUpToDate more clear (2 days ago) <Sergey Rostov> *fde1d3fdf7- Wrap exceptions from external script configuration loader with error handling (2 days ago) <Natalia Selezneva> *56eb86b7c6- Remove KotlinGradleBuildScriptsResolver for IDEA < 191 (2 days ago) <Natalia Selezneva> *2a22cc23e9- KotlinGradleBuildScriptsResolver: update to new API from IDEA Gradle plugin (2 days ago) <Natalia Selezneva> *8bb6cf81c5- Extract logic common for different platforms to simplify bunch process (2 days ago) <Natalia Selezneva> *e2928550ca- Fix retrieving virtual file (2 days ago) <Sergey Rostov> *9105e38041- Mark not applied configuration as up-to-date, simplify concurrency handling (2 days ago) <Sergey Rostov> *0422abdb7b- LoadedScriptConfiguration and CachedConfigurationSnapshot are merged to ScriptConfigurationSnapshot (2 days ago) <Sergey Rostov> *a89ce4c590- BackgroundExecutor: cancel all tasks on user cancel, remove useless updateProgress call (2 days ago) <Sergey Rostov> *19d35d7f27- Implement Gradle specific behavior for script configuration update logic (2 days ago) <Sergey Rostov> *548e8e27dc- Minor: rename parameter (2 days ago) <Natalia Selezneva> *f0053ee34c- Minor: use properties instead of string constants (2 days ago) <Natalia Selezneva> *9d2cc484aa- ide, scripting: rework script configuration caching, introduce persistent fs cache (2 days ago) <Sergey Rostov> *915c9c367c- Minor: rename script related classes (2 days ago) <Natalia Selezneva> *33475f30bc- Minor: move files (2 days ago) <Natalia Selezneva> *9f3c2d0292- build.gradle.kts: import script dependencies on Gradle Project sync (2 days ago) <Sergey Rostov> *de54e549af- (tag: build-1.3.70-dev-1451) Refactor CHECK_BYTECODE_LISTING directive for JVM IR tests (2 days ago) <Alexander Udalov> *ce09be3f59- Add TargetBackend.isIR, simplify JVM IR test configuration (2 days ago) <Alexander Udalov> *ab65a6bc6c- (tag: build-1.3.70-dev-1447) Build fix, tests regenerated (2 days ago) <Vladimir Ilmov> *608885d118- (tag: build-1.3.70-dev-1445, origin/sbogolepov/metadata_only_libraries_support) [Linker] Extend KotlinIrLinker infrastructure to support libraries that doesn't contain IR. Also bump ABI version because of addition of `ir_provider` property (2 days ago) <Sergey Bogolepov> *5629627cca- (tag: build-1.3.70-dev-1444) Mobile MPP: Initialize Mobile MPP plugin (2 days ago) <Kirill Shmakov> *f3770314c5- (tag: build-1.3.70-dev-1443) Pill: Fix reflect dependency in compiler/fir.resolve module (2 days ago) <Yan Zhulanow> *ef8b3cb72a- Prefer Kotlin Junit test run configurations when possible (KT-33787) (2 days ago) <Yan Zhulanow> *987307cf92- Prefer Kotlin Gradle test run configurations when possible (KT-33787) (2 days ago) <Yan Zhulanow> *214810ca01- (tag: build-1.3.70-dev-1439) Suspend test removed. Will be added later as part of appropriate ticket. (3 days ago) <Vladimir Ilmov>
This commit is contained in:
+1
-1
@@ -93,7 +93,7 @@ internal abstract class AbstractValueUsageTransformer(
|
|||||||
with(expression) {
|
with(expression) {
|
||||||
dispatchReceiver = dispatchReceiver?.useAsDispatchReceiver(expression)
|
dispatchReceiver = dispatchReceiver?.useAsDispatchReceiver(expression)
|
||||||
extensionReceiver = extensionReceiver?.useAsExtensionReceiver(expression)
|
extensionReceiver = extensionReceiver?.useAsExtensionReceiver(expression)
|
||||||
for (index in descriptor.valueParameters.indices) {
|
for (index in symbol.owner.valueParameters.indices) {
|
||||||
val argument = getValueArgument(index) ?: continue
|
val argument = getValueArgument(index) ?: continue
|
||||||
val parameter = symbol.owner.valueParameters[index]
|
val parameter = symbol.owner.valueParameters[index]
|
||||||
putValueArgument(index, argument.useAsValueArgument(expression, parameter))
|
putValueArgument(index, argument.useAsValueArgument(expression, parameter))
|
||||||
|
|||||||
-4
@@ -70,10 +70,6 @@ internal class InteropBuiltIns(builtIns: KonanBuiltIns) {
|
|||||||
|
|
||||||
val typeOf = packageScope.getContributedFunctions("typeOf").single()
|
val typeOf = packageScope.getContributedFunctions("typeOf").single()
|
||||||
|
|
||||||
val concurrentPackageScope = builtIns.builtInsModule.getPackage(FqName("kotlin.native.concurrent")).memberScope
|
|
||||||
|
|
||||||
val executeImplFunction = concurrentPackageScope.getContributedFunctions("executeImpl").single()
|
|
||||||
|
|
||||||
private fun KonanBuiltIns.getUnsignedClass(unsignedType: UnsignedType): ClassDescriptor =
|
private fun KonanBuiltIns.getUnsignedClass(unsignedType: UnsignedType): ClassDescriptor =
|
||||||
this.builtInsModule.findClassAcrossModuleDependencies(unsignedType.classId)!!
|
this.builtInsModule.findClassAcrossModuleDependencies(unsignedType.classId)!!
|
||||||
|
|
||||||
|
|||||||
+47
-2
@@ -7,12 +7,15 @@ package org.jetbrains.kotlin.backend.konan
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.findPackage
|
import org.jetbrains.kotlin.backend.konan.descriptors.findPackage
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getArgumentValueOrNull
|
import org.jetbrains.kotlin.backend.konan.descriptors.getArgumentValueOrNull
|
||||||
|
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValueOrNull
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValue
|
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValue
|
||||||
|
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValueOrNull
|
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValueOrNull
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
import org.jetbrains.kotlin.ir.types.classifierOrFail
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -44,7 +47,6 @@ fun ClassDescriptor.isObjCClass(): Boolean =
|
|||||||
fun KotlinType.isObjCObjectType(): Boolean =
|
fun KotlinType.isObjCObjectType(): Boolean =
|
||||||
(this.supertypes() + this).any { TypeUtils.getClassDescriptor(it)?.fqNameSafe == objCObjectFqName }
|
(this.supertypes() + this).any { TypeUtils.getClassDescriptor(it)?.fqNameSafe == objCObjectFqName }
|
||||||
|
|
||||||
|
|
||||||
private fun IrClass.getAllSuperClassifiers(): List<IrClass> =
|
private fun IrClass.getAllSuperClassifiers(): List<IrClass> =
|
||||||
listOf(this) + this.superTypes.flatMap { (it.classifierOrFail.owner as IrClass).getAllSuperClassifiers() }
|
listOf(this) + this.superTypes.flatMap { (it.classifierOrFail.owner as IrClass).getAllSuperClassifiers() }
|
||||||
|
|
||||||
@@ -68,6 +70,10 @@ fun ClassDescriptor.isObjCMetaClass(): Boolean = this.getAllSuperClassifiers().a
|
|||||||
it.fqNameSafe == objCClassFqName
|
it.fqNameSafe == objCClassFqName
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun IrClass.isObjCMetaClass(): Boolean = this.getAllSuperClassifiers().any {
|
||||||
|
it.fqNameForIrSerialization == objCClassFqName
|
||||||
|
}
|
||||||
|
|
||||||
fun IrClass.isObjCProtocolClass(): Boolean =
|
fun IrClass.isObjCProtocolClass(): Boolean =
|
||||||
this.fqNameForIrSerialization == objCProtocolFqName
|
this.fqNameForIrSerialization == objCProtocolFqName
|
||||||
|
|
||||||
@@ -77,6 +83,9 @@ fun ClassDescriptor.isObjCProtocolClass(): Boolean =
|
|||||||
fun FunctionDescriptor.isObjCClassMethod() =
|
fun FunctionDescriptor.isObjCClassMethod() =
|
||||||
this.containingDeclaration.let { it is ClassDescriptor && it.isObjCClass() }
|
this.containingDeclaration.let { it is ClassDescriptor && it.isObjCClass() }
|
||||||
|
|
||||||
|
fun IrFunction.isObjCClassMethod() =
|
||||||
|
this.parent.let { it is IrClass && it.isObjCClass() }
|
||||||
|
|
||||||
@Deprecated("Use IR version rather than descriptor version")
|
@Deprecated("Use IR version rather than descriptor version")
|
||||||
fun FunctionDescriptor.isExternalObjCClassMethod() =
|
fun FunctionDescriptor.isExternalObjCClassMethod() =
|
||||||
this.containingDeclaration.let { it is ClassDescriptor && it.isExternalObjCClass() }
|
this.containingDeclaration.let { it is ClassDescriptor && it.isExternalObjCClass() }
|
||||||
@@ -108,12 +117,24 @@ private fun FunctionDescriptor.decodeObjCMethodAnnotation(): ObjCMethodInfo? {
|
|||||||
return objCMethodInfo(methodAnnotation)
|
return objCMethodInfo(methodAnnotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun IrFunction.decodeObjCMethodAnnotation(): ObjCMethodInfo? {
|
||||||
|
assert (this.isReal)
|
||||||
|
val methodAnnotation = this.annotations.findAnnotation(objCMethodFqName) ?: return null
|
||||||
|
return objCMethodInfo(methodAnnotation)
|
||||||
|
}
|
||||||
|
|
||||||
private fun objCMethodInfo(annotation: AnnotationDescriptor) = ObjCMethodInfo(
|
private fun objCMethodInfo(annotation: AnnotationDescriptor) = ObjCMethodInfo(
|
||||||
selector = annotation.getStringValue("selector"),
|
selector = annotation.getStringValue("selector"),
|
||||||
encoding = annotation.getStringValue("encoding"),
|
encoding = annotation.getStringValue("encoding"),
|
||||||
isStret = annotation.getArgumentValueOrNull<Boolean>("isStret") ?: false
|
isStret = annotation.getArgumentValueOrNull<Boolean>("isStret") ?: false
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private fun objCMethodInfo(annotation: IrConstructorCall) = ObjCMethodInfo(
|
||||||
|
selector = annotation.getAnnotationStringValue("selector"),
|
||||||
|
encoding = annotation.getAnnotationStringValue("encoding"),
|
||||||
|
isStret = annotation.getAnnotationValueOrNull<Boolean>("isStret") ?: false
|
||||||
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param onlyExternal indicates whether to accept overriding methods from Kotlin classes
|
* @param onlyExternal indicates whether to accept overriding methods from Kotlin classes
|
||||||
*/
|
*/
|
||||||
@@ -129,10 +150,29 @@ private fun FunctionDescriptor.getObjCMethodInfo(onlyExternal: Boolean): ObjCMet
|
|||||||
return this.overriddenDescriptors.asSequence().mapNotNull { it.getObjCMethodInfo(onlyExternal) }.firstOrNull()
|
return this.overriddenDescriptors.asSequence().mapNotNull { it.getObjCMethodInfo(onlyExternal) }.firstOrNull()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param onlyExternal indicates whether to accept overriding methods from Kotlin classes
|
||||||
|
*/
|
||||||
|
private fun IrSimpleFunction.getObjCMethodInfo(onlyExternal: Boolean): ObjCMethodInfo? {
|
||||||
|
if (this.isReal) {
|
||||||
|
this.decodeObjCMethodAnnotation()?.let { return it }
|
||||||
|
|
||||||
|
if (onlyExternal) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.overriddenSymbols.mapNotNull { it.owner.getObjCMethodInfo(onlyExternal) }.firstOrNull()
|
||||||
|
}
|
||||||
|
|
||||||
fun FunctionDescriptor.getExternalObjCMethodInfo(): ObjCMethodInfo? = this.getObjCMethodInfo(onlyExternal = true)
|
fun FunctionDescriptor.getExternalObjCMethodInfo(): ObjCMethodInfo? = this.getObjCMethodInfo(onlyExternal = true)
|
||||||
|
|
||||||
|
fun IrFunction.getExternalObjCMethodInfo(): ObjCMethodInfo? = (this as? IrSimpleFunction)?.getObjCMethodInfo(onlyExternal = true)
|
||||||
|
|
||||||
fun FunctionDescriptor.getObjCMethodInfo(): ObjCMethodInfo? = this.getObjCMethodInfo(onlyExternal = false)
|
fun FunctionDescriptor.getObjCMethodInfo(): ObjCMethodInfo? = this.getObjCMethodInfo(onlyExternal = false)
|
||||||
|
|
||||||
|
fun IrFunction.getObjCMethodInfo(): ObjCMethodInfo? = (this as? IrSimpleFunction)?.getObjCMethodInfo(onlyExternal = false)
|
||||||
|
|
||||||
fun IrFunction.isObjCBridgeBased(): Boolean {
|
fun IrFunction.isObjCBridgeBased(): Boolean {
|
||||||
assert(this.isReal)
|
assert(this.isReal)
|
||||||
|
|
||||||
@@ -223,7 +263,7 @@ val IrConstructor.isObjCConstructor get() = this.annotations.hasAnnotation(objCC
|
|||||||
// TODO-DCE-OBJC-INIT: Selector should be preserved by DCE.
|
// TODO-DCE-OBJC-INIT: Selector should be preserved by DCE.
|
||||||
fun IrConstructor.getObjCInitMethod(): IrSimpleFunction? {
|
fun IrConstructor.getObjCInitMethod(): IrSimpleFunction? {
|
||||||
return this.annotations.findAnnotation(objCConstructorFqName)?.let {
|
return this.annotations.findAnnotation(objCConstructorFqName)?.let {
|
||||||
val initSelector = it.getStringValue("initSelector")
|
val initSelector = it.getAnnotationStringValue("initSelector")
|
||||||
this.constructedClass.declarations.asSequence()
|
this.constructedClass.declarations.asSequence()
|
||||||
.filterIsInstance<IrSimpleFunction>()
|
.filterIsInstance<IrSimpleFunction>()
|
||||||
.single { it.getExternalObjCMethodInfo()?.selector == initSelector }
|
.single { it.getExternalObjCMethodInfo()?.selector == initSelector }
|
||||||
@@ -239,6 +279,11 @@ fun FunctionDescriptor.getObjCFactoryInitMethodInfo(): ObjCMethodInfo? {
|
|||||||
return objCMethodInfo(factoryAnnotation)
|
return objCMethodInfo(factoryAnnotation)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun IrFunction.getObjCFactoryInitMethodInfo(): ObjCMethodInfo? {
|
||||||
|
val factoryAnnotation = this.annotations.findAnnotation(objCFactoryFqName) ?: return null
|
||||||
|
return objCMethodInfo(factoryAnnotation)
|
||||||
|
}
|
||||||
|
|
||||||
fun inferObjCSelector(descriptor: FunctionDescriptor): String = if (descriptor.valueParameters.isEmpty()) {
|
fun inferObjCSelector(descriptor: FunctionDescriptor): String = if (descriptor.valueParameters.isEmpty()) {
|
||||||
descriptor.name.asString()
|
descriptor.name.asString()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+2
-2
@@ -46,6 +46,7 @@ import org.jetbrains.kotlin.name.FqName
|
|||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
import org.jetbrains.kotlin.backend.konan.getObjCMethodInfo
|
||||||
|
|
||||||
internal interface KotlinStubs {
|
internal interface KotlinStubs {
|
||||||
val irBuiltIns: IrBuiltIns
|
val irBuiltIns: IrBuiltIns
|
||||||
@@ -538,7 +539,6 @@ internal fun KotlinStubs.generateCFunctionPointer(
|
|||||||
expression.endOffset,
|
expression.endOffset,
|
||||||
expression.type,
|
expression.type,
|
||||||
fakeFunction.symbol,
|
fakeFunction.symbol,
|
||||||
fakeFunction.descriptor,
|
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -1511,6 +1511,6 @@ private fun KotlinStubs.reportUnsupportedType(reason: String, type: IrType, loca
|
|||||||
|
|
||||||
val typeLocation: String = location.render()
|
val typeLocation: String = location.render()
|
||||||
|
|
||||||
reportError(location.element, "type ${type.toKotlinType()}$typeLocation is not supported here" +
|
reportError(location.element, "type ${type.render()} $typeLocation is not supported here" +
|
||||||
if (reason.isNotEmpty()) ": $reason" else "")
|
if (reason.isNotEmpty()) ": $reason" else "")
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-10
@@ -5,20 +5,21 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.konan.descriptors
|
package org.jetbrains.kotlin.backend.konan.descriptors
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.backend.common.atMostOne
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.resolveFakeOverride
|
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||||
import org.jetbrains.kotlin.backend.konan.isObjCClass
|
import org.jetbrains.kotlin.backend.konan.isObjCClass
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.longName
|
import org.jetbrains.kotlin.backend.konan.llvm.longName
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
|
import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConst
|
import org.jetbrains.kotlin.ir.expressions.IrConst
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall
|
||||||
|
import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
|
||||||
import org.jetbrains.kotlin.ir.types.isUnit
|
import org.jetbrains.kotlin.ir.types.isUnit
|
||||||
import org.jetbrains.kotlin.ir.util.*
|
import org.jetbrains.kotlin.ir.util.*
|
||||||
import org.jetbrains.kotlin.types.SimpleType
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List of all implemented interfaces (including those which implemented by a super class)
|
* List of all implemented interfaces (including those which implemented by a super class)
|
||||||
@@ -219,14 +220,14 @@ internal tailrec fun IrDeclaration.findPackage(): IrPackageFragment {
|
|||||||
?: (parent as IrDeclaration).findPackage()
|
?: (parent as IrDeclaration).findPackage()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun IrFunctionSymbol.isComparisonFunction(map: Map<SimpleType, IrSimpleFunctionSymbol>): Boolean =
|
fun IrFunctionSymbol.isComparisonFunction(map: Map<IrClassifierSymbol, IrSimpleFunctionSymbol>): Boolean =
|
||||||
this in map.values
|
this in map.values
|
||||||
|
|
||||||
val IrDeclaration.isPropertyAccessor get() =
|
val IrDeclaration.isPropertyAccessor get() =
|
||||||
this is IrSimpleFunction && this.correspondingProperty != null
|
this is IrSimpleFunction && this.correspondingPropertySymbol != null
|
||||||
|
|
||||||
val IrDeclaration.isPropertyField get() =
|
val IrDeclaration.isPropertyField get() =
|
||||||
this is IrField && this.correspondingProperty != null
|
this is IrField && this.correspondingPropertySymbol != null
|
||||||
|
|
||||||
val IrDeclaration.isTopLevelDeclaration get() =
|
val IrDeclaration.isTopLevelDeclaration get() =
|
||||||
parent !is IrDeclaration && !this.isPropertyAccessor && !this.isPropertyField
|
parent !is IrDeclaration && !this.isPropertyAccessor && !this.isPropertyField
|
||||||
@@ -235,9 +236,9 @@ fun IrDeclaration.findTopLevelDeclaration(): IrDeclaration = when {
|
|||||||
this.isTopLevelDeclaration ->
|
this.isTopLevelDeclaration ->
|
||||||
this
|
this
|
||||||
this.isPropertyAccessor ->
|
this.isPropertyAccessor ->
|
||||||
(this as IrSimpleFunction).correspondingProperty!!.findTopLevelDeclaration()
|
(this as IrSimpleFunction).correspondingPropertySymbol!!.owner.findTopLevelDeclaration()
|
||||||
this.isPropertyField ->
|
this.isPropertyField ->
|
||||||
(this as IrField).correspondingProperty!!.findTopLevelDeclaration()
|
(this as IrField).correspondingPropertySymbol!!.owner.findTopLevelDeclaration()
|
||||||
else ->
|
else ->
|
||||||
(this.parent as IrDeclaration).findTopLevelDeclaration()
|
(this.parent as IrDeclaration).findTopLevelDeclaration()
|
||||||
}
|
}
|
||||||
@@ -247,15 +248,20 @@ internal val IrClass.isFrozen: Boolean
|
|||||||
// RTTI is used for non-reference type box or Objective-C object wrapper:
|
// RTTI is used for non-reference type box or Objective-C object wrapper:
|
||||||
!this.defaultType.binaryTypeIsReference() || this.isObjCClass()
|
!this.defaultType.binaryTypeIsReference() || this.isObjCClass()
|
||||||
|
|
||||||
fun IrConstructorCall.getAnnotationValue() = (getValueArgument(0) as? IrConst<String>)?.value
|
fun IrConstructorCall.getAnnotationStringValue() = (getValueArgument(0) as? IrConst<String>)?.value
|
||||||
|
|
||||||
fun IrConstructorCall.getStringValue(name: String): String {
|
fun IrConstructorCall.getAnnotationStringValue(name: String): String {
|
||||||
val parameter = symbol.owner.valueParameters.single { it.name.asString() == name }
|
val parameter = symbol.owner.valueParameters.single { it.name.asString() == name }
|
||||||
return (getValueArgument(parameter.index) as IrConst<String>).value
|
return (getValueArgument(parameter.index) as IrConst<String>).value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun <T> IrConstructorCall.getAnnotationValueOrNull(name: String): T? {
|
||||||
|
val parameter = symbol.owner.valueParameters.atMostOne { it.name.asString() == name }
|
||||||
|
return parameter?.let { getValueArgument(it.index)?.let { (it as IrConst<T>).value } }
|
||||||
|
}
|
||||||
|
|
||||||
fun IrFunction.externalSymbolOrThrow(): String? {
|
fun IrFunction.externalSymbolOrThrow(): String? {
|
||||||
annotations.findAnnotation(RuntimeNames.symbolNameAnnotation)?.let { return it.getAnnotationValue() }
|
annotations.findAnnotation(RuntimeNames.symbolNameAnnotation)?.let { return it.getAnnotationStringValue() }
|
||||||
|
|
||||||
if (annotations.hasAnnotation(KonanFqNames.objCMethod)) return null
|
if (annotations.hasAnnotation(KonanFqNames.objCMethod)) return null
|
||||||
|
|
||||||
@@ -265,3 +271,5 @@ fun IrFunction.externalSymbolOrThrow(): String? {
|
|||||||
|
|
||||||
throw Error("external function ${this.longName} must have @TypedIntrinsic, @SymbolName or @ObjCMethod annotation")
|
throw Error("external function ${this.longName} must have @TypedIntrinsic, @SymbolName or @ObjCMethod annotation")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val IrFunction.isBuiltInOperator get() = origin == IrBuiltIns.BUILTIN_OPERATOR
|
||||||
+18
-40
@@ -8,14 +8,11 @@ package org.jetbrains.kotlin.backend.konan.descriptors
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.SharedVariablesManager
|
import org.jetbrains.kotlin.backend.common.ir.SharedVariablesManager
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
|
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
|
||||||
import org.jetbrains.kotlin.descriptors.PropertyDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.VariableDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
import org.jetbrains.kotlin.descriptors.impl.LocalVariableDescriptor
|
||||||
import org.jetbrains.kotlin.ir.IrStatement
|
import org.jetbrains.kotlin.ir.IrStatement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
import org.jetbrains.kotlin.ir.declarations.IrProperty
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
import org.jetbrains.kotlin.ir.declarations.IrVariable
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrVariableImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrExpression
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
import org.jetbrains.kotlin.ir.expressions.IrGetValue
|
||||||
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
|
import org.jetbrains.kotlin.ir.expressions.IrSetVariable
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
|
||||||
@@ -39,14 +36,6 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
|
|||||||
return refClass.descriptor.defaultType.replace(listOf(TypeProjectionImpl(elementType)))
|
return refClass.descriptor.defaultType.replace(listOf(TypeProjectionImpl(elementType)))
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getElementPropertyDescriptor(sharedVariableDescriptor: VariableDescriptor): PropertyDescriptor {
|
|
||||||
return sharedVariableDescriptor.type.memberScope.getContributedDescriptors()
|
|
||||||
.filterIsInstance<PropertyDescriptor>()
|
|
||||||
.single {
|
|
||||||
it.name.asString() == "element"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun declareSharedVariable(originalDeclaration: IrVariable): IrVariable {
|
override fun declareSharedVariable(originalDeclaration: IrVariable): IrVariable {
|
||||||
val variableDescriptor = originalDeclaration.descriptor
|
val variableDescriptor = originalDeclaration.descriptor
|
||||||
val sharedVariableDescriptor = LocalVariableDescriptor(
|
val sharedVariableDescriptor = LocalVariableDescriptor(
|
||||||
@@ -76,12 +65,9 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
|
|||||||
override fun defineSharedValue(originalDeclaration: IrVariable, sharedVariableDeclaration: IrVariable): IrStatement {
|
override fun defineSharedValue(originalDeclaration: IrVariable, sharedVariableDeclaration: IrVariable): IrStatement {
|
||||||
val initializer = originalDeclaration.initializer ?: return sharedVariableDeclaration
|
val initializer = originalDeclaration.initializer ?: return sharedVariableDeclaration
|
||||||
|
|
||||||
val elementPropertyDescriptor = getElementPropertyDescriptor(sharedVariableDeclaration.descriptor)
|
|
||||||
|
|
||||||
val sharedVariableInitialization =
|
val sharedVariableInitialization =
|
||||||
IrCallImpl(initializer.startOffset, initializer.endOffset,
|
IrCallImpl(initializer.startOffset, initializer.endOffset,
|
||||||
context.irBuiltIns.unitType, elementProperty.setter!!.symbol,
|
context.irBuiltIns.unitType, elementProperty.setter!!.symbol)
|
||||||
elementPropertyDescriptor.setter!!)
|
|
||||||
|
|
||||||
sharedVariableInitialization.dispatchReceiver =
|
sharedVariableInitialization.dispatchReceiver =
|
||||||
IrGetValueImpl(initializer.startOffset, initializer.endOffset,
|
IrGetValueImpl(initializer.startOffset, initializer.endOffset,
|
||||||
@@ -95,31 +81,23 @@ internal class KonanSharedVariablesManager(val context: KonanBackendContext) : S
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue): IrExpression {
|
override fun getSharedValue(sharedVariableSymbol: IrVariableSymbol, originalGet: IrGetValue) =
|
||||||
|
IrCallImpl(originalGet.startOffset, originalGet.endOffset,
|
||||||
|
originalGet.type, elementProperty.getter!!.symbol).apply {
|
||||||
|
dispatchReceiver = IrGetValueImpl(
|
||||||
|
originalGet.startOffset, originalGet.endOffset,
|
||||||
|
sharedVariableSymbol.owner.type, sharedVariableSymbol
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
val elementPropertyDescriptor = getElementPropertyDescriptor(sharedVariableSymbol.descriptor)
|
override fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable) =
|
||||||
|
IrCallImpl(originalSet.startOffset, originalSet.endOffset, context.irBuiltIns.unitType,
|
||||||
return IrCallImpl(originalGet.startOffset, originalGet.endOffset,
|
elementProperty.setter!!.symbol).apply {
|
||||||
originalGet.type, elementProperty.getter!!.symbol,
|
dispatchReceiver = IrGetValueImpl(
|
||||||
elementPropertyDescriptor.getter!!).apply {
|
originalSet.startOffset, originalSet.endOffset,
|
||||||
dispatchReceiver = IrGetValueImpl(
|
sharedVariableSymbol.owner.type, sharedVariableSymbol
|
||||||
originalGet.startOffset, originalGet.endOffset,
|
)
|
||||||
sharedVariableSymbol.owner.type, sharedVariableSymbol
|
putValueArgument(0, originalSet.value)
|
||||||
)
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setSharedValue(sharedVariableSymbol: IrVariableSymbol, originalSet: IrSetVariable): IrExpression {
|
|
||||||
val elementPropertyDescriptor = getElementPropertyDescriptor(sharedVariableSymbol.descriptor)
|
|
||||||
|
|
||||||
return IrCallImpl(originalSet.startOffset, originalSet.endOffset, context.irBuiltIns.unitType,
|
|
||||||
elementProperty.setter!!.symbol, elementPropertyDescriptor.setter!!).apply {
|
|
||||||
dispatchReceiver = IrGetValueImpl(
|
|
||||||
originalSet.startOffset, originalSet.endOffset,
|
|
||||||
sharedVariableSymbol.owner.type, sharedVariableSymbol
|
|
||||||
)
|
|
||||||
putValueArgument(0, originalSet.value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-10
@@ -10,20 +10,12 @@ import org.jetbrains.kotlin.backend.konan.llvm.llvmSymbolOrigin
|
|||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.types.IrType
|
import org.jetbrains.kotlin.ir.types.IrType
|
||||||
import org.jetbrains.kotlin.ir.types.toKotlinType
|
import org.jetbrains.kotlin.ir.types.toKotlinType
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
import org.jetbrains.kotlin.ir.util.file
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.module
|
|
||||||
|
|
||||||
// This file contains some IR utilities which actually use descriptors.
|
// This file contains some IR utilities which actually use descriptors.
|
||||||
// TODO: port this code to IR.
|
// TODO: port this code to IR.
|
||||||
|
|
||||||
internal fun IrFunction.getObjCMethodInfo() = this.descriptor.getObjCMethodInfo()
|
internal val IrDeclaration.llvmSymbolOrigin get() = this.file.packageFragmentDescriptor.llvmSymbolOrigin
|
||||||
internal fun IrFunction.getExternalObjCMethodInfo() = this.descriptor.getExternalObjCMethodInfo()
|
|
||||||
internal fun IrFunction.isObjCClassMethod() = this.descriptor.isObjCClassMethod()
|
|
||||||
|
|
||||||
internal fun IrClass.isObjCMetaClass() = this.descriptor.isObjCMetaClass()
|
|
||||||
|
|
||||||
internal val IrDeclaration.llvmSymbolOrigin get() = this.descriptor.llvmSymbolOrigin
|
|
||||||
|
|
||||||
internal fun IrType.isObjCObjectType() = this.toKotlinType().isObjCObjectType()
|
internal fun IrType.isObjCObjectType() = this.toKotlinType().isObjCObjectType()
|
||||||
|
|
||||||
|
|||||||
+15
-1
@@ -60,6 +60,8 @@ internal class KonanSymbols(
|
|||||||
val nativePtrType = nativePtr.typeWith(arguments = emptyList())
|
val nativePtrType = nativePtr.typeWith(arguments = emptyList())
|
||||||
val nonNullNativePtr = symbolTable.referenceClass(context.nonNullNativePtr)
|
val nonNullNativePtr = symbolTable.referenceClass(context.nonNullNativePtr)
|
||||||
|
|
||||||
|
val immutableBlobOf = symbolTable.referenceSimpleFunction(context.immutableBlobOf)
|
||||||
|
|
||||||
private fun unsignedClass(unsignedType: UnsignedType): IrClassSymbol = classById(unsignedType.classId)
|
private fun unsignedClass(unsignedType: UnsignedType): IrClassSymbol = classById(unsignedType.classId)
|
||||||
|
|
||||||
val uByte = unsignedClass(UnsignedType.UBYTE)
|
val uByte = unsignedClass(UnsignedType.UBYTE)
|
||||||
@@ -130,6 +132,8 @@ internal class KonanSymbols(
|
|||||||
val interopCValueRead = symbolTable.referenceSimpleFunction(context.interopBuiltIns.cValueRead)
|
val interopCValueRead = symbolTable.referenceSimpleFunction(context.interopBuiltIns.cValueRead)
|
||||||
val interopAllocType = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocType)
|
val interopAllocType = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocType)
|
||||||
|
|
||||||
|
val interopTypeOf = symbolTable.referenceSimpleFunction(context.interopBuiltIns.typeOf)
|
||||||
|
|
||||||
val interopCPointerGetRawValue = symbolTable.referenceSimpleFunction(context.interopBuiltIns.cPointerGetRawValue)
|
val interopCPointerGetRawValue = symbolTable.referenceSimpleFunction(context.interopBuiltIns.cPointerGetRawValue)
|
||||||
|
|
||||||
val interopAllocObjCObject = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocObjCObject)
|
val interopAllocObjCObject = symbolTable.referenceSimpleFunction(context.interopBuiltIns.allocObjCObject)
|
||||||
@@ -168,6 +172,12 @@ internal class KonanSymbols(
|
|||||||
val interopObjCObjectRawValueGetter =
|
val interopObjCObjectRawValueGetter =
|
||||||
symbolTable.referenceSimpleFunction(context.interopBuiltIns.objCObjectRawPtr)
|
symbolTable.referenceSimpleFunction(context.interopBuiltIns.objCObjectRawPtr)
|
||||||
|
|
||||||
|
val interopNativePointedRawPtrGetter =
|
||||||
|
symbolTable.referenceSimpleFunction(context.interopBuiltIns.nativePointedRawPtrGetter)
|
||||||
|
|
||||||
|
val interopCPointerRawValue =
|
||||||
|
symbolTable.referenceProperty(context.interopBuiltIns.cPointerRawValue)
|
||||||
|
|
||||||
val interopInterpretObjCPointer =
|
val interopInterpretObjCPointer =
|
||||||
symbolTable.referenceSimpleFunction(context.interopBuiltIns.interpretObjCPointer)
|
symbolTable.referenceSimpleFunction(context.interopBuiltIns.interpretObjCPointer)
|
||||||
|
|
||||||
@@ -201,7 +211,11 @@ internal class KonanSymbols(
|
|||||||
) as ClassDescriptor
|
) as ClassDescriptor
|
||||||
)
|
)
|
||||||
|
|
||||||
val executeImpl = symbolTable.referenceSimpleFunction(context.interopBuiltIns.executeImplFunction)
|
val executeImpl = symbolTable.referenceSimpleFunction(
|
||||||
|
builtIns.builtInsModule.getPackage(FqName("kotlin.native.concurrent")).memberScope
|
||||||
|
.getContributedFunctions(Name.identifier("executeImpl"), NoLookupLocation.FROM_BACKEND)
|
||||||
|
.single()
|
||||||
|
)
|
||||||
|
|
||||||
val areEqualByValue = context.getKonanInternalFunctions("areEqualByValue").map {
|
val areEqualByValue = context.getKonanInternalFunctions("areEqualByValue").map {
|
||||||
symbolTable.referenceSimpleFunction(it)
|
symbolTable.referenceSimpleFunction(it)
|
||||||
|
|||||||
+5
-5
@@ -9,11 +9,11 @@ import llvm.LLVMTypeRef
|
|||||||
import org.jetbrains.kotlin.backend.common.serialization.KotlinManglerImpl
|
import org.jetbrains.kotlin.backend.common.serialization.KotlinManglerImpl
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.externalSymbolOrThrow
|
import org.jetbrains.kotlin.backend.konan.descriptors.externalSymbolOrThrow
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValue
|
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isAbstract
|
import org.jetbrains.kotlin.backend.konan.descriptors.isAbstract
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.allParameters
|
import org.jetbrains.kotlin.backend.konan.ir.allParameters
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.getObjCMethodInfo
|
import org.jetbrains.kotlin.backend.konan.getObjCMethodInfo
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.isObjCClassMethod
|
import org.jetbrains.kotlin.backend.konan.isObjCClassMethod
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.isUnit
|
import org.jetbrains.kotlin.backend.konan.ir.isUnit
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.isExported
|
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.isExported
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
@@ -89,7 +89,7 @@ object KonanMangler : KotlinManglerImpl() {
|
|||||||
append(it.selector)
|
append(it.selector)
|
||||||
if (this@platformSpecificFunctionName is IrConstructor && this@platformSpecificFunctionName.isObjCConstructor) append("#Constructor")
|
if (this@platformSpecificFunctionName is IrConstructor && this@platformSpecificFunctionName.isObjCConstructor) append("#Constructor")
|
||||||
|
|
||||||
if ((this@platformSpecificFunctionName as? IrSimpleFunction)?.correspondingProperty != null) {
|
if ((this@platformSpecificFunctionName as? IrSimpleFunction)?.correspondingPropertySymbol != null) {
|
||||||
append("#Accessor")
|
append("#Accessor")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ object KonanMangler : KotlinManglerImpl() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.annotations.findAnnotation(RuntimeNames.exportForCppRuntime)?.let {
|
this.annotations.findAnnotation(RuntimeNames.exportForCppRuntime)?.let {
|
||||||
val name = it.getAnnotationValue() ?: this.name.asString()
|
val name = it.getAnnotationStringValue() ?: this.name.asString()
|
||||||
return name // no wrapping currently required
|
return name // no wrapping currently required
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+4
-5
@@ -3,7 +3,7 @@ package org.jetbrains.kotlin.backend.konan.llvm
|
|||||||
import kotlinx.cinterop.cValuesOf
|
import kotlinx.cinterop.cValuesOf
|
||||||
import llvm.*
|
import llvm.*
|
||||||
import org.jetbrains.kotlin.backend.konan.RuntimeNames
|
import org.jetbrains.kotlin.backend.konan.RuntimeNames
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValue
|
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isTypedIntrinsic
|
import org.jetbrains.kotlin.backend.konan.descriptors.isTypedIntrinsic
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.objc.genObjCSelector
|
import org.jetbrains.kotlin.backend.konan.llvm.objc.genObjCSelector
|
||||||
import org.jetbrains.kotlin.backend.konan.reportCompilationError
|
import org.jetbrains.kotlin.backend.konan.reportCompilationError
|
||||||
@@ -107,7 +107,7 @@ internal interface IntrinsicGeneratorEnvironment {
|
|||||||
|
|
||||||
fun evaluateCall(function: IrFunction, args: List<LLVMValueRef>, resultLifetime: Lifetime, superClass: IrClass? = null): LLVMValueRef
|
fun evaluateCall(function: IrFunction, args: List<LLVMValueRef>, resultLifetime: Lifetime, superClass: IrClass? = null): LLVMValueRef
|
||||||
|
|
||||||
fun evaluateExplicitArgs(expression: IrMemberAccessExpression): List<LLVMValueRef>
|
fun evaluateExplicitArgs(expression: IrFunctionAccessExpression): List<LLVMValueRef>
|
||||||
|
|
||||||
fun evaluateExpression(value: IrExpression): LLVMValueRef
|
fun evaluateExpression(value: IrExpression): LLVMValueRef
|
||||||
}
|
}
|
||||||
@@ -118,7 +118,7 @@ internal fun tryGetIntrinsicType(callSite: IrFunctionAccessExpression): Intrinsi
|
|||||||
private fun getIntrinsicType(callSite: IrFunctionAccessExpression): IntrinsicType {
|
private fun getIntrinsicType(callSite: IrFunctionAccessExpression): IntrinsicType {
|
||||||
val function = callSite.symbol.owner
|
val function = callSite.symbol.owner
|
||||||
val annotation = function.annotations.findAnnotation(RuntimeNames.typedIntrinsicAnnotation)!!
|
val annotation = function.annotations.findAnnotation(RuntimeNames.typedIntrinsicAnnotation)!!
|
||||||
val value = annotation.getAnnotationValue()!!
|
val value = annotation.getAnnotationStringValue()!!
|
||||||
return IntrinsicType.valueOf(value)
|
return IntrinsicType.valueOf(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,8 +452,7 @@ internal class IntrinsicGenerator(private val environment: IntrinsicGeneratorEnv
|
|||||||
private val kImmOne = LLVMConstInt(int32Type, 1, 1)!!
|
private val kImmOne = LLVMConstInt(int32Type, 1, 1)!!
|
||||||
|
|
||||||
private fun FunctionGenerationContext.emitGetObjCClass(callSite: IrCall): LLVMValueRef {
|
private fun FunctionGenerationContext.emitGetObjCClass(callSite: IrCall): LLVMValueRef {
|
||||||
val descriptor = callSite.descriptor.original
|
val typeArgument = callSite.getTypeArgument(0)
|
||||||
val typeArgument = callSite.getTypeArgument(descriptor.typeParameters.single())
|
|
||||||
return getObjCClass(typeArgument!!.getClass()!!, environment.exceptionHandler)
|
return getObjCClass(typeArgument!!.getClass()!!, environment.exceptionHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-10
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.backend.konan.llvm
|
|||||||
|
|
||||||
import kotlinx.cinterop.*
|
import kotlinx.cinterop.*
|
||||||
import llvm.*
|
import llvm.*
|
||||||
import org.jetbrains.kotlin.backend.common.descriptors.allParameters
|
|
||||||
import org.jetbrains.kotlin.backend.common.ir.ir2string
|
import org.jetbrains.kotlin.backend.common.ir.ir2string
|
||||||
import org.jetbrains.kotlin.backend.common.lower.inline.InlinerExpressionLocationHint
|
import org.jetbrains.kotlin.backend.common.lower.inline.InlinerExpressionLocationHint
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
@@ -208,7 +207,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
override fun evaluateCall(function: IrFunction, args: List<LLVMValueRef>, resultLifetime: Lifetime, superClass: IrClass?) =
|
override fun evaluateCall(function: IrFunction, args: List<LLVMValueRef>, resultLifetime: Lifetime, superClass: IrClass?) =
|
||||||
evaluateSimpleFunctionCall(function, args, resultLifetime, superClass)
|
evaluateSimpleFunctionCall(function, args, resultLifetime, superClass)
|
||||||
|
|
||||||
override fun evaluateExplicitArgs(expression: IrMemberAccessExpression): List<LLVMValueRef> =
|
override fun evaluateExplicitArgs(expression: IrFunctionAccessExpression): List<LLVMValueRef> =
|
||||||
this@CodeGeneratorVisitor.evaluateExplicitArgs(expression)
|
this@CodeGeneratorVisitor.evaluateExplicitArgs(expression)
|
||||||
|
|
||||||
override fun evaluateExpression(value: IrExpression): LLVMValueRef =
|
override fun evaluateExpression(value: IrExpression): LLVMValueRef =
|
||||||
@@ -1481,17 +1480,17 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
if (!value.symbol.owner.isStatic) {
|
if (!value.symbol.owner.isStatic) {
|
||||||
val thisPtr = evaluateExpression(value.receiver!!)
|
val thisPtr = evaluateExpression(value.receiver!!)
|
||||||
return functionGenerationContext.loadSlot(
|
return functionGenerationContext.loadSlot(
|
||||||
fieldPtrOfClass(thisPtr, value.symbol.owner), value.descriptor.isVar())
|
fieldPtrOfClass(thisPtr, value.symbol.owner), !value.symbol.owner.isFinal)
|
||||||
} else {
|
} else {
|
||||||
assert(value.receiver == null)
|
assert(value.receiver == null)
|
||||||
return if (value.symbol.owner.correspondingProperty?.isConst == true) {
|
return if (value.symbol.owner.correspondingPropertySymbol?.owner?.isConst == true) {
|
||||||
evaluateConst(value.symbol.owner.initializer?.expression as IrConst<*>)
|
evaluateConst(value.symbol.owner.initializer?.expression as IrConst<*>)
|
||||||
} else {
|
} else {
|
||||||
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive) {
|
if (context.config.threadsAreAllowed && value.symbol.owner.isMainOnlyNonPrimitive) {
|
||||||
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
functionGenerationContext.checkMainThread(currentCodeContext.exceptionHandler)
|
||||||
}
|
}
|
||||||
val ptr = context.llvmDeclarations.forStaticField(value.symbol.owner).storage
|
val ptr = context.llvmDeclarations.forStaticField(value.symbol.owner).storage
|
||||||
functionGenerationContext.loadSlot(ptr, value.descriptor.isVar())
|
functionGenerationContext.loadSlot(ptr, !value.symbol.owner.isFinal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1941,12 +1940,12 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
* Returns results in the same order as LLVM function expects, assuming that all explicit arguments
|
* Returns results in the same order as LLVM function expects, assuming that all explicit arguments
|
||||||
* exactly correspond to a tail of LLVM parameters.
|
* exactly correspond to a tail of LLVM parameters.
|
||||||
*/
|
*/
|
||||||
private fun evaluateExplicitArgs(expression: IrMemberAccessExpression): List<LLVMValueRef> {
|
private fun evaluateExplicitArgs(expression: IrFunctionAccessExpression): List<LLVMValueRef> {
|
||||||
val evaluatedArgs = expression.getArguments().map { (param, argExpr) ->
|
val evaluatedArgs = expression.getArgumentsWithIr().map { (param, argExpr) ->
|
||||||
param to evaluateExpression(argExpr)
|
param to evaluateExpression(argExpr)
|
||||||
}.toMap()
|
}.toMap()
|
||||||
|
|
||||||
val allValueParameters = expression.descriptor.allParameters
|
val allValueParameters = expression.symbol.owner.allParameters
|
||||||
|
|
||||||
return allValueParameters.dropWhile { it !in evaluatedArgs }.map {
|
return allValueParameters.dropWhile { it !in evaluatedArgs }.map {
|
||||||
evaluatedArgs[it]!!
|
evaluatedArgs[it]!!
|
||||||
@@ -2051,7 +2050,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
else args
|
else args
|
||||||
return when {
|
return when {
|
||||||
function.isTypedIntrinsic -> intrinsicGenerator.evaluateCall(callee, args)
|
function.isTypedIntrinsic -> intrinsicGenerator.evaluateCall(callee, args)
|
||||||
function.symbol in context.irBuiltIns.irBuiltInsSymbols -> evaluateOperatorCall(callee, argsWithContinuationIfNeeded)
|
function.isBuiltInOperator -> evaluateOperatorCall(callee, argsWithContinuationIfNeeded)
|
||||||
else -> evaluateSimpleFunctionCall(function, argsWithContinuationIfNeeded, resultLifetime, callee.superQualifierSymbol?.owner)
|
else -> evaluateSimpleFunctionCall(function, argsWithContinuationIfNeeded, resultLifetime, callee.superQualifierSymbol?.owner)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2133,7 +2132,7 @@ internal class CodeGeneratorVisitor(val context: Context, val lifetimes: Map<IrE
|
|||||||
assert(irClass.isExternalObjCClass())
|
assert(irClass.isExternalObjCClass())
|
||||||
|
|
||||||
val annotation = irClass.annotations.findAnnotation(externalObjCClassFqName)!!
|
val annotation = irClass.annotations.findAnnotation(externalObjCClassFqName)!!
|
||||||
val protocolGetterName = annotation.getStringValue("protocolGetter")
|
val protocolGetterName = annotation.getAnnotationStringValue("protocolGetter")
|
||||||
val protocolGetter = context.llvm.externalFunction(
|
val protocolGetter = context.llvm.externalFunction(
|
||||||
protocolGetterName,
|
protocolGetterName,
|
||||||
functionType(int8TypePtr, false),
|
functionType(int8TypePtr, false),
|
||||||
|
|||||||
+3
-3
@@ -9,7 +9,7 @@ import llvm.LLVMStoreSizeOfType
|
|||||||
import llvm.LLVMValueRef
|
import llvm.LLVMValueRef
|
||||||
import org.jetbrains.kotlin.backend.common.atMostOne
|
import org.jetbrains.kotlin.backend.common.atMostOne
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getStringValue
|
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
|
||||||
@@ -127,8 +127,8 @@ internal class KotlinObjCClassInfoGenerator(override val context: Context) : Con
|
|||||||
return@mapNotNull null
|
return@mapNotNull null
|
||||||
|
|
||||||
ObjCMethodDesc(
|
ObjCMethodDesc(
|
||||||
annotation.getStringValue("selector"),
|
annotation.getAnnotationStringValue("selector"),
|
||||||
annotation.getStringValue("encoding"),
|
annotation.getAnnotationStringValue("encoding"),
|
||||||
it.llvmFunction
|
it.llvmFunction
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -139,7 +139,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
|||||||
private fun exportTypeInfoIfRequired(irClass: IrClass, typeInfoGlobal: LLVMValueRef?) {
|
private fun exportTypeInfoIfRequired(irClass: IrClass, typeInfoGlobal: LLVMValueRef?) {
|
||||||
val annotation = irClass.annotations.findAnnotation(EXPORT_TYPE_INFO_FQ_NAME)
|
val annotation = irClass.annotations.findAnnotation(EXPORT_TYPE_INFO_FQ_NAME)
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
val name = annotation.getAnnotationValue()!!
|
val name = annotation.getAnnotationStringValue()!!
|
||||||
// TODO: use LLVMAddAlias.
|
// TODO: use LLVMAddAlias.
|
||||||
val global = addGlobal(name, pointerType(runtime.typeInfoType), isExported = true)
|
val global = addGlobal(name, pointerType(runtime.typeInfoType), isExported = true)
|
||||||
LLVMSetInitializer(global, typeInfoGlobal)
|
LLVMSetInitializer(global, typeInfoGlobal)
|
||||||
|
|||||||
+2
-2
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.backend.konan.llvm
|
package org.jetbrains.kotlin.backend.konan.llvm
|
||||||
|
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationValue
|
import org.jetbrains.kotlin.backend.konan.descriptors.getAnnotationStringValue
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
import org.jetbrains.kotlin.ir.declarations.IrFunction
|
||||||
import org.jetbrains.kotlin.ir.util.findAnnotation
|
import org.jetbrains.kotlin.ir.util.findAnnotation
|
||||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||||
@@ -17,6 +17,6 @@ private val retainForTargetAnnotationName = FqName("kotlin.native.RetainForTarge
|
|||||||
internal fun IrFunction.retainAnnotation(target: KonanTarget): Boolean {
|
internal fun IrFunction.retainAnnotation(target: KonanTarget): Boolean {
|
||||||
if (this.annotations.findAnnotation(retainAnnotationName) != null) return true
|
if (this.annotations.findAnnotation(retainAnnotationName) != null) return true
|
||||||
val forTarget = this.annotations.findAnnotation(retainForTargetAnnotationName)
|
val forTarget = this.annotations.findAnnotation(retainForTargetAnnotationName)
|
||||||
if (forTarget != null && forTarget.getAnnotationValue() == target.name) return true
|
if (forTarget != null && forTarget.getAnnotationStringValue() == target.name) return true
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ private class AutoboxingTransformer(val context: Context) : AbstractValueUsageTr
|
|||||||
}
|
}
|
||||||
|
|
||||||
private val IrCall.callTarget: IrFunction
|
private val IrCall.callTarget: IrFunction
|
||||||
get() = if (superQualifier == null && symbol.owner.isOverridable) {
|
get() = if (superQualifierSymbol == null && symbol.owner.isOverridable) {
|
||||||
// A virtual call.
|
// A virtual call.
|
||||||
symbol.owner
|
symbol.owner
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+1
-6
@@ -37,9 +37,7 @@ import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
|
|||||||
|
|
||||||
internal class WorkersBridgesBuilding(val context: Context) : DeclarationContainerLoweringPass, IrElementTransformerVoid() {
|
internal class WorkersBridgesBuilding(val context: Context) : DeclarationContainerLoweringPass, IrElementTransformerVoid() {
|
||||||
|
|
||||||
val interop = context.interopBuiltIns
|
|
||||||
val symbols = context.ir.symbols
|
val symbols = context.ir.symbols
|
||||||
val nullableAnyType = context.builtIns.nullableAnyType
|
|
||||||
lateinit var runtimeJobFunction: IrSimpleFunction
|
lateinit var runtimeJobFunction: IrSimpleFunction
|
||||||
|
|
||||||
override fun lower(irDeclarationContainer: IrDeclarationContainer) {
|
override fun lower(irDeclarationContainer: IrDeclarationContainer) {
|
||||||
@@ -59,8 +57,7 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
|
|||||||
override fun visitCall(expression: IrCall): IrExpression {
|
override fun visitCall(expression: IrCall): IrExpression {
|
||||||
expression.transformChildrenVoid(this)
|
expression.transformChildrenVoid(this)
|
||||||
|
|
||||||
val descriptor = expression.descriptor.original
|
if (expression.symbol != symbols.executeImpl)
|
||||||
if (descriptor != interop.executeImplFunction)
|
|
||||||
return expression
|
return expression
|
||||||
|
|
||||||
val job = expression.getValueArgument(3) as IrFunctionReference
|
val job = expression.getValueArgument(3) as IrFunctionReference
|
||||||
@@ -118,7 +115,6 @@ internal class WorkersBridgesBuilding(val context: Context) : DeclarationContain
|
|||||||
endOffset = job.endOffset,
|
endOffset = job.endOffset,
|
||||||
type = job.type,
|
type = job.type,
|
||||||
symbol = bridge.symbol,
|
symbol = bridge.symbol,
|
||||||
descriptor = bridge.descriptor,
|
|
||||||
typeArgumentsCount = 0)
|
typeArgumentsCount = 0)
|
||||||
)
|
)
|
||||||
return expression
|
return expression
|
||||||
@@ -238,7 +234,6 @@ private fun Context.buildBridge(startOffset: Int, endOffset: Int,
|
|||||||
endOffset,
|
endOffset,
|
||||||
targetSymbol.owner.returnType,
|
targetSymbol.owner.returnType,
|
||||||
targetSymbol,
|
targetSymbol,
|
||||||
targetSymbol.descriptor,
|
|
||||||
superQualifierSymbol = superQualifierSymbol /* Call non-virtually */
|
superQualifierSymbol = superQualifierSymbol /* Call non-virtually */
|
||||||
).apply {
|
).apply {
|
||||||
bridge.dispatchReceiverParameter?.let {
|
bridge.dispatchReceiverParameter?.let {
|
||||||
|
|||||||
+3
-4
@@ -9,13 +9,12 @@ import org.jetbrains.kotlin.backend.common.FileLoweringPass
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.IrBuildingTransformer
|
import org.jetbrains.kotlin.backend.common.lower.IrBuildingTransformer
|
||||||
import org.jetbrains.kotlin.backend.common.lower.at
|
import org.jetbrains.kotlin.backend.common.lower.at
|
||||||
import org.jetbrains.kotlin.backend.konan.Context
|
import org.jetbrains.kotlin.backend.konan.Context
|
||||||
import org.jetbrains.kotlin.ir.builders.irCall
|
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.types.isString
|
import org.jetbrains.kotlin.ir.types.isString
|
||||||
|
import org.jetbrains.kotlin.ir.util.fqNameForIrSerialization
|
||||||
import org.jetbrains.kotlin.ir.util.irCall
|
import org.jetbrains.kotlin.ir.util.irCall
|
||||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
|
||||||
|
|
||||||
internal class CompileTimeEvaluateLowering(val context: Context): FileLoweringPass {
|
internal class CompileTimeEvaluateLowering(val context: Context): FileLoweringPass {
|
||||||
|
|
||||||
@@ -24,9 +23,9 @@ internal class CompileTimeEvaluateLowering(val context: Context): FileLoweringPa
|
|||||||
override fun visitCall(expression: IrCall): IrExpression {
|
override fun visitCall(expression: IrCall): IrExpression {
|
||||||
expression.transformChildrenVoid(this)
|
expression.transformChildrenVoid(this)
|
||||||
|
|
||||||
val descriptor = expression.descriptor.original
|
val callee = expression.symbol.owner
|
||||||
// TODO
|
// TODO
|
||||||
if (descriptor.fqNameSafe.asString() != "kotlin.collections.listOf" || descriptor.valueParameters.size != 1)
|
if (callee.fqNameForIrSerialization.asString() != "kotlin.collections.listOf" || callee.valueParameters.size != 1)
|
||||||
return expression
|
return expression
|
||||||
val elementsArr = expression.getValueArgument(0) as? IrVararg
|
val elementsArr = expression.getValueArgument(0) as? IrVararg
|
||||||
?: return expression
|
?: return expression
|
||||||
|
|||||||
+2
-3
@@ -28,9 +28,8 @@ internal class DataClassOperatorsLowering(val context: Context): FunctionLowerin
|
|||||||
override fun visitCall(expression: IrCall): IrExpression {
|
override fun visitCall(expression: IrCall): IrExpression {
|
||||||
expression.transformChildrenVoid(this)
|
expression.transformChildrenVoid(this)
|
||||||
|
|
||||||
val descriptor = expression.descriptor.original
|
if (expression.symbol != irBuiltins.dataClassArrayMemberToStringSymbol
|
||||||
if (descriptor != irBuiltins.dataClassArrayMemberToString
|
&& expression.symbol != irBuiltins.dataClassArrayMemberHashCodeSymbol)
|
||||||
&& descriptor != irBuiltins.dataClassArrayMemberHashCode)
|
|
||||||
return expression
|
return expression
|
||||||
|
|
||||||
val argument = expression.getValueArgument(0)!!
|
val argument = expression.getValueArgument(0)!!
|
||||||
|
|||||||
+2
-10
@@ -12,13 +12,8 @@ import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
||||||
import org.jetbrains.kotlin.backend.konan.Context
|
import org.jetbrains.kotlin.backend.konan.Context
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
||||||
import org.jetbrains.kotlin.backend.konan.KonanBackendContext
|
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.buildSimpleAnnotation
|
import org.jetbrains.kotlin.backend.konan.ir.buildSimpleAnnotation
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.typeWithStarProjections
|
|
||||||
import org.jetbrains.kotlin.backend.konan.isObjCClass
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptorImpl
|
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
|
||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
import org.jetbrains.kotlin.ir.declarations.impl.IrFieldImpl
|
||||||
@@ -123,7 +118,7 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
return when (receiversCount) {
|
return when (receiversCount) {
|
||||||
1 -> createKProperty(expression, this) // Has receiver.
|
1 -> createKProperty(expression, this) // Has receiver.
|
||||||
|
|
||||||
2 -> error("Callable reference to properties with two receivers is not allowed: ${expression.descriptor}")
|
2 -> error("Callable reference to properties with two receivers is not allowed: ${expression.symbol.owner.name}")
|
||||||
|
|
||||||
else -> { // Cache KProperties with no arguments.
|
else -> { // Cache KProperties with no arguments.
|
||||||
val field = kProperties.getOrPut(expression.symbol.owner) {
|
val field = kProperties.getOrPut(expression.symbol.owner) {
|
||||||
@@ -195,7 +190,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
else
|
else
|
||||||
irTemporary(value = it, nameHint = "\$extensionReceiver${tempIndex++}")
|
irTemporary(value = it, nameHint = "\$extensionReceiver${tempIndex++}")
|
||||||
}
|
}
|
||||||
val propertyDescriptor = expression.descriptor
|
|
||||||
val returnType = expression.getter?.owner?.returnType ?: expression.field!!.owner.type
|
val returnType = expression.getter?.owner?.returnType ?: expression.field!!.owner.type
|
||||||
|
|
||||||
val getterCallableReference = expression.getter?.owner?.let { getter ->
|
val getterCallableReference = expression.getter?.owner?.let { getter ->
|
||||||
@@ -216,7 +210,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
type = getterKFunctionType,
|
type = getterKFunctionType,
|
||||||
symbol = expression.getter!!,
|
symbol = expression.getter!!,
|
||||||
descriptor = getter.descriptor,
|
|
||||||
typeArgumentsCount = getter.typeParameters.size,
|
typeArgumentsCount = getter.typeParameters.size,
|
||||||
valueArgumentsCount = getter.valueParameters.size
|
valueArgumentsCount = getter.valueParameters.size
|
||||||
).apply {
|
).apply {
|
||||||
@@ -239,7 +232,6 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
endOffset = endOffset,
|
endOffset = endOffset,
|
||||||
type = setterKFunctionType,
|
type = setterKFunctionType,
|
||||||
symbol = expression.setter!!,
|
symbol = expression.setter!!,
|
||||||
descriptor = setter.descriptor,
|
|
||||||
typeArgumentsCount = setter.typeParameters.size,
|
typeArgumentsCount = setter.typeParameters.size,
|
||||||
valueArgumentsCount = setter.valueParameters.size
|
valueArgumentsCount = setter.valueParameters.size
|
||||||
).apply {
|
).apply {
|
||||||
@@ -257,7 +249,7 @@ internal class PropertyDelegationLowering(val context: Context) : FileLoweringPa
|
|||||||
isLocal = false,
|
isLocal = false,
|
||||||
isMutable = setterCallableReference != null)
|
isMutable = setterCallableReference != null)
|
||||||
val initializer = irCall(symbol.owner, constructorTypeArguments).apply {
|
val initializer = irCall(symbol.owner, constructorTypeArguments).apply {
|
||||||
putValueArgument(0, irString(propertyDescriptor.name.asString()))
|
putValueArgument(0, irString(expression.symbol.owner.name.asString()))
|
||||||
putValueArgument(1, with(kTypeGenerator) { irKType(returnType) })
|
putValueArgument(1, with(kTypeGenerator) { irKType(returnType) })
|
||||||
if (getterCallableReference != null)
|
if (getterCallableReference != null)
|
||||||
putValueArgument(2, getterCallableReference)
|
putValueArgument(2, getterCallableReference)
|
||||||
|
|||||||
+1
-1
@@ -127,7 +127,7 @@ internal class EnumUsageLowering(val context: Context)
|
|||||||
val ordinal = loweredEnum.entriesMap[name]!!
|
val ordinal = loweredEnum.entriesMap[name]!!
|
||||||
return IrCallImpl(
|
return IrCallImpl(
|
||||||
startOffset, endOffset, enumClass.defaultType,
|
startOffset, endOffset, enumClass.defaultType,
|
||||||
loweredEnum.itemGetterSymbol.owner.symbol, loweredEnum.itemGetterSymbol.descriptor,
|
loweredEnum.itemGetterSymbol.owner.symbol,
|
||||||
typeArgumentsCount = 0
|
typeArgumentsCount = 0
|
||||||
).apply {
|
).apply {
|
||||||
dispatchReceiver = IrCallImpl(startOffset, endOffset, loweredEnum.valuesGetter.returnType, loweredEnum.valuesGetter.symbol)
|
dispatchReceiver = IrCallImpl(startOffset, endOffset, loweredEnum.valuesGetter.returnType, loweredEnum.valuesGetter.symbol)
|
||||||
|
|||||||
+1
-1
@@ -134,7 +134,7 @@ internal class ExpectToActualDefaultValueCopier(private val irModule: IrModuleFr
|
|||||||
symbol.descriptor.isExpect -> symbol.owner.findActualForExpected().symbol
|
symbol.descriptor.isExpect -> symbol.owner.findActualForExpected().symbol
|
||||||
|
|
||||||
symbol.descriptor.propertyIfAccessor.isExpect -> {
|
symbol.descriptor.propertyIfAccessor.isExpect -> {
|
||||||
val property = symbol.owner.correspondingProperty!!
|
val property = symbol.owner.correspondingPropertySymbol!!.owner
|
||||||
val actualPropertyDescriptor = property.descriptor.findActualForExpect()
|
val actualPropertyDescriptor = property.descriptor.findActualForExpect()
|
||||||
val accessorDescriptor = when (symbol.owner) {
|
val accessorDescriptor = when (symbol.owner) {
|
||||||
property.getter -> actualPropertyDescriptor.getter!!
|
property.getter -> actualPropertyDescriptor.getter!!
|
||||||
|
|||||||
+16
-22
@@ -18,12 +18,12 @@ import org.jetbrains.kotlin.backend.common.push
|
|||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.cgen.*
|
import org.jetbrains.kotlin.backend.konan.cgen.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.allOverriddenFunctions
|
import org.jetbrains.kotlin.backend.konan.descriptors.allOverriddenFunctions
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
import org.jetbrains.kotlin.backend.konan.descriptors.synthesizedName
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.companionObject
|
import org.jetbrains.kotlin.backend.konan.ir.companionObject
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.IntrinsicType
|
import org.jetbrains.kotlin.backend.konan.llvm.IntrinsicType
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.tryGetIntrinsicType
|
import org.jetbrains.kotlin.backend.konan.llvm.tryGetIntrinsicType
|
||||||
|
import org.jetbrains.kotlin.backend.konan.serialization.resolveFakeOverrideMaybeAbstract
|
||||||
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
import org.jetbrains.kotlin.builtins.UnsignedTypes
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
@@ -47,7 +47,6 @@ import org.jetbrains.kotlin.ir.util.*
|
|||||||
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
import org.jetbrains.kotlin.ir.visitors.transformChildrenVoid
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.OverridingUtil
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||||
|
|
||||||
internal abstract class BaseInteropIrTransformer(private val context: Context) : IrBuildingTransformer(context) {
|
internal abstract class BaseInteropIrTransformer(private val context: Context) : IrBuildingTransformer(context) {
|
||||||
@@ -569,7 +568,6 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
|
|||||||
endOffset,
|
endOffset,
|
||||||
context.irBuiltIns.unitType,
|
context.irBuiltIns.unitType,
|
||||||
superConstructor,
|
superConstructor,
|
||||||
superConstructor.descriptor,
|
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -645,11 +643,9 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
|
|||||||
override fun visitCall(expression: IrCall): IrExpression {
|
override fun visitCall(expression: IrCall): IrExpression {
|
||||||
expression.transformChildrenVoid()
|
expression.transformChildrenVoid()
|
||||||
|
|
||||||
val descriptor = expression.descriptor.original
|
|
||||||
|
|
||||||
val callee = expression.symbol.owner
|
val callee = expression.symbol.owner
|
||||||
|
|
||||||
descriptor.getObjCFactoryInitMethodInfo()?.let { initMethodInfo ->
|
callee.getObjCFactoryInitMethodInfo()?.let { initMethodInfo ->
|
||||||
val arguments = (0 until expression.valueArgumentsCount)
|
val arguments = (0 until expression.valueArgumentsCount)
|
||||||
.map { index -> expression.getValueArgument(index) }
|
.map { index -> expression.getValueArgument(index) }
|
||||||
|
|
||||||
@@ -659,7 +655,7 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
descriptor.getExternalObjCMethodInfo()?.let { methodInfo ->
|
callee.getExternalObjCMethodInfo()?.let { methodInfo ->
|
||||||
val isInteropStubsFile =
|
val isInteropStubsFile =
|
||||||
currentFile.annotations.hasAnnotation(FqName("kotlinx.cinterop.InteropStubs"))
|
currentFile.annotations.hasAnnotation(FqName("kotlinx.cinterop.InteropStubs"))
|
||||||
|
|
||||||
@@ -672,14 +668,14 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
|
|||||||
val arguments = callee.valueParameters.map { expression.getValueArgument(it.index) }
|
val arguments = callee.valueParameters.map { expression.getValueArgument(it.index) }
|
||||||
assert(expression.dispatchReceiver == null || expression.extensionReceiver == null)
|
assert(expression.dispatchReceiver == null || expression.extensionReceiver == null)
|
||||||
|
|
||||||
if (expression.superQualifier?.isObjCMetaClass() == true) {
|
if (expression.superQualifierSymbol?.owner?.isObjCMetaClass() == true) {
|
||||||
context.reportCompilationError(
|
context.reportCompilationError(
|
||||||
"Super calls to Objective-C meta classes are not supported yet",
|
"Super calls to Objective-C meta classes are not supported yet",
|
||||||
currentFile, expression
|
currentFile, expression
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expression.superQualifier?.isInterface == true) {
|
if (expression.superQualifierSymbol?.owner?.isInterface == true) {
|
||||||
context.reportCompilationError(
|
context.reportCompilationError(
|
||||||
"Super calls to Objective-C protocols are not allowed",
|
"Super calls to Objective-C protocols are not allowed",
|
||||||
currentFile, expression
|
currentFile, expression
|
||||||
@@ -698,8 +694,8 @@ internal class InteropLoweringPart1(val context: Context) : BaseInteropIrTransfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return when (descriptor) {
|
return when (callee.symbol) {
|
||||||
context.interopBuiltIns.typeOf -> {
|
symbols.interopTypeOf -> {
|
||||||
val typeArgument = expression.getSingleTypeArgument()
|
val typeArgument = expression.getSingleTypeArgument()
|
||||||
val classSymbol = typeArgument.classifierOrNull as? IrClassSymbol
|
val classSymbol = typeArgument.classifierOrNull as? IrClassSymbol
|
||||||
|
|
||||||
@@ -839,11 +835,10 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
|
|||||||
|
|
||||||
expression.transformChildrenVoid(this)
|
expression.transformChildrenVoid(this)
|
||||||
builder.at(expression)
|
builder.at(expression)
|
||||||
val descriptor = expression.descriptor.original
|
|
||||||
val function = expression.symbol.owner
|
val function = expression.symbol.owner
|
||||||
|
|
||||||
if (descriptor == interop.nativePointedRawPtrGetter ||
|
if ((function as? IrSimpleFunction)?.resolveFakeOverrideMaybeAbstract()?.symbol
|
||||||
OverridingUtil.overrides(descriptor, interop.nativePointedRawPtrGetter, false)) {
|
== symbols.interopNativePointedRawPtrGetter) {
|
||||||
|
|
||||||
// Replace by the intrinsic call to be handled by code generator:
|
// Replace by the intrinsic call to be handled by code generator:
|
||||||
return builder.irCall(symbols.interopNativePointedGetRawPointer).apply {
|
return builder.irCall(symbols.interopNativePointedGetRawPointer).apply {
|
||||||
@@ -884,7 +879,7 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
|
|||||||
if (irCallableReference == null || irCallableReference.getArguments().isNotEmpty()
|
if (irCallableReference == null || irCallableReference.getArguments().isNotEmpty()
|
||||||
|| irCallableReference.symbol !is IrSimpleFunctionSymbol) {
|
|| irCallableReference.symbol !is IrSimpleFunctionSymbol) {
|
||||||
context.reportCompilationError(
|
context.reportCompilationError(
|
||||||
"${descriptor.fqNameSafe} must take an unbound, non-capturing function or lambda",
|
"${function.fqNameForIrSerialization} must take an unbound, non-capturing function or lambda",
|
||||||
irFile, expression
|
irFile, expression
|
||||||
)
|
)
|
||||||
// TODO: should probably be reported during analysis.
|
// TODO: should probably be reported during analysis.
|
||||||
@@ -894,8 +889,8 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
|
|||||||
val target = targetSymbol.owner
|
val target = targetSymbol.owner
|
||||||
val signatureTypes = target.allParameters.map { it.type } + target.returnType
|
val signatureTypes = target.allParameters.map { it.type } + target.returnType
|
||||||
|
|
||||||
descriptor.typeParameters.forEachIndexed { index, typeParameterDescriptor ->
|
function.typeParameters.indices.forEach { index ->
|
||||||
val typeArgument = expression.getTypeArgument(typeParameterDescriptor)!!.toKotlinType()
|
val typeArgument = expression.getTypeArgument(index)!!.toKotlinType()
|
||||||
val signatureType = signatureTypes[index].toKotlinType()
|
val signatureType = signatureTypes[index].toKotlinType()
|
||||||
if (typeArgument.constructor != signatureType.constructor ||
|
if (typeArgument.constructor != signatureType.constructor ||
|
||||||
typeArgument.isMarkedNullable != signatureType.isMarkedNullable) {
|
typeArgument.isMarkedNullable != signatureType.isMarkedNullable) {
|
||||||
@@ -1020,17 +1015,16 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
|
|||||||
|
|
||||||
if (irCallableReference == null || irCallableReference.getArguments().isNotEmpty()) {
|
if (irCallableReference == null || irCallableReference.getArguments().isNotEmpty()) {
|
||||||
context.reportCompilationError(
|
context.reportCompilationError(
|
||||||
"${descriptor.fqNameSafe} must take an unbound, non-capturing function or lambda",
|
"${function.fqNameForIrSerialization} must take an unbound, non-capturing function or lambda",
|
||||||
irFile, expression
|
irFile, expression
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
val targetSymbol = irCallableReference.symbol
|
val targetSymbol = irCallableReference.symbol
|
||||||
val target = targetSymbol.descriptor
|
|
||||||
val jobPointer = IrFunctionReferenceImpl(
|
val jobPointer = IrFunctionReferenceImpl(
|
||||||
builder.startOffset, builder.endOffset,
|
builder.startOffset, builder.endOffset,
|
||||||
symbols.executeImpl.owner.valueParameters[3].type,
|
symbols.executeImpl.owner.valueParameters[3].type,
|
||||||
targetSymbol, target,
|
targetSymbol,
|
||||||
typeArgumentsCount = 0)
|
typeArgumentsCount = 0)
|
||||||
|
|
||||||
builder.irCall(symbols.executeImpl).apply {
|
builder.irCall(symbols.executeImpl).apply {
|
||||||
@@ -1043,8 +1037,8 @@ private class InteropTransformer(val context: Context, override val irFile: IrFi
|
|||||||
else -> expression
|
else -> expression
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return when (descriptor) {
|
return when (function) {
|
||||||
interop.cPointerRawValue.getter ->
|
symbols.interopCPointerRawValue.owner.getter ->
|
||||||
// Replace by the intrinsic call to be handled by code generator:
|
// Replace by the intrinsic call to be handled by code generator:
|
||||||
builder.irCall(symbols.interopCPointerGetRawValue).apply {
|
builder.irCall(symbols.interopCPointerGetRawValue).apply {
|
||||||
extensionReceiver = expression.dispatchReceiver
|
extensionReceiver = expression.dispatchReceiver
|
||||||
|
|||||||
+2
-3
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.common.IrElementTransformerVoidWithContext
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
import org.jetbrains.kotlin.backend.konan.Context
|
import org.jetbrains.kotlin.backend.konan.Context
|
||||||
import org.jetbrains.kotlin.backend.konan.error
|
import org.jetbrains.kotlin.backend.konan.error
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.typeWithoutArguments
|
|
||||||
import org.jetbrains.kotlin.backend.konan.reportCompilationError
|
import org.jetbrains.kotlin.backend.konan.reportCompilationError
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.declarations.IrFile
|
import org.jetbrains.kotlin.ir.declarations.IrFile
|
||||||
@@ -74,11 +73,11 @@ internal class PostInlineLowering(val context: Context) : FileLoweringPass {
|
|||||||
// Function inlining is changing function symbol at callsite
|
// Function inlining is changing function symbol at callsite
|
||||||
// and unbound symbol replacement is happening later.
|
// and unbound symbol replacement is happening later.
|
||||||
// So we compare descriptors for now.
|
// So we compare descriptors for now.
|
||||||
if (expression.descriptor == context.immutableBlobOf) {
|
if (expression.symbol == symbols.immutableBlobOf) {
|
||||||
// Convert arguments of the binary blob to special IrConst<String> structure, so that
|
// Convert arguments of the binary blob to special IrConst<String> structure, so that
|
||||||
// vararg lowering will not affect it.
|
// vararg lowering will not affect it.
|
||||||
val args = expression.getValueArgument(0) as? IrVararg
|
val args = expression.getValueArgument(0) as? IrVararg
|
||||||
if (args == null) throw Error("varargs shall not be lowered yet")
|
?: throw Error("varargs shall not be lowered yet")
|
||||||
if (args.elements.any { it is IrSpreadElement }) {
|
if (args.elements.any { it is IrSpreadElement }) {
|
||||||
context.reportCompilationError("no spread elements allowed here", irFile, args)
|
context.reportCompilationError("no spread elements allowed here", irFile, args)
|
||||||
}
|
}
|
||||||
|
|||||||
-2
@@ -106,7 +106,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
it.function.endOffset,
|
it.function.endOffset,
|
||||||
registerTestCase.valueParameters[1].type,
|
registerTestCase.valueParameters[1].type,
|
||||||
it.function.symbol,
|
it.function.symbol,
|
||||||
it.function.descriptor,
|
|
||||||
typeArgumentsCount = 0,
|
typeArgumentsCount = 0,
|
||||||
valueArgumentsCount = 0))
|
valueArgumentsCount = 0))
|
||||||
putValueArgument(2, irBoolean(it.ignored))
|
putValueArgument(2, irBoolean(it.ignored))
|
||||||
@@ -127,7 +126,6 @@ internal class TestProcessor (val context: Context) {
|
|||||||
it.function.endOffset,
|
it.function.endOffset,
|
||||||
registerFunction.valueParameters[1].type,
|
registerFunction.valueParameters[1].type,
|
||||||
it.function.symbol,
|
it.function.symbol,
|
||||||
it.function.descriptor,
|
|
||||||
typeArgumentsCount = 0,
|
typeArgumentsCount = 0,
|
||||||
valueArgumentsCount = 0))
|
valueArgumentsCount = 0))
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.ir.IrElement
|
|||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.*
|
import org.jetbrains.kotlin.ir.expressions.*
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrBlockImpl
|
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrConstImpl
|
||||||
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
import org.jetbrains.kotlin.ir.expressions.impl.IrVarargImpl
|
||||||
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
|
||||||
@@ -65,12 +64,13 @@ internal class VarargInjectionLowering constructor(val context: KonanBackendCont
|
|||||||
val transformer = this
|
val transformer = this
|
||||||
|
|
||||||
private fun replaceEmptyParameterWithEmptyArray(expression: IrFunctionAccessExpression) {
|
private fun replaceEmptyParameterWithEmptyArray(expression: IrFunctionAccessExpression) {
|
||||||
log { "call of: ${expression.descriptor}" }
|
val callee = expression.symbol.owner
|
||||||
|
log { "call of: ${callee.fqNameForIrSerialization}" }
|
||||||
context.createIrBuilder(owner, expression.startOffset, expression.endOffset).apply {
|
context.createIrBuilder(owner, expression.startOffset, expression.endOffset).apply {
|
||||||
expression.descriptor.valueParameters.forEach {
|
callee.valueParameters.forEach {
|
||||||
log { "varargElementType: ${it.varargElementType} expr: ${ir2string(expression.getValueArgument(it))}" }
|
log { "varargElementType: ${it.varargElementType} expr: ${ir2string(expression.getValueArgument(it.index))}" }
|
||||||
}
|
}
|
||||||
expression.symbol.owner.valueParameters
|
callee.valueParameters
|
||||||
.filter { it.varargElementType != null && expression.getValueArgument(it.index) == null }
|
.filter { it.varargElementType != null && expression.getValueArgument(it.index) == null }
|
||||||
.forEach {
|
.forEach {
|
||||||
expression.putValueArgument(
|
expression.putValueArgument(
|
||||||
|
|||||||
+1
-1
@@ -644,7 +644,7 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag
|
|||||||
error("Constructor call should be done with IrConstructorCall")
|
error("Constructor call should be done with IrConstructorCall")
|
||||||
} else {
|
} else {
|
||||||
callee as IrSimpleFunction
|
callee as IrSimpleFunction
|
||||||
if (callee.isOverridable && value.superQualifier == null) {
|
if (callee.isOverridable && value.superQualifierSymbol == null) {
|
||||||
val owner = callee.parentAsClass
|
val owner = callee.parentAsClass
|
||||||
val actualReceiverType = value.dispatchReceiver!!.type
|
val actualReceiverType = value.dispatchReceiver!!.type
|
||||||
val actualReceiverClassifier = actualReceiverType.classifierOrFail
|
val actualReceiverClassifier = actualReceiverType.classifierOrFail
|
||||||
|
|||||||
+2
-4
@@ -10,7 +10,6 @@ import org.jetbrains.kotlin.backend.konan.descriptors.isAbstract
|
|||||||
import org.jetbrains.kotlin.backend.konan.descriptors.target
|
import org.jetbrains.kotlin.backend.konan.descriptors.target
|
||||||
import org.jetbrains.kotlin.backend.konan.ir.*
|
import org.jetbrains.kotlin.backend.konan.ir.*
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.*
|
import org.jetbrains.kotlin.backend.konan.llvm.*
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.functionName
|
|
||||||
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.symbolName
|
import org.jetbrains.kotlin.backend.konan.llvm.KonanMangler.symbolName
|
||||||
import org.jetbrains.kotlin.backend.konan.lower.DECLARATION_ORIGIN_BRIDGE_METHOD
|
import org.jetbrains.kotlin.backend.konan.lower.DECLARATION_ORIGIN_BRIDGE_METHOD
|
||||||
import org.jetbrains.kotlin.backend.konan.lower.bridgeTarget
|
import org.jetbrains.kotlin.backend.konan.lower.bridgeTarget
|
||||||
@@ -30,8 +29,7 @@ import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
|
|||||||
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
|
import org.jetbrains.kotlin.load.java.BuiltinMethodsWithSpecialGenericSignature
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
import org.jetbrains.kotlin.backend.konan.descriptors.isBuiltInOperator
|
||||||
import org.jetbrains.kotlin.resolve.constants.IntValue
|
|
||||||
|
|
||||||
internal object DataFlowIR {
|
internal object DataFlowIR {
|
||||||
|
|
||||||
@@ -599,7 +597,7 @@ internal object DataFlowIR {
|
|||||||
attributes = attributes or FunctionAttributes.EXPLICITLY_EXPORTED
|
attributes = attributes or FunctionAttributes.EXPLICITLY_EXPORTED
|
||||||
}
|
}
|
||||||
val symbol = when {
|
val symbol = when {
|
||||||
it.isExternal || (it.symbol in context.irBuiltIns.irBuiltInsSymbols) -> {
|
it.isExternal || it.isBuiltInOperator -> {
|
||||||
val escapesAnnotation = it.annotations.findAnnotation(FQ_NAME_ESCAPES)
|
val escapesAnnotation = it.annotations.findAnnotation(FQ_NAME_ESCAPES)
|
||||||
val pointsToAnnotation = it.annotations.findAnnotation(FQ_NAME_POINTS_TO)
|
val pointsToAnnotation = it.annotations.findAnnotation(FQ_NAME_POINTS_TO)
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
|||||||
+4
-7
@@ -13,8 +13,6 @@ import org.jetbrains.kotlin.backend.common.push
|
|||||||
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
import org.jetbrains.kotlin.backend.common.lower.createIrBuilder
|
||||||
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
import org.jetbrains.kotlin.backend.common.lower.irBlock
|
||||||
import org.jetbrains.kotlin.backend.konan.*
|
import org.jetbrains.kotlin.backend.konan.*
|
||||||
import org.jetbrains.kotlin.backend.konan.descriptors.isInterface
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
|
||||||
import org.jetbrains.kotlin.ir.IrElement
|
import org.jetbrains.kotlin.ir.IrElement
|
||||||
import org.jetbrains.kotlin.ir.builders.*
|
import org.jetbrains.kotlin.ir.builders.*
|
||||||
import org.jetbrains.kotlin.ir.declarations.*
|
import org.jetbrains.kotlin.ir.declarations.*
|
||||||
@@ -1312,7 +1310,6 @@ internal object Devirtualization {
|
|||||||
callSite.startOffset, callSite.endOffset,
|
callSite.startOffset, callSite.endOffset,
|
||||||
actualType,
|
actualType,
|
||||||
actualCallee.symbol,
|
actualCallee.symbol,
|
||||||
actualCallee.descriptor,
|
|
||||||
actualCallee.typeParameters.size,
|
actualCallee.typeParameters.size,
|
||||||
actualCallee.valueParameters.size,
|
actualCallee.valueParameters.size,
|
||||||
callSite.origin,
|
callSite.origin,
|
||||||
@@ -1369,8 +1366,8 @@ internal object Devirtualization {
|
|||||||
|| possibleCallees.any { it.receiverType is DataFlowIR.Type.External })
|
|| possibleCallees.any { it.receiverType is DataFlowIR.Type.External })
|
||||||
return expression
|
return expression
|
||||||
|
|
||||||
val descriptor = expression.descriptor
|
val callee = expression.symbol.owner
|
||||||
val owner = (descriptor.containingDeclaration as ClassDescriptor)
|
val owner = callee.parentAsClass
|
||||||
// TODO: Think how to evaluate different unfold factors (in terms of both execution speed and code size).
|
// TODO: Think how to evaluate different unfold factors (in terms of both execution speed and code size).
|
||||||
val classMaxUnfoldFactor = 3
|
val classMaxUnfoldFactor = 3
|
||||||
val interfaceMaxUnfoldFactor = 3
|
val interfaceMaxUnfoldFactor = 3
|
||||||
@@ -1383,7 +1380,7 @@ internal object Devirtualization {
|
|||||||
val startOffset = expression.startOffset
|
val startOffset = expression.startOffset
|
||||||
val endOffset = expression.endOffset
|
val endOffset = expression.endOffset
|
||||||
val function = expression.symbol.owner
|
val function = expression.symbol.owner
|
||||||
val type = if (descriptor.isSuspend)
|
val type = if (callee.isSuspend)
|
||||||
context.irBuiltIns.anyNType
|
context.irBuiltIns.anyNType
|
||||||
else function.returnType
|
else function.returnType
|
||||||
val irBuilder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
|
val irBuilder = context.createIrBuilder(currentScope!!.scope.scopeOwnerSymbol, startOffset, endOffset)
|
||||||
@@ -1492,7 +1489,7 @@ internal object Devirtualization {
|
|||||||
typeOperand, typeOperandClassifier, expression)
|
typeOperand, typeOperandClassifier, expression)
|
||||||
}
|
}
|
||||||
with (coercion) {
|
with (coercion) {
|
||||||
return IrCallImpl(startOffset, endOffset, type, symbol, descriptor, typeArgumentsCount, origin).apply {
|
return IrCallImpl(startOffset, endOffset, type, symbol, typeArgumentsCount, origin).apply {
|
||||||
putValueArgument(0, castedExpression)
|
putValueArgument(0, castedExpression)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -30,9 +30,11 @@ import org.jetbrains.kotlin.resolve.OverridingUtil
|
|||||||
*/
|
*/
|
||||||
internal fun IrSimpleFunction.resolveFakeOverrideMaybeAbstract() = this.resolveFakeOverride(allowAbstract = true)
|
internal fun IrSimpleFunction.resolveFakeOverrideMaybeAbstract() = this.resolveFakeOverride(allowAbstract = true)
|
||||||
|
|
||||||
internal fun IrProperty.resolveFakeOverrideMaybeAbstract() = this.getter!!.resolveFakeOverrideMaybeAbstract().correspondingProperty!!
|
internal fun IrProperty.resolveFakeOverrideMaybeAbstract() =
|
||||||
|
this.getter!!.resolveFakeOverrideMaybeAbstract().correspondingPropertySymbol!!.owner
|
||||||
|
|
||||||
internal fun IrField.resolveFakeOverrideMaybeAbstract() = this.correspondingProperty!!.getter!!.resolveFakeOverrideMaybeAbstract().correspondingProperty!!.backingField
|
internal fun IrField.resolveFakeOverrideMaybeAbstract() =
|
||||||
|
this.correspondingPropertySymbol!!.owner.resolveFakeOverrideMaybeAbstract().backingField
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of given method.
|
* Implementation of given method.
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@ import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns
|
|||||||
|
|
||||||
class KonanGlobalDeclarationTable(builtIns: IrBuiltIns) : GlobalDeclarationTable(KonanMangler) {
|
class KonanGlobalDeclarationTable(builtIns: IrBuiltIns) : GlobalDeclarationTable(KonanMangler) {
|
||||||
init {
|
init {
|
||||||
loadKnownBuiltins(builtIns, 0)
|
loadKnownBuiltins(builtIns)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -33,7 +33,7 @@ class KonanIrLinker(
|
|||||||
symbolTable: SymbolTable,
|
symbolTable: SymbolTable,
|
||||||
forwardModuleDescriptor: ModuleDescriptor?,
|
forwardModuleDescriptor: ModuleDescriptor?,
|
||||||
exportedDependencies: List<ModuleDescriptor>
|
exportedDependencies: List<ModuleDescriptor>
|
||||||
) : KotlinIrLinker(logger, builtIns, symbolTable, exportedDependencies, forwardModuleDescriptor, 0L),
|
) : KotlinIrLinker(logger, builtIns, symbolTable, exportedDependencies, forwardModuleDescriptor, KonanMangler),
|
||||||
DescriptorUniqIdAware by DeserializedDescriptorUniqIdAware {
|
DescriptorUniqIdAware by DeserializedDescriptorUniqIdAware {
|
||||||
|
|
||||||
override val descriptorReferenceDeserializer =
|
override val descriptorReferenceDeserializer =
|
||||||
|
|||||||
+1
-1
@@ -254,7 +254,7 @@ fun IrBuilderWithScope.irCall(irFunction: IrFunction, typeArguments: List<IrType
|
|||||||
internal fun irCall(startOffset: Int, endOffset: Int, irFunction: IrFunction, typeArguments: List<IrType>): IrCall =
|
internal fun irCall(startOffset: Int, endOffset: Int, irFunction: IrFunction, typeArguments: List<IrType>): IrCall =
|
||||||
IrCallImpl(
|
IrCallImpl(
|
||||||
startOffset, endOffset, irFunction.substitutedReturnType(typeArguments),
|
startOffset, endOffset, irFunction.substitutedReturnType(typeArguments),
|
||||||
irFunction.symbol, irFunction.descriptor.substitute(typeArguments), typeArguments.size
|
irFunction.symbol, typeArguments.size
|
||||||
).apply {
|
).apply {
|
||||||
typeArguments.forEachIndexed { index, irType ->
|
typeArguments.forEachIndexed { index, irType ->
|
||||||
this.putTypeArgument(index, irType)
|
this.putTypeArgument(index, irType)
|
||||||
|
|||||||
+6
-6
@@ -18,12 +18,12 @@
|
|||||||
buildKotlinVersion=1.3.70-dev-1070
|
buildKotlinVersion=1.3.70-dev-1070
|
||||||
buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1070,branch:default:any,pinned:true/artifacts/content/maven
|
buildKotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1070,branch:default:any,pinned:true/artifacts/content/maven
|
||||||
remoteRoot=konan_tests
|
remoteRoot=konan_tests
|
||||||
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1438,branch:default:any,pinned:true/artifacts/content/maven
|
kotlinCompilerRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1526,branch:default:any,pinned:true/artifacts/content/maven
|
||||||
kotlinVersion=1.3.70-dev-1438
|
kotlinVersion=1.3.70-dev-1526
|
||||||
kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1438,branch:default:any,pinned:true/artifacts/content/maven
|
kotlinStdlibRepo=https://teamcity.jetbrains.com/guestAuth/app/rest/builds/buildType:(id:Kotlin_KotlinPublic_Compiler),number:1.3.70-dev-1526,branch:default:any,pinned:true/artifacts/content/maven
|
||||||
kotlinStdlibVersion=1.3.70-dev-1438
|
kotlinStdlibVersion=1.3.70-dev-1526
|
||||||
kotlinStdlibTestsVersion=1.3.70-dev-1438
|
kotlinStdlibTestsVersion=1.3.70-dev-1526
|
||||||
testKotlinCompilerVersion=1.3.70-dev-1438
|
testKotlinCompilerVersion=1.3.70-dev-1526
|
||||||
konanVersion=1.3.70
|
konanVersion=1.3.70
|
||||||
|
|
||||||
# A version of Xcode required to build the Kotlin/Native compiler.
|
# A version of Xcode required to build the Kotlin/Native compiler.
|
||||||
|
|||||||
@@ -80,7 +80,8 @@ internal class KonanLibraryProperResolver(
|
|||||||
distributionKlib,
|
distributionKlib,
|
||||||
localKonanDir,
|
localKonanDir,
|
||||||
skipCurrentDir,
|
skipCurrentDir,
|
||||||
logger
|
logger,
|
||||||
|
emptyList()
|
||||||
), SearchPathResolverWithTarget<KonanLibrary>
|
), SearchPathResolverWithTarget<KonanLibrary>
|
||||||
{
|
{
|
||||||
override fun libraryBuilder(file: File, isDefault: Boolean) = createKonanLibrary(file, target, isDefault)
|
override fun libraryBuilder(file: File, isDefault: Boolean) = createKonanLibrary(file, target, isDefault)
|
||||||
|
|||||||
Reference in New Issue
Block a user