Move compiler to new version, add primitive types. (#33)

This commit is contained in:
Nikolay Igotti
2016-11-03 15:31:33 +03:00
committed by GitHub
parent c6a5ec26d9
commit a2e4f0f467
19 changed files with 1217 additions and 21 deletions
+6 -5
View File
@@ -13,7 +13,8 @@ apply plugin: 'java'
apply plugin: 'kotlin'
apply plugin: org.jetbrains.kotlin.NativeInteropPlugin
String kotlinCompilerModule = 'org.jetbrains.kotlin:kotlin-compiler:1.1-20161025.164748-245'
String kotlinCompilerModule = 'org.jetbrains.kotlin:kotlin-compiler:1.1-20161102.121224-247'
// (gets applied to this project and all its subprojects)
allprojects {
@@ -84,13 +85,13 @@ String[] linkerOpts1() {
List<String> ldflags = new ArrayList<>()
if (System.properties['os.name'].startsWith("Linux"))
ldflags.addAll(["-L$llvmDir/lib",
"-Wl,-Bstatic", "-Wl,--whole-archive"]
"-Wl,-Bstatic", "-Wl,--whole-archive"]
+ libs
+ ["-Wl,--no-whole-archive", "-Wl,-Bdynamic",
"-L$libffiDir/lib -lffi",
"-lrt", "-ldl","-lpthread", "-lz", "-lm"])
"-L$libffiDir/lib -lffi",
"-lrt", "-ldl","-lpthread", "-lz", "-lm"])
else
ldflags.addAll(["-L$llvmDir/lib", "-lc++"]
ldflags.addAll(["-L$llvmDir/lib", "-lc++"]
+ libs
+ ["-L$libffiDir/lib", "-lffi"])
ArrayList<String> strldflags = new ArrayList<>()
@@ -18,4 +18,17 @@ public class K2NativeCompilerArguments extends CommonCompilerArguments {
@ValueDescription("<path>")
public String[] headers;
public K2NativeCompilerArguments() {
}
public K2NativeCompilerArguments(K2NativeCompilerArguments arguments) {
super(arguments);
this.outputFile = arguments.outputFile;
this.runtimeFile = arguments.runtimeFile;
this.headers = arguments.headers;
}
public CommonCompilerArguments copy() {
return new K2NativeCompilerArguments(this);
}
}
@@ -4,10 +4,7 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.descriptors.Modality
import org.jetbrains.kotlin.resolve.OverridingUtil
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.descriptorUtil.classId
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperClassNotAny
import org.jetbrains.kotlin.resolve.descriptorUtil.getSuperInterfaces
import org.jetbrains.kotlin.resolve.descriptorUtil.*
/**
* List of all implemented interfaces (including those which implemented by a super class)
@@ -33,4 +30,15 @@ internal val FunctionDescriptor.implementation: FunctionDescriptor
val filtered = OverridingUtil.filterOutOverridden(overridden)
return filtered.first { it.modality != Modality.ABSTRACT } as FunctionDescriptor
}
}
}
private val intrinsicTypes = setOf(
"kotlin.Unit",
"kotlin.Boolean", "kotlin.Char",
"kotlin.Byte", "kotlin.Short",
"kotlin.Int", "kotlin.Long",
"kotlin.Float", "kotlin.Double"
)
internal val ClassDescriptor.isIntrinsic: Boolean
get() = this.fqNameSafe.asString() in intrinsicTypes
@@ -165,4 +165,7 @@ internal interface ContextUtils {
val FqName.localHash: LocalHash
get() = this.toString().localHash
val pointerSize: Int
get() = LLVMPointerSize(llvmTargetData)
}
@@ -12,7 +12,9 @@ internal fun getLLVMType(type: KotlinType): LLVMOpaqueType {
KotlinBuiltIns.isInt(type) -> LLVMInt32Type()
KotlinBuiltIns.isLong(type) -> LLVMInt64Type()
KotlinBuiltIns.isUnit(type) -> LLVMVoidType() // TODO: handle Unit parameter case
KotlinBuiltIns.isFloat(type) -> LLVMFloatType()
KotlinBuiltIns.isDouble(type) -> LLVMDoubleType()
!KotlinBuiltIns.isPrimitiveType(type) -> LLVMPointerType(LLVMInt8Type(), 0)
else -> throw NotImplementedError()
else -> throw NotImplementedError(type.toString() + " is not supported")
}!!
}
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.backend.native.llvm
import kotlin_native.interop.*
import llvm.*
import org.jetbrains.kotlin.backend.native.isIntrinsic
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.impl.LazyClassReceiverParameterDescriptor
@@ -12,6 +13,7 @@ import org.jetbrains.kotlin.ir.expressions.*
import org.jetbrains.kotlin.ir.visitors.IrElementVisitorVoid
import org.jetbrains.kotlin.ir.visitors.acceptChildrenVoid
import org.jetbrains.kotlin.ir.visitors.acceptVoid
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
fun emitLLVM(module: IrModuleFragment, runtimeFile: String, outFile: String) {
@@ -51,6 +53,11 @@ internal class RTTIGeneratorVisitor(context: Context) : IrElementVisitorVoid {
return
}
if (declaration.descriptor.isIntrinsic) {
// do not generate any code for intrinsic classes as they require special handling
return
}
generator.generate(declaration.descriptor)
}
@@ -106,6 +113,11 @@ internal class CodeGeneratorVisitor(val context: Context) : IrElementVisitorVoid
return
}
if (declaration.descriptor.isIntrinsic) {
// do not generate any code for intrinsic classes as they require special handling
return
}
super.visitClass(declaration)
}
@@ -26,7 +26,8 @@ internal val ClassDescriptor.symbolName: String
get() = when (this.kind) {
CLASS -> "kclass:"
INTERFACE -> "kinf:"
else -> TODO("fixme")
OBJECT -> "kclass:"
else -> TODO("fixme: " + this.kind)
} + fqNameSafe
internal val ClassDescriptor.typeInfoSymbolName: String
@@ -128,11 +128,12 @@ internal class RTTIGenerator(override val context: Context) : ContextUtils {
}
private val arrayClasses = mapOf(
Pair("kotlin.ByteArray", -1),
Pair("kotlin.CharArray", -2),
Pair("kotlin.IntArray", -4),
Pair("kotlin.String", -1)
);
"kotlin.Array" to -pointerSize,
"kotlin.ByteArray" to -1,
"kotlin.CharArray" to -2,
"kotlin.IntArray" to -4,
"kotlin.String" to -1
)
private fun getInstanceSize(classType: LLVMOpaqueType?, className: FqName) : Int {
val arraySize = arrayClasses.get(className.asString());
+28
View File
@@ -28,6 +28,34 @@ ArrayHeader* Kotlin_Any_toString(const ObjHeader* thiz) {
// Arrays.kt
// TODO: those must be compiler intrinsics afterwards.
KRef Kotlin_Array_get(const ArrayHeader* obj, KInt index) {
if (static_cast<uint32_t>(index) >= obj->count_) {
ThrowArrayIndexOutOfBoundsException();
}
return *ArrayAddressOfElementAt(obj, index);
}
void Kotlin_Array_set(ArrayHeader* obj, KInt index, KRef value) {
if (static_cast<uint32_t>(index) >= obj->count_) {
ThrowArrayIndexOutOfBoundsException();
}
*ArrayAddressOfElementAt(obj, index) = value;
}
ArrayHeader* Kotlin_Array_clone(const ArrayHeader* array) {
uint32_t length = ArraySizeBytes(array);
ArrayHeader* result = ArrayContainer(theArrayTypeInfo, length).GetPlace();
memcpy(
ArrayAddressOfElementAt(result, 0),
ArrayAddressOfElementAt(array, 0),
length);
return result;
}
KInt Kotlin_Array_getArrayLength(const ArrayHeader* array) {
return array->count_;
}
KByte Kotlin_ByteArray_get(const ArrayHeader* obj, KInt index) {
if (static_cast<uint32_t>(index) >= obj->count_) {
ThrowArrayIndexOutOfBoundsException();
+15
View File
@@ -10,6 +10,8 @@ typedef uint16_t KChar;
// Note that it is signed.
typedef int32_t KInt;
typedef ObjHeader* KRef;
// Optimized versions not accessing type info.
inline KByte* ByteArrayAddressOfElementAt(ArrayHeader* obj, KInt index) {
return reinterpret_cast<KByte*>(obj + 1) + index;
@@ -37,6 +39,14 @@ inline const KInt* IntArrayAddressOfElementAt(const ArrayHeader* obj, KInt index
return reinterpret_cast<const KInt*>(obj + 1) + index;
}
inline KRef* ArrayAddressOfElementAt(ArrayHeader* obj, KInt index) {
return reinterpret_cast<KRef*>(obj + 1) + index;
}
inline const KRef* ArrayAddressOfElementAt(const ArrayHeader* obj, KInt index) {
return reinterpret_cast<const KRef*>(obj + 1) + index;
}
#ifdef __cplusplus
extern "C" {
#endif
@@ -48,6 +58,11 @@ ArrayHeader* Kotlin_Any_toString(const ObjHeader* thiz);
// Arrays.kt
// TODO: those must be compiler intrinsics afterwards.
ArrayHeader* Kotlin_Array_clone(const ArrayHeader* thiz);
KRef Kotlin_Array_get(const ArrayHeader* thiz, KInt index);
void Kotlin_Array_set(ArrayHeader* thiz, KInt index, KRef value);
KInt Kotlin_Array_getArrayLength(const ArrayHeader* thiz);
ArrayHeader* Kotlin_ByteArray_clone(const ArrayHeader* thiz);
KByte Kotlin_ByteArray_get(const ArrayHeader* thiz, KInt index);
void Kotlin_ByteArray_set(ArrayHeader* thiz, KInt index, KByte value);
+1
View File
@@ -9,6 +9,7 @@ extern "C" {
extern const TypeInfo* theAnyTypeInfo;
extern const TypeInfo* theCloneableTypeInfo;
extern const TypeInfo* theArrayTypeInfo;
extern const TypeInfo* theByteArrayTypeInfo;
extern const TypeInfo* theCharArrayTypeInfo;
extern const TypeInfo* theIntArrayTypeInfo;
+42
View File
@@ -0,0 +1,42 @@
package kotlin
/**
* Superclass for all platform classes representing numeric values.
*/
public abstract class Number {
/**
* Returns the value of this number as a [Double], which may involve rounding.
*/
public abstract fun toDouble(): Double
/**
* Returns the value of this number as a [Float], which may involve rounding.
*/
public abstract fun toFloat(): Float
/**
* Returns the value of this number as a [Long], which may involve rounding or truncation.
*/
public abstract fun toLong(): Long
/**
* Returns the value of this number as an [Int], which may involve rounding or truncation.
*/
public abstract fun toInt(): Int
/**
* Returns the [Char] with the numeric value equal to this number, truncated to 16 bits if appropriate.
*/
public abstract fun toChar(): Char
/**
* Returns the value of this number as a [Short], which may involve rounding or truncation.
*/
public abstract fun toShort(): Short
/**
* Returns the value of this number as a [Byte], which may involve rounding or truncation.
*/
public abstract fun toByte(): Byte
}
+21
View File
@@ -1,5 +1,26 @@
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.
+29
View File
@@ -0,0 +1,29 @@
package kotlin
/**
* Represents a value which is either `true` or `false`. On the JVM, non-nullable values of this type are
* represented as values of the primitive type `boolean`.
*/
public class Boolean : Comparable<Boolean> {
/**
* Returns the inverse of this boolean.
*/
external public operator fun not(): Boolean
/**
* Performs a logical `and` operation between this Boolean and the [other] one.
*/
external public infix fun and(other: Boolean): Boolean
/**
* Performs a logical `or` operation between this Boolean and the [other] one.
*/
external public infix fun or(other: Boolean): Boolean
/**
* Performs a logical `xor` operation between this Boolean and the [other] one.
*/
external public infix fun xor(other: Boolean): Boolean
external public override fun compareTo(other: Boolean): Int
}
+80
View File
@@ -0,0 +1,80 @@
package kotlin
/**
* Represents a 16-bit Unicode character.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `char`.
*/
public class Char : Comparable<Char> {
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override fun compareTo(other: Char): Int
/** Adds the other Int value to this value resulting a Char. */
external public operator fun plus(other: Int): Char
/** Subtracts the other Char value from this value resulting an Int. */
external public operator fun minus(other: Char): Int
/** Subtracts the other Int value from this value resulting a Char. */
external public operator fun minus(other: Int): Char
/** Increments this value. */
external public operator fun inc(): Char
/** Decrements this value. */
external public operator fun dec(): Char
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Char): CharRange
/** Returns the value of this character as a `Byte`. */
external public fun toByte(): Byte
/** Returns the value of this character as a `Char`. */
external public fun toChar(): Char
/** Returns the value of this character as a `Short`. */
external public fun toShort(): Short
/** Returns the value of this character as a `Int`. */
external public fun toInt(): Int
/** Returns the value of this character as a `Long`. */
external public fun toLong(): Long
/** Returns the value of this character as a `Float`. */
external public fun toFloat(): Float
/** Returns the value of this character as a `Double`. */
external public fun toDouble(): Double
companion object {
/**
* The minimum value of a Unicode high-surrogate code unit.
*/
// public const val MIN_HIGH_SURROGATE: Char = '\uD800'
/**
* The maximum value of a Unicode high-surrogate code unit.
*/
// public const val MAX_HIGH_SURROGATE: Char = '\uDBFF'
/**
* The minimum value of a Unicode low-surrogate code unit.
*/
// public const val MIN_LOW_SURROGATE: Char = '\uDC00'
/**
* The maximum value of a Unicode low-surrogate code unit.
*/
// public const val MAX_LOW_SURROGATE: Char = '\uDFFF'
/**
* The minimum value of a Unicode surrogate code unit.
*/
// public const val MIN_SURROGATE: Char = MIN_HIGH_SURROGATE
/**
* The maximum value of a Unicode surrogate code unit.
*/
// public const val MAX_SURROGATE: Char = MAX_LOW_SURROGATE
}
}
@@ -0,0 +1,13 @@
package kotlin
/**
* Classes which inherit from this interface have a defined total ordering between their instances.
*/
public interface Comparable<in T> {
/**
* Compares this object with the specified object for order. Returns zero if this object is equal
* to the specified [other] object, a negative number if it's less than [other], or a positive number
* if it's greater than [other].
*/
public operator fun compareTo(other: T): Int
}
@@ -0,0 +1,921 @@
package kotlin
/**
* Represents a 8-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `byte`.
*/
public class Byte : Number(), Comparable<Byte> {
companion object {
/**
* A constant holding the minimum value an instance of Byte can have.
*/
public const val MIN_VALUE: Byte = -128
/**
* A constant holding the maximum value an instance of Byte can have.
*/
public const val MAX_VALUE: Byte = 127
}
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override operator fun compareTo(other: Byte): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Short): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Int): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Long): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Float): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Double): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Byte): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Short): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Int): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Long): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Float): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Double): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Byte): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Short): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Int): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Long): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Float): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Double): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Byte): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Short): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Int): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Long): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Float): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Double): Double
/** Divides this value by the other value. */
external public operator fun div(other: Byte): Int
/** Divides this value by the other value. */
external public operator fun div(other: Short): Int
/** Divides this value by the other value. */
external public operator fun div(other: Int): Int
/** Divides this value by the other value. */
external public operator fun div(other: Long): Long
/** Divides this value by the other value. */
external public operator fun div(other: Float): Float
/** Divides this value by the other value. */
external public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Byte): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Short): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Int): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Double): Double
/** Increments this value. */
external public operator fun inc(): Byte
/** Decrements this value. */
external public operator fun dec(): Byte
/** Returns this value. */
external public operator fun unaryPlus(): Int
/** Returns the negative of this value. */
external public operator fun unaryMinus(): Int
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Byte): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Short): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Int): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Long): LongRange
external public override fun toByte(): Byte
external public override fun toChar(): Char
external public override fun toShort(): Short
external public override fun toInt(): Int
external public override fun toLong(): Long
external public override fun toFloat(): Float
external public override fun toDouble(): Double
}
/**
* Represents a 16-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `short`.
*/
public class Short : Number(), Comparable<Short> {
companion object {
/**
* A constant holding the minimum value an instance of Short can have.
*/
// public const val MIN_VALUE: Short = -32768
/**
* A constant holding the maximum value an instance of Short can have.
*/
public const val MAX_VALUE: Short = 32767
}
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Byte): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override operator fun compareTo(other: Short): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Int): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Long): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Float): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Double): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Byte): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Short): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Int): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Long): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Float): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Double): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Byte): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Short): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Int): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Long): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Float): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Double): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Byte): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Short): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Int): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Long): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Float): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Double): Double
/** Divides this value by the other value. */
external public operator fun div(other: Byte): Int
/** Divides this value by the other value. */
external public operator fun div(other: Short): Int
/** Divides this value by the other value. */
external public operator fun div(other: Int): Int
/** Divides this value by the other value. */
external public operator fun div(other: Long): Long
/** Divides this value by the other value. */
external public operator fun div(other: Float): Float
/** Divides this value by the other value. */
external public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Byte): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Short): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Int): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Double): Double
/** Increments this value. */
external public operator fun inc(): Short
/** Decrements this value. */
external public operator fun dec(): Short
/** Returns this value. */
external public operator fun unaryPlus(): Int
/** Returns the negative of this value. */
external public operator fun unaryMinus(): Int
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Byte): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Short): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Int): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Long): LongRange
external public override fun toByte(): Byte
external public override fun toChar(): Char
external public override fun toShort(): Short
external public override fun toInt(): Int
external public override fun toLong(): Long
external public override fun toFloat(): Float
external public override fun toDouble(): Double
}
/**
* Represents a 32-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `int`.
*/
public class Int : Number(), Comparable<Int> {
companion object {
/**
* A constant holding the minimum value an instance of Int can have.
*/
public const val MIN_VALUE: Int = -2147483648
/**
* A constant holding the maximum value an instance of Int can have.
*/
public const val MAX_VALUE: Int = 2147483647
}
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Byte): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Short): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override operator fun compareTo(other: Int): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Long): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Float): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Double): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Byte): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Short): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Int): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Long): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Float): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Double): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Byte): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Short): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Int): Int
/** Subtracts the other value from this value. */
external public operator fun minus(other: Long): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Float): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Double): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Byte): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Short): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Int): Int
/** Multiplies this value by the other value. */
external public operator fun times(other: Long): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Float): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Double): Double
/** Divides this value by the other value. */
external public operator fun div(other: Byte): Int
/** Divides this value by the other value. */
external public operator fun div(other: Short): Int
/** Divides this value by the other value. */
external public operator fun div(other: Int): Int
/** Divides this value by the other value. */
external public operator fun div(other: Long): Long
/** Divides this value by the other value. */
external public operator fun div(other: Float): Float
/** Divides this value by the other value. */
external public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Byte): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Short): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Int): Int
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Double): Double
/** Increments this value. */
external public operator fun inc(): Int
/** Decrements this value. */
external public operator fun dec(): Int
/** Returns this value. */
external public operator fun unaryPlus(): Int
/** Returns the negative of this value. */
external public operator fun unaryMinus(): Int
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Byte): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Short): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Int): IntRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Long): LongRange
/** Shifts this value left by [bits]. */
external public infix fun shl(bitCount: Int): Int
/** Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit. */
external public infix fun shr(bitCount: Int): Int
/** Shifts this value right by [bits], filling the leftmost bits with zeros. */
external public infix fun ushr(bitCount: Int): Int
/** Performs a bitwise AND operation between the two values. */
external public infix fun and(other: Int): Int
/** Performs a bitwise OR operation between the two values. */
external public infix fun or(other: Int): Int
/** Performs a bitwise XOR operation between the two values. */
external public infix fun xor(other: Int): Int
/** Inverts the bits in this value/ */
external public fun inv(): Int
external public override fun toByte(): Byte
external public override fun toChar(): Char
external public override fun toShort(): Short
external public override fun toInt(): Int
external public override fun toLong(): Long
external public override fun toFloat(): Float
external public override fun toDouble(): Double
}
/**
* Represents a 64-bit signed integer.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `long`.
*/
public class Long : Number(), Comparable<Long> {
companion object {
/**
* A constant holding the minimum value an instance of Long can have.
*/
public const val MIN_VALUE: Long = -9223372036854775807L - 1L
/**
* A constant holding the maximum value an instance of Long can have.
*/
public const val MAX_VALUE: Long = 9223372036854775807L
}
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Byte): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Short): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Int): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override operator fun compareTo(other: Long): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Float): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Double): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Byte): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Short): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Int): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Long): Long
/** Adds the other value to this value. */
external public operator fun plus(other: Float): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Double): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Byte): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Short): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Int): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Long): Long
/** Subtracts the other value from this value. */
external public operator fun minus(other: Float): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Double): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Byte): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Short): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Int): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Long): Long
/** Multiplies this value by the other value. */
external public operator fun times(other: Float): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Double): Double
/** Divides this value by the other value. */
external public operator fun div(other: Byte): Long
/** Divides this value by the other value. */
external public operator fun div(other: Short): Long
/** Divides this value by the other value. */
external public operator fun div(other: Int): Long
/** Divides this value by the other value. */
external public operator fun div(other: Long): Long
/** Divides this value by the other value. */
external public operator fun div(other: Float): Float
/** Divides this value by the other value. */
external public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Byte): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Short): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Int): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Long): Long
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Double): Double
/** Increments this value. */
external public operator fun inc(): Long
/** Decrements this value. */
external public operator fun dec(): Long
/** Returns this value. */
external public operator fun unaryPlus(): Long
/** Returns the negative of this value. */
external public operator fun unaryMinus(): Long
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Byte): LongRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Short): LongRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Int): LongRange
/** Creates a range from this value to the specified [other] value. */
// external public operator fun rangeTo(other: Long): LongRange
/** Shifts this value left by [bits]. */
external public infix fun shl(bitCount: Int): Long
/** Shifts this value right by [bits], filling the leftmost bits with copies of the sign bit. */
external public infix fun shr(bitCount: Int): Long
/** Shifts this value right by [bits], filling the leftmost bits with zeros. */
external public infix fun ushr(bitCount: Int): Long
/** Performs a bitwise AND operation between the two values. */
external public infix fun and(other: Long): Long
/** Performs a bitwise OR operation between the two values. */
external public infix fun or(other: Long): Long
/** Performs a bitwise XOR operation between the two values. */
external public infix fun xor(other: Long): Long
/** Inverts the bits in this value/ */
external public fun inv(): Long
external public override fun toByte(): Byte
external public override fun toChar(): Char
external public override fun toShort(): Short
external public override fun toInt(): Int
external public override fun toLong(): Long
external public override fun toFloat(): Float
external public override fun toDouble(): Double
}
/**
* Represents a single-precision 32-bit IEEE 754 floating point number.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `float`.
*/
public class Float : Number(), Comparable<Float> {
companion object {
/**
* A constant holding the smallest *positive* nonzero value of Float.
*/
//public val MIN_VALUE: Float
/**
* A constant holding the largest positive finite value of Float.
*/
//public val MAX_VALUE: Float
/**
* A constant holding the positive infinity value of Float.
*/
//public val POSITIVE_INFINITY: Float
/**
* A constant holding the negative infinity value of Float.
*/
//public val NEGATIVE_INFINITY: Float
/**
* A constant holding the "not a number" value of Float.
*/
//public val NaN: Float
}
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Byte): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Short): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Int): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Long): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override operator fun compareTo(other: Float): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Double): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Byte): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Short): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Int): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Long): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Float): Float
/** Adds the other value to this value. */
external public operator fun plus(other: Double): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Byte): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Short): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Int): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Long): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Float): Float
/** Subtracts the other value from this value. */
external public operator fun minus(other: Double): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Byte): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Short): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Int): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Long): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Float): Float
/** Multiplies this value by the other value. */
external public operator fun times(other: Double): Double
/** Divides this value by the other value. */
external public operator fun div(other: Byte): Float
/** Divides this value by the other value. */
external public operator fun div(other: Short): Float
/** Divides this value by the other value. */
external public operator fun div(other: Int): Float
/** Divides this value by the other value. */
external public operator fun div(other: Long): Float
/** Divides this value by the other value. */
external public operator fun div(other: Float): Float
/** Divides this value by the other value. */
external public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Byte): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Short): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Int): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Long): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Float): Float
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Double): Double
/** Increments this value. */
external public operator fun inc(): Float
/** Decrements this value. */
external public operator fun dec(): Float
/** Returns this value. */
external public operator fun unaryPlus(): Float
/** Returns the negative of this value. */
external public operator fun unaryMinus(): Float
external public override fun toByte(): Byte
external public override fun toChar(): Char
external public override fun toShort(): Short
external public override fun toInt(): Int
external public override fun toLong(): Long
external public override fun toFloat(): Float
external public override fun toDouble(): Double
}
/**
* Represents a double-precision 64-bit IEEE 754 floating point number.
* On the JVM, non-nullable values of this type are represented as values of the primitive type `double`.
*/
public class Double : Number(), Comparable<Double> {
companion object {
/**
* A constant holding the smallest *positive* nonzero value of Double.
*/
//public val MIN_VALUE: Double
/**
* A constant holding the largest positive finite value of Double.
*/
//public val MAX_VALUE: Double
/**
* A constant holding the positive infinity value of Double.
*/
// public val POSITIVE_INFINITY: Double
/**
* A constant holding the negative infinity value of Double.
*/
// public val NEGATIVE_INFINITY: Double
/**
* A constant holding the "not a number" value of Double.
*/
// public val NaN: Double
}
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Byte): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Short): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Int): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Long): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public operator fun compareTo(other: Float): Int
/**
* Compares this value with the specified value for order.
* Returns zero if this value is equal to the specified other value, a negative number if its less than other,
* or a positive number if its greater than other.
*/
external public override operator fun compareTo(other: Double): Int
/** Adds the other value to this value. */
external public operator fun plus(other: Byte): Double
/** Adds the other value to this value. */
external public operator fun plus(other: Short): Double
/** Adds the other value to this value. */
external public operator fun plus(other: Int): Double
/** Adds the other value to this value. */
external public operator fun plus(other: Long): Double
/** Adds the other value to this value. */
external public operator fun plus(other: Float): Double
/** Adds the other value to this value. */
external public operator fun plus(other: Double): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Byte): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Short): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Int): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Long): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Float): Double
/** Subtracts the other value from this value. */
external public operator fun minus(other: Double): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Byte): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Short): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Int): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Long): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Float): Double
/** Multiplies this value by the other value. */
external public operator fun times(other: Double): Double
/** Divides this value by the other value. */
external public operator fun div(other: Byte): Double
/** Divides this value by the other value. */
external public operator fun div(other: Short): Double
/** Divides this value by the other value. */
external public operator fun div(other: Int): Double
/** Divides this value by the other value. */
external public operator fun div(other: Long): Double
/** Divides this value by the other value. */
external public operator fun div(other: Float): Double
/** Divides this value by the other value. */
external public operator fun div(other: Double): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Byte): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Short): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Int): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Long): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Float): Double
/** Calculates the remainder of dividing this value by the other value. */
external public operator fun mod(other: Double): Double
/** Increments this value. */
external public operator fun inc(): Double
/** Decrements this value. */
external public operator fun dec(): Double
/** Returns this value. */
external public operator fun unaryPlus(): Double
/** Returns the negative of this value. */
external public operator fun unaryMinus(): Double
external public override fun toByte(): Byte
external public override fun toChar(): Char
external public override fun toShort(): Short
external public override fun toInt(): Int
external public override fun toLong(): Long
external public override fun toFloat(): Float
external public override fun toDouble(): Double
}
+5
View File
@@ -0,0 +1,5 @@
package kotlin
public object Unit {
// override fun toString() = "kotlin.Unit"
}
@@ -8,13 +8,13 @@ package kotlin
* TODO: changing symbol name breaks the binary compatibility,
* so it should probably be allowed on `internal` and `private` functions only.
*/
@Target(AnnotationTarget.FUNCTION)
@Retention(AnnotationRetention.SOURCE)
//@Target(AnnotationTarget.FUNCTION)
//@Retention(AnnotationRetention.SOURCE)
annotation class SymbolName(val name: kotlin.String)
/**
* Exports the TypeInfo of this class by given name to use it from runtime.
*/
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
//@Target(AnnotationTarget.CLASS)
//@Retention(AnnotationRetention.SOURCE)
annotation class ExportTypeInfo(val name: kotlin.String)