cl: compile async functions

This commit is contained in:
Li Jie
2024-08-04 09:54:34 +08:00
parent 806193fc6e
commit efa771f3ff
18 changed files with 1127 additions and 1103 deletions

37
cl/_testdata/async/in.go Normal file
View File

@@ -0,0 +1,37 @@
package async_compile
import (
"fmt"
"github.com/goplus/llgo/x/async"
)
func GenInts() (co *async.Promise[int]) {
co.Yield(1)
co.Yield(2)
co.Yield(3)
return
}
func WrapGenInts() *async.Promise[int] {
return GenInts()
}
func UseGenInts() int {
co := WrapGenInts()
r := 0
for !co.Done() {
r += co.Next()
}
return r
}
func GenIntsWithDefer() (co *async.Promise[int]) {
defer func() {
if r := recover(); r != nil {
fmt.Println("panic:", r)
}
}()
co.Yield(1)
panic("GenIntsWithDefer")
}