Ok, full functions as values support with types and fixes of earlier bugs. Now typedef the function pointer types when generateing C.
This commit is contained in:
@@ -1 +1,8 @@
|
||||
9
|
||||
9
|
||||
7
|
||||
8
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
|
||||
@@ -4,9 +4,52 @@ fun test(): void {
|
||||
println(9)
|
||||
}
|
||||
|
||||
fun test2(toPrint: int): void {
|
||||
println(toPrint)
|
||||
}
|
||||
|
||||
fun test3(): fun():void {
|
||||
return test4;
|
||||
}
|
||||
|
||||
fun test4(): void {
|
||||
println(11)
|
||||
}
|
||||
|
||||
fun doIt(fun: fun():void):void {
|
||||
fun()
|
||||
}
|
||||
|
||||
fun itToBeDone():void {
|
||||
println(12)
|
||||
}
|
||||
|
||||
fun doItParam(fun: fun(int):void, param:int):void {
|
||||
fun(param)
|
||||
}
|
||||
|
||||
fun itToBeDoneParam(param:int):void {
|
||||
println(param)
|
||||
}
|
||||
|
||||
fun main(): int {
|
||||
var val = test
|
||||
var val2: fun():void = test
|
||||
val()
|
||||
val2()
|
||||
|
||||
|
||||
var val3 = test2
|
||||
var val4: fun(int):void = test2
|
||||
val3(7)
|
||||
val4(8)
|
||||
|
||||
test3()()
|
||||
doIt(itToBeDone)
|
||||
doItParam(itToBeDoneParam, 13)
|
||||
var indrdo = doItParam
|
||||
var indrdoParam = itToBeDoneParam
|
||||
indrdo(indrdoParam, 14)
|
||||
return 0
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user