-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aba336d
commit 70ffc25
Showing
42 changed files
with
434 additions
and
92 deletions.
There are no files selected for viewing
Submodule acceptance-tests
updated
from 922462 to 0a8ab4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
...er-plugin/src/kgp_1.8.0..2.0.0/kotlin/co/touchlab/skie/context/getBitcodeEmbeddingMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package co.touchlab.skie.context | ||
|
||
import co.touchlab.skie.configuration.SwiftCompilerConfiguration | ||
import org.jetbrains.kotlin.backend.konan.KonanConfigKeys | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
import org.jetbrains.kotlin.backend.konan.BitcodeEmbedding | ||
|
||
actual fun CompilerConfiguration.getBitcodeEmbeddingMode(): SwiftCompilerConfiguration.BitcodeEmbeddingMode { | ||
return when (this[KonanConfigKeys.BITCODE_EMBEDDING_MODE]) { | ||
BitcodeEmbedding.Mode.FULL -> SwiftCompilerConfiguration.BitcodeEmbeddingMode.Full | ||
BitcodeEmbedding.Mode.MARKER -> SwiftCompilerConfiguration.BitcodeEmbeddingMode.Marker | ||
BitcodeEmbedding.Mode.NONE, null -> SwiftCompilerConfiguration.BitcodeEmbeddingMode.None | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...1.8.0..2.0.0/kotlin/co/touchlab/skie/kir/irbuilder/impl/symboltable/DummyIrConstructor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package co.touchlab.skie.kir.irbuilder.impl.symboltable | ||
|
||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor | ||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility | ||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI | ||
import org.jetbrains.kotlin.ir.declarations.IrConstructor | ||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin | ||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent | ||
import org.jetbrains.kotlin.ir.declarations.IrFactory | ||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter | ||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter | ||
import org.jetbrains.kotlin.ir.declarations.MetadataSource | ||
import org.jetbrains.kotlin.ir.expressions.IrBody | ||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall | ||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol | ||
import org.jetbrains.kotlin.ir.types.IrType | ||
import org.jetbrains.kotlin.name.Name | ||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource | ||
|
||
|
||
actual class DummyIrConstructor actual constructor(override val symbol: IrConstructorSymbol) : IrConstructor() { | ||
|
||
override var isPrimary: Boolean by unsupported() | ||
override val startOffset: Int by unsupported() | ||
override val endOffset: Int by unsupported() | ||
override val factory: IrFactory by unsupported() | ||
override var origin: IrDeclarationOrigin by unsupported() | ||
override var parent: IrDeclarationParent by unsupported() | ||
override var name: Name by unsupported() | ||
override var visibility: DescriptorVisibility by unsupported() | ||
override var body: IrBody? by unsupported() | ||
override var contextReceiverParametersCount: Int by unsupported() | ||
|
||
@ObsoleteDescriptorBasedAPI | ||
override val descriptor: ClassConstructorDescriptor by unsupported() | ||
override var dispatchReceiverParameter: IrValueParameter? by unsupported() | ||
override var extensionReceiverParameter: IrValueParameter? by unsupported() | ||
override var isExpect: Boolean by unsupported() | ||
override var isInline: Boolean by unsupported() | ||
override var returnType: IrType by unsupported() | ||
override var valueParameters: List<IrValueParameter> by unsupported() | ||
override val containerSource: DeserializedContainerSource? by unsupported() | ||
override var metadata: MetadataSource? by unsupported() | ||
override var annotations: List<IrConstructorCall> by unsupported() | ||
override var isExternal: Boolean by unsupported() | ||
override var typeParameters: List<IrTypeParameter> by unsupported() | ||
} |
40 changes: 40 additions & 0 deletions
40
....0/kotlin/co/touchlab/skie/kir/irbuilder/impl/symboltable/IrBaseRebindablePublicSymbol.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package co.touchlab.skie.kir.irbuilder.impl.symboltable | ||
|
||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor | ||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor | ||
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner | ||
import org.jetbrains.kotlin.ir.symbols.IrBindableSymbol | ||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol | ||
import org.jetbrains.kotlin.ir.util.IdSignature | ||
import org.jetbrains.kotlin.ir.symbols.impl.IrPublicSymbolBase | ||
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterPublicSymbolImpl as KotlinIrTypeParameterPublicSymbolImpl | ||
|
||
actual fun IrTypeParameterPublicSymbolImpl( | ||
signature: IdSignature, | ||
descriptor: TypeParameterDescriptor, | ||
): IrTypeParameterSymbol { | ||
return KotlinIrTypeParameterPublicSymbolImpl(signature, descriptor) | ||
} | ||
|
||
actual abstract class IrBaseRebindablePublicSymbol<out Descriptor : DeclarationDescriptor, Owner : IrSymbolOwner> actual constructor( | ||
signature: IdSignature, | ||
descriptor: Descriptor, | ||
) : IrBindableSymbol<Descriptor, Owner>, IrPublicSymbolBase<Descriptor>(signature, descriptor) { | ||
|
||
private var _owner: Owner? = null | ||
actual override val owner: Owner | ||
get() = _owner ?: throw IllegalStateException("Symbol is not bound") | ||
|
||
actual override fun bind(owner: Owner) { | ||
this._owner = owner | ||
} | ||
|
||
actual fun unbind() { | ||
this._owner = null | ||
} | ||
|
||
actual override val isBound: Boolean | ||
get() = _owner != null | ||
|
||
actual override var privateSignature: IdSignature? = null | ||
} |
26 changes: 26 additions & 0 deletions
26
...1.8.0..2.0.0/kotlin/co/touchlab/skie/kir/type/translation/KirDeclarationTypeTranslator.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package co.touchlab.skie.kir.type.translation | ||
|
||
import co.touchlab.skie.oir.type.OirType | ||
import co.touchlab.skie.oir.type.PointerOirType | ||
import co.touchlab.skie.oir.type.PrimitiveOirType | ||
import co.touchlab.skie.oir.type.VoidOirType | ||
import org.jetbrains.kotlin.backend.konan.binaryRepresentationIsNullable | ||
import org.jetbrains.kotlin.backend.konan.objcexport.ObjCValueType | ||
import org.jetbrains.kotlin.types.KotlinType | ||
|
||
actual fun ObjCValueType.mapToOir(kotlinType: KotlinType): OirType = | ||
when (this) { | ||
ObjCValueType.BOOL -> PrimitiveOirType.BOOL | ||
ObjCValueType.UNICHAR -> PrimitiveOirType.unichar | ||
ObjCValueType.CHAR -> PrimitiveOirType.int8_t | ||
ObjCValueType.SHORT -> PrimitiveOirType.int16_t | ||
ObjCValueType.INT -> PrimitiveOirType.int32_t | ||
ObjCValueType.LONG_LONG -> PrimitiveOirType.int64_t | ||
ObjCValueType.UNSIGNED_CHAR -> PrimitiveOirType.uint8_t | ||
ObjCValueType.UNSIGNED_SHORT -> PrimitiveOirType.uint16_t | ||
ObjCValueType.UNSIGNED_INT -> PrimitiveOirType.uint32_t | ||
ObjCValueType.UNSIGNED_LONG_LONG -> PrimitiveOirType.uint64_t | ||
ObjCValueType.FLOAT -> PrimitiveOirType.float | ||
ObjCValueType.DOUBLE -> PrimitiveOirType.double | ||
ObjCValueType.POINTER -> PointerOirType(VoidOirType, kotlinType.binaryRepresentationIsNullable()) | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
...r/linker-plugin/src/kgp_2.0.20/kotlin/co/touchlab/skie/context/getBitcodeEmbeddingMode.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package co.touchlab.skie.context | ||
|
||
import co.touchlab.skie.configuration.SwiftCompilerConfiguration | ||
import org.jetbrains.kotlin.config.CompilerConfiguration | ||
|
||
actual fun CompilerConfiguration.getBitcodeEmbeddingMode(): SwiftCompilerConfiguration.BitcodeEmbeddingMode { | ||
return SwiftCompilerConfiguration.BitcodeEmbeddingMode.None | ||
} |
44 changes: 44 additions & 0 deletions
44
...0/kotlin/co/touchlab/skie/kir/irbuilder/impl/symboltable/DummyIrConstructor.kgp_2.0.20.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package co.touchlab.skie.kir.irbuilder.impl.symboltable | ||
|
||
import org.jetbrains.kotlin.descriptors.ClassConstructorDescriptor | ||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility | ||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI | ||
import org.jetbrains.kotlin.ir.declarations.IrConstructor | ||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin | ||
import org.jetbrains.kotlin.ir.declarations.IrFactory | ||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter | ||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter | ||
import org.jetbrains.kotlin.ir.declarations.MetadataSource | ||
import org.jetbrains.kotlin.ir.expressions.IrBody | ||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall | ||
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol | ||
import org.jetbrains.kotlin.ir.types.IrType | ||
import org.jetbrains.kotlin.name.Name | ||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource | ||
|
||
actual class DummyIrConstructor actual constructor(override val symbol: IrConstructorSymbol) : IrConstructor() { | ||
|
||
override var isPrimary: Boolean by unsupported() | ||
override val startOffset: Int by unsupported() | ||
override val endOffset: Int by unsupported() | ||
override val factory: IrFactory by unsupported() | ||
override var origin: IrDeclarationOrigin by unsupported() | ||
override var name: Name by unsupported() | ||
override var visibility: DescriptorVisibility by unsupported() | ||
override var body: IrBody? by unsupported() | ||
override var contextReceiverParametersCount: Int by unsupported() | ||
|
||
@ObsoleteDescriptorBasedAPI | ||
override val descriptor: ClassConstructorDescriptor by unsupported() | ||
override var dispatchReceiverParameter: IrValueParameter? by unsupported() | ||
override var extensionReceiverParameter: IrValueParameter? by unsupported() | ||
override var isExpect: Boolean by unsupported() | ||
override var isInline: Boolean by unsupported() | ||
override var returnType: IrType by unsupported() | ||
override var valueParameters: List<IrValueParameter> by unsupported() | ||
override val containerSource: DeserializedContainerSource? by unsupported() | ||
override var metadata: MetadataSource? by unsupported() | ||
override var annotations: List<IrConstructorCall> by unsupported() | ||
override var isExternal: Boolean by unsupported() | ||
override var typeParameters: List<IrTypeParameter> by unsupported() | ||
} |
59 changes: 59 additions & 0 deletions
59
...otlin/co/touchlab/skie/kir/irbuilder/impl/symboltable/DummyIrSimpleFunction.kgp_2.0.20.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package co.touchlab.skie.kir.irbuilder.impl.symboltable | ||
|
||
import org.jetbrains.kotlin.descriptors.DescriptorVisibility | ||
import org.jetbrains.kotlin.descriptors.FunctionDescriptor | ||
import org.jetbrains.kotlin.descriptors.Modality | ||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI | ||
import org.jetbrains.kotlin.ir.declarations.IrAttributeContainer | ||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationOrigin | ||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent | ||
import org.jetbrains.kotlin.ir.declarations.IrFactory | ||
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction | ||
import org.jetbrains.kotlin.ir.declarations.IrTypeParameter | ||
import org.jetbrains.kotlin.ir.declarations.IrValueParameter | ||
import org.jetbrains.kotlin.ir.declarations.MetadataSource | ||
import org.jetbrains.kotlin.ir.expressions.IrBody | ||
import org.jetbrains.kotlin.ir.expressions.IrConstructorCall | ||
import org.jetbrains.kotlin.ir.symbols.IrPropertySymbol | ||
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol | ||
import org.jetbrains.kotlin.ir.types.IrType | ||
import org.jetbrains.kotlin.name.Name | ||
import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource | ||
|
||
actual class DummyIrSimpleFunction actual constructor( | ||
override val symbol: IrSimpleFunctionSymbol, | ||
) : IrSimpleFunction() { | ||
|
||
override var startOffset: Int by unsupported() | ||
override var endOffset: Int by unsupported() | ||
override var attributeOwnerId: IrAttributeContainer by unsupported() | ||
override val factory: IrFactory by unsupported() | ||
override var origin: IrDeclarationOrigin by unsupported() | ||
override var originalBeforeInline: IrAttributeContainer? by unsupported() | ||
override var name: Name by unsupported() | ||
override var visibility: DescriptorVisibility by unsupported() | ||
override var body: IrBody? by unsupported() | ||
override var contextReceiverParametersCount: Int by unsupported() | ||
|
||
@ObsoleteDescriptorBasedAPI | ||
override val descriptor: FunctionDescriptor by unsupported() | ||
override var dispatchReceiverParameter: IrValueParameter? by unsupported() | ||
override var extensionReceiverParameter: IrValueParameter? by unsupported() | ||
override var isExpect: Boolean by unsupported() | ||
override var isInline: Boolean by unsupported() | ||
override var returnType: IrType by unsupported() | ||
override var valueParameters: List<IrValueParameter> by unsupported() | ||
override val containerSource: DeserializedContainerSource? by unsupported() | ||
override var metadata: MetadataSource? by unsupported() | ||
override var annotations: List<IrConstructorCall> by unsupported() | ||
override var overriddenSymbols: List<IrSimpleFunctionSymbol> by unsupported() | ||
override var modality: Modality by unsupported() | ||
override var isExternal: Boolean by unsupported() | ||
override var correspondingPropertySymbol: IrPropertySymbol? by unsupported() | ||
override var isFakeOverride: Boolean by unsupported() | ||
override var isInfix: Boolean by unsupported() | ||
override var isOperator: Boolean by unsupported() | ||
override var isSuspend: Boolean by unsupported() | ||
override var isTailrec: Boolean by unsupported() | ||
override var typeParameters: List<IrTypeParameter> by unsupported() | ||
} |
99 changes: 99 additions & 0 deletions
99
...20/kotlin/co/touchlab/skie/kir/irbuilder/impl/symboltable/IrBaseRebindablePublicSymbol.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package co.touchlab.skie.kir.irbuilder.impl.symboltable | ||
|
||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor | ||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor | ||
import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor | ||
import org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI | ||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration | ||
import org.jetbrains.kotlin.ir.declarations.IrSymbolOwner | ||
import org.jetbrains.kotlin.ir.descriptors.toIrBasedDescriptor | ||
import org.jetbrains.kotlin.ir.symbols.IrBindableSymbol | ||
import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol | ||
import org.jetbrains.kotlin.ir.symbols.impl.IrTypeParameterSymbolImpl | ||
import org.jetbrains.kotlin.ir.symbols.isPublicApi | ||
import org.jetbrains.kotlin.ir.util.IdSignature | ||
import org.jetbrains.kotlin.ir.util.render | ||
|
||
actual fun IrTypeParameterPublicSymbolImpl( | ||
signature: IdSignature, | ||
descriptor: TypeParameterDescriptor, | ||
): IrTypeParameterSymbol { | ||
return IrTypeParameterSymbolImpl(descriptor, signature) | ||
} | ||
|
||
actual abstract class IrBaseRebindablePublicSymbol<out Descriptor : DeclarationDescriptor, Owner : IrSymbolOwner> actual constructor( | ||
actual override val signature: IdSignature, | ||
descriptor: Descriptor, | ||
) : IrBindableSymbol<Descriptor, Owner> { | ||
|
||
// private var _owner: B? = null | ||
// override val owner: B | ||
// get() = _owner ?: throw IllegalStateException("Symbol is not bound") | ||
// | ||
// override fun bind(owner: B) { | ||
// this._owner = owner | ||
// } | ||
// | ||
// fun unbind() { | ||
// this._owner = null | ||
// } | ||
// | ||
// override val isBound: Boolean | ||
// get() = _owner != null | ||
// | ||
// override var privateSignature: IdSignature? = null | ||
|
||
private val _descriptor: Descriptor? = descriptor | ||
|
||
@ObsoleteDescriptorBasedAPI | ||
@Suppress("UNCHECKED_CAST") | ||
actual override val descriptor: Descriptor | ||
get() = _descriptor ?: (owner as IrDeclaration).toIrBasedDescriptor() as Descriptor | ||
|
||
@ObsoleteDescriptorBasedAPI | ||
actual override val hasDescriptor: Boolean | ||
get() = _descriptor != null | ||
|
||
private var _owner: Owner? = null | ||
actual override val owner: Owner | ||
get() = _owner ?: error("${javaClass.simpleName} is unbound. Signature: $signature") | ||
|
||
actual override var privateSignature: IdSignature? = null | ||
|
||
init { | ||
assert(descriptor == null || isOriginalDescriptor(descriptor)) { | ||
"Substituted descriptor $descriptor for ${descriptor!!.original}" | ||
} | ||
if (!isPublicApi && descriptor != null) { | ||
val containingDeclaration = descriptor.containingDeclaration | ||
assert(containingDeclaration == null || isOriginalDescriptor(containingDeclaration)) { | ||
"Substituted containing declaration: $containingDeclaration\nfor descriptor: $descriptor" | ||
} | ||
} | ||
} | ||
|
||
private fun isOriginalDescriptor(descriptor: DeclarationDescriptor): Boolean = | ||
// TODO fix declaring/referencing value parameters: compute proper original descriptor | ||
descriptor is ValueParameterDescriptor && isOriginalDescriptor(descriptor.containingDeclaration) || | ||
descriptor == descriptor.original | ||
|
||
actual override val isBound: Boolean | ||
get() = _owner != null | ||
|
||
actual override fun bind(owner: Owner) { | ||
this._owner = owner | ||
} | ||
|
||
actual fun unbind() { | ||
this._owner = null | ||
} | ||
|
||
override fun toString(): String { | ||
if (isBound) return owner.render() | ||
return if (isPublicApi) | ||
"Unbound public symbol ${this::class.java.simpleName}: $signature" | ||
else | ||
"Unbound private symbol " + | ||
if (_descriptor != null) "${this::class.java.simpleName}: $_descriptor" else super.toString() | ||
} | ||
} |
Oops, something went wrong.