goplus / llgo

A Go compiler based on LLVM in order to better integrate Go with the C ecosystem including Python
Apache License 2.0
365 stars 26 forks source link

cl: instr funcAddr support typec funclit #833

Closed visualfc closed 1 month ago

visualfc commented 1 month ago

c.Func support typec funclit

package main

import (
    "unsafe"

    "github.com/goplus/llgo/c"
)

//llgo:type C
type Add func(int, int) int

func add(a, b int) int {
    return a + b
}

func main() {
    var fn Add = add
    var myfn Add = func(a, b int) int {
        return a + b
    }
    println(c.Func(add) == c.Func(fn))
    println(c.Func(fn) == *(*unsafe.Pointer)(unsafe.Pointer(&fn)))
    println(c.Func(myfn) == *(*unsafe.Pointer)(unsafe.Pointer(&myfn)))
}
codecov[bot] commented 1 month ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 97.48%. Comparing base (9ea88fe) to head (4e69cd2). Report is 6 commits behind head on main.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #833 +/- ## ======================================= Coverage 97.47% 97.48% ======================================= Files 20 20 Lines 5157 5162 +5 ======================================= + Hits 5027 5032 +5 Misses 110 110 Partials 20 20 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.