translator: add support packages, rewrite system for resolving variables and classes, add packages to kotstd, add test count to test framework, a lot of small changes
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun assert_c(value: Boolean)
|
||||
|
||||
fun assert(value: Boolean) {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_boolean_size(): Int
|
||||
|
||||
class BooleanArray(var size: Int) {
|
||||
@@ -43,7 +45,6 @@ class BooleanArray(var size: Int) {
|
||||
|
||||
return newInstance
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun BooleanArray.print() {
|
||||
@@ -62,7 +63,7 @@ fun BooleanArray.print() {
|
||||
|
||||
fun BooleanArray.println() {
|
||||
this.print()
|
||||
println()
|
||||
//println()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun malloc_array(size: Int): Int
|
||||
external fun kotlinclib_get_byte(src: Int, index: Int): Byte
|
||||
external fun kotlinclib_set_byte(src: Int, index: Int, value: Byte)
|
||||
@@ -62,7 +64,7 @@ fun ByteArray.print() {
|
||||
|
||||
fun ByteArray.println() {
|
||||
this.print()
|
||||
println()
|
||||
//println()
|
||||
}
|
||||
|
||||
fun ByteArray.copyOf(newSize: Int): ByteArray {
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import ByteArray
|
||||
import IntArray
|
||||
import LongArray
|
||||
import ShortArray
|
||||
package kotlin
|
||||
|
||||
/*
|
||||
* Library for console interaction
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_get_int(src: Int, index: Int): Int
|
||||
external fun kotlinclib_set_int(src: Int, index: Int, value: Int)
|
||||
external fun kotlinclib_int_size(): Int
|
||||
@@ -61,7 +63,7 @@ fun IntArray.print() {
|
||||
|
||||
fun IntArray.println() {
|
||||
this.print()
|
||||
println()
|
||||
//println()
|
||||
}
|
||||
|
||||
fun IntArray.copyOf(newSize: Int): IntArray {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin.collections
|
||||
|
||||
/** An iterator over a sequence of values of type `Byte`. */
|
||||
public abstract class ByteIterator {
|
||||
final fun next() = nextByte()
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_get_long(src: Int, index: Int): Long
|
||||
external fun kotlinclib_set_long(src: Int, index: Int, value: Long)
|
||||
external fun kotlinclib_long_size(): Int
|
||||
@@ -59,7 +61,7 @@ fun LongArray.print() {
|
||||
|
||||
fun LongArray.println() {
|
||||
this.print()
|
||||
println()
|
||||
//println()
|
||||
}
|
||||
|
||||
fun LongArray.copyOf(newSize: Int): LongArray {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_byteToChar(value: Byte): Char
|
||||
external fun kotlinclib_byteToShort(value: Byte): Short
|
||||
external fun kotlinclib_byteToInt(value: Byte): Int
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_charToByte(value: Char): Byte
|
||||
external fun kotlinclib_charToShort(value: Char): Short
|
||||
external fun kotlinclib_charToInt(value: Char): Int
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_doubleToByte(value: Double): Byte
|
||||
external fun kotlinclib_doubleToChar(value: Double): Char
|
||||
external fun kotlinclib_doubleToShort(value: Double): Short
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_floatToByte(value: Float): Byte
|
||||
external fun kotlinclib_floatToChar(value: Float): Char
|
||||
external fun kotlinclib_floatToShort(value: Float): Short
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_intToByte(value: Int): Byte
|
||||
external fun kotlinclib_intToChar(value: Int): Char
|
||||
external fun kotlinclib_intToShort(value: Int): Short
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_longToByte(value: Long): Byte
|
||||
external fun kotlinclib_longToChar(value: Long): Char
|
||||
external fun kotlinclib_longToShort(value: Long): Short
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_shortToByte(value: Short): Byte
|
||||
external fun kotlinclib_shortToChar(value: Short): Char
|
||||
external fun kotlinclib_shortToInt(value: Short): Int
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
/**
|
||||
* A progression of values of type `Int`.
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
package kotlin.ranges
|
||||
|
||||
import kotlin.IntProgression
|
||||
import kotlin.collections.IntIterator
|
||||
|
||||
public class IntRange(val start: Int, val endInclusive: Int) {
|
||||
val progression = IntProgression(start, endInclusive, 1)
|
||||
val first: Int
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
external fun kotlinclib_get_short(src: Int, index: Int): Short
|
||||
external fun kotlinclib_set_short(src: Int, index: Int, value: Short)
|
||||
external fun kotlinclib_short_size(): Int
|
||||
@@ -60,7 +62,7 @@ fun ShortArray.print() {
|
||||
|
||||
fun ShortArray.println() {
|
||||
this.print()
|
||||
println()
|
||||
//println()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
package kotlin
|
||||
|
||||
// a mod b (in arithmetical sense)
|
||||
private fun mod(a: Int, b: Int): Int {
|
||||
val mod = a % b
|
||||
|
||||
@@ -3,7 +3,7 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "thumbv7m-none--eabi"
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak i32 @malloc_array(i32 %x) #0 {
|
||||
define weak i32 @kotlin.malloc_array(i32 %x) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %x, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -15,7 +15,7 @@ define weak i32 @malloc_array(i32 %x) #0 {
|
||||
declare i8* @malloc_heap(i32) #1
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak zeroext i8 @kotlinclib_get_byte(i32 %data, i32 %index) #0 {
|
||||
define weak zeroext i8 @kotlin.kotlinclib_get_byte(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -29,7 +29,7 @@ define weak zeroext i8 @kotlinclib_get_byte(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 zeroext %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_byte(i32 %data, i32 %index, i8 zeroext %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i8, align 1
|
||||
@@ -49,7 +49,7 @@ define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 zeroext %value)
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) #0 {
|
||||
define weak i32 @kotlin.kotlinclib_get_int(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -63,7 +63,7 @@ define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i32, align 4
|
||||
@@ -83,7 +83,7 @@ define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) #0 {
|
||||
define weak signext i16 @kotlin.kotlinclib_get_short(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -97,7 +97,7 @@ define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i16, align 2
|
||||
@@ -117,7 +117,7 @@ define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak i32 @kotlinclib_get_long(i32 %data, i32 %index) #0 {
|
||||
define weak i32 @kotlin.kotlinclib_get_long(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -131,7 +131,7 @@ define weak i32 @kotlinclib_get_long(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_set_long(i32 %data, i32 %index, i32 %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_long(i32 %data, i32 %index, i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i32, align 4
|
||||
|
||||
@@ -3,7 +3,7 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "thumbv7m-none--eabi"
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @assert_c(i1 %value) #0 {
|
||||
define weak void @kotlin.assert_c(i1 %value) #0 {
|
||||
%1 = alloca i1, align 4
|
||||
store i1 %value, i1* %1, align 4
|
||||
ret void
|
||||
|
||||
+19
-19
@@ -3,133 +3,133 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "thumbv7m-none--eabi"
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_int(i32 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_int(i32 %message) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %message, i32* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_long(i32 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_long(i32 %message) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %message, i32* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_byte(i8 zeroext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_byte(i8 zeroext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_short(i16 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_short(i16 signext %message) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %message, i16* %1, align 2
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_char(i8 zeroext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_char(i8 zeroext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_boolean(i1 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_boolean(i1 %message) #0 {
|
||||
%1 = alloca i1, align 4
|
||||
store i1 %message, i1* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_float(float %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_float(float %message) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %message, float* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_double(double %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_double(double %message) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %message, double* %1, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_print_string(i8* %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_string(i8* %message) #0 {
|
||||
%1 = alloca i8*, align 4
|
||||
store i8* %message, i8** %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_int(i32 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_int(i32 %message) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %message, i32* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_long(i32 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_long(i32 %message) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %message, i32* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_byte(i8 zeroext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_byte(i8 zeroext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_short(i16 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_short(i16 signext %message) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %message, i16* %1, align 2
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_char(i8 zeroext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_char(i8 zeroext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_boolean(i1 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_boolean(i1 %message) #0 {
|
||||
%1 = alloca i1, align 4
|
||||
store i1 %message, i1* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_float(float %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_float(float %message) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %message, float* %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_double(double %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_double(double %message) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %message, double* %1, align 8
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println_string(i8* %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_string(i8* %message) #0 {
|
||||
%1 = alloca i8*, align 4
|
||||
store i8* %message, i8** %1, align 4
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define weak void @kotlinclib_println() #0 {
|
||||
define weak void @kotlin.kotlinclib_println() #0 {
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
|
||||
target triple = "thumbv7m-none--eabi"
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_intToByte(i32 %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_intToByte(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -12,7 +12,7 @@ define zeroext i8 @kotlinclib_intToByte(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_intToChar(i32 %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_intToChar(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -21,7 +21,7 @@ define zeroext i8 @kotlinclib_intToChar(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define signext i16 @kotlinclib_intToShort(i32 %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_intToShort(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -30,7 +30,7 @@ define signext i16 @kotlinclib_intToShort(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_intToLong(i32 %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_intToLong(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -38,7 +38,7 @@ define i32 @kotlinclib_intToLong(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define float @kotlinclib_intToFloat(i32 %value) #0 {
|
||||
define float @kotlin.kotlinclib_intToFloat(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -47,7 +47,7 @@ define float @kotlinclib_intToFloat(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define double @kotlinclib_intToDouble(i32 %value) #0 {
|
||||
define double @kotlin.kotlinclib_intToDouble(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -56,7 +56,7 @@ define double @kotlinclib_intToDouble(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_byteToChar(i8 zeroext %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_byteToChar(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -64,7 +64,7 @@ define zeroext i8 @kotlinclib_byteToChar(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define signext i16 @kotlinclib_byteToShort(i8 zeroext %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_byteToShort(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -73,7 +73,7 @@ define signext i16 @kotlinclib_byteToShort(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_byteToInt(i8 zeroext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_byteToInt(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -82,7 +82,7 @@ define i32 @kotlinclib_byteToInt(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_byteToLong(i8 zeroext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_byteToLong(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -91,7 +91,7 @@ define i32 @kotlinclib_byteToLong(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define float @kotlinclib_byteToFloat(i8 zeroext %value) #0 {
|
||||
define float @kotlin.kotlinclib_byteToFloat(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -100,7 +100,7 @@ define float @kotlinclib_byteToFloat(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define double @kotlinclib_byteToDouble(i8 zeroext %value) #0 {
|
||||
define double @kotlin.kotlinclib_byteToDouble(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -109,7 +109,7 @@ define double @kotlinclib_byteToDouble(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_charToByte(i8 zeroext %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_charToByte(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -117,7 +117,7 @@ define zeroext i8 @kotlinclib_charToByte(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define signext i16 @kotlinclib_charToShort(i8 zeroext %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_charToShort(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -126,7 +126,7 @@ define signext i16 @kotlinclib_charToShort(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_charToInt(i8 zeroext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_charToInt(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -135,7 +135,7 @@ define i32 @kotlinclib_charToInt(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_charToLong(i8 zeroext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_charToLong(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -144,7 +144,7 @@ define i32 @kotlinclib_charToLong(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define float @kotlinclib_charToFloat(i8 zeroext %value) #0 {
|
||||
define float @kotlin.kotlinclib_charToFloat(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -153,7 +153,7 @@ define float @kotlinclib_charToFloat(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define double @kotlinclib_charToDouble(i8 zeroext %value) #0 {
|
||||
define double @kotlin.kotlinclib_charToDouble(i8 zeroext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -162,7 +162,7 @@ define double @kotlinclib_charToDouble(i8 zeroext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_shortToByte(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -171,7 +171,7 @@ define zeroext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_shortToChar(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -180,7 +180,7 @@ define zeroext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_shortToInt(i16 signext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_shortToInt(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -189,7 +189,7 @@ define i32 @kotlinclib_shortToInt(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_shortToLong(i16 signext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_shortToLong(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -198,7 +198,7 @@ define i32 @kotlinclib_shortToLong(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define float @kotlinclib_shortToFloat(i16 signext %value) #0 {
|
||||
define float @kotlin.kotlinclib_shortToFloat(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -207,7 +207,7 @@ define float @kotlinclib_shortToFloat(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define double @kotlinclib_shortToDouble(i16 signext %value) #0 {
|
||||
define double @kotlin.kotlinclib_shortToDouble(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -216,7 +216,7 @@ define double @kotlinclib_shortToDouble(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_longToByte(i32 %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_longToByte(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -225,7 +225,7 @@ define zeroext i8 @kotlinclib_longToByte(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_longToChar(i32 %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_longToChar(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -234,7 +234,7 @@ define zeroext i8 @kotlinclib_longToChar(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define signext i16 @kotlinclib_longToShort(i32 %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_longToShort(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -243,7 +243,7 @@ define signext i16 @kotlinclib_longToShort(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_longToInt(i32 %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_longToInt(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -251,7 +251,7 @@ define i32 @kotlinclib_longToInt(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define float @kotlinclib_longToFloat(i32 %value) #0 {
|
||||
define float @kotlin.kotlinclib_longToFloat(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -260,7 +260,7 @@ define float @kotlinclib_longToFloat(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define double @kotlinclib_longToDouble(i32 %value) #0 {
|
||||
define double @kotlin.kotlinclib_longToDouble(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -269,7 +269,7 @@ define double @kotlinclib_longToDouble(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_floatToByte(float %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_floatToByte(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -278,7 +278,7 @@ define zeroext i8 @kotlinclib_floatToByte(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_floatToChar(float %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_floatToChar(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -287,7 +287,7 @@ define zeroext i8 @kotlinclib_floatToChar(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define signext i16 @kotlinclib_floatToShort(float %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_floatToShort(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -296,7 +296,7 @@ define signext i16 @kotlinclib_floatToShort(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_floatToInt(float %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_floatToInt(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -305,7 +305,7 @@ define i32 @kotlinclib_floatToInt(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_floatToLong(float %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_floatToLong(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -314,7 +314,7 @@ define i32 @kotlinclib_floatToLong(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define double @kotlinclib_floatToDouble(float %value) #0 {
|
||||
define double @kotlin.kotlinclib_floatToDouble(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -323,7 +323,7 @@ define double @kotlinclib_floatToDouble(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_doubleToByte(double %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_doubleToByte(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -332,7 +332,7 @@ define zeroext i8 @kotlinclib_doubleToByte(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define zeroext i8 @kotlinclib_doubleToChar(double %value) #0 {
|
||||
define zeroext i8 @kotlin.kotlinclib_doubleToChar(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -341,7 +341,7 @@ define zeroext i8 @kotlinclib_doubleToChar(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define signext i16 @kotlinclib_doubleToShort(double %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_doubleToShort(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -350,7 +350,7 @@ define signext i16 @kotlinclib_doubleToShort(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_doubleToInt(double %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_doubleToInt(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -359,7 +359,7 @@ define i32 @kotlinclib_doubleToInt(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_doubleToLong(double %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_doubleToLong(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -368,7 +368,7 @@ define i32 @kotlinclib_doubleToLong(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define float @kotlinclib_doubleToFloat(double %value) #0 {
|
||||
define float @kotlin.kotlinclib_doubleToFloat(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -377,44 +377,43 @@ define float @kotlinclib_doubleToFloat(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_int_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_int_size() #0 {
|
||||
ret i32 4
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_long_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_long_size() #0 {
|
||||
ret i32 4
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_boolean_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_boolean_size() #0 {
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_short_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_short_size() #0 {
|
||||
ret i32 2
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_double_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_double_size() #0 {
|
||||
ret i32 8
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_float_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_float_size() #0 {
|
||||
ret i32 4
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_char_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_char_size() #0 {
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind
|
||||
define i32 @kotlinclib_byte_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_byte_size() #0 {
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ target triple = "x86_64-pc-linux-gnu"
|
||||
declare i8* @malloc_heap(i32) #1
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak i32 @malloc_array(i32 %x) #0 {
|
||||
define weak i32 @kotlin.malloc_array(i32 %x) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %x, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -17,7 +17,7 @@ define weak i32 @malloc_array(i32 %x) #0 {
|
||||
declare i8* @malloc(i32) #1
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak signext i8 @kotlinclib_get_byte(i32 %data, i32 %index) #0 {
|
||||
define weak signext i8 @kotlin.kotlinclib_get_byte(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -33,7 +33,7 @@ define weak signext i8 @kotlinclib_get_byte(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i8, align 1
|
||||
@@ -55,7 +55,7 @@ define weak void @kotlinclib_set_byte(i32 %data, i32 %index, i8 signext %value)
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) #0 {
|
||||
define weak i32 @kotlin.kotlinclib_get_int(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -71,7 +71,7 @@ define weak i32 @kotlinclib_get_int(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i32, align 4
|
||||
@@ -93,7 +93,7 @@ define weak void @kotlinclib_set_int(i32 %data, i32 %index, i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) #0 {
|
||||
define weak signext i16 @kotlin.kotlinclib_get_short(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -109,7 +109,7 @@ define weak signext i16 @kotlinclib_get_short(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i16, align 2
|
||||
@@ -131,7 +131,7 @@ define weak void @kotlinclib_set_short(i32 %data, i32 %index, i16 signext %value
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak i64 @kotlinclib_get_long(i32 %data, i32 %index) #0 {
|
||||
define weak i64 @kotlin.kotlinclib_get_long(i32 %data, i32 %index) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
store i32 %data, i32* %1, align 4
|
||||
@@ -147,7 +147,7 @@ define weak i64 @kotlinclib_get_long(i32 %data, i32 %index) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_set_long(i32 %data, i32 %index, i64 %value) #0 {
|
||||
define weak void @kotlin.kotlinclib_set_long(i32 %data, i32 %index, i64 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
%2 = alloca i32, align 4
|
||||
%3 = alloca i64, align 8
|
||||
|
||||
@@ -5,7 +5,7 @@ target triple = "x86_64-pc-linux-gnu"
|
||||
@.str = private unnamed_addr constant [71 x i8] c"Exception in thread \22main\22 java.lang.AssertionError: Assertion failed\0A\00", align 1
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @assert_c(i1 %value) #0 {
|
||||
define weak void @kotlin.assert_c(i1 %value) #0 {
|
||||
%1 = alloca i1, align 4
|
||||
store i1 %value, i1* %1, align 4
|
||||
%2 = load i1* %1, align 4
|
||||
|
||||
+38
-38
@@ -12,7 +12,7 @@ target triple = "x86_64-pc-linux-gnu"
|
||||
@.str7 = private unnamed_addr constant [3 x i8] c"%s\00", align 1
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_int(i32 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_int(i32 %message) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %message, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -23,7 +23,7 @@ define weak void @kotlinclib_print_int(i32 %message) #0 {
|
||||
declare i32 @printf(i8*, ...) #1
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_long(i64 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_long(i64 %message) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %message, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -32,7 +32,7 @@ define weak void @kotlinclib_print_long(i64 %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_byte(i8 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_byte(i8 signext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -42,7 +42,7 @@ define weak void @kotlinclib_print_byte(i8 signext %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_short(i16 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_short(i16 signext %message) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %message, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -52,7 +52,7 @@ define weak void @kotlinclib_print_short(i16 signext %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_char(i8 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_char(i8 signext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -62,7 +62,7 @@ define weak void @kotlinclib_print_char(i8 signext %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_boolean(i1 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_boolean(i1 %message) #0 {
|
||||
%1 = alloca i1, align 4
|
||||
store i1 %message, i1* %1, align 4
|
||||
%2 = load i1* %1, align 4
|
||||
@@ -82,7 +82,7 @@ define weak void @kotlinclib_print_boolean(i1 %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_float(float %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_float(float %message) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %message, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -92,7 +92,7 @@ define weak void @kotlinclib_print_float(float %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_double(double %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_double(double %message) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %message, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -101,7 +101,7 @@ define weak void @kotlinclib_print_double(double %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_print_string(i8* %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_print_string(i8* %message) #0 {
|
||||
%1 = alloca i8*, align 8
|
||||
store i8* %message, i8** %1, align 8
|
||||
%2 = load i8** %1, align 8
|
||||
@@ -110,98 +110,98 @@ define weak void @kotlinclib_print_string(i8* %message) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println() #0 {
|
||||
call void @kotlinclib_print_char(i8 signext 10)
|
||||
define weak void @kotlin.kotlinclib_println() #0 {
|
||||
call void @kotlin.kotlinclib_print_char(i8 signext 10)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_int(i32 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_int(i32 %message) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %message, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
call void @kotlinclib_print_int(i32 %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_int(i32 %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_long(i64 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_long(i64 %message) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %message, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
call void @kotlinclib_print_long(i64 %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_long(i64 %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_byte(i8 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_byte(i8 signext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
call void @kotlinclib_print_byte(i8 signext %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_byte(i8 signext %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_short(i16 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_short(i16 signext %message) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %message, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
call void @kotlinclib_print_short(i16 signext %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_short(i16 signext %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_char(i8 signext %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_char(i8 signext %message) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %message, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
call void @kotlinclib_print_char(i8 signext %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_char(i8 signext %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_boolean(i1 %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_boolean(i1 %message) #0 {
|
||||
%1 = alloca i1, align 4
|
||||
store i1 %message, i1* %1, align 4
|
||||
%2 = load i1* %1, align 4
|
||||
call void @kotlinclib_print_boolean(i1 %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_boolean(i1 %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_float(float %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_float(float %message) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %message, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
call void @kotlinclib_print_float(float %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_float(float %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_double(double %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_double(double %message) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %message, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
call void @kotlinclib_print_double(double %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_double(double %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define weak void @kotlinclib_println_string(i8* %message) #0 {
|
||||
define weak void @kotlin.kotlinclib_println_string(i8* %message) #0 {
|
||||
%1 = alloca i8*, align 8
|
||||
store i8* %message, i8** %1, align 8
|
||||
%2 = load i8** %1, align 8
|
||||
call void @kotlinclib_print_string(i8* %2)
|
||||
call void @kotlinclib_println()
|
||||
call void @kotlin.kotlinclib_print_string(i8* %2)
|
||||
call void @kotlin.kotlinclib_println()
|
||||
ret void
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-pc-linux-gnu"
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_intToByte(i32 %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_intToByte(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -12,7 +12,7 @@ define signext i8 @kotlinclib_intToByte(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_intToChar(i32 %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_intToChar(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -21,7 +21,7 @@ define signext i8 @kotlinclib_intToChar(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i16 @kotlinclib_intToShort(i32 %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_intToShort(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -30,7 +30,7 @@ define signext i16 @kotlinclib_intToShort(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i64 @kotlinclib_intToLong(i32 %value) #0 {
|
||||
define i64 @kotlin.kotlinclib_intToLong(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -39,7 +39,7 @@ define i64 @kotlinclib_intToLong(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define float @kotlinclib_intToFloat(i32 %value) #0 {
|
||||
define float @kotlin.kotlinclib_intToFloat(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -48,7 +48,7 @@ define float @kotlinclib_intToFloat(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define double @kotlinclib_intToDouble(i32 %value) #0 {
|
||||
define double @kotlin.kotlinclib_intToDouble(i32 %value) #0 {
|
||||
%1 = alloca i32, align 4
|
||||
store i32 %value, i32* %1, align 4
|
||||
%2 = load i32* %1, align 4
|
||||
@@ -57,7 +57,7 @@ define double @kotlinclib_intToDouble(i32 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_byteToChar(i8 signext %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_byteToChar(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -65,7 +65,7 @@ define signext i8 @kotlinclib_byteToChar(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i16 @kotlinclib_byteToShort(i8 signext %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_byteToShort(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -74,7 +74,7 @@ define signext i16 @kotlinclib_byteToShort(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_byteToInt(i8 signext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_byteToInt(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -83,7 +83,7 @@ define i32 @kotlinclib_byteToInt(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i64 @kotlinclib_byteToLong(i8 signext %value) #0 {
|
||||
define i64 @kotlin.kotlinclib_byteToLong(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -92,7 +92,7 @@ define i64 @kotlinclib_byteToLong(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define float @kotlinclib_byteToFloat(i8 signext %value) #0 {
|
||||
define float @kotlin.kotlinclib_byteToFloat(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -101,7 +101,7 @@ define float @kotlinclib_byteToFloat(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define double @kotlinclib_byteToDouble(i8 signext %value) #0 {
|
||||
define double @kotlin.kotlinclib_byteToDouble(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -110,7 +110,7 @@ define double @kotlinclib_byteToDouble(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_charToByte(i8 signext %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_charToByte(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -118,7 +118,7 @@ define signext i8 @kotlinclib_charToByte(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i16 @kotlinclib_charToShort(i8 signext %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_charToShort(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -127,7 +127,7 @@ define signext i16 @kotlinclib_charToShort(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_charToInt(i8 signext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_charToInt(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -136,7 +136,7 @@ define i32 @kotlinclib_charToInt(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i64 @kotlinclib_charToLong(i8 signext %value) #0 {
|
||||
define i64 @kotlin.kotlinclib_charToLong(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -145,7 +145,7 @@ define i64 @kotlinclib_charToLong(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define float @kotlinclib_charToFloat(i8 signext %value) #0 {
|
||||
define float @kotlin.kotlinclib_charToFloat(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -154,7 +154,7 @@ define float @kotlinclib_charToFloat(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define double @kotlinclib_charToDouble(i8 signext %value) #0 {
|
||||
define double @kotlin.kotlinclib_charToDouble(i8 signext %value) #0 {
|
||||
%1 = alloca i8, align 1
|
||||
store i8 %value, i8* %1, align 1
|
||||
%2 = load i8* %1, align 1
|
||||
@@ -163,7 +163,7 @@ define double @kotlinclib_charToDouble(i8 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_shortToByte(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -172,7 +172,7 @@ define signext i8 @kotlinclib_shortToByte(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_shortToChar(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -181,7 +181,7 @@ define signext i8 @kotlinclib_shortToChar(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_shortToInt(i16 signext %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_shortToInt(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -190,7 +190,7 @@ define i32 @kotlinclib_shortToInt(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i64 @kotlinclib_shortToLong(i16 signext %value) #0 {
|
||||
define i64 @kotlin.kotlinclib_shortToLong(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -199,7 +199,7 @@ define i64 @kotlinclib_shortToLong(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define float @kotlinclib_shortToFloat(i16 signext %value) #0 {
|
||||
define float @kotlin.kotlinclib_shortToFloat(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -208,7 +208,7 @@ define float @kotlinclib_shortToFloat(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define double @kotlinclib_shortToDouble(i16 signext %value) #0 {
|
||||
define double @kotlin.kotlinclib_shortToDouble(i16 signext %value) #0 {
|
||||
%1 = alloca i16, align 2
|
||||
store i16 %value, i16* %1, align 2
|
||||
%2 = load i16* %1, align 2
|
||||
@@ -217,7 +217,7 @@ define double @kotlinclib_shortToDouble(i16 signext %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_longToByte(i64 %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_longToByte(i64 %value) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %value, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -226,7 +226,7 @@ define signext i8 @kotlinclib_longToByte(i64 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_longToChar(i64 %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_longToChar(i64 %value) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %value, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -235,7 +235,7 @@ define signext i8 @kotlinclib_longToChar(i64 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i16 @kotlinclib_longToShort(i64 %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_longToShort(i64 %value) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %value, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -244,7 +244,7 @@ define signext i16 @kotlinclib_longToShort(i64 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_longToInt(i64 %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_longToInt(i64 %value) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %value, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -253,7 +253,7 @@ define i32 @kotlinclib_longToInt(i64 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define float @kotlinclib_longToFloat(i64 %value) #0 {
|
||||
define float @kotlin.kotlinclib_longToFloat(i64 %value) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %value, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -262,7 +262,7 @@ define float @kotlinclib_longToFloat(i64 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define double @kotlinclib_longToDouble(i64 %value) #0 {
|
||||
define double @kotlin.kotlinclib_longToDouble(i64 %value) #0 {
|
||||
%1 = alloca i64, align 8
|
||||
store i64 %value, i64* %1, align 8
|
||||
%2 = load i64* %1, align 8
|
||||
@@ -271,7 +271,7 @@ define double @kotlinclib_longToDouble(i64 %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_floatToByte(float %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_floatToByte(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -280,7 +280,7 @@ define signext i8 @kotlinclib_floatToByte(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_floatToChar(float %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_floatToChar(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -289,7 +289,7 @@ define signext i8 @kotlinclib_floatToChar(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i16 @kotlinclib_floatToShort(float %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_floatToShort(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -298,7 +298,7 @@ define signext i16 @kotlinclib_floatToShort(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_floatToInt(float %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_floatToInt(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -307,7 +307,7 @@ define i32 @kotlinclib_floatToInt(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i64 @kotlinclib_floatToLong(float %value) #0 {
|
||||
define i64 @kotlin.kotlinclib_floatToLong(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -316,7 +316,7 @@ define i64 @kotlinclib_floatToLong(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define double @kotlinclib_floatToDouble(float %value) #0 {
|
||||
define double @kotlin.kotlinclib_floatToDouble(float %value) #0 {
|
||||
%1 = alloca float, align 4
|
||||
store float %value, float* %1, align 4
|
||||
%2 = load float* %1, align 4
|
||||
@@ -325,7 +325,7 @@ define double @kotlinclib_floatToDouble(float %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_doubleToByte(double %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_doubleToByte(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -334,7 +334,7 @@ define signext i8 @kotlinclib_doubleToByte(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i8 @kotlinclib_doubleToChar(double %value) #0 {
|
||||
define signext i8 @kotlin.kotlinclib_doubleToChar(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -343,7 +343,7 @@ define signext i8 @kotlinclib_doubleToChar(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define signext i16 @kotlinclib_doubleToShort(double %value) #0 {
|
||||
define signext i16 @kotlin.kotlinclib_doubleToShort(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -352,7 +352,7 @@ define signext i16 @kotlinclib_doubleToShort(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_doubleToInt(double %value) #0 {
|
||||
define i32 @kotlin.kotlinclib_doubleToInt(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -361,7 +361,7 @@ define i32 @kotlinclib_doubleToInt(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i64 @kotlinclib_doubleToLong(double %value) #0 {
|
||||
define i64 @kotlin.kotlinclib_doubleToLong(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -370,7 +370,7 @@ define i64 @kotlinclib_doubleToLong(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define float @kotlinclib_doubleToFloat(double %value) #0 {
|
||||
define float @kotlin.kotlinclib_doubleToFloat(double %value) #0 {
|
||||
%1 = alloca double, align 8
|
||||
store double %value, double* %1, align 8
|
||||
%2 = load double* %1, align 8
|
||||
@@ -379,42 +379,42 @@ define float @kotlinclib_doubleToFloat(double %value) #0 {
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_int_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_int_size() #0 {
|
||||
ret i32 4
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_long_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_long_size() #0 {
|
||||
ret i32 8
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_boolean_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_boolean_size() #0 {
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_short_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_short_size() #0 {
|
||||
ret i32 2
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_double_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_double_size() #0 {
|
||||
ret i32 8
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_float_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_float_size() #0 {
|
||||
ret i32 4
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_char_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_char_size() #0 {
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
; Function Attrs: nounwind uwtable
|
||||
define i32 @kotlinclib_byte_size() #0 {
|
||||
define i32 @kotlin.kotlinclib_byte_size() #0 {
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
|
||||
+12
-1
@@ -34,9 +34,13 @@ TESTS=$( ls $DIRECTORY/input/* $1) # Note that "ls $DIRECTORY/input $1" is wrong
|
||||
if [ "$2" == "--proto" ]; then
|
||||
TESTS=$( ls $DIRECTORY/input/proto* $1)
|
||||
fi
|
||||
total_scripts=0
|
||||
successful_scripts=0
|
||||
|
||||
for i in $TESTS; do
|
||||
rm -f $DIRECTORY/linked/*
|
||||
TEST=`basename $i ".txt"`
|
||||
successful=1
|
||||
echo -e "${orange}test: ${TEST}${nc}"
|
||||
echo "#include <stdlib.h>" >> $MAIN
|
||||
echo "#include <stdio.h>" >> $MAIN
|
||||
@@ -78,22 +82,29 @@ for i in $TESTS; do
|
||||
fi
|
||||
fi
|
||||
|
||||
java -jar build/libs/translator-1.0.jar -I ../kotstd/include $DIRECTORY/kotlin/$TEST.kt > $DIRECTORY/linked/$TEST.ll
|
||||
java -jar build/libs/translator-1.0.jar -I ../kotstd/include $DIRECTORY/kotlin/$TEST.kt > $DIRECTORY/linked/$TEST.ll
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Translation error: ${DIRECTORY}/kotlin/${TEST}.kt${nc}"
|
||||
successful=0
|
||||
fi
|
||||
|
||||
llvm-link-3.6 -S $DIRECTORY/linked/*.ll > $DIRECTORY/linked/run.ll
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${red}Error linking with llvm${nc}"
|
||||
successful=0
|
||||
fi
|
||||
|
||||
lli-3.6 $DIRECTORY/linked/run.ll
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${lightRed}Error running test${nc}"
|
||||
successful=0
|
||||
fi
|
||||
|
||||
if [ "$2" == "--once" ]; then
|
||||
exit
|
||||
fi
|
||||
successful_scripts=$((successful_scripts+successful))
|
||||
total_scripts=$((total_scripts+1))
|
||||
done
|
||||
|
||||
echo -e "Result: ${orange} [${successful_scripts}]/[${total_scripts}]"
|
||||
@@ -11,13 +11,11 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForReceiver
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getFunctionResolvedCallWithAssert
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCallWithAssert
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getValueArgumentsInParentheses
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.*
|
||||
import org.jetbrains.kotlin.resolve.calls.model.DefaultValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ExpressionValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedValueArgument
|
||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallImpl
|
||||
import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
@@ -195,25 +193,20 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
}
|
||||
|
||||
private fun evaluateDotBody(receiverExpr: KtExpression, selectorExpr: KtExpression, scopeDepth: Int): LLVMSingleValue? {
|
||||
val receiverName = receiverExpr.text
|
||||
var receiverName = receiverExpr.text
|
||||
var receiver = when (receiverExpr) {
|
||||
is KtCallExpression,
|
||||
is KtPrefixExpression,
|
||||
is KtPostfixExpression,
|
||||
is KtBinaryExpression -> evaluateExpression(receiverExpr, scopeDepth) as LLVMVariable
|
||||
is KtDotQualifiedExpression -> {
|
||||
val location = receiverName.split(".")
|
||||
var codegen: StructCodegen? = state.classes[location[0]]
|
||||
var i = 1
|
||||
while (i < location.size && codegen != null) {
|
||||
codegen = codegen.nestedClasses[location[i]]
|
||||
i++
|
||||
}
|
||||
val codegen = resolveCodegenByName(receiverName, receiverName.split("."))
|
||||
|
||||
if (codegen != null) null else evaluateExpression(receiverExpr, scopeDepth) as LLVMVariable
|
||||
}
|
||||
is KtNameReferenceExpression -> {
|
||||
val referenceContext = state.bindingContext.get(BindingContext.REFERENCE_TARGET, receiverExpr)
|
||||
receiverName = referenceContext!!.fqNameSafe.asString()
|
||||
when (referenceContext) {
|
||||
is PropertyDescriptorImpl -> {
|
||||
val receiverThis = variableManager["this"]!!
|
||||
@@ -231,12 +224,17 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
return evaluateExtensionExpression(receiverExpr, receiver, selectorExpr as KtCallExpression, scopeDepth)
|
||||
}
|
||||
|
||||
val selectorName = when (selectorExpr) {
|
||||
is KtNameReferenceExpression -> state.bindingContext.get(BindingContext.REFERENCE_TARGET, selectorExpr)?.fqNameSafe?.asString() ?: selectorExpr.text
|
||||
else -> selectorExpr.text
|
||||
}
|
||||
|
||||
if (receiver != null) {
|
||||
if (receiver.pointer == 2) {
|
||||
receiver = codeBuilder.loadAndGetVariable(receiver)
|
||||
}
|
||||
when (receiver.type) {
|
||||
is LLVMReferenceType -> return evaluateMemberMethodOrField(receiver, selectorExpr.text, scopeDepth, selectorExpr)
|
||||
is LLVMReferenceType -> return evaluateMemberMethodOrField(receiver, selectorName, scopeDepth, selectorExpr)
|
||||
else -> return evaluateExtensionExpression(receiverExpr, receiver, selectorExpr as KtCallExpression, scopeDepth)
|
||||
}
|
||||
}
|
||||
@@ -251,10 +249,22 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
val receiverType = state.bindingContext.get(BindingContext.EXPRESSION_TYPE_INFO, receiver)
|
||||
val standardType = LLVMMapStandardType(receiverType!!.type!!, state)
|
||||
|
||||
val function = selector.firstChild.firstChild.text
|
||||
val targetFunction = state.bindingContext.get(BindingContext.CALL, selector.calleeExpression)
|
||||
val resolvedCall = state.bindingContext.get(BindingContext.RESOLVED_CALL, targetFunction)
|
||||
val targetFunctionName = resolvedCall!!.candidateDescriptor.fqNameSafe.asString().removeSuffix(".<init>")
|
||||
val nameWithoutMangling = resolvedCall.candidateDescriptor.name.asString().replace(Regex("""(.?)<init>"""), "")
|
||||
val packageNameFirst = targetFunction?.calleeExpression?.getContainingKtFile()?.packageFqName?.asString()?.removeSuffix(".<init>") ?: ""
|
||||
val packageNameSecond = resolvedCall.candidateDescriptor.containingDeclaration.fqNameSafe.asString().removeSuffix(".<init>")
|
||||
|
||||
val names = parseArgList(selector, scopeDepth)
|
||||
val type = if (names.size > 0) LLVMType.mangleFunctionArguments(names) else ""
|
||||
val extensionCodegen = state.extensionFunctions[standardType.toString()]?.get("$function$type") ?: throw UnexpectedException("$standardType:$function$type")
|
||||
|
||||
val constructedFunctionName = standardType.mangle() + nameWithoutMangling.addBeforeIfNotEmpty(".") + type
|
||||
|
||||
val extensionCodegen = state.extensionFunctions[standardType.toString()]?.get(packageNameFirst.addAfterIfNotEmpty(".") + constructedFunctionName) ?:
|
||||
state.extensionFunctions[standardType.toString()]?.get(packageNameSecond.addAfterIfNotEmpty(".") + constructedFunctionName) ?:
|
||||
state.extensionFunctions[standardType.toString()]?.get(targetFunctionName)
|
||||
?: throw UnexpectedException(constructedFunctionName)
|
||||
val receiverExpression = receiverExpressionArgument ?: evaluateExpression(receiver, scopeDepth + 1)!!
|
||||
|
||||
val typeThisArgument = when (standardType) {
|
||||
@@ -276,7 +286,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
|
||||
fun evaluateMemberMethodOrField(receiver: LLVMVariable, selectorName: String, scopeDepth: Int, call: PsiElement? = null): LLVMSingleValue? {
|
||||
val type = receiver.type as LLVMReferenceType
|
||||
val clazz = resolveClassOrObjectLocation(type) ?: throw UnexpectedException(type.toString())
|
||||
val clazz = resolveClassOrObjectLocation(type) ?: throw UnexpectedException(type.toString() + receiver.toString())
|
||||
val field = clazz.fieldsIndex[selectorName]
|
||||
|
||||
if (field != null) {
|
||||
@@ -287,9 +297,8 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
|
||||
(call as? KtCallExpression) ?: throw UnexpectedException("$receiver:$selectorName")
|
||||
val names = parseArgList(call as KtCallExpression, scopeDepth)
|
||||
val typePath = type.location.joinToString(".")
|
||||
val types = if (names.size > 0) LLVMType.mangleFunctionArguments(names) else ""
|
||||
val methodName = "${if (typePath.length > 0) "$typePath." else ""}${clazz.structName}.${selectorName.substringBefore('(').trim()}$types"
|
||||
val methodName = call.getCall(state.bindingContext)!!.getResolvedCallWithAssert(state.bindingContext).candidateDescriptor.fqNameSafe.asString() + types
|
||||
|
||||
val method = clazz.methods[methodName] ?: throw UnexpectedException(methodName)
|
||||
val returnType = clazz.methods[methodName]!!.returnType!!.type
|
||||
@@ -363,23 +372,27 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
}
|
||||
}
|
||||
|
||||
private fun evaluateReferenceExpression(expr: KtReferenceExpression, scopeDepth: Int, classScope: StructCodegen? = null): LLVMSingleValue? =
|
||||
when {
|
||||
expr is KtArrayAccessExpression -> evaluateArrayAccessExpression(expr, scopeDepth + 1)
|
||||
isEnumClassField(expr, classScope) -> resolveEnumClassField(expr, classScope)
|
||||
variableManager[expr.firstChild.text] != null -> variableManager[expr.firstChild.text]
|
||||
(expr is KtNameReferenceExpression) && (classScope != null) -> evaluateNameReferenceExpression(expr, classScope.parentCodegen!!)
|
||||
else -> {
|
||||
val clazz = resolveCodegen(expr)
|
||||
val receiver = if (clazz != null) variableManager[clazz.fullName] ?: variableManager["this"] else variableManager["this"]
|
||||
evaluateMemberMethodOrField(receiver!!, expr.firstChild.text, topLevel)
|
||||
}
|
||||
private fun evaluateReferenceExpression(expr: KtReferenceExpression, scopeDepth: Int, classScope: StructCodegen? = null): LLVMSingleValue? {
|
||||
val targetName = state.bindingContext.get(BindingContext.REFERENCE_TARGET, expr)?.fqNameSafe?.asString()?.replace(".<init>", "")
|
||||
return when {
|
||||
expr is KtArrayAccessExpression -> evaluateArrayAccessExpression(expr, scopeDepth + 1)
|
||||
isEnumClassField(expr, classScope) -> resolveEnumClassField(expr, classScope)
|
||||
(targetName != null) && (variableManager[targetName] != null) -> variableManager[targetName]
|
||||
((expr is KtNameReferenceExpression) && (classScope != null)) -> evaluateNameReferenceExpression(expr, classScope.parentCodegen!!)
|
||||
else -> {
|
||||
val clazz = classScope ?: resolveCodegen(expr)
|
||||
val receiver = if (clazz != null) variableManager[clazz.fullName] ?: variableManager["this"] else variableManager["this"]
|
||||
targetName ?: throw RuntimeException(expr.firstChild.text)
|
||||
evaluateMemberMethodOrField(receiver ?: throw UnexpectedException(targetName), targetName, topLevel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun evaluateNameReferenceExpression(expr: KtNameReferenceExpression, classScope: StructCodegen): LLVMSingleValue? {
|
||||
val fieldName = state.bindingContext.get(BindingContext.REFERENCE_TARGET, expr)!!.name.toString()
|
||||
val companionObject = (classScope as ClassCodegen).companionObjectCodegen ?: throw UnexpectedException(expr.text)
|
||||
val field = companionObject.fieldsIndex[fieldName] ?: throw UnexpectedException(expr.text)
|
||||
val field = companionObject.fieldsIndex[fieldName] ?: return null
|
||||
val receiver = variableManager[companionObject.fullName]!!
|
||||
val result = codeBuilder.getNewVariable(field.type, pointer = 1)
|
||||
|
||||
@@ -402,25 +415,36 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
?: state.bindingContext.get(BindingContext.REFERENCE_TARGET, expr as KtReferenceExpression)?.fqNameSafe?.toString()?.split(".")
|
||||
?: return null
|
||||
|
||||
val name = location.last()
|
||||
val name = type?.constructor?.declarationDescriptor?.fqNameSafe?.asString() ?: throw UnexpectedException(expr.text)
|
||||
|
||||
return resolveCodegenByName(name, location)
|
||||
}
|
||||
|
||||
private fun resolveCodegenByName(name: String, location: List<String>): StructCodegen? {
|
||||
val classType = LLVMReferenceType(name, prefix = "class")
|
||||
classType.location.addAll(location.dropLast(1))
|
||||
var locationPrefix = ""
|
||||
for (currentLocation in location.dropLast(1)) {
|
||||
locationPrefix += (if (locationPrefix.length > 0) "." else "") + currentLocation
|
||||
classType.location.add(locationPrefix)
|
||||
}
|
||||
|
||||
return resolveClassOrObjectLocation(classType)
|
||||
}
|
||||
|
||||
private fun evaluateCallExpression(expr: KtCallExpression, scopeDepth: Int, classScope: StructCodegen? = null, caller: LLVMVariable? = null): LLVMSingleValue? {
|
||||
var names = parseArgList(expr, scopeDepth)
|
||||
var name = expr.firstChild.firstChild.text
|
||||
val targetFunction = state.bindingContext.get(BindingContext.CALL, expr.calleeExpression)
|
||||
val resolvedCall = state.bindingContext.get(BindingContext.RESOLVED_CALL, targetFunction)
|
||||
var resolvedCall = state.bindingContext.get(BindingContext.RESOLVED_CALL, targetFunction)
|
||||
if (resolvedCall is VariableAsFunctionResolvedCallImpl) {
|
||||
resolvedCall = resolvedCall.variableCall
|
||||
}
|
||||
val targetFunctionName = resolvedCall!!.candidateDescriptor.fqNameSafe.asString().removeSuffix(".<init>")
|
||||
val functionDescriptor = expr.getFunctionResolvedCallWithAssert(state.bindingContext).candidateDescriptor
|
||||
val arguments = resolvedCall!!.valueArguments.toSortedMap(compareBy { it.index }).values
|
||||
val arguments = resolvedCall.valueArguments.toSortedMap(compareBy { it.index }).values
|
||||
|
||||
val external = state.externalFunctions.containsKey(name)
|
||||
val external = state.externalFunctions.containsKey(targetFunctionName)
|
||||
val functionArguments = functionDescriptor.valueParameters.map { it -> it.type }.map { LLVMMapStandardType(it, state) }
|
||||
val function = "$name${if (!external) LLVMType.mangleFunctionTypes(functionArguments) else ""}"
|
||||
val function = "$targetFunctionName${if (!external) LLVMType.mangleFunctionTypes(functionArguments) else ""}"
|
||||
|
||||
|
||||
if (state.functions.containsKey(function) || state.externalFunctions.containsKey(function)) {
|
||||
@@ -430,22 +454,22 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
return evaluateFunctionCallExpression(LLVMVariable(function, descriptor.returnType!!.type, scope = LLVMVariableScope()), args)
|
||||
}
|
||||
|
||||
if (state.classes.containsKey(name) || classScope?.structName == name) {
|
||||
val descriptor = state.classes[name] ?: classScope ?: return null
|
||||
if (state.classes.containsKey(targetFunctionName) || classScope?.structName == targetFunctionName) {
|
||||
val descriptor = state.classes[targetFunctionName] ?: classScope ?: return null
|
||||
val detectedConstructor = LLVMType.mangleFunctionTypes(functionArguments)
|
||||
val args = codeBuilder.loadArgsIfRequired(names, descriptor.constructorFields[detectedConstructor]!!)
|
||||
return evaluateConstructorCallExpression(LLVMVariable(descriptor.fullName + detectedConstructor, descriptor.type, scope = LLVMVariableScope()), args)
|
||||
}
|
||||
|
||||
val localFunction = variableManager[name]
|
||||
val localFunction = variableManager[targetFunctionName]
|
||||
if (localFunction != null) {
|
||||
val type = localFunction.type as LLVMFunctionType
|
||||
val args = codeBuilder.loadArgsIfRequired(names, type.arguments)
|
||||
return evaluateFunctionCallExpression(LLVMVariable(name, type.returnType.type, scope = LLVMRegisterScope()), args)
|
||||
return evaluateFunctionCallExpression(LLVMVariable(targetFunctionName, type.returnType.type, scope = LLVMRegisterScope()), args)
|
||||
}
|
||||
|
||||
if (classScope != null) {
|
||||
val methodShortName = "${classScope.fullName}.$function"
|
||||
val methodShortName = function
|
||||
if (classScope.methods.containsKey(methodShortName)) {
|
||||
val descriptor = classScope.methods[methodShortName]!!
|
||||
val parentDescriptor = descriptor.parentCodegen!!
|
||||
@@ -467,8 +491,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
}
|
||||
|
||||
val containingClass = resolveContainingClass(expr) ?: return null
|
||||
name = "${containingClass.fullName}.$function"
|
||||
val method = containingClass.methods[name]!!
|
||||
val method = containingClass.methods[function] ?: throw RuntimeException("Cannot find function $targetFunctionName")
|
||||
val args = mutableListOf<LLVMSingleValue>()
|
||||
|
||||
if (caller != null) {
|
||||
@@ -485,16 +508,19 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
}
|
||||
|
||||
private fun resolveContainingClass(expr: KtElement): StructCodegen? {
|
||||
val name = expr.getResolvedCallWithAssert(state.bindingContext).dispatchReceiver?.type?.toString() ?: return null
|
||||
val location = expr.getResolvedCallWithAssert(state.bindingContext).dispatchReceiver!!.type.getSubtypesPredicate().toString().split(".").dropLast(1)
|
||||
val name = expr.getResolvedCallWithAssert(state.bindingContext).dispatchReceiver?.type?.constructor?.declarationDescriptor?.fqNameSafe?.asString() ?: return null
|
||||
|
||||
if (location.size > 0) {
|
||||
val type = LLVMReferenceType(name, prefix = "class")
|
||||
type.location.addAll(location)
|
||||
return resolveClassOrObjectLocation(type)
|
||||
var currentResolvedClassName = ""
|
||||
var codegen: StructCodegen? = null
|
||||
for (classPart in name.split(".")) {
|
||||
currentResolvedClassName += (if (currentResolvedClassName.length > 0) "." else "") + classPart
|
||||
codegen = (codegen?.nestedClasses ?: state.classes)[currentResolvedClassName]
|
||||
?: (if ((codegen as? ClassCodegen)?.companionObjectCodegen?.structName == currentResolvedClassName) (codegen as? ClassCodegen)?.companionObjectCodegen else null)
|
||||
?: state.objects[currentResolvedClassName]
|
||||
?: codegen
|
||||
}
|
||||
|
||||
return state.classes[name] ?: state.objects[name]
|
||||
return codegen
|
||||
}
|
||||
|
||||
private fun evaluateFunctionCallExpression(function: LLVMVariable, names: List<LLVMSingleValue>): LLVMSingleValue? {
|
||||
@@ -786,7 +812,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
return LLVMExpression(resultOp.type, "load ${firstOp.getType()} $firstOp, align ${firstOp.type!!.align}")
|
||||
}
|
||||
".." -> {
|
||||
val descriptor = state.classes["IntRange"]
|
||||
val descriptor = state.classes["kotlin.ranges.IntRange"]
|
||||
val arguments = listOf(firstOp, secondNativeOp)
|
||||
val detectedConstructor = LLVMType.mangleFunctionTypes(arguments.map { it.type!! })
|
||||
val result = evaluateConstructorCallExpression(LLVMVariable(descriptor!!.fullName + detectedConstructor, descriptor.type, scope = LLVMVariableScope()), arguments)
|
||||
@@ -931,13 +957,14 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
codeBuilder.addUnconditionalJump(bodyLabel)
|
||||
codeBuilder.markWithLabel(bodyLabel)
|
||||
val currentParameter = evaluateFunctionCallExpression(LLVMVariable("$returnTypeName.nextInt", LLVMIntType(), scope = LLVMVariableScope()), listOf(iteratorThisArgument))!!
|
||||
val loopParameter = state.bindingContext.get(BindingContext.VALUE_PARAMETER, expr.loopParameter!!)?.fqNameSafe?.asString() ?: expr.loopParameter!!.name!!
|
||||
|
||||
val allocVar = variableManager.receiveVariable(expr.loopParameter!!.name!!, nextDescriptor.returnType!!.type, LLVMRegisterScope(), pointer =
|
||||
val allocVar = variableManager.receiveVariable(loopParameter, nextDescriptor.returnType!!.type, LLVMRegisterScope(), pointer =
|
||||
nextDescriptor.returnType!!.pointer)
|
||||
variableManager.addVariable(expr.loopParameter!!.name!!, allocVar, scopeDepth + 1)
|
||||
variableManager.addVariable(loopParameter, allocVar, scopeDepth + 1)
|
||||
codeBuilder.allocStackVar(allocVar)
|
||||
allocVar.pointer++
|
||||
allocVar.kotlinName = expr.loopParameter!!.name!!
|
||||
allocVar.kotlinName = loopParameter
|
||||
|
||||
addPrimitiveBinaryOperation(KtTokens.EQ, null, allocVar, currentParameter)
|
||||
|
||||
@@ -1101,7 +1128,7 @@ abstract class BlockCodegen(val state: TranslationState, val variableManager: Va
|
||||
|
||||
private fun evaluateValExpression(element: KtProperty, scopeDepth: Int): LLVMVariable? {
|
||||
val variable = state.bindingContext.get(BindingContext.VARIABLE, element)!!
|
||||
val identifier = variable.name.toString()
|
||||
val identifier = variable.fqNameSafe.asString().replace(".<init>", "")
|
||||
|
||||
val assignExpression = evaluateExpression(element.delegateExpressionOrInitializer, scopeDepth)
|
||||
val expectedExpressionType = LLVMInstanceOfStandardType("", variable.type, state = state)
|
||||
|
||||
@@ -15,15 +15,16 @@ class ClassCodegen(state: TranslationState,
|
||||
variableManager: VariableManager,
|
||||
val clazz: KtClass,
|
||||
codeBuilder: LLVMBuilder,
|
||||
packageName: String,
|
||||
parentCodegen: StructCodegen? = null) :
|
||||
StructCodegen(state, variableManager, clazz, codeBuilder, parentCodegen) {
|
||||
StructCodegen(state, variableManager, clazz, codeBuilder, packageName, parentCodegen) {
|
||||
|
||||
val annotation: Boolean
|
||||
val enum: Boolean
|
||||
var companionObjectCodegen: ObjectCodegen? = null
|
||||
|
||||
override var size: Int = 0
|
||||
override val structName: String = clazz.name!!
|
||||
override val structName: String = clazz.fqName?.asString()!!
|
||||
override val type: LLVMReferenceType
|
||||
|
||||
init {
|
||||
@@ -34,16 +35,10 @@ class ClassCodegen(state: TranslationState,
|
||||
}
|
||||
|
||||
val descriptor = state.bindingContext.get(BindingContext.CLASS, clazz) ?: throw TranslationException()
|
||||
val parameterList = clazz.getPrimaryConstructorParameterList()?.parameters ?: listOf()
|
||||
|
||||
annotation = descriptor.kind == ClassKind.ANNOTATION_CLASS
|
||||
enum = descriptor.kind == ClassKind.ENUM_CLASS
|
||||
|
||||
indexFields(parameterList)
|
||||
generateInnerFields(clazz.declarations)
|
||||
|
||||
calculateTypeSize()
|
||||
type.size = size
|
||||
type.align = TranslationState.pointerAlign
|
||||
}
|
||||
|
||||
@@ -65,6 +60,13 @@ class ClassCodegen(state: TranslationState,
|
||||
}
|
||||
|
||||
override fun prepareForGenerate() {
|
||||
val parameterList = clazz.getPrimaryConstructorParameterList()?.parameters ?: listOf()
|
||||
indexFields(parameterList)
|
||||
generateInnerFields(clazz.declarations)
|
||||
|
||||
calculateTypeSize()
|
||||
type.size = size
|
||||
|
||||
if (annotation) {
|
||||
return
|
||||
}
|
||||
@@ -75,7 +77,7 @@ class ClassCodegen(state: TranslationState,
|
||||
val companionObjectDescriptor = descriptor.companionObjectDescriptor
|
||||
if (companionObjectDescriptor != null) {
|
||||
val companionObject = clazz.getCompanionObjects().first()
|
||||
companionObjectCodegen = ObjectCodegen(state, variableManager, companionObject, codeBuilder, this)
|
||||
companionObjectCodegen = ObjectCodegen(state, variableManager, companionObject, codeBuilder, packageName, this)
|
||||
companionObjectCodegen!!.prepareForGenerate()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package org.kotlinnative.translator
|
||||
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtNamedFunction
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getNextSiblingIgnoringWhitespaceAndComments
|
||||
import org.jetbrains.kotlin.psi.psiUtil.isExtensionDeclaration
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.resolve.source.KotlinSourceElement
|
||||
import org.kotlinnative.translator.llvm.*
|
||||
import org.kotlinnative.translator.llvm.types.LLVMFunctionType
|
||||
@@ -19,6 +21,7 @@ class FunctionCodegen(state: TranslationState,
|
||||
variableManager: VariableManager,
|
||||
val function: KtNamedFunction,
|
||||
codeBuilder: LLVMBuilder,
|
||||
val packageName: String,
|
||||
val parentCodegen: StructCodegen? = null) :
|
||||
BlockCodegen(state, variableManager, codeBuilder) {
|
||||
|
||||
@@ -34,7 +37,7 @@ class FunctionCodegen(state: TranslationState,
|
||||
init {
|
||||
val descriptor = state.bindingContext.get(BindingContext.FUNCTION, function)!!
|
||||
args.addAll(descriptor.valueParameters.map {
|
||||
LLVMInstanceOfStandardType(it.name.toString(), it.type, state = state)
|
||||
LLVMInstanceOfStandardType(it?.fqNameSafe?.asString() ?: it.name.toString(), it.type, state = state)
|
||||
})
|
||||
|
||||
returnType = LLVMInstanceOfStandardType("instance", descriptor.returnType!!, state = state)
|
||||
@@ -43,14 +46,21 @@ class FunctionCodegen(state: TranslationState,
|
||||
}
|
||||
external = isExternal()
|
||||
name = "${function.fqName}${if (args.size > 0 && !external) LLVMType.mangleFunctionArguments(args) else ""}"
|
||||
val pureName = name.substringAfterLast('.')
|
||||
if (pureName == "main") {
|
||||
state.mainFunctions.add(name)
|
||||
}
|
||||
|
||||
if (isExtensionDeclaration) {
|
||||
name = "${function.name}${if (args.size > 0 && !external) LLVMType.mangleFunctionArguments(args) else ""}"
|
||||
val receiverType = descriptor.extensionReceiverParameter!!.type
|
||||
val translatorType = LLVMMapStandardType(receiverType, state)
|
||||
functionNamePrefix += translatorType.typename + "."
|
||||
val packageName = (function.containingFile as KtFile).packageFqName.asString()
|
||||
functionNamePrefix += if (packageName.length > 0) "$packageName." else ""
|
||||
functionNamePrefix += translatorType.mangle() + "."
|
||||
|
||||
val extensionFunctionsOfThisType = state.extensionFunctions.getOrDefault(translatorType.toString(), HashMap())
|
||||
extensionFunctionsOfThisType.put(name, this)
|
||||
extensionFunctionsOfThisType.put(functionNamePrefix + name, this)
|
||||
state.extensionFunctions.put(translatorType.toString(), extensionFunctionsOfThisType)
|
||||
}
|
||||
|
||||
|
||||
@@ -12,10 +12,11 @@ class ObjectCodegen(state: TranslationState,
|
||||
variableManager: VariableManager,
|
||||
val objectDeclaration: KtObjectDeclaration,
|
||||
codeBuilder: LLVMBuilder,
|
||||
packageName: String,
|
||||
parentCodegen: StructCodegen? = null) :
|
||||
StructCodegen(state, variableManager, objectDeclaration, codeBuilder, parentCodegen = parentCodegen) {
|
||||
StructCodegen(state, variableManager, objectDeclaration, codeBuilder, packageName, parentCodegen) {
|
||||
override var size: Int = 0
|
||||
override val structName: String = objectDeclaration.name!!
|
||||
override val structName: String = objectDeclaration.fqName?.asString()!!
|
||||
override val type: LLVMReferenceType
|
||||
|
||||
init {
|
||||
@@ -26,15 +27,14 @@ class ObjectCodegen(state: TranslationState,
|
||||
}
|
||||
primaryConstructorIndex = LLVMType.mangleFunctionArguments(emptyList())
|
||||
constructorFields.put(primaryConstructorIndex!!, arrayListOf())
|
||||
|
||||
generateInnerFields(objectDeclaration.declarations)
|
||||
|
||||
calculateTypeSize()
|
||||
type.size = size
|
||||
type.align = TranslationState.pointerAlign
|
||||
}
|
||||
|
||||
override fun prepareForGenerate() {
|
||||
generateInnerFields(objectDeclaration.declarations)
|
||||
calculateTypeSize()
|
||||
type.size = size
|
||||
type.align = TranslationState.pointerAlign
|
||||
|
||||
super.prepareForGenerate()
|
||||
|
||||
val classInstance = LLVMVariable("object.instance.$fullName", type, objectDeclaration.name, LLVMVariableScope(), pointer = 1)
|
||||
|
||||
@@ -7,39 +7,50 @@ class ProjectTranslator(val files: List<KtFile>, val state: TranslationState) {
|
||||
|
||||
fun generateCode(): String {
|
||||
codeBuilder.clean()
|
||||
files.map { addDeclarations(it) }
|
||||
files.map { addClassDeclarations(it) }
|
||||
files.map { addObjectDeclarations(it) }
|
||||
files.map { addFunctionDeclarations(it) }
|
||||
files.map { addPropertyDeclarations(it) }
|
||||
generateProjectBody()
|
||||
return codeBuilder.toString()
|
||||
}
|
||||
|
||||
fun addDeclarations(file: KtFile) {
|
||||
fun addFunctionDeclarations(file: KtFile) {
|
||||
val variableManager = VariableManager(state.globalVariableCollection)
|
||||
for (declaration in file.declarations) {
|
||||
when (declaration) {
|
||||
is KtNamedFunction -> {
|
||||
val function = FunctionCodegen(state, variableManager, declaration, codeBuilder)
|
||||
if (function.external) {
|
||||
state.externalFunctions.put(function.fullName, function)
|
||||
} else {
|
||||
state.functions.put(function.fullName, function)
|
||||
}
|
||||
}
|
||||
is KtClass -> {
|
||||
val codegen = ClassCodegen(state, variableManager, declaration, codeBuilder)
|
||||
state.classes.put(declaration.name!!, codegen)
|
||||
}
|
||||
is KtProperty -> {
|
||||
val property = PropertyCodegen(state, variableManager, declaration, codeBuilder)
|
||||
state.properties.put(declaration.name!!, property)
|
||||
}
|
||||
is KtObjectDeclaration -> {
|
||||
val property = ObjectCodegen(state, variableManager, declaration, codeBuilder)
|
||||
state.objects.put(declaration.name!!, property)
|
||||
}
|
||||
for (declaration in file.declarations.filter { it is KtNamedFunction }) {
|
||||
val function = FunctionCodegen(state, variableManager, declaration as KtNamedFunction, codeBuilder, file.packageFqName.asString())
|
||||
if (function.external) {
|
||||
state.externalFunctions.put(function.fullName, function)
|
||||
} else {
|
||||
state.functions.put(function.fullName, function)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun addClassDeclarations(file: KtFile) {
|
||||
val variableManager = VariableManager(state.globalVariableCollection)
|
||||
for (declaration in file.declarations.filter { it is KtClass }) {
|
||||
val codegen = ClassCodegen(state, variableManager, declaration as KtClass, codeBuilder, file.packageFqName.asString())
|
||||
state.classes.put(codegen.structName, codegen)
|
||||
}
|
||||
}
|
||||
|
||||
fun addPropertyDeclarations(file: KtFile) {
|
||||
val variableManager = VariableManager(state.globalVariableCollection)
|
||||
for (declaration in file.declarations.filter { it is KtProperty }) {
|
||||
val property = PropertyCodegen(state, variableManager, declaration as KtProperty, codeBuilder)
|
||||
state.properties.put(declaration.name!!, property)
|
||||
}
|
||||
}
|
||||
|
||||
fun addObjectDeclarations(file: KtFile) {
|
||||
val variableManager = VariableManager(state.globalVariableCollection)
|
||||
for (declaration in file.declarations.filter { it is KtObjectDeclaration }) {
|
||||
val codegen = ObjectCodegen(state, variableManager, declaration as KtObjectDeclaration, codeBuilder, file.packageFqName.asString())
|
||||
state.objects.put(codegen.structName, codegen)
|
||||
}
|
||||
}
|
||||
|
||||
private fun generateProjectBody() {
|
||||
with(state) {
|
||||
properties.values.map { it.generate() }
|
||||
@@ -51,6 +62,10 @@ class ProjectTranslator(val files: List<KtFile>, val state: TranslationState) {
|
||||
functions.values.filter { it.isExtensionDeclaration }.map { it.generate() }
|
||||
functions.values.filter { !it.isExtensionDeclaration }.map { it.generate() }
|
||||
}
|
||||
|
||||
if (!state.mainFunctions.contains("main") && state.mainFunctions.isNotEmpty()) {
|
||||
codeBuilder.declareEntryPoint(state.mainFunctions.first())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.lexer.KtTokens
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.kotlinnative.translator.llvm.*
|
||||
import org.kotlinnative.translator.llvm.types.LLVMCharType
|
||||
@@ -16,6 +17,7 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
val variableManager: VariableManager,
|
||||
val classOrObject: KtClassOrObject,
|
||||
val codeBuilder: LLVMBuilder,
|
||||
val packageName: String,
|
||||
val parentCodegen: StructCodegen? = null) {
|
||||
|
||||
val fields = ArrayList<LLVMVariable>()
|
||||
@@ -32,7 +34,8 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
var methods = HashMap<String, FunctionCodegen>()
|
||||
abstract val structName: String
|
||||
val fullName: String
|
||||
get() = "${if (type.location.size > 0) "${type.location.joinToString(".")}." else ""}$structName"
|
||||
//get() = "${if (type.location.size > 0) "${type.location.joinToString(".")}." else ""}$structName"
|
||||
get() = structName
|
||||
|
||||
open fun prepareForGenerate() {
|
||||
generateStruct()
|
||||
@@ -40,7 +43,7 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
for (declaration in classOrObject.declarations) {
|
||||
when (declaration) {
|
||||
is KtNamedFunction -> {
|
||||
val function = FunctionCodegen(state, variableManager, declaration, codeBuilder, this)
|
||||
val function = FunctionCodegen(state, variableManager, declaration, codeBuilder, packageName, this)
|
||||
methods.put(function.name, function)
|
||||
}
|
||||
}
|
||||
@@ -103,11 +106,13 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
enumFields.put(name, field)
|
||||
}
|
||||
is KtClass -> {
|
||||
nestedClasses.put(declaration.name!!,
|
||||
//declaration.fqName?.asString() ?: declaration.name!!
|
||||
//declaration.fqName!!.asString()
|
||||
nestedClasses.put(declaration.fqName!!.asString(),
|
||||
ClassCodegen(state,
|
||||
VariableManager(state.globalVariableCollection),
|
||||
declaration, codeBuilder,
|
||||
this))
|
||||
packageName, this))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -144,7 +149,7 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
variableManager.addVariable("this", classVal, 0)
|
||||
|
||||
val secondaryConstructorArguments = descriptor!!.valueParameters.map {
|
||||
LLVMInstanceOfStandardType(it.name.toString(), it.type, state = state)
|
||||
LLVMInstanceOfStandardType(it.fqNameSafe.asString().replace(".<init>", ""), it.type, state = state)
|
||||
}
|
||||
|
||||
argFields.add(classVal)
|
||||
@@ -248,7 +253,17 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
|
||||
protected fun resolveType(field: KtNamedDeclaration, ktType: KotlinType): LLVMClassVariable {
|
||||
val annotations = parseFieldAnnotations(field)
|
||||
val result = LLVMInstanceOfStandardType(field.name!!, ktType, LLVMRegisterScope(), state = state)
|
||||
/*val fieldName = when(field) {
|
||||
is KtParameter->
|
||||
else ->
|
||||
}*/
|
||||
|
||||
//}
|
||||
val fieldName = state.bindingContext.get(BindingContext.VALUE_PARAMETER, field as?KtParameter)?.fqNameSafe?.asString()?.replace(".<init>", "")
|
||||
?: field.fqName?.asString() ?: field.name!!
|
||||
|
||||
val result = LLVMInstanceOfStandardType(fieldName, ktType, LLVMRegisterScope(), state = state)
|
||||
//throw RuntimeException("Unknown field " + field.name!!)
|
||||
|
||||
if (result.type is LLVMReferenceType) {
|
||||
val type = result.type as LLVMReferenceType
|
||||
@@ -257,7 +272,7 @@ abstract class StructCodegen(val state: TranslationState,
|
||||
}
|
||||
|
||||
if (state.classes.containsKey(field.name!!)) {
|
||||
return LLVMClassVariable(result.label, state.classes[field.name!!]!!.type, result.pointer)
|
||||
return LLVMClassVariable(result.label, state.classes[fieldName]!!.type, result.pointer)
|
||||
}
|
||||
|
||||
if (annotations.contains("Plain")) {
|
||||
|
||||
@@ -43,6 +43,7 @@ class TranslationState(val environment: KotlinCoreEnvironment, val bindingContex
|
||||
var objects = HashMap<String, ObjectCodegen>()
|
||||
var properties = HashMap<String, PropertyCodegen>()
|
||||
val codeBuilder = LLVMBuilder(arm)
|
||||
val mainFunctions = ArrayList<String>()
|
||||
|
||||
val extensionFunctions = HashMap<String, HashMap<String, FunctionCodegen>>()
|
||||
|
||||
|
||||
@@ -294,6 +294,14 @@ class LLVMBuilder(val arm: Boolean = false) {
|
||||
localCode.appendln(code)
|
||||
}
|
||||
|
||||
fun declareEntryPoint(name: String) {
|
||||
localCode.appendln("define weak void @main()")
|
||||
addStartExpression()
|
||||
addFunctionCall(LLVMVariable(name, LLVMVoidType(), scope = LLVMVariableScope()), listOf())
|
||||
addAnyReturn(LLVMVoidType())
|
||||
addEndExpression()
|
||||
}
|
||||
|
||||
override fun toString() = globalCode.toString() + localCode.toString()
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package org.kotlinnative.translator.llvm
|
||||
import org.jetbrains.kotlin.builtins.isFunctionTypeOrSubtype
|
||||
import org.jetbrains.kotlin.cfg.pseudocode.getSubtypesPredicate
|
||||
import org.jetbrains.kotlin.js.descriptorUtils.nameIfStandardType
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe
|
||||
import org.jetbrains.kotlin.types.KotlinType
|
||||
import org.jetbrains.kotlin.types.typeUtil.isUnit
|
||||
import org.kotlinnative.translator.TranslationState
|
||||
@@ -33,10 +34,17 @@ fun LLVMInstanceOfStandardType(name: String, type: KotlinType, scope: LLVMScope
|
||||
type.isUnit() -> LLVMVariable("", LLVMVoidType(), name, scope)
|
||||
type.isMarkedNullable -> LLVMVariable(name, LLVMReferenceType(typeName, prefix = "class"), name, scope, pointer = pointerMark)
|
||||
else -> {
|
||||
val refType = state.classes[type.toString()]?.type ?: LLVMReferenceType(typeName, align = TranslationState.pointerAlign, prefix = "class")
|
||||
val declarationDescriptor = type.constructor.declarationDescriptor!!
|
||||
val refName = declarationDescriptor.fqNameSafe.asString()
|
||||
val targetPackage = declarationDescriptor.fqNameSafe.parent().asString()
|
||||
val refType = state.classes[type.toString()]?.type ?: LLVMReferenceType(refName, packageName = targetPackage, align = TranslationState.pointerAlign, prefix = "class")
|
||||
|
||||
val result = LLVMVariable(name, refType, name, scope, pointer = 1)
|
||||
refType.location.addAll(type.getSubtypesPredicate().toString().split(".").dropLast(1))
|
||||
var currentPrefix = ""
|
||||
for (currentLocation in type.getSubtypesPredicate().toString().split(".").dropLast(1)) {
|
||||
currentPrefix += (if (currentPrefix.length > 0) "." else "") + currentLocation
|
||||
refType.location.add(currentPrefix)
|
||||
}
|
||||
result
|
||||
}
|
||||
}
|
||||
@@ -44,3 +52,11 @@ fun LLVMInstanceOfStandardType(name: String, type: KotlinType, scope: LLVMScope
|
||||
|
||||
fun LLVMMapStandardType(type: KotlinType, state: TranslationState): LLVMType =
|
||||
LLVMInstanceOfStandardType("type", type, LLVMRegisterScope(), state).type
|
||||
|
||||
fun String.addBeforeIfNotEmpty(add: String): String {
|
||||
return if (this.length > 0) add + this else this
|
||||
}
|
||||
|
||||
fun String.addAfterIfNotEmpty(add: String): String {
|
||||
return if (this.length > 0) this + add else this
|
||||
}
|
||||
+1
-1
@@ -4,7 +4,7 @@ import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
|
||||
class LLVMBooleanType() : LLVMType() {
|
||||
class LLVMBooleanType() : LLVMType("kotlin") {
|
||||
|
||||
//TODO switch by types: int + double = int
|
||||
override fun operatorMinus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.kotlinnative.translator.llvm.types
|
||||
import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
class LLVMByteType() : LLVMType() {
|
||||
class LLVMByteType() : LLVMType("kotlin") {
|
||||
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMBooleanType(), "icmp slt i8 $firstOp, $secondOp")
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.kotlinnative.translator.llvm.types
|
||||
import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
class LLVMCharType() : LLVMType() {
|
||||
class LLVMCharType() : LLVMType("kotlin") {
|
||||
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMBooleanType(), "icmp slt i8 $firstOp, $secondOp")
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
|
||||
class LLVMDoubleType() : LLVMType() {
|
||||
class LLVMDoubleType() : LLVMType("kotlin") {
|
||||
|
||||
//TODO switch by types: int + double = int
|
||||
override fun operatorMinus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
|
||||
class LLVMFloatType() : LLVMType() {
|
||||
class LLVMFloatType() : LLVMType("kotlin") {
|
||||
|
||||
//TODO switch by types: int + double = int
|
||||
override fun operatorMinus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
|
||||
class LLVMIntType() : LLVMType() {
|
||||
class LLVMIntType() : LLVMType("kotlin") {
|
||||
|
||||
override fun operatorOr(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMIntType(), "or i32 $firstOp, $secondOp")
|
||||
|
||||
@@ -5,7 +5,7 @@ import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
|
||||
class LLVMLongType() : LLVMType() {
|
||||
class LLVMLongType() : LLVMType("kotlin") {
|
||||
|
||||
override fun operatorOr(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMLongType(), "or i64 $firstOp, $secondOp")
|
||||
|
||||
+5
-4
@@ -9,14 +9,15 @@ class LLVMReferenceType(val type: String,
|
||||
var prefix: String = "",
|
||||
override var align: Int = TranslationState.pointerAlign,
|
||||
override var size: Int = TranslationState.pointerSize,
|
||||
var byRef: Boolean = true) : LLVMReferred, LLVMType() {
|
||||
packageName: String = "",
|
||||
var byRef: Boolean = true) : LLVMReferred, LLVMType(packageName) {
|
||||
|
||||
override val defaultValue: String = "null"
|
||||
|
||||
override val typename: String
|
||||
get() = "$prefix${if (prefix.length > 0) "." else ""}${
|
||||
if (location.size > 0) "${location.joinToString(".")}." else ""
|
||||
}$type"
|
||||
get() = "$prefix${if (prefix.length > 0) "." else ""}" +
|
||||
"$type"
|
||||
|
||||
|
||||
override fun toString() = "%$typename"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.kotlinnative.translator.llvm.types
|
||||
import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
class LLVMShortType() : LLVMType() {
|
||||
class LLVMShortType() : LLVMType("kotlin") {
|
||||
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
|
||||
LLVMExpression(LLVMBooleanType(), "icmp slt i16 $firstOp, $secondOp")
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.kotlinnative.translator.llvm.types
|
||||
|
||||
class LLVMStringType(override val length: Int, var isLoaded: Boolean = true) : LLVMArray, LLVMType() {
|
||||
class LLVMStringType(override val length: Int, var isLoaded: Boolean = true) : LLVMArray, LLVMType("kotlin") {
|
||||
|
||||
override var size: Int = 1
|
||||
override val align = 8
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.kotlinnative.translator.exceptions.UnimplementedException
|
||||
import org.kotlinnative.translator.llvm.LLVMExpression
|
||||
import org.kotlinnative.translator.llvm.LLVMSingleValue
|
||||
|
||||
abstract class LLVMType() : Cloneable {
|
||||
abstract class LLVMType(val packageName: String = "") : Cloneable {
|
||||
|
||||
open fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
|
||||
open fun operatorTimes(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
|
||||
class Main {
|
||||
class classfields_2_class {
|
||||
var i = 0
|
||||
|
||||
fun main() {
|
||||
fun method() {
|
||||
i = 5
|
||||
}
|
||||
|
||||
fun changeI(): Int {
|
||||
main()
|
||||
method()
|
||||
return i
|
||||
}
|
||||
}
|
||||
|
||||
fun test1(): Int {
|
||||
val main = Main()
|
||||
val main = classfields_2_class()
|
||||
return main.changeI()
|
||||
}
|
||||
|
||||
fun test2(): Int {
|
||||
val main = Main()
|
||||
val main = classfields_2_class()
|
||||
return main.i
|
||||
}
|
||||
|
||||
fun test3(): Int {
|
||||
return Main().changeI()
|
||||
return classfields_2_class().changeI()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user