Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gop support #269

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading