github.com/goplus/igop@v0.25.0/cmd/igop/gop_support.go (about) 1 //go:build go1.18 2 // +build go1.18 3 4 package main 5 6 import ( 7 "go/ast" 8 "go/constant" 9 "go/token" 10 "go/types" 11 "io" 12 "net/http" 13 "time" 14 _ "unsafe" 15 16 "github.com/goplus/igop" 17 _ "github.com/goplus/igop/cmd/igop/pkg/github.com/modern-go/reflect2" 18 ) 19 20 //go:generate go run ../qexp -outdir pkg github.com/modern-go/reflect2 21 22 type operandMode byte 23 type builtinId int 24 25 type operand struct { 26 mode operandMode 27 expr ast.Expr 28 typ types.Type 29 val constant.Value 30 id builtinId 31 } 32 33 type positioner interface { 34 Pos() token.Pos 35 } 36 37 //go:linkname checker_infer go/types.(*Checker).infer 38 func checker_infer(check *types.Checker, posn positioner, tparams []*types.TypeParam, targs []types.Type, params *types.Tuple, args []*operand) (result []types.Type) 39 40 //go:linkname serveContent net/http.serveContent 41 func serveContent(w http.ResponseWriter, r *http.Request, name string, modtime time.Time, sizeFunc func() (int64, error), content io.ReadSeeker) 42 43 //go:linkname toHTTPError net/http.toHTTPError 44 func toHTTPError(err error) (msg string, httpStatus int) 45 46 func init() { 47 // support github.com/goplus/gogen.checker_infer 48 igop.RegisterExternal("go/types.(*Checker).infer", checker_infer) 49 igop.RegisterExternal("net/http.serveContent", serveContent) 50 igop.RegisterExternal("net/http.toHTTPError", toHTTPError) 51 }