3a49e690467749a2b22e6db6ac7bd47b47b6e1ce
for code
--------8<--------
> cat ../backend.native/tests/codegen/basics/cast_simple.kt
open class A() {}
class B(): A() {}
fun castSimple(o: Any) : A = o as A
fun castTest(): Boolean {
val b = B()
castSimple(b)
return true
}
--------8<--------
translator generates
--------8<--------
>llvm-dis-mp-3.8 ../backend.native/tests/codegen/basics/cast_simple.kt.bc -o -
; ModuleID = '../backend.native/tests/codegen/basics/cast_simple.kt.bc'
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.12.0"
...
define i8* @"kfun:castSimple(Any)"(i8*) {
entry:
%o = alloca i8*
store i8* %0, i8** %o
%tmp_1 = load i8*, i8** %o
%tmp_2 = bitcast i8* %tmp_1 to %struct.ObjHeader*
call void @CheckInstance(%struct.ObjHeader* %tmp_2, %struct.TypeInfo* @"ktype:A")
ret i8* %tmp_1
}
--------8<--------
Kotlin-native backend
Build
Download dependencies:
gradle :dependencies:update
To run native translator just use:
gradle :backend.native:run
And it will run simple example (currently prints out IR of test file). For more tests, use:
gradle :backend.native:tests:run
Description
Languages
Kotlin
79.9%
Java
10.4%
Swift
4.3%
C
2.8%
C++
2.1%
Other
0.3%