Add more runtime, avoid codegen for interfaces. (#47)
* Add more runtime, avoid codegen for interfaces. * backend: fix bug in RTTIGenerator kotlin.Nothing has no supertypes * runtime: enable kotlin.Nothing
This commit is contained in:
+6
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.backend.konan.llvm
|
||||
|
||||
import kotlin_native.interop.*
|
||||
import llvm.*
|
||||
import org.jetbrains.kotlin.backend.konan.isInterface
|
||||
import org.jetbrains.kotlin.backend.konan.isIntrinsic
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
@@ -204,6 +205,11 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
|
||||
return
|
||||
}
|
||||
|
||||
if (declaration.descriptor.isInterface) {
|
||||
// Do not generate any code for interfaces.
|
||||
return
|
||||
}
|
||||
|
||||
super.visitClass(declaration)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
val superVtableEntries = if (KotlinBuiltIns.isAny(classDesc)) {
|
||||
val superVtableEntries = if (KotlinBuiltIns.isSpecialClassWithNoSupertypes(classDesc)) {
|
||||
emptyList()
|
||||
} else {
|
||||
getVtableEntries(classDesc.getSuperClassOrAny())
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
package kotlin
|
||||
|
||||
@ExportTypeInfo("theArrayTypeInfo")
|
||||
class Array<T> : Cloneable {
|
||||
// Constructors are handled with compiler magic.
|
||||
private constructor() {}
|
||||
|
||||
public val size: Int
|
||||
get() = getArrayLength()
|
||||
|
||||
@SymbolName("Kotlin_Array_clone")
|
||||
external public override fun clone(): Any
|
||||
|
||||
@SymbolName("Kotlin_Array_get")
|
||||
external public operator fun get(index: Int): T
|
||||
|
||||
@SymbolName("Kotlin_Array_set")
|
||||
external public operator fun set(index: Int, value: T): Unit
|
||||
|
||||
@SymbolName("Kotlin_Array_getArrayLength")
|
||||
external private fun getArrayLength(): Int
|
||||
}
|
||||
@@ -1,26 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
@ExportTypeInfo("theArrayTypeInfo")
|
||||
class Array<T> : Cloneable {
|
||||
// Constructors are handled with compiler magic.
|
||||
private constructor() {}
|
||||
|
||||
public val size: Int
|
||||
get() = getArrayLength()
|
||||
|
||||
@SymbolName("Kotlin_Array_clone")
|
||||
external public override fun clone(): Any
|
||||
|
||||
@SymbolName("Kotlin_Array_get")
|
||||
external public operator fun get(index: Int): T
|
||||
|
||||
@SymbolName("Kotlin_Array_set")
|
||||
external public operator fun set(index: Int, value: T): Unit
|
||||
|
||||
@SymbolName("Kotlin_Array_getArrayLength")
|
||||
external private fun getArrayLength(): Int
|
||||
}
|
||||
|
||||
@ExportTypeInfo("theByteArrayTypeInfo")
|
||||
class ByteArray : Cloneable {
|
||||
// Constructors are handled with compiler magic.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* The common base class of all enum classes.
|
||||
* See the [Kotlin language documentation](http://kotlinlang.org/docs/reference/enum-classes.html) for more
|
||||
* information on enum classes.
|
||||
*/
|
||||
/*
|
||||
public abstract class Enum<E : Enum<E>>(name: String, ordinal: Int): Comparable<E> {
|
||||
companion object {}
|
||||
|
||||
/**
|
||||
* Returns the name of this enum constant, exactly as declared in its enum declaration.
|
||||
*/
|
||||
public final val name: String
|
||||
|
||||
/**
|
||||
* Returns the ordinal of this enumeration constant (its position in its enum declaration, where the initial constant
|
||||
* is assigned an ordinal of zero).
|
||||
*/
|
||||
public final val ordinal: Int
|
||||
|
||||
public override final fun compareTo(other: E): Int
|
||||
|
||||
/**
|
||||
* Throws an exception since enum constants cannot be cloned.
|
||||
* This method prevents enum classes from inheriting from [Cloneable].
|
||||
*/
|
||||
protected final fun clone(): Any
|
||||
|
||||
public override final fun equals(other: Any?): Boolean
|
||||
public override final fun hashCode(): Int
|
||||
public override fun toString(): String
|
||||
} */
|
||||
@@ -0,0 +1,86 @@
|
||||
package kotlin.collections
|
||||
|
||||
/**
|
||||
* An iterator over a collection or another entity that can be represented as a sequence of elements.
|
||||
* Allows to sequentially access the elements.
|
||||
*/
|
||||
public interface Iterator<out T> {
|
||||
/**
|
||||
* Returns the next element in the iteration.
|
||||
*/
|
||||
public operator fun next(): T
|
||||
|
||||
/**
|
||||
* Returns `true` if the iteration has more elements.
|
||||
*/
|
||||
public operator fun hasNext(): Boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* An iterator over a mutable collection. Provides the ability to remove elements while iterating.
|
||||
* @see MutableCollection.iterator
|
||||
*/
|
||||
public interface MutableIterator<out T> : Iterator<T> {
|
||||
/**
|
||||
* Removes from the underlying collection the last element returned by this iterator.
|
||||
*/
|
||||
public fun remove(): Unit
|
||||
}
|
||||
|
||||
/**
|
||||
* An iterator over a collection that supports indexed access.
|
||||
* @see List.listIterator
|
||||
*/
|
||||
public interface ListIterator<out T> : Iterator<T> {
|
||||
// Query Operations
|
||||
override fun next(): T
|
||||
override fun hasNext(): Boolean
|
||||
|
||||
/**
|
||||
* Returns `true` if there are elements in the iteration before the current element.
|
||||
*/
|
||||
public fun hasPrevious(): Boolean
|
||||
|
||||
/**
|
||||
* Returns the previous element in the iteration and moves the cursor position backwards.
|
||||
*/
|
||||
public fun previous(): T
|
||||
|
||||
/**
|
||||
* Returns the index of the element that would be returned by a subsequent call to [next].
|
||||
*/
|
||||
public fun nextIndex(): Int
|
||||
|
||||
/**
|
||||
* Returns the index of the element that would be returned by a subsequent call to [previous].
|
||||
*/
|
||||
public fun previousIndex(): Int
|
||||
}
|
||||
|
||||
/**
|
||||
* An iterator over a mutable collection that supports indexed access. Provides the ability
|
||||
* to add, modify and remove elements while iterating.
|
||||
*/
|
||||
public interface MutableListIterator<T> : ListIterator<T>, MutableIterator<T> {
|
||||
// Query Operations
|
||||
override fun next(): T
|
||||
override fun hasNext(): Boolean
|
||||
|
||||
// Modification Operations
|
||||
override fun remove(): Unit
|
||||
|
||||
/**
|
||||
* Replaces the last element returned by [next] or [previous] with the specified element [element].
|
||||
*/
|
||||
public fun set(element: T): Unit
|
||||
|
||||
/**
|
||||
* Adds the specified element [element] into the underlying collection immediately before the element that would be
|
||||
* returned by [next], if any, and after the element that would be returned by [previous], if any.
|
||||
* (If the collection contains no elements, the new element becomes the sole element in the collection.)
|
||||
* The new element is inserted before the implicit cursor: a subsequent call to [next] would be unaffected,
|
||||
* and a subsequent call to [previous] would return the new element. (This call increases by one the value \
|
||||
* that would be returned by a call to [nextIndex] or [previousIndex].)
|
||||
*/
|
||||
public fun add(element: T): Unit
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* Nothing has no instances. You can use Nothing to represent "a value that never exists": for example,
|
||||
* if a function has the return type of Nothing, it means that it never returns (always throws an exception).
|
||||
*/
|
||||
public class Nothing private constructor() {}
|
||||
Reference in New Issue
Block a user