diff --git a/.github/workflows/go117.yml b/.github/workflows/go117.yml deleted file mode 100644 index 665b88f0..00000000 --- a/.github/workflows/go117.yml +++ /dev/null @@ -1,110 +0,0 @@ -name: Go1.17 - -on: - push: - branches: [ main ] - pull_request: - branches: [ main ] - -jobs: - - macos: - name: Test Go1.17 for macOS - runs-on: macos-latest - steps: - - - name: Set up Go 1.17 - uses: actions/setup-go@v2 - with: - go-version: 1.17.x - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - - - name: Build - run: go build -v . - - - name: Install igop - run: go install -v ./cmd/igop - - - name: Go Test - run: GOARCH=amd64 go test -race -v . - - - name: Test $GOROOT/test - run: GOARCH=amd64 go run ./cmd/igoptest - - linux: - name: Test Go1.17 for Linux - runs-on: ubuntu-latest - steps: - - - name: Set up Go 1.17 - uses: actions/setup-go@v2 - with: - go-version: 1.17.x - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - - - name: Build - run: go build -v . - - - name: Install igop - run: go install -v ./cmd/igop - - - name: Go Test amd64 - run: GOARCH=amd64 go test -race -v . - - - name: Test $GOROOT/test - run: GOARCH=amd64 go run ./cmd/igoptest - - windows: - name: Test Go1.17 for Windows - runs-on: windows-latest - steps: - - - name: Set up Go 1.17 - uses: actions/setup-go@v2 - with: - go-version: 1.17.x - - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - - - name: Get dependencies - run: | - go get -v -t -d ./... - - - name: Build - run: go build -v . - - - name: Install igop - run: go install -v ./cmd/igop - - - name: Go Test amd64 - run: | - set GOARCH=amd64 - go test -race -v . - - - name: Test $GOROOT/test amd64 - run: | - set GOARCH=amd64 - go run ./cmd/igoptest - - - name: Go Test 386 - run: | - set GOARCH=386 - go test -v . - - - name: Go $GOROOT/test 386 - run: | - set GOARCH=386 - go run ./cmd/igoptest diff --git a/.github/workflows/go116.yml b/.github/workflows/go122.yml similarity index 87% rename from .github/workflows/go116.yml rename to .github/workflows/go122.yml index 496a1638..2185f2df 100644 --- a/.github/workflows/go116.yml +++ b/.github/workflows/go122.yml @@ -1,4 +1,4 @@ -name: Go1.16 +name: Go1.22 on: push: @@ -9,14 +9,14 @@ on: jobs: macos: - name: Test Go1.16 for macOS + name: Test Go1.22 for macOS runs-on: macos-latest steps: - - name: Set up Go 1.16 + - name: Set up Go 1.22 uses: actions/setup-go@v2 with: - go-version: 1.16.x + go-version: 1.22.x - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -38,14 +38,14 @@ jobs: run: GOARCH=amd64 go run ./cmd/igoptest linux: - name: Test Go1.16 for Linux + name: Test Go1.22 for Linux runs-on: ubuntu-latest steps: - - name: Set up Go 1.16 + - name: Set up Go 1.22 uses: actions/setup-go@v2 with: - go-version: 1.16.x + go-version: 1.22.x - name: Check out code into the Go module directory uses: actions/checkout@v2 @@ -67,14 +67,14 @@ jobs: run: GOARCH=amd64 go run ./cmd/igoptest windows: - name: Test Go1.16 for Windows + name: Test Go1.22 for Windows runs-on: windows-latest steps: - - name: Set up Go 1.16 + - name: Set up Go 1.22 uses: actions/setup-go@v2 with: - go-version: 1.16.x + go-version: 1.22.x - name: Check out code into the Go module directory uses: actions/checkout@v2 diff --git a/README.md b/README.md index 484cb9a0..ef1bb565 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,17 @@ # iGo+ The Go/Go+ Interpreter -[![Go1.16](https://github.com/goplus/igop/workflows/Go1.16/badge.svg)](https://github.com/goplus/igop/actions/workflows/go116.yml) -[![Go1.17](https://github.com/goplus/igop/workflows/Go1.17/badge.svg)](https://github.com/goplus/igop/actions/workflows/go117.yml) +github.com/goplus/igop/actions/workflows/go117.yml) [![Go1.18](https://github.com/goplus/igop/workflows/Go1.18/badge.svg)](https://github.com/goplus/igop/actions/workflows/go118.yml) [![Go1.19](https://github.com/goplus/igop/workflows/Go1.19/badge.svg)](https://github.com/goplus/igop/actions/workflows/go119.yml) [![Go1.20](https://github.com/goplus/igop/workflows/Go1.20/badge.svg)](https://github.com/goplus/igop/actions/workflows/go120.yml) [![Go1.21](https://github.com/goplus/igop/workflows/Go1.21/badge.svg)](https://github.com/goplus/igop/actions/workflows/go121.yml) +[![Go1.22](https://github.com/goplus/igop/workflows/Go1.22/badge.svg)](https://github.com/goplus/igop/actions/workflows/go122.yml) [![Go Reference](https://pkg.go.dev/badge/github.com/goplus/igop.svg)](https://pkg.go.dev/github.com/goplus/igop) ### Go Version -- Go1.16 ~ Go1.21 +- Go1.16 ~ Go1.22 - macOS Linux Windows WebAssembly GopherJS and more. ### ABI @@ -26,10 +26,11 @@ support ABI0 and ABIInternal - Go1.19: amd64 arm64 ppc64/ppc64le riscv64 - Go1.20: amd64 arm64 ppc64/ppc64le riscv64 - Go1.21: amd64 arm64 ppc64/ppc64le riscv64 + - Go1.22: amd64 arm64 ppc64/ppc64le riscv64 ### Generics -- support generics (Go1.18/Go1.19/Go1.20/Go1.21) +- support generics (Go1.18 ~ Go1.22) - support [Go1.20 nested type-parameterized declarations](https://github.com/golang/go/blob/master/test/typeparam/nested.go) on Go1.18/Go1.19 (Experimental) ### runtime.GC diff --git a/builtin.go b/builtin.go index b6e12e66..6703584f 100644 --- a/builtin.go +++ b/builtin.go @@ -555,6 +555,58 @@ func (interp *Interp) callBuiltinByStack(caller *frame, fn string, ssaArgs []ssa case "clear": arg0 := caller.reg(ia[0]) valueClear(reflect.ValueOf(arg0)) + case "max": + v := reflect.ValueOf(caller.reg(ia[0])) + for _, i := range ia { + arg := reflect.ValueOf(caller.reg(i)) + if i > 0 { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if v.Int() < arg.Int() { + v = arg + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + if v.Uint() < arg.Uint() { + v = arg + } + case reflect.Float32, reflect.Float64: + if v.Float() < arg.Float() { + v = arg + } + case reflect.String: + if v.String() < arg.String() { + v = arg + } + } + } + } + caller.setReg(ir, v.Interface()) + case "min": + v := reflect.ValueOf(caller.reg(ia[0])) + for _, i := range ia { + arg := reflect.ValueOf(caller.reg(i)) + if i > 0 { + switch v.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if v.Int() > arg.Int() { + v = arg + } + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + if v.Uint() > arg.Uint() { + v = arg + } + case reflect.Float32, reflect.Float64: + if v.Float() > arg.Float() { + v = arg + } + case reflect.String: + if v.String() > arg.String() { + v = arg + } + } + } + } + caller.setReg(ir, v.Interface()) default: panic("unknown built-in: " + fn) } diff --git a/cmd/igoptest/main.go b/cmd/igoptest/main.go index 1967b8cb..98195b6d 100644 --- a/cmd/igoptest/main.go +++ b/cmd/igoptest/main.go @@ -61,7 +61,7 @@ func init() { ver := runtime.Version()[:6] switch ver { - case "go1.17", "go1.18", "go1.19", "go1.20", "go1.21": + case "go1.17", "go1.18", "go1.19", "go1.20", "go1.21", "go1.22": // gorootTestSkips["fixedbugs/issue45045.go"] = "runtime.SetFinalizer" // gorootTestSkips["fixedbugs/issue46725.go"] = "runtime.SetFinalizer" gorootTestSkips["abi/fibish.go"] = "slow, 34s" @@ -86,9 +86,21 @@ func init() { gorootTestSkips["typeparam/cons.go"] = "skip golang.org/x/tools v0.7.0 on go1.18" gorootTestSkips["typeparam/list2.go"] = "skip golang.org/x/tools v0.7.0 on go1.18" } - if ver == "go1.21" { + if ver == "go1.21" || ver == "go1.22" { gorootTestSkips["fixedbugs/issue19658.go"] = "skip command" } + if ver == "go1.22" { + gorootTestSkips["fixedbugs/bug369.go"] = "skip command" + gorootTestSkips["fixedbugs/issue10607.go"] = "skip command" + gorootTestSkips["fixedbugs/issue21317.go"] = "skip command" + gorootTestSkips["fixedbugs/issue38093.go"] = "skip js" + gorootTestSkips["fixedbugs/issue64565.go"] = "skip command" + gorootTestSkips["fixedbugs/issue9355.go"] = "skip command" + gorootTestSkips["linkmain_run.go"] = "skip link" + gorootTestSkips["linkobj.go"] = "skip link" + gorootTestSkips["linkx_run.go"] = "skip link" + gorootTestSkips["chanlinear.go"] = "skip -gc-exp" + } case "go1.16": gorootTestSkips["fixedbugs/issue7740.go"] = "BUG, const float" case "go1.15": @@ -105,6 +117,10 @@ func init() { gorootTestSkips["fixedbugs/issue15002.go"] = "skip windows" gorootTestSkips["fixedbugs/issue5493.go"] = "skip windows" gorootTestSkips["fixedbugs/issue5963.go"] = "skip windows" + if ver == "go1.22" { + gorootTestSkips["recover4.go"] = "skip windows" + gorootTestSkips["sigchld.go"] = "skip windows" + } skips := make(map[string]string) for k, v := range gorootTestSkips { diff --git a/go.mod b/go.mod index 32ba8a1c..e4e7ed4d 100644 --- a/go.mod +++ b/go.mod @@ -4,17 +4,17 @@ go 1.16 require ( github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 - github.com/goplus/gop v1.1.9 - github.com/goplus/gox v1.12.8 - github.com/goplus/mod v0.12.1 - github.com/goplus/reflectx v1.2.1 + github.com/goplus/gop v1.2.0-pre.1.0.20240207161635-4085ba2e137f + github.com/goplus/gox v1.14.7 + github.com/goplus/mod v0.13.0 + github.com/goplus/reflectx v1.2.2 github.com/modern-go/reflect2 v1.0.2 github.com/peterh/liner v1.2.2 - github.com/qiniu/x v1.13.2 + github.com/qiniu/x v1.13.3 github.com/visualfc/funcval v0.1.4 github.com/visualfc/gid v0.1.0 github.com/visualfc/goembed v0.3.2 github.com/visualfc/xtype v0.2.0 golang.org/x/mod v0.14.0 - golang.org/x/tools v0.14.0 + golang.org/x/tools v0.17.0 ) diff --git a/go.sum b/go.sum index 5b01a1ff..5e3b9816 100644 --- a/go.sum +++ b/go.sum @@ -6,18 +6,16 @@ github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/ github.com/gopherjs/gopherjs v0.0.0-20180708170036-38b413be4187/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 h1:l5lAOZEym3oK3SQ2HBHWsJUfbNBiTXJDeW2QDxw9AQ0= github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/goplus/c2go v0.7.16/go.mod h1:XODEFX2PeEEJXNLLdykWeZgMSaKJ51fVm+C9IM3FxNQ= -github.com/goplus/gop v1.1.9 h1:7e0jQFbTeFGOU5Rmd58YV/1nRLySdooSAFGWAeW6UBo= -github.com/goplus/gop v1.1.9/go.mod h1:OQBkI9FbIOJWtHP9ahB1d6cKEq+2P10IJ588ewGhnhk= -github.com/goplus/gox v1.12.1/go.mod h1:wymoQJ7ydd42cTlaXb4wNbvn4LlKjR+j8PZehI7v1zQ= -github.com/goplus/gox v1.12.8 h1:xXpsGbNIIDmykOQwI/kDcoA3cOX5ISvLPlU5RiPtyZY= -github.com/goplus/gox v1.12.8/go.mod h1:MOJnwqA8/rSUkn0vsayHFK7TD/3XQrdexMTqdzR70X0= -github.com/goplus/mod v0.11.5/go.mod h1:NDC5E+XOT8vcJCMjqKhLDJHTHX7lyVN4Vbfi2U7dBhs= -github.com/goplus/mod v0.11.8/go.mod h1:yl2QncBKTdXk+8UaNsdo4u2zSpGEJYA5JKjgD3K2h00= -github.com/goplus/mod v0.12.1 h1:4M1py5liQ/bfxPPXcmVbYn3JAjfcDpTANtih5omFI6c= -github.com/goplus/mod v0.12.1/go.mod h1:ZtlS9wHOcAVxZ/zq7WLdKVes1HG/8Yn3KNuWZGcpeTs= -github.com/goplus/reflectx v1.2.1 h1:y3Bq7cmP/zO++VFpZetC3zljVM3LkGivh2GgUJLu4wI= -github.com/goplus/reflectx v1.2.1/go.mod h1:wHOS9ilbB4zrecI0W1dMmkW9JMcpXV7VjALVbNU9xfM= +github.com/goplus/c2go v0.7.21/go.mod h1:45zjbWGW8NDuGfTOrFchCIpH9TbiH7TPg8/zF6EdEyk= +github.com/goplus/gop v1.2.0-pre.1.0.20240207161635-4085ba2e137f h1:EsryFWThtzZAAXkjOOoQkVDTHHSijJwWYAJXVF2xdUk= +github.com/goplus/gop v1.2.0-pre.1.0.20240207161635-4085ba2e137f/go.mod h1:bUvpxW+/8T13pi07HO0SxNPCL+k5D5IkauiBYyU2Ec4= +github.com/goplus/gox v1.14.2/go.mod h1:G7Hz+cAOUyJyN9pPHrpqhfQPDUtiJNmoRVTwoaQ9nw0= +github.com/goplus/gox v1.14.7 h1:C70XxjEVRjrmkblNkbM5oSZOJTOgimsXRtK6/XVlk5s= +github.com/goplus/gox v1.14.7/go.mod h1:G7Hz+cAOUyJyN9pPHrpqhfQPDUtiJNmoRVTwoaQ9nw0= +github.com/goplus/mod v0.13.0 h1:M/VsI/NWTcs2+vtWBG7793zmlCimKlSMY5LXaiztXV8= +github.com/goplus/mod v0.13.0/go.mod h1:Qin2SxKoK+3cNFwtg4Jnk1F9Qn5vR6Kwlvr6lTCRJNI= +github.com/goplus/reflectx v1.2.2 h1:T1p20OIH/HcnAvQQNnDLwl6AZOjU34icsfc6migD6L8= +github.com/goplus/reflectx v1.2.2/go.mod h1:wHOS9ilbB4zrecI0W1dMmkW9JMcpXV7VjALVbNU9xfM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/mattn/go-runewidth v0.0.3 h1:a+kO+98RDGEfo6asOGMmpodZq4FNtnGP54yps8BzLR4= github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= @@ -28,10 +26,8 @@ github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/qiniu/x v1.13.0/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E= -github.com/qiniu/x v1.13.1/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E= -github.com/qiniu/x v1.13.2 h1:mgWOfB9Rpk6AEtlBoObZVxH+b2FHSntYrxc4KX5Ta98= -github.com/qiniu/x v1.13.2/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E= +github.com/qiniu/x v1.13.3 h1:NER9aJnVzjH0XapzIWrWNAn2SPwck0xGMyIIlfCMm84= +github.com/qiniu/x v1.13.3/go.mod h1:INZ2TSWSJVWO/RuELQROERcslBwVgFG7MkTfEdaQz9E= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -54,11 +50,10 @@ github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5t golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/mod v0.13.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/mod v0.14.0 h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= @@ -67,13 +62,13 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.15.0/go.mod h1:idbUs1IY1+zTqbi8yxTbhexhEEk5ur9LInksu6HrEpk= -golang.org/x/net v0.16.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= -golang.org/x/sync v0.4.0 h1:zxkM55ReGkDlKSM+Fu41A+zmbZuaPVbGMzvvdUPznYQ= -golang.org/x/sync v0.4.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ= +golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -84,27 +79,28 @@ golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU= +golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= -golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= golang.org/x/tools v0.13.0/go.mod h1:HvlwmtVNQAhOuCjW7xxvovg8wbNq7LwfXh/k7wXUl58= -golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc= -golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg= +golang.org/x/tools v0.17.0 h1:FvmRgNOcs3kOa+T20R1uhfP9F6HgG2mfxDv1vrx1Htc= +golang.org/x/tools v0.17.0/go.mod h1:xsh6VxdV005rRVaS6SSAf9oiAqljS7UZUacMZ8Bnsps= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/gopbuild/build.go b/gopbuild/build.go index 79c3edc0..3d48c671 100644 --- a/gopbuild/build.go +++ b/gopbuild/build.go @@ -73,6 +73,7 @@ func RegisterClassFileType(ext string, class string, works []*Class, pkgPaths .. } func init() { + cl.SetDebug(cl.FlagNoMarkAutogen) igop.RegisterFileProcess(".gop", BuildFile) igop.RegisterFileProcess(".gox", BuildFile) RegisterClassFileType(".gmx", "Game", []*Class{{Ext: ".spx", Class: "Sprite"}}, "github.com/goplus/spx", "math") @@ -276,8 +277,7 @@ func (c *Context) loadPackage(srcDir string, pkgs map[string]*ast.Package) (*Pac mainPkg.GoFiles = map[string]*goast.File{"_igop_builtin.go": f} } } - conf := &cl.Config{ - WorkingDir: srcDir, TargetDir: srcDir, Fset: c.fset} + conf := &cl.Config{Fset: c.fset} conf.Importer = c conf.LookupClass = func(ext string) (c *cl.Project, ok bool) { c, ok = projects[ext] diff --git a/gopbuild/build_test.go b/gopbuild/build_test.go index c48aed43..7a911b89 100644 --- a/gopbuild/build_test.go +++ b/gopbuild/build_test.go @@ -48,9 +48,9 @@ println "Go+" `, `package main import "fmt" - -func main() { //line main.gop:2 +func main() { +//line main.gop:2:1 fmt.Println("Go+") } `) @@ -65,9 +65,9 @@ import "fmt" type Rect struct { } - -func (this *Rect) Main() { //line Rect.gox:2 +func (this *Rect) Main() { +//line Rect.gox:2:1 fmt.Println("Go+") } func main() { @@ -93,9 +93,9 @@ type Rect struct { Buffer v int } - -func (this *Rect) Main() { //line Rect.gox:9 +func (this *Rect) Main() { +//line Rect.gox:9:1 fmt.Println("Go+") } func main() { @@ -121,9 +121,9 @@ type Rect struct { *Buffer v int } - -func (this *Rect) Main() { //line Rect.gox:9 +func (this *Rect) Main() { +//line Rect.gox:9:1 fmt.Println("Go+") } func main() { @@ -139,17 +139,17 @@ println "Go+" `, `package main import ( - "fmt" "bytes" + "fmt" ) type Rect struct { *bytes.Buffer v int } - -func (this *Rect) Main() { //line Rect.gox:7 +func (this *Rect) Main() { +//line Rect.gox:7:1 fmt.Println("Go+") } func main() { @@ -165,17 +165,17 @@ println "Go+" `, `package main import ( - "fmt" "bytes" + "fmt" ) type Rect struct { bytes.Buffer v int } - -func (this *Rect) Main() { //line Rect.gox:7 +func (this *Rect) Main() { +//line Rect.gox:7:1 fmt.Println("Go+") } func main() { @@ -194,12 +194,12 @@ import ( "github.com/goplus/gop/builtin/ng" "math/big" ) - -func main() { //line main.gop:2 +func main() { +//line main.gop:2:1 a := ng.Bigrat_Init__2(big.NewRat(1, 2)) -//line main.gop:3 - fmt.Println(a.Gop_Add(ng.Bigrat_Init__2(big.NewRat(1, 2)))) +//line main.gop:3:1 + fmt.Println((ng.Bigrat).Gop_Add(a, ng.Bigrat_Init__2(big.NewRat(1, 2)))) } `) } @@ -212,11 +212,11 @@ println(v) `, `package main import "fmt" - -func main() { //line main.gop:2 +func main() { +//line main.gop:2:1 v := typeof(100) -//line main.gop:3 +//line main.gop:3:1 fmt.Println(v) } `) @@ -240,16 +240,16 @@ import ( ) var r io.Reader - -func main() { //line main.gop:6 +func main() { +//line main.gop:6:1 for _gop_it := iox.Lines(r).Gop_Enum(); ; { var _gop_ok bool line, _gop_ok := _gop_it.Next() if !_gop_ok { break } -//line main.gop:7 +//line main.gop:7:1 fmt.Println(line) } } @@ -280,104 +280,106 @@ println addSafe("10", "abc") import ( "fmt" - "strconv" "github.com/qiniu/x/errors" + "strconv" ) - +//line main.gop:6:1 func add(x string, y string) (int, error) { -//line main.gop:7 +//line main.gop:7:1 var _autoGo_1 int -//line main.gop:7 +//line main.gop:7:1 { -//line main.gop:7 +//line main.gop:7:1 var _gop_err error -//line main.gop:7 +//line main.gop:7:1 _autoGo_1, _gop_err = strconv.Atoi(x) -//line main.gop:7 +//line main.gop:7:1 if _gop_err != nil { -//line main.gop:7 +//line main.gop:7:1 _gop_err = errors.NewFrame(_gop_err, "strconv.Atoi(x)", "main.gop", 7, "main.add") -//line main.gop:7 +//line main.gop:7:1 return 0, _gop_err } -//line main.gop:7 +//line main.gop:7:1 goto _autoGo_2 _autoGo_2: -//line main.gop:7 +//line main.gop:7:1 } -//line main.gop:7 +//line main.gop:7:1 var _autoGo_3 int -//line main.gop:7 +//line main.gop:7:1 { -//line main.gop:7 +//line main.gop:7:1 var _gop_err error -//line main.gop:7 +//line main.gop:7:1 _autoGo_3, _gop_err = strconv.Atoi(y) -//line main.gop:7 +//line main.gop:7:1 if _gop_err != nil { -//line main.gop:7 +//line main.gop:7:1 _gop_err = errors.NewFrame(_gop_err, "strconv.Atoi(y)", "main.gop", 7, "main.add") -//line main.gop:7 +//line main.gop:7:1 return 0, _gop_err } -//line main.gop:7 +//line main.gop:7:1 goto _autoGo_4 _autoGo_4: -//line main.gop:7 +//line main.gop:7:1 } -//line main.gop:7 +//line main.gop:7:1 return _autoGo_1 + _autoGo_3, nil } +//line main.gop:10:1 func addSafe(x string, y string) int { -//line main.gop:11 +//line main.gop:11:1 return func() (_gop_ret int) { -//line main.gop:11 +//line main.gop:11:1 var _gop_err error -//line main.gop:11 +//line main.gop:11:1 _gop_ret, _gop_err = strconv.Atoi(x) -//line main.gop:11 +//line main.gop:11:1 if _gop_err != nil { -//line main.gop:11 +//line main.gop:11:1 return 0 } -//line main.gop:11 +//line main.gop:11:1 return }() + func() (_gop_ret int) { -//line main.gop:11 +//line main.gop:11:1 var _gop_err error -//line main.gop:11 +//line main.gop:11:1 _gop_ret, _gop_err = strconv.Atoi(y) -//line main.gop:11 +//line main.gop:11:1 if _gop_err != nil { -//line main.gop:11 +//line main.gop:11:1 return 0 } -//line main.gop:11 +//line main.gop:11:1 return }() } -func main() { //line main.gop:14 +func main() { +//line main.gop:14:1 fmt.Println(func() (_gop_ret int) { -//line main.gop:14 +//line main.gop:14:1 var _gop_err error -//line main.gop:14 +//line main.gop:14:1 _gop_ret, _gop_err = add("100", "23") -//line main.gop:14 +//line main.gop:14:1 if _gop_err != nil { -//line main.gop:14 +//line main.gop:14:1 _gop_err = errors.NewFrame(_gop_err, "add(\"100\", \"23\")", "main.gop", 14, "main.main") -//line main.gop:14 +//line main.gop:14:1 panic(_gop_err) } -//line main.gop:14 +//line main.gop:14:1 return }()) -//line main.gop:16 +//line main.gop:16:1 sum, err := add("10", "abc") -//line main.gop:17 +//line main.gop:17:1 fmt.Println(sum, err) -//line main.gop:19 +//line main.gop:19:1 fmt.Println(addSafe("10", "abc")) } `)