translator: additional tests for classes and callbacks
This commit is contained in:
@@ -10,7 +10,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
val disposer = Disposer.newDisposable()
|
||||
val state = parseAndAnalyze(args.asList(), disposer, arm = true)
|
||||
val state = parseAndAnalyze(args.asList(), disposer, arm = false)
|
||||
|
||||
val files = state.environment.getSourceFiles()
|
||||
if (files.isEmpty()) {
|
||||
|
||||
@@ -91,7 +91,7 @@ class LLVMBuilder(val arm: Boolean) {
|
||||
storeVariable(result, secondNativeOp)
|
||||
return result
|
||||
}
|
||||
else -> addPrimitiveReferenceOperation(referenceName, firstNativeOp, secondNativeOp);
|
||||
else -> addPrimitiveReferenceOperation(referenceName, firstNativeOp, secondNativeOp)
|
||||
}
|
||||
val resultOp = getNewVariable(llvmExpression.variableType)
|
||||
addAssignment(resultOp, llvmExpression)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
|
||||
int apply_c(int x, int (*foo)(int)) {
|
||||
return foo(x);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
compact_test(1) == 2
|
||||
compact_test(3) == 4
|
||||
external_test(3) == 2
|
||||
external_test(4) == 3
|
||||
mixed_test(1) == 4
|
||||
mixed_test(9) == 12
|
||||
@@ -0,0 +1,2 @@
|
||||
change(0) == 1
|
||||
change(1) == 2
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
external fun apply_c(arg: Int, x: (Int)-> Int): Int
|
||||
|
||||
fun inc(i: Int): Int {
|
||||
return i + 1
|
||||
}
|
||||
|
||||
fun dec(i: Int): Int {
|
||||
return i - 1
|
||||
}
|
||||
|
||||
fun apply(arg: Int, x: (Int) -> Int): Int {
|
||||
return x(arg)
|
||||
}
|
||||
|
||||
fun compact_test(x: Int): Int {
|
||||
return apply(apply(apply(x, ::inc), ::inc), ::dec)
|
||||
}
|
||||
|
||||
fun external_test(x: Int): Int {
|
||||
return apply_c(apply_c(apply_c(x, ::dec), ::dec), ::inc)
|
||||
}
|
||||
|
||||
fun mixed_test(x: Int): Int {
|
||||
return apply(apply_c(apply(apply_c(apply(x, ::inc), ::inc), ::inc), ::dec), ::inc)
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
class MyClass(val b: Int, var c: Int)
|
||||
|
||||
fun change(x: Int): Int {
|
||||
|
||||
val y = MyClass(x, x)
|
||||
y.c = x
|
||||
y.c = x
|
||||
y.c = 1
|
||||
y.c = x + 1
|
||||
|
||||
return y.c
|
||||
}
|
||||
Reference in New Issue
Block a user