github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/label.go (about) 1 package ccall 2 3 /* 4 #cgo CFLAGS: -I../ 5 #cgo CFLAGS: -Iinclude 6 7 #include <jit/jit.h> 8 */ 9 import "C" 10 import ( 11 "reflect" 12 "unsafe" 13 ) 14 15 type Label struct { 16 c C.jit_label_t 17 } 18 19 var ( 20 UndefinedLabel = &Label{C.jit_label_undefined} 21 ) 22 23 type Labels []*Label 24 25 func (l Labels) c() *C.jit_label_t { 26 clabels := make([]C.jit_label_t, len(l)) 27 for idx, label := range l { 28 clabels[idx] = label.c 29 } 30 return (*C.jit_label_t)(unsafe.Pointer((*reflect.SliceHeader)(unsafe.Pointer(&clabels)).Data)) 31 } 32 33 func toLabel(c C.jit_label_t) *Label { 34 return &Label{c} 35 }