Skip to content

Commit

Permalink
Merge pull request #269 from visualfc/gop_support
Browse files Browse the repository at this point in the history
gop support
  • Loading branch information
visualfc authored Mar 11, 2024
2 parents 05e3440 + 9f6e1b7 commit 3671b00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/igop/gox_support.go → cmd/igop/gop_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import (
"go/constant"
"go/token"
"go/types"
"io"
"net/http"
"time"
_ "unsafe"

"github.com/goplus/igop"
Expand All @@ -34,7 +37,15 @@ type positioner interface {
//go:linkname checker_infer go/types.(*Checker).infer
func checker_infer(check *types.Checker, posn positioner, tparams []*types.TypeParam, targs []types.Type, params *types.Tuple, args []*operand) (result []types.Type)

//go:linkname serveContent net/http.serveContent
func serveContent(w http.ResponseWriter, r *http.Request, name string, modtime time.Time, sizeFunc func() (int64, error), content io.ReadSeeker)

//go:linkname toHTTPError net/http.toHTTPError
func toHTTPError(err error) (msg string, httpStatus int)

func init() {
// support github.com/goplus/gogen.checker_infer
igop.RegisterExternal("go/types.(*Checker).infer", checker_infer)
igop.RegisterExternal("net/http.serveContent", serveContent)
igop.RegisterExternal("net/http.toHTTPError", toHTTPError)
}
3 changes: 3 additions & 0 deletions context.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,9 @@ func (ctx *Context) loadPackage(bp *build.Package, path string, dir string) (*so
if embed != nil {
files = append(files, embed)
}
if bp.Name == "main" {
path = "main"
}
tp := &sourcePackage{
Package: types.NewPackage(path, bp.Name),
Files: files,
Expand Down

0 comments on commit 3671b00

Please sign in to comment.