mirror of
https://github.com/moby/moby.git
synced 2026-08-04 15:11:00 +00:00
Merge pull request #51594 from thaJeztah/bump_x_deps
vendor: update various golang.org/x/xxx dependencies
This commit is contained in:
14
go.mod
14
go.mod
@@ -105,11 +105,11 @@ require (
|
||||
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.38.0
|
||||
go.opentelemetry.io/otel/sdk v1.38.0
|
||||
go.opentelemetry.io/otel/trace v1.38.0
|
||||
golang.org/x/mod v0.29.0
|
||||
golang.org/x/net v0.46.0
|
||||
golang.org/x/sync v0.17.0
|
||||
golang.org/x/sys v0.37.0
|
||||
golang.org/x/text v0.30.0
|
||||
golang.org/x/mod v0.30.0
|
||||
golang.org/x/net v0.47.0
|
||||
golang.org/x/sync v0.18.0
|
||||
golang.org/x/sys v0.38.0
|
||||
golang.org/x/text v0.31.0
|
||||
golang.org/x/time v0.14.0
|
||||
google.golang.org/genproto/googleapis/api v0.0.0-20250825161204-c5933d9347a5
|
||||
google.golang.org/grpc v1.76.0
|
||||
@@ -243,9 +243,9 @@ require (
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
go.uber.org/zap v1.27.0 // indirect
|
||||
go.yaml.in/yaml/v2 v2.4.3 // indirect
|
||||
golang.org/x/crypto v0.43.0 // indirect
|
||||
golang.org/x/crypto v0.44.0 // indirect
|
||||
golang.org/x/oauth2 v0.30.0 // indirect
|
||||
golang.org/x/tools v0.37.0 // indirect
|
||||
golang.org/x/tools v0.38.0 // indirect
|
||||
google.golang.org/api v0.248.0 // indirect
|
||||
google.golang.org/genproto v0.0.0-20250603155806-513f23925822 // indirect; TODO(thaJeztah): should we keep this one aligned with the other google.golang.org/genproto/xxx modules?
|
||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20250825161204-c5933d9347a5 // indirect
|
||||
|
||||
32
go.sum
32
go.sum
@@ -706,8 +706,8 @@ golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201124201722-c8d3bf9c5392/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.43.0 h1:dduJYIi3A3KOfdGOHX8AVZ/jGiyPa3IbBozJ5kNuE04=
|
||||
golang.org/x/crypto v0.43.0/go.mod h1:BFbav4mRNlXJL4wNeejLpWxB7wMbc79PdRGhWKncxR0=
|
||||
golang.org/x/crypto v0.44.0 h1:A97SsFvM3AIwEEmTBiaxPPTYpDC47w720rdiiUvgoAU=
|
||||
golang.org/x/crypto v0.44.0/go.mod h1:013i+Nw79BMiQiMsOPcVCB5ZIJbYkerPrGnOa00tvmc=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
golang.org/x/exp v0.0.0-20250911091902-df9299821621 h1:2id6c1/gto0kaHYyrixvknJ8tUK/Qs5IsmBtrc+FtgU=
|
||||
golang.org/x/exp v0.0.0-20250911091902-df9299821621/go.mod h1:TwQYMMnGpvZyc+JpB/UAuTNIsVJifOlSkrZkhcvpVUk=
|
||||
@@ -716,8 +716,8 @@ golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvx
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.29.0 h1:HV8lRxZC4l2cr3Zq1LvtOsi/ThTgWnUk/y64QSs8GwA=
|
||||
golang.org/x/mod v0.29.0/go.mod h1:NyhrlYXJ2H4eJiRy/WDBO6HMqZQ6q9nk4JzS3NuCK+w=
|
||||
golang.org/x/mod v0.30.0 h1:fDEXFVZ/fmCKProc/yAXXUijritrDzahmwwefnjoPFk=
|
||||
golang.org/x/mod v0.30.0/go.mod h1:lAsf5O2EvJeSFMiBxXDki7sCgAxEUcZHXoXMKT4GJKc=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
@@ -734,8 +734,8 @@ golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLL
|
||||
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.46.0 h1:giFlY12I07fugqwPuWJi68oOnpfqFnJIJzaIIm2JVV4=
|
||||
golang.org/x/net v0.46.0/go.mod h1:Q9BGdFy1y4nkUwiLvT5qtyhAnEHgnQ/zd8PfU6nc210=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
golang.org/x/oauth2 v0.0.0-20170912212905-13449ad91cb2/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
|
||||
@@ -747,8 +747,8 @@ golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJ
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
|
||||
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sync v0.18.0 h1:kr88TuHDroi+UVf+0hZnirlk8o8T+4MrK6mr60WkH/I=
|
||||
golang.org/x/sync v0.18.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
|
||||
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
@@ -770,17 +770,17 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.37.0 h1:fdNQudmxPjkdUTPnLn5mdQv7Zwvbvpaxqs831goi9kQ=
|
||||
golang.org/x/sys v0.37.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.36.0 h1:zMPR+aF8gfksFprF/Nc/rd1wRS1EI6nDBGyWAvDzx2Q=
|
||||
golang.org/x/term v0.36.0/go.mod h1:Qu394IJq6V6dCBRgwqshf3mPF85AqzYEzofzRdZkWss=
|
||||
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.30.0 h1:yznKA/E9zq54KzlzBEAWn1NXSQ8DIp/NYMy88xJjl4k=
|
||||
golang.org/x/text v0.30.0/go.mod h1:yDdHFIX9t+tORqspjENWgzaCVXgk0yYnYuSZ8UzzBVM=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
golang.org/x/time v0.0.0-20170424234030-8be79e1e0910/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/time v0.14.0 h1:MRx4UaLrDotUKUdCIqzPC48t1Y9hANFKIRpNx+Te8PI=
|
||||
golang.org/x/time v0.14.0/go.mod h1:eL/Oa2bBBK0TkX57Fyni+NgnyQQN4LitPmob2Hjnqw4=
|
||||
@@ -793,8 +793,8 @@ golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtn
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
|
||||
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
|
||||
golang.org/x/tools v0.38.0 h1:Hx2Xv8hISq8Lm16jvBZ2VQf+RLmbd7wVUsALibYI/IQ=
|
||||
golang.org/x/tools v0.38.0/go.mod h1:yEsQ/d/YK8cjh0L6rZlY8tgtlKiBNTL14pGDJPJpYQs=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
|
||||
18
vendor/golang.org/x/crypto/argon2/argon2.go
generated
vendored
18
vendor/golang.org/x/crypto/argon2/argon2.go
generated
vendored
@@ -6,7 +6,7 @@
|
||||
// Argon2 was selected as the winner of the Password Hashing Competition and can
|
||||
// be used to derive cryptographic keys from passwords.
|
||||
//
|
||||
// For a detailed specification of Argon2 see [1].
|
||||
// For a detailed specification of Argon2 see [argon2-specs.pdf].
|
||||
//
|
||||
// If you aren't sure which function you need, use Argon2id (IDKey) and
|
||||
// the parameter recommendations for your scenario.
|
||||
@@ -17,7 +17,7 @@
|
||||
// It uses data-independent memory access, which is preferred for password
|
||||
// hashing and password-based key derivation. Argon2i requires more passes over
|
||||
// memory than Argon2id to protect from trade-off attacks. The recommended
|
||||
// parameters (taken from [2]) for non-interactive operations are time=3 and to
|
||||
// parameters (taken from [RFC 9106 Section 7.3]) for non-interactive operations are time=3 and to
|
||||
// use the maximum available memory.
|
||||
//
|
||||
// # Argon2id
|
||||
@@ -27,11 +27,11 @@
|
||||
// half of the first iteration over the memory and data-dependent memory access
|
||||
// for the rest. Argon2id is side-channel resistant and provides better brute-
|
||||
// force cost savings due to time-memory tradeoffs than Argon2i. The recommended
|
||||
// parameters for non-interactive operations (taken from [2]) are time=1 and to
|
||||
// parameters for non-interactive operations (taken from [RFC 9106 Section 7.3]) are time=1 and to
|
||||
// use the maximum available memory.
|
||||
//
|
||||
// [1] https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf
|
||||
// [2] https://tools.ietf.org/html/draft-irtf-cfrg-argon2-03#section-9.3
|
||||
// [argon2-specs.pdf]: https://github.com/P-H-C/phc-winner-argon2/blob/master/argon2-specs.pdf
|
||||
// [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3
|
||||
package argon2
|
||||
|
||||
import (
|
||||
@@ -59,7 +59,7 @@ const (
|
||||
//
|
||||
// key := argon2.Key([]byte("some password"), salt, 3, 32*1024, 4, 32)
|
||||
//
|
||||
// The draft RFC recommends[2] time=3, and memory=32*1024 is a sensible number.
|
||||
// [RFC 9106 Section 7.3] recommends time=3, and memory=32*1024 as a sensible number.
|
||||
// If using that amount of memory (32 MB) is not possible in some contexts then
|
||||
// the time parameter can be increased to compensate.
|
||||
//
|
||||
@@ -69,6 +69,8 @@ const (
|
||||
// adjusted to the number of available CPUs. The cost parameters should be
|
||||
// increased as memory latency and CPU parallelism increases. Remember to get a
|
||||
// good random salt.
|
||||
//
|
||||
// [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3
|
||||
func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint32) []byte {
|
||||
return deriveKey(argon2i, password, salt, nil, nil, time, memory, threads, keyLen)
|
||||
}
|
||||
@@ -83,7 +85,7 @@ func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint3
|
||||
//
|
||||
// key := argon2.IDKey([]byte("some password"), salt, 1, 64*1024, 4, 32)
|
||||
//
|
||||
// The draft RFC recommends[2] time=1, and memory=64*1024 is a sensible number.
|
||||
// [RFC 9106 Section 7.3] recommends time=1, and memory=64*1024 as a sensible number.
|
||||
// If using that amount of memory (64 MB) is not possible in some contexts then
|
||||
// the time parameter can be increased to compensate.
|
||||
//
|
||||
@@ -93,6 +95,8 @@ func Key(password, salt []byte, time, memory uint32, threads uint8, keyLen uint3
|
||||
// adjusted to the numbers of available CPUs. The cost parameters should be
|
||||
// increased as memory latency and CPU parallelism increases. Remember to get a
|
||||
// good random salt.
|
||||
//
|
||||
// [RFC 9106 Section 7.3]: https://www.rfc-editor.org/rfc/rfc9106.html#section-7.3
|
||||
func IDKey(password, salt []byte, time, memory uint32, threads uint8, keyLen uint32) []byte {
|
||||
return deriveKey(argon2id, password, salt, nil, nil, time, memory, threads, keyLen)
|
||||
}
|
||||
|
||||
2
vendor/golang.org/x/crypto/chacha20/chacha_arm64.s
generated
vendored
2
vendor/golang.org/x/crypto/chacha20/chacha_arm64.s
generated
vendored
@@ -29,7 +29,7 @@ loop:
|
||||
MOVD $NUM_ROUNDS, R21
|
||||
VLD1 (R11), [V30.S4, V31.S4]
|
||||
|
||||
// load contants
|
||||
// load constants
|
||||
// VLD4R (R10), [V0.S4, V1.S4, V2.S4, V3.S4]
|
||||
WORD $0x4D60E940
|
||||
|
||||
|
||||
10
vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go
generated
vendored
10
vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go
generated
vendored
@@ -56,7 +56,10 @@ func (c *chacha20poly1305) seal(dst, nonce, plaintext, additionalData []byte) []
|
||||
|
||||
ret, out := sliceForAppend(dst, len(plaintext)+16)
|
||||
if alias.InexactOverlap(out, plaintext) {
|
||||
panic("chacha20poly1305: invalid buffer overlap")
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and input")
|
||||
}
|
||||
if alias.AnyOverlap(out, additionalData) {
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
|
||||
}
|
||||
chacha20Poly1305Seal(out[:], state[:], plaintext, additionalData)
|
||||
return ret
|
||||
@@ -73,7 +76,10 @@ func (c *chacha20poly1305) open(dst, nonce, ciphertext, additionalData []byte) (
|
||||
ciphertext = ciphertext[:len(ciphertext)-16]
|
||||
ret, out := sliceForAppend(dst, len(ciphertext))
|
||||
if alias.InexactOverlap(out, ciphertext) {
|
||||
panic("chacha20poly1305: invalid buffer overlap")
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and input")
|
||||
}
|
||||
if alias.AnyOverlap(out, additionalData) {
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
|
||||
}
|
||||
if !chacha20Poly1305Open(out, state[:], ciphertext, additionalData) {
|
||||
for i := range out {
|
||||
|
||||
10
vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_generic.go
generated
vendored
10
vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_generic.go
generated
vendored
@@ -31,7 +31,10 @@ func (c *chacha20poly1305) sealGeneric(dst, nonce, plaintext, additionalData []b
|
||||
ret, out := sliceForAppend(dst, len(plaintext)+poly1305.TagSize)
|
||||
ciphertext, tag := out[:len(plaintext)], out[len(plaintext):]
|
||||
if alias.InexactOverlap(out, plaintext) {
|
||||
panic("chacha20poly1305: invalid buffer overlap")
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and input")
|
||||
}
|
||||
if alias.AnyOverlap(out, additionalData) {
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
|
||||
}
|
||||
|
||||
var polyKey [32]byte
|
||||
@@ -67,7 +70,10 @@ func (c *chacha20poly1305) openGeneric(dst, nonce, ciphertext, additionalData []
|
||||
|
||||
ret, out := sliceForAppend(dst, len(ciphertext))
|
||||
if alias.InexactOverlap(out, ciphertext) {
|
||||
panic("chacha20poly1305: invalid buffer overlap")
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and input")
|
||||
}
|
||||
if alias.AnyOverlap(out, additionalData) {
|
||||
panic("chacha20poly1305: invalid buffer overlap of output and additional data")
|
||||
}
|
||||
if !p.Verify(tag) {
|
||||
for i := range out {
|
||||
|
||||
66
vendor/golang.org/x/crypto/sha3/doc.go
generated
vendored
66
vendor/golang.org/x/crypto/sha3/doc.go
generated
vendored
@@ -1,66 +0,0 @@
|
||||
// Copyright 2014 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package sha3 implements the SHA-3 fixed-output-length hash functions and
|
||||
// the SHAKE variable-output-length hash functions defined by FIPS-202.
|
||||
//
|
||||
// All types in this package also implement [encoding.BinaryMarshaler],
|
||||
// [encoding.BinaryAppender] and [encoding.BinaryUnmarshaler] to marshal and
|
||||
// unmarshal the internal state of the hash.
|
||||
//
|
||||
// Both types of hash function use the "sponge" construction and the Keccak
|
||||
// permutation. For a detailed specification see http://keccak.noekeon.org/
|
||||
//
|
||||
// # Guidance
|
||||
//
|
||||
// If you aren't sure what function you need, use SHAKE256 with at least 64
|
||||
// bytes of output. The SHAKE instances are faster than the SHA3 instances;
|
||||
// the latter have to allocate memory to conform to the hash.Hash interface.
|
||||
//
|
||||
// If you need a secret-key MAC (message authentication code), prepend the
|
||||
// secret key to the input, hash with SHAKE256 and read at least 32 bytes of
|
||||
// output.
|
||||
//
|
||||
// # Security strengths
|
||||
//
|
||||
// The SHA3-x (x equals 224, 256, 384, or 512) functions have a security
|
||||
// strength against preimage attacks of x bits. Since they only produce "x"
|
||||
// bits of output, their collision-resistance is only "x/2" bits.
|
||||
//
|
||||
// The SHAKE-256 and -128 functions have a generic security strength of 256 and
|
||||
// 128 bits against all attacks, provided that at least 2x bits of their output
|
||||
// is used. Requesting more than 64 or 32 bytes of output, respectively, does
|
||||
// not increase the collision-resistance of the SHAKE functions.
|
||||
//
|
||||
// # The sponge construction
|
||||
//
|
||||
// A sponge builds a pseudo-random function from a public pseudo-random
|
||||
// permutation, by applying the permutation to a state of "rate + capacity"
|
||||
// bytes, but hiding "capacity" of the bytes.
|
||||
//
|
||||
// A sponge starts out with a zero state. To hash an input using a sponge, up
|
||||
// to "rate" bytes of the input are XORed into the sponge's state. The sponge
|
||||
// is then "full" and the permutation is applied to "empty" it. This process is
|
||||
// repeated until all the input has been "absorbed". The input is then padded.
|
||||
// The digest is "squeezed" from the sponge in the same way, except that output
|
||||
// is copied out instead of input being XORed in.
|
||||
//
|
||||
// A sponge is parameterized by its generic security strength, which is equal
|
||||
// to half its capacity; capacity + rate is equal to the permutation's width.
|
||||
// Since the KeccakF-1600 permutation is 1600 bits (200 bytes) wide, this means
|
||||
// that the security strength of a sponge instance is equal to (1600 - bitrate) / 2.
|
||||
//
|
||||
// # Recommendations
|
||||
//
|
||||
// The SHAKE functions are recommended for most new uses. They can produce
|
||||
// output of arbitrary length. SHAKE256, with an output length of at least
|
||||
// 64 bytes, provides 256-bit security against all attacks. The Keccak team
|
||||
// recommends it for most applications upgrading from SHA2-512. (NIST chose a
|
||||
// much stronger, but much slower, sponge instance for SHA3-512.)
|
||||
//
|
||||
// The SHA-3 functions are "drop-in" replacements for the SHA-2 functions.
|
||||
// They produce output of the same length, with the same security strengths
|
||||
// against all attacks. This means, in particular, that SHA3-256 only has
|
||||
// 128-bit collision resistance, because its output length is 32 bytes.
|
||||
package sha3
|
||||
133
vendor/golang.org/x/crypto/sha3/hashes.go
generated
vendored
133
vendor/golang.org/x/crypto/sha3/hashes.go
generated
vendored
@@ -2,127 +2,94 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package sha3 implements the SHA-3 hash algorithms and the SHAKE extendable
|
||||
// output functions defined in FIPS 202.
|
||||
//
|
||||
// Most of this package is a wrapper around the crypto/sha3 package in the
|
||||
// standard library. The only exception is the legacy Keccak hash functions.
|
||||
package sha3
|
||||
|
||||
// This file provides functions for creating instances of the SHA-3
|
||||
// and SHAKE hash functions, as well as utility functions for hashing
|
||||
// bytes.
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/sha3"
|
||||
"hash"
|
||||
)
|
||||
|
||||
// New224 creates a new SHA3-224 hash.
|
||||
// Its generic security strength is 224 bits against preimage attacks,
|
||||
// and 112 bits against collision attacks.
|
||||
//
|
||||
// It is a wrapper for the [sha3.New224] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func New224() hash.Hash {
|
||||
return new224()
|
||||
return sha3.New224()
|
||||
}
|
||||
|
||||
// New256 creates a new SHA3-256 hash.
|
||||
// Its generic security strength is 256 bits against preimage attacks,
|
||||
// and 128 bits against collision attacks.
|
||||
//
|
||||
// It is a wrapper for the [sha3.New256] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func New256() hash.Hash {
|
||||
return new256()
|
||||
return sha3.New256()
|
||||
}
|
||||
|
||||
// New384 creates a new SHA3-384 hash.
|
||||
// Its generic security strength is 384 bits against preimage attacks,
|
||||
// and 192 bits against collision attacks.
|
||||
//
|
||||
// It is a wrapper for the [sha3.New384] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func New384() hash.Hash {
|
||||
return new384()
|
||||
return sha3.New384()
|
||||
}
|
||||
|
||||
// New512 creates a new SHA3-512 hash.
|
||||
// Its generic security strength is 512 bits against preimage attacks,
|
||||
// and 256 bits against collision attacks.
|
||||
//
|
||||
// It is a wrapper for the [sha3.New512] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func New512() hash.Hash {
|
||||
return new512()
|
||||
}
|
||||
|
||||
func init() {
|
||||
crypto.RegisterHash(crypto.SHA3_224, New224)
|
||||
crypto.RegisterHash(crypto.SHA3_256, New256)
|
||||
crypto.RegisterHash(crypto.SHA3_384, New384)
|
||||
crypto.RegisterHash(crypto.SHA3_512, New512)
|
||||
}
|
||||
|
||||
const (
|
||||
dsbyteSHA3 = 0b00000110
|
||||
dsbyteKeccak = 0b00000001
|
||||
dsbyteShake = 0b00011111
|
||||
dsbyteCShake = 0b00000100
|
||||
|
||||
// rateK[c] is the rate in bytes for Keccak[c] where c is the capacity in
|
||||
// bits. Given the sponge size is 1600 bits, the rate is 1600 - c bits.
|
||||
rateK256 = (1600 - 256) / 8
|
||||
rateK448 = (1600 - 448) / 8
|
||||
rateK512 = (1600 - 512) / 8
|
||||
rateK768 = (1600 - 768) / 8
|
||||
rateK1024 = (1600 - 1024) / 8
|
||||
)
|
||||
|
||||
func new224Generic() *state {
|
||||
return &state{rate: rateK448, outputLen: 28, dsbyte: dsbyteSHA3}
|
||||
}
|
||||
|
||||
func new256Generic() *state {
|
||||
return &state{rate: rateK512, outputLen: 32, dsbyte: dsbyteSHA3}
|
||||
}
|
||||
|
||||
func new384Generic() *state {
|
||||
return &state{rate: rateK768, outputLen: 48, dsbyte: dsbyteSHA3}
|
||||
}
|
||||
|
||||
func new512Generic() *state {
|
||||
return &state{rate: rateK1024, outputLen: 64, dsbyte: dsbyteSHA3}
|
||||
}
|
||||
|
||||
// NewLegacyKeccak256 creates a new Keccak-256 hash.
|
||||
//
|
||||
// Only use this function if you require compatibility with an existing cryptosystem
|
||||
// that uses non-standard padding. All other users should use New256 instead.
|
||||
func NewLegacyKeccak256() hash.Hash {
|
||||
return &state{rate: rateK512, outputLen: 32, dsbyte: dsbyteKeccak}
|
||||
}
|
||||
|
||||
// NewLegacyKeccak512 creates a new Keccak-512 hash.
|
||||
//
|
||||
// Only use this function if you require compatibility with an existing cryptosystem
|
||||
// that uses non-standard padding. All other users should use New512 instead.
|
||||
func NewLegacyKeccak512() hash.Hash {
|
||||
return &state{rate: rateK1024, outputLen: 64, dsbyte: dsbyteKeccak}
|
||||
return sha3.New512()
|
||||
}
|
||||
|
||||
// Sum224 returns the SHA3-224 digest of the data.
|
||||
func Sum224(data []byte) (digest [28]byte) {
|
||||
h := New224()
|
||||
h.Write(data)
|
||||
h.Sum(digest[:0])
|
||||
return
|
||||
//
|
||||
// It is a wrapper for the [sha3.Sum224] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func Sum224(data []byte) [28]byte {
|
||||
return sha3.Sum224(data)
|
||||
}
|
||||
|
||||
// Sum256 returns the SHA3-256 digest of the data.
|
||||
func Sum256(data []byte) (digest [32]byte) {
|
||||
h := New256()
|
||||
h.Write(data)
|
||||
h.Sum(digest[:0])
|
||||
return
|
||||
//
|
||||
// It is a wrapper for the [sha3.Sum256] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func Sum256(data []byte) [32]byte {
|
||||
return sha3.Sum256(data)
|
||||
}
|
||||
|
||||
// Sum384 returns the SHA3-384 digest of the data.
|
||||
func Sum384(data []byte) (digest [48]byte) {
|
||||
h := New384()
|
||||
h.Write(data)
|
||||
h.Sum(digest[:0])
|
||||
return
|
||||
//
|
||||
// It is a wrapper for the [sha3.Sum384] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func Sum384(data []byte) [48]byte {
|
||||
return sha3.Sum384(data)
|
||||
}
|
||||
|
||||
// Sum512 returns the SHA3-512 digest of the data.
|
||||
func Sum512(data []byte) (digest [64]byte) {
|
||||
h := New512()
|
||||
h.Write(data)
|
||||
h.Sum(digest[:0])
|
||||
return
|
||||
//
|
||||
// It is a wrapper for the [sha3.Sum512] function in the standard library.
|
||||
//
|
||||
//go:fix inline
|
||||
func Sum512(data []byte) [64]byte {
|
||||
return sha3.Sum512(data)
|
||||
}
|
||||
|
||||
23
vendor/golang.org/x/crypto/sha3/hashes_noasm.go
generated
vendored
23
vendor/golang.org/x/crypto/sha3/hashes_noasm.go
generated
vendored
@@ -1,23 +0,0 @@
|
||||
// Copyright 2023 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !gc || purego || !s390x
|
||||
|
||||
package sha3
|
||||
|
||||
func new224() *state {
|
||||
return new224Generic()
|
||||
}
|
||||
|
||||
func new256() *state {
|
||||
return new256Generic()
|
||||
}
|
||||
|
||||
func new384() *state {
|
||||
return new384Generic()
|
||||
}
|
||||
|
||||
func new512() *state {
|
||||
return new512Generic()
|
||||
}
|
||||
13
vendor/golang.org/x/crypto/sha3/keccakf_amd64.go
generated
vendored
13
vendor/golang.org/x/crypto/sha3/keccakf_amd64.go
generated
vendored
@@ -1,13 +0,0 @@
|
||||
// Copyright 2015 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build amd64 && !purego && gc
|
||||
|
||||
package sha3
|
||||
|
||||
// This function is implemented in keccakf_amd64.s.
|
||||
|
||||
//go:noescape
|
||||
|
||||
func keccakF1600(a *[25]uint64)
|
||||
5419
vendor/golang.org/x/crypto/sha3/keccakf_amd64.s
generated
vendored
5419
vendor/golang.org/x/crypto/sha3/keccakf_amd64.s
generated
vendored
File diff suppressed because it is too large
Load Diff
49
vendor/golang.org/x/crypto/sha3/sha3.go → vendor/golang.org/x/crypto/sha3/legacy_hash.go
generated
vendored
49
vendor/golang.org/x/crypto/sha3/sha3.go → vendor/golang.org/x/crypto/sha3/legacy_hash.go
generated
vendored
@@ -4,15 +4,46 @@
|
||||
|
||||
package sha3
|
||||
|
||||
// This implementation is only used for NewLegacyKeccak256 and
|
||||
// NewLegacyKeccak512, which are not implemented by crypto/sha3.
|
||||
// All other functions in this package are wrappers around crypto/sha3.
|
||||
|
||||
import (
|
||||
"crypto/subtle"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"hash"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/cpu"
|
||||
)
|
||||
|
||||
const (
|
||||
dsbyteKeccak = 0b00000001
|
||||
|
||||
// rateK[c] is the rate in bytes for Keccak[c] where c is the capacity in
|
||||
// bits. Given the sponge size is 1600 bits, the rate is 1600 - c bits.
|
||||
rateK256 = (1600 - 256) / 8
|
||||
rateK512 = (1600 - 512) / 8
|
||||
rateK1024 = (1600 - 1024) / 8
|
||||
)
|
||||
|
||||
// NewLegacyKeccak256 creates a new Keccak-256 hash.
|
||||
//
|
||||
// Only use this function if you require compatibility with an existing cryptosystem
|
||||
// that uses non-standard padding. All other users should use New256 instead.
|
||||
func NewLegacyKeccak256() hash.Hash {
|
||||
return &state{rate: rateK512, outputLen: 32, dsbyte: dsbyteKeccak}
|
||||
}
|
||||
|
||||
// NewLegacyKeccak512 creates a new Keccak-512 hash.
|
||||
//
|
||||
// Only use this function if you require compatibility with an existing cryptosystem
|
||||
// that uses non-standard padding. All other users should use New512 instead.
|
||||
func NewLegacyKeccak512() hash.Hash {
|
||||
return &state{rate: rateK1024, outputLen: 64, dsbyte: dsbyteKeccak}
|
||||
}
|
||||
|
||||
// spongeDirection indicates the direction bytes are flowing through the sponge.
|
||||
type spongeDirection int
|
||||
|
||||
@@ -173,12 +204,9 @@ func (d *state) Sum(in []byte) []byte {
|
||||
}
|
||||
|
||||
const (
|
||||
magicSHA3 = "sha\x08"
|
||||
magicShake = "sha\x09"
|
||||
magicCShake = "sha\x0a"
|
||||
magicKeccak = "sha\x0b"
|
||||
// magic || rate || main state || n || sponge direction
|
||||
marshaledSize = len(magicSHA3) + 1 + 200 + 1 + 1
|
||||
marshaledSize = len(magicKeccak) + 1 + 200 + 1 + 1
|
||||
)
|
||||
|
||||
func (d *state) MarshalBinary() ([]byte, error) {
|
||||
@@ -187,12 +215,6 @@ func (d *state) MarshalBinary() ([]byte, error) {
|
||||
|
||||
func (d *state) AppendBinary(b []byte) ([]byte, error) {
|
||||
switch d.dsbyte {
|
||||
case dsbyteSHA3:
|
||||
b = append(b, magicSHA3...)
|
||||
case dsbyteShake:
|
||||
b = append(b, magicShake...)
|
||||
case dsbyteCShake:
|
||||
b = append(b, magicCShake...)
|
||||
case dsbyteKeccak:
|
||||
b = append(b, magicKeccak...)
|
||||
default:
|
||||
@@ -210,12 +232,9 @@ func (d *state) UnmarshalBinary(b []byte) error {
|
||||
return errors.New("sha3: invalid hash state")
|
||||
}
|
||||
|
||||
magic := string(b[:len(magicSHA3)])
|
||||
b = b[len(magicSHA3):]
|
||||
magic := string(b[:len(magicKeccak)])
|
||||
b = b[len(magicKeccak):]
|
||||
switch {
|
||||
case magic == magicSHA3 && d.dsbyte == dsbyteSHA3:
|
||||
case magic == magicShake && d.dsbyte == dsbyteShake:
|
||||
case magic == magicCShake && d.dsbyte == dsbyteCShake:
|
||||
case magic == magicKeccak && d.dsbyte == dsbyteKeccak:
|
||||
default:
|
||||
return errors.New("sha3: invalid hash state identifier")
|
||||
@@ -2,10 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !amd64 || purego || !gc
|
||||
|
||||
package sha3
|
||||
|
||||
// This implementation is only used for NewLegacyKeccak256 and
|
||||
// NewLegacyKeccak512, which are not implemented by crypto/sha3.
|
||||
// All other functions in this package are wrappers around crypto/sha3.
|
||||
|
||||
import "math/bits"
|
||||
|
||||
// rc stores the round constants for use in the ι step.
|
||||
303
vendor/golang.org/x/crypto/sha3/sha3_s390x.go
generated
vendored
303
vendor/golang.org/x/crypto/sha3/sha3_s390x.go
generated
vendored
@@ -1,303 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build gc && !purego
|
||||
|
||||
package sha3
|
||||
|
||||
// This file contains code for using the 'compute intermediate
|
||||
// message digest' (KIMD) and 'compute last message digest' (KLMD)
|
||||
// instructions to compute SHA-3 and SHAKE hashes on IBM Z.
|
||||
|
||||
import (
|
||||
"hash"
|
||||
|
||||
"golang.org/x/sys/cpu"
|
||||
)
|
||||
|
||||
// codes represent 7-bit KIMD/KLMD function codes as defined in
|
||||
// the Principles of Operation.
|
||||
type code uint64
|
||||
|
||||
const (
|
||||
// function codes for KIMD/KLMD
|
||||
sha3_224 code = 32
|
||||
sha3_256 = 33
|
||||
sha3_384 = 34
|
||||
sha3_512 = 35
|
||||
shake_128 = 36
|
||||
shake_256 = 37
|
||||
nopad = 0x100
|
||||
)
|
||||
|
||||
// kimd is a wrapper for the 'compute intermediate message digest' instruction.
|
||||
// src must be a multiple of the rate for the given function code.
|
||||
//
|
||||
//go:noescape
|
||||
func kimd(function code, chain *[200]byte, src []byte)
|
||||
|
||||
// klmd is a wrapper for the 'compute last message digest' instruction.
|
||||
// src padding is handled by the instruction.
|
||||
//
|
||||
//go:noescape
|
||||
func klmd(function code, chain *[200]byte, dst, src []byte)
|
||||
|
||||
type asmState struct {
|
||||
a [200]byte // 1600 bit state
|
||||
buf []byte // care must be taken to ensure cap(buf) is a multiple of rate
|
||||
rate int // equivalent to block size
|
||||
storage [3072]byte // underlying storage for buf
|
||||
outputLen int // output length for full security
|
||||
function code // KIMD/KLMD function code
|
||||
state spongeDirection // whether the sponge is absorbing or squeezing
|
||||
}
|
||||
|
||||
func newAsmState(function code) *asmState {
|
||||
var s asmState
|
||||
s.function = function
|
||||
switch function {
|
||||
case sha3_224:
|
||||
s.rate = 144
|
||||
s.outputLen = 28
|
||||
case sha3_256:
|
||||
s.rate = 136
|
||||
s.outputLen = 32
|
||||
case sha3_384:
|
||||
s.rate = 104
|
||||
s.outputLen = 48
|
||||
case sha3_512:
|
||||
s.rate = 72
|
||||
s.outputLen = 64
|
||||
case shake_128:
|
||||
s.rate = 168
|
||||
s.outputLen = 32
|
||||
case shake_256:
|
||||
s.rate = 136
|
||||
s.outputLen = 64
|
||||
default:
|
||||
panic("sha3: unrecognized function code")
|
||||
}
|
||||
|
||||
// limit s.buf size to a multiple of s.rate
|
||||
s.resetBuf()
|
||||
return &s
|
||||
}
|
||||
|
||||
func (s *asmState) clone() *asmState {
|
||||
c := *s
|
||||
c.buf = c.storage[:len(s.buf):cap(s.buf)]
|
||||
return &c
|
||||
}
|
||||
|
||||
// copyIntoBuf copies b into buf. It will panic if there is not enough space to
|
||||
// store all of b.
|
||||
func (s *asmState) copyIntoBuf(b []byte) {
|
||||
bufLen := len(s.buf)
|
||||
s.buf = s.buf[:len(s.buf)+len(b)]
|
||||
copy(s.buf[bufLen:], b)
|
||||
}
|
||||
|
||||
// resetBuf points buf at storage, sets the length to 0 and sets cap to be a
|
||||
// multiple of the rate.
|
||||
func (s *asmState) resetBuf() {
|
||||
max := (cap(s.storage) / s.rate) * s.rate
|
||||
s.buf = s.storage[:0:max]
|
||||
}
|
||||
|
||||
// Write (via the embedded io.Writer interface) adds more data to the running hash.
|
||||
// It never returns an error.
|
||||
func (s *asmState) Write(b []byte) (int, error) {
|
||||
if s.state != spongeAbsorbing {
|
||||
panic("sha3: Write after Read")
|
||||
}
|
||||
length := len(b)
|
||||
for len(b) > 0 {
|
||||
if len(s.buf) == 0 && len(b) >= cap(s.buf) {
|
||||
// Hash the data directly and push any remaining bytes
|
||||
// into the buffer.
|
||||
remainder := len(b) % s.rate
|
||||
kimd(s.function, &s.a, b[:len(b)-remainder])
|
||||
if remainder != 0 {
|
||||
s.copyIntoBuf(b[len(b)-remainder:])
|
||||
}
|
||||
return length, nil
|
||||
}
|
||||
|
||||
if len(s.buf) == cap(s.buf) {
|
||||
// flush the buffer
|
||||
kimd(s.function, &s.a, s.buf)
|
||||
s.buf = s.buf[:0]
|
||||
}
|
||||
|
||||
// copy as much as we can into the buffer
|
||||
n := len(b)
|
||||
if len(b) > cap(s.buf)-len(s.buf) {
|
||||
n = cap(s.buf) - len(s.buf)
|
||||
}
|
||||
s.copyIntoBuf(b[:n])
|
||||
b = b[n:]
|
||||
}
|
||||
return length, nil
|
||||
}
|
||||
|
||||
// Read squeezes an arbitrary number of bytes from the sponge.
|
||||
func (s *asmState) Read(out []byte) (n int, err error) {
|
||||
// The 'compute last message digest' instruction only stores the digest
|
||||
// at the first operand (dst) for SHAKE functions.
|
||||
if s.function != shake_128 && s.function != shake_256 {
|
||||
panic("sha3: can only call Read for SHAKE functions")
|
||||
}
|
||||
|
||||
n = len(out)
|
||||
|
||||
// need to pad if we were absorbing
|
||||
if s.state == spongeAbsorbing {
|
||||
s.state = spongeSqueezing
|
||||
|
||||
// write hash directly into out if possible
|
||||
if len(out)%s.rate == 0 {
|
||||
klmd(s.function, &s.a, out, s.buf) // len(out) may be 0
|
||||
s.buf = s.buf[:0]
|
||||
return
|
||||
}
|
||||
|
||||
// write hash into buffer
|
||||
max := cap(s.buf)
|
||||
if max > len(out) {
|
||||
max = (len(out)/s.rate)*s.rate + s.rate
|
||||
}
|
||||
klmd(s.function, &s.a, s.buf[:max], s.buf)
|
||||
s.buf = s.buf[:max]
|
||||
}
|
||||
|
||||
for len(out) > 0 {
|
||||
// flush the buffer
|
||||
if len(s.buf) != 0 {
|
||||
c := copy(out, s.buf)
|
||||
out = out[c:]
|
||||
s.buf = s.buf[c:]
|
||||
continue
|
||||
}
|
||||
|
||||
// write hash directly into out if possible
|
||||
if len(out)%s.rate == 0 {
|
||||
klmd(s.function|nopad, &s.a, out, nil)
|
||||
return
|
||||
}
|
||||
|
||||
// write hash into buffer
|
||||
s.resetBuf()
|
||||
if cap(s.buf) > len(out) {
|
||||
s.buf = s.buf[:(len(out)/s.rate)*s.rate+s.rate]
|
||||
}
|
||||
klmd(s.function|nopad, &s.a, s.buf, nil)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Sum appends the current hash to b and returns the resulting slice.
|
||||
// It does not change the underlying hash state.
|
||||
func (s *asmState) Sum(b []byte) []byte {
|
||||
if s.state != spongeAbsorbing {
|
||||
panic("sha3: Sum after Read")
|
||||
}
|
||||
|
||||
// Copy the state to preserve the original.
|
||||
a := s.a
|
||||
|
||||
// Hash the buffer. Note that we don't clear it because we
|
||||
// aren't updating the state.
|
||||
switch s.function {
|
||||
case sha3_224, sha3_256, sha3_384, sha3_512:
|
||||
klmd(s.function, &a, nil, s.buf)
|
||||
return append(b, a[:s.outputLen]...)
|
||||
case shake_128, shake_256:
|
||||
d := make([]byte, s.outputLen, 64)
|
||||
klmd(s.function, &a, d, s.buf)
|
||||
return append(b, d[:s.outputLen]...)
|
||||
default:
|
||||
panic("sha3: unknown function")
|
||||
}
|
||||
}
|
||||
|
||||
// Reset resets the Hash to its initial state.
|
||||
func (s *asmState) Reset() {
|
||||
for i := range s.a {
|
||||
s.a[i] = 0
|
||||
}
|
||||
s.resetBuf()
|
||||
s.state = spongeAbsorbing
|
||||
}
|
||||
|
||||
// Size returns the number of bytes Sum will return.
|
||||
func (s *asmState) Size() int {
|
||||
return s.outputLen
|
||||
}
|
||||
|
||||
// BlockSize returns the hash's underlying block size.
|
||||
// The Write method must be able to accept any amount
|
||||
// of data, but it may operate more efficiently if all writes
|
||||
// are a multiple of the block size.
|
||||
func (s *asmState) BlockSize() int {
|
||||
return s.rate
|
||||
}
|
||||
|
||||
// Clone returns a copy of the ShakeHash in its current state.
|
||||
func (s *asmState) Clone() ShakeHash {
|
||||
return s.clone()
|
||||
}
|
||||
|
||||
// new224 returns an assembly implementation of SHA3-224 if available,
|
||||
// otherwise it returns a generic implementation.
|
||||
func new224() hash.Hash {
|
||||
if cpu.S390X.HasSHA3 {
|
||||
return newAsmState(sha3_224)
|
||||
}
|
||||
return new224Generic()
|
||||
}
|
||||
|
||||
// new256 returns an assembly implementation of SHA3-256 if available,
|
||||
// otherwise it returns a generic implementation.
|
||||
func new256() hash.Hash {
|
||||
if cpu.S390X.HasSHA3 {
|
||||
return newAsmState(sha3_256)
|
||||
}
|
||||
return new256Generic()
|
||||
}
|
||||
|
||||
// new384 returns an assembly implementation of SHA3-384 if available,
|
||||
// otherwise it returns a generic implementation.
|
||||
func new384() hash.Hash {
|
||||
if cpu.S390X.HasSHA3 {
|
||||
return newAsmState(sha3_384)
|
||||
}
|
||||
return new384Generic()
|
||||
}
|
||||
|
||||
// new512 returns an assembly implementation of SHA3-512 if available,
|
||||
// otherwise it returns a generic implementation.
|
||||
func new512() hash.Hash {
|
||||
if cpu.S390X.HasSHA3 {
|
||||
return newAsmState(sha3_512)
|
||||
}
|
||||
return new512Generic()
|
||||
}
|
||||
|
||||
// newShake128 returns an assembly implementation of SHAKE-128 if available,
|
||||
// otherwise it returns a generic implementation.
|
||||
func newShake128() ShakeHash {
|
||||
if cpu.S390X.HasSHA3 {
|
||||
return newAsmState(shake_128)
|
||||
}
|
||||
return newShake128Generic()
|
||||
}
|
||||
|
||||
// newShake256 returns an assembly implementation of SHAKE-256 if available,
|
||||
// otherwise it returns a generic implementation.
|
||||
func newShake256() ShakeHash {
|
||||
if cpu.S390X.HasSHA3 {
|
||||
return newAsmState(shake_256)
|
||||
}
|
||||
return newShake256Generic()
|
||||
}
|
||||
33
vendor/golang.org/x/crypto/sha3/sha3_s390x.s
generated
vendored
33
vendor/golang.org/x/crypto/sha3/sha3_s390x.s
generated
vendored
@@ -1,33 +0,0 @@
|
||||
// Copyright 2017 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build gc && !purego
|
||||
|
||||
#include "textflag.h"
|
||||
|
||||
// func kimd(function code, chain *[200]byte, src []byte)
|
||||
TEXT ·kimd(SB), NOFRAME|NOSPLIT, $0-40
|
||||
MOVD function+0(FP), R0
|
||||
MOVD chain+8(FP), R1
|
||||
LMG src+16(FP), R2, R3 // R2=base, R3=len
|
||||
|
||||
continue:
|
||||
WORD $0xB93E0002 // KIMD --, R2
|
||||
BVS continue // continue if interrupted
|
||||
MOVD $0, R0 // reset R0 for pre-go1.8 compilers
|
||||
RET
|
||||
|
||||
// func klmd(function code, chain *[200]byte, dst, src []byte)
|
||||
TEXT ·klmd(SB), NOFRAME|NOSPLIT, $0-64
|
||||
// TODO: SHAKE support
|
||||
MOVD function+0(FP), R0
|
||||
MOVD chain+8(FP), R1
|
||||
LMG dst+16(FP), R2, R3 // R2=base, R3=len
|
||||
LMG src+40(FP), R4, R5 // R4=base, R5=len
|
||||
|
||||
continue:
|
||||
WORD $0xB93F0024 // KLMD R2, R4
|
||||
BVS continue // continue if interrupted
|
||||
MOVD $0, R0 // reset R0 for pre-go1.8 compilers
|
||||
RET
|
||||
172
vendor/golang.org/x/crypto/sha3/shake.go
generated
vendored
172
vendor/golang.org/x/crypto/sha3/shake.go
generated
vendored
@@ -4,24 +4,10 @@
|
||||
|
||||
package sha3
|
||||
|
||||
// This file defines the ShakeHash interface, and provides
|
||||
// functions for creating SHAKE and cSHAKE instances, as well as utility
|
||||
// functions for hashing bytes to arbitrary-length output.
|
||||
//
|
||||
//
|
||||
// SHAKE implementation is based on FIPS PUB 202 [1]
|
||||
// cSHAKE implementations is based on NIST SP 800-185 [2]
|
||||
//
|
||||
// [1] https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf
|
||||
// [2] https://doi.org/10.6028/NIST.SP.800-185
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"crypto/sha3"
|
||||
"hash"
|
||||
"io"
|
||||
"math/bits"
|
||||
)
|
||||
|
||||
// ShakeHash defines the interface to hash functions that support
|
||||
@@ -32,7 +18,7 @@ type ShakeHash interface {
|
||||
hash.Hash
|
||||
|
||||
// Read reads more output from the hash; reading affects the hash's
|
||||
// state. (ShakeHash.Read is thus very different from Hash.Sum)
|
||||
// state. (ShakeHash.Read is thus very different from Hash.Sum.)
|
||||
// It never returns an error, but subsequent calls to Write or Sum
|
||||
// will panic.
|
||||
io.Reader
|
||||
@@ -41,115 +27,18 @@ type ShakeHash interface {
|
||||
Clone() ShakeHash
|
||||
}
|
||||
|
||||
// cSHAKE specific context
|
||||
type cshakeState struct {
|
||||
*state // SHA-3 state context and Read/Write operations
|
||||
|
||||
// initBlock is the cSHAKE specific initialization set of bytes. It is initialized
|
||||
// by newCShake function and stores concatenation of N followed by S, encoded
|
||||
// by the method specified in 3.3 of [1].
|
||||
// It is stored here in order for Reset() to be able to put context into
|
||||
// initial state.
|
||||
initBlock []byte
|
||||
}
|
||||
|
||||
func bytepad(data []byte, rate int) []byte {
|
||||
out := make([]byte, 0, 9+len(data)+rate-1)
|
||||
out = append(out, leftEncode(uint64(rate))...)
|
||||
out = append(out, data...)
|
||||
if padlen := rate - len(out)%rate; padlen < rate {
|
||||
out = append(out, make([]byte, padlen)...)
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
func leftEncode(x uint64) []byte {
|
||||
// Let n be the smallest positive integer for which 2^(8n) > x.
|
||||
n := (bits.Len64(x) + 7) / 8
|
||||
if n == 0 {
|
||||
n = 1
|
||||
}
|
||||
// Return n || x with n as a byte and x an n bytes in big-endian order.
|
||||
b := make([]byte, 9)
|
||||
binary.BigEndian.PutUint64(b[1:], x)
|
||||
b = b[9-n-1:]
|
||||
b[0] = byte(n)
|
||||
return b
|
||||
}
|
||||
|
||||
func newCShake(N, S []byte, rate, outputLen int, dsbyte byte) ShakeHash {
|
||||
c := cshakeState{state: &state{rate: rate, outputLen: outputLen, dsbyte: dsbyte}}
|
||||
c.initBlock = make([]byte, 0, 9+len(N)+9+len(S)) // leftEncode returns max 9 bytes
|
||||
c.initBlock = append(c.initBlock, leftEncode(uint64(len(N))*8)...)
|
||||
c.initBlock = append(c.initBlock, N...)
|
||||
c.initBlock = append(c.initBlock, leftEncode(uint64(len(S))*8)...)
|
||||
c.initBlock = append(c.initBlock, S...)
|
||||
c.Write(bytepad(c.initBlock, c.rate))
|
||||
return &c
|
||||
}
|
||||
|
||||
// Reset resets the hash to initial state.
|
||||
func (c *cshakeState) Reset() {
|
||||
c.state.Reset()
|
||||
c.Write(bytepad(c.initBlock, c.rate))
|
||||
}
|
||||
|
||||
// Clone returns copy of a cSHAKE context within its current state.
|
||||
func (c *cshakeState) Clone() ShakeHash {
|
||||
b := make([]byte, len(c.initBlock))
|
||||
copy(b, c.initBlock)
|
||||
return &cshakeState{state: c.clone(), initBlock: b}
|
||||
}
|
||||
|
||||
// Clone returns copy of SHAKE context within its current state.
|
||||
func (c *state) Clone() ShakeHash {
|
||||
return c.clone()
|
||||
}
|
||||
|
||||
func (c *cshakeState) MarshalBinary() ([]byte, error) {
|
||||
return c.AppendBinary(make([]byte, 0, marshaledSize+len(c.initBlock)))
|
||||
}
|
||||
|
||||
func (c *cshakeState) AppendBinary(b []byte) ([]byte, error) {
|
||||
b, err := c.state.AppendBinary(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b = append(b, c.initBlock...)
|
||||
return b, nil
|
||||
}
|
||||
|
||||
func (c *cshakeState) UnmarshalBinary(b []byte) error {
|
||||
if len(b) <= marshaledSize {
|
||||
return errors.New("sha3: invalid hash state")
|
||||
}
|
||||
if err := c.state.UnmarshalBinary(b[:marshaledSize]); err != nil {
|
||||
return err
|
||||
}
|
||||
c.initBlock = bytes.Clone(b[marshaledSize:])
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewShake128 creates a new SHAKE128 variable-output-length ShakeHash.
|
||||
// Its generic security strength is 128 bits against all attacks if at
|
||||
// least 32 bytes of its output are used.
|
||||
func NewShake128() ShakeHash {
|
||||
return newShake128()
|
||||
return &shakeWrapper{sha3.NewSHAKE128(), 32, false, sha3.NewSHAKE128}
|
||||
}
|
||||
|
||||
// NewShake256 creates a new SHAKE256 variable-output-length ShakeHash.
|
||||
// Its generic security strength is 256 bits against all attacks if
|
||||
// at least 64 bytes of its output are used.
|
||||
func NewShake256() ShakeHash {
|
||||
return newShake256()
|
||||
}
|
||||
|
||||
func newShake128Generic() *state {
|
||||
return &state{rate: rateK256, outputLen: 32, dsbyte: dsbyteShake}
|
||||
}
|
||||
|
||||
func newShake256Generic() *state {
|
||||
return &state{rate: rateK512, outputLen: 64, dsbyte: dsbyteShake}
|
||||
return &shakeWrapper{sha3.NewSHAKE256(), 64, false, sha3.NewSHAKE256}
|
||||
}
|
||||
|
||||
// NewCShake128 creates a new instance of cSHAKE128 variable-output-length ShakeHash,
|
||||
@@ -159,10 +48,9 @@ func newShake256Generic() *state {
|
||||
// computations on same input with different S yield unrelated outputs.
|
||||
// When N and S are both empty, this is equivalent to NewShake128.
|
||||
func NewCShake128(N, S []byte) ShakeHash {
|
||||
if len(N) == 0 && len(S) == 0 {
|
||||
return NewShake128()
|
||||
}
|
||||
return newCShake(N, S, rateK256, 32, dsbyteCShake)
|
||||
return &shakeWrapper{sha3.NewCSHAKE128(N, S), 32, false, func() *sha3.SHAKE {
|
||||
return sha3.NewCSHAKE128(N, S)
|
||||
}}
|
||||
}
|
||||
|
||||
// NewCShake256 creates a new instance of cSHAKE256 variable-output-length ShakeHash,
|
||||
@@ -172,10 +60,9 @@ func NewCShake128(N, S []byte) ShakeHash {
|
||||
// computations on same input with different S yield unrelated outputs.
|
||||
// When N and S are both empty, this is equivalent to NewShake256.
|
||||
func NewCShake256(N, S []byte) ShakeHash {
|
||||
if len(N) == 0 && len(S) == 0 {
|
||||
return NewShake256()
|
||||
}
|
||||
return newCShake(N, S, rateK512, 64, dsbyteCShake)
|
||||
return &shakeWrapper{sha3.NewCSHAKE256(N, S), 64, false, func() *sha3.SHAKE {
|
||||
return sha3.NewCSHAKE256(N, S)
|
||||
}}
|
||||
}
|
||||
|
||||
// ShakeSum128 writes an arbitrary-length digest of data into hash.
|
||||
@@ -191,3 +78,42 @@ func ShakeSum256(hash, data []byte) {
|
||||
h.Write(data)
|
||||
h.Read(hash)
|
||||
}
|
||||
|
||||
// shakeWrapper adds the Size, Sum, and Clone methods to a sha3.SHAKE
|
||||
// to implement the ShakeHash interface.
|
||||
type shakeWrapper struct {
|
||||
*sha3.SHAKE
|
||||
outputLen int
|
||||
squeezing bool
|
||||
newSHAKE func() *sha3.SHAKE
|
||||
}
|
||||
|
||||
func (w *shakeWrapper) Read(p []byte) (n int, err error) {
|
||||
w.squeezing = true
|
||||
return w.SHAKE.Read(p)
|
||||
}
|
||||
|
||||
func (w *shakeWrapper) Clone() ShakeHash {
|
||||
s := w.newSHAKE()
|
||||
b, err := w.MarshalBinary()
|
||||
if err != nil {
|
||||
panic(err) // unreachable
|
||||
}
|
||||
if err := s.UnmarshalBinary(b); err != nil {
|
||||
panic(err) // unreachable
|
||||
}
|
||||
return &shakeWrapper{s, w.outputLen, w.squeezing, w.newSHAKE}
|
||||
}
|
||||
|
||||
func (w *shakeWrapper) Size() int { return w.outputLen }
|
||||
|
||||
func (w *shakeWrapper) Sum(b []byte) []byte {
|
||||
if w.squeezing {
|
||||
panic("sha3: Sum after Read")
|
||||
}
|
||||
out := make([]byte, w.outputLen)
|
||||
// Clone the state so that we don't affect future Write calls.
|
||||
s := w.Clone()
|
||||
s.Read(out)
|
||||
return append(b, out...)
|
||||
}
|
||||
|
||||
15
vendor/golang.org/x/crypto/sha3/shake_noasm.go
generated
vendored
15
vendor/golang.org/x/crypto/sha3/shake_noasm.go
generated
vendored
@@ -1,15 +0,0 @@
|
||||
// Copyright 2023 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build !gc || purego || !s390x
|
||||
|
||||
package sha3
|
||||
|
||||
func newShake128() *state {
|
||||
return newShake128Generic()
|
||||
}
|
||||
|
||||
func newShake256() *state {
|
||||
return newShake256Generic()
|
||||
}
|
||||
2
vendor/golang.org/x/crypto/ssh/messages.go
generated
vendored
2
vendor/golang.org/x/crypto/ssh/messages.go
generated
vendored
@@ -792,7 +792,7 @@ func marshalString(to []byte, s []byte) []byte {
|
||||
return to[len(s):]
|
||||
}
|
||||
|
||||
var bigIntType = reflect.TypeOf((*big.Int)(nil))
|
||||
var bigIntType = reflect.TypeFor[*big.Int]()
|
||||
|
||||
// Decode a packet into its corresponding message.
|
||||
func decode(packet []byte) (interface{}, error) {
|
||||
|
||||
2
vendor/golang.org/x/mod/module/module.go
generated
vendored
2
vendor/golang.org/x/mod/module/module.go
generated
vendored
@@ -261,7 +261,7 @@ func modPathOK(r rune) bool {
|
||||
|
||||
// importPathOK reports whether r can appear in a package import path element.
|
||||
//
|
||||
// Import paths are intermediate between module paths and file paths: we allow
|
||||
// Import paths are intermediate between module paths and file paths: we
|
||||
// disallow characters that would be confusing or ambiguous as arguments to
|
||||
// 'go get' (such as '@' and ' ' ), but allow certain characters that are
|
||||
// otherwise-unambiguous on the command line and historically used for some
|
||||
|
||||
4
vendor/golang.org/x/mod/semver/semver.go
generated
vendored
4
vendor/golang.org/x/mod/semver/semver.go
generated
vendored
@@ -45,8 +45,8 @@ func IsValid(v string) bool {
|
||||
|
||||
// Canonical returns the canonical formatting of the semantic version v.
|
||||
// It fills in any missing .MINOR or .PATCH and discards build metadata.
|
||||
// Two semantic versions compare equal only if their canonical formattings
|
||||
// are identical strings.
|
||||
// Two semantic versions compare equal only if their canonical formatting
|
||||
// is an identical string.
|
||||
// The canonical invalid semantic version is the empty string.
|
||||
func Canonical(v string) string {
|
||||
p, ok := parse(v)
|
||||
|
||||
37
vendor/golang.org/x/net/context/context.go
generated
vendored
37
vendor/golang.org/x/net/context/context.go
generated
vendored
@@ -2,42 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package context defines the Context type, which carries deadlines,
|
||||
// cancellation signals, and other request-scoped values across API boundaries
|
||||
// and between processes.
|
||||
// As of Go 1.7 this package is available in the standard library under the
|
||||
// name [context].
|
||||
// Package context has been superseded by the standard library [context] package.
|
||||
//
|
||||
// Incoming requests to a server should create a [Context], and outgoing
|
||||
// calls to servers should accept a Context. The chain of function
|
||||
// calls between them must propagate the Context, optionally replacing
|
||||
// it with a derived Context created using [WithCancel], [WithDeadline],
|
||||
// [WithTimeout], or [WithValue].
|
||||
//
|
||||
// Programs that use Contexts should follow these rules to keep interfaces
|
||||
// consistent across packages and enable static analysis tools to check context
|
||||
// propagation:
|
||||
//
|
||||
// Do not store Contexts inside a struct type; instead, pass a Context
|
||||
// explicitly to each function that needs it. This is discussed further in
|
||||
// https://go.dev/blog/context-and-structs. The Context should be the first
|
||||
// parameter, typically named ctx:
|
||||
//
|
||||
// func DoSomething(ctx context.Context, arg Arg) error {
|
||||
// // ... use ctx ...
|
||||
// }
|
||||
//
|
||||
// Do not pass a nil [Context], even if a function permits it. Pass [context.TODO]
|
||||
// if you are unsure about which Context to use.
|
||||
//
|
||||
// Use context Values only for request-scoped data that transits processes and
|
||||
// APIs, not for passing optional parameters to functions.
|
||||
//
|
||||
// The same Context may be passed to functions running in different goroutines;
|
||||
// Contexts are safe for simultaneous use by multiple goroutines.
|
||||
//
|
||||
// See https://go.dev/blog/context for example code for a server that uses
|
||||
// Contexts.
|
||||
// Deprecated: Use the standard library context package instead.
|
||||
package context
|
||||
|
||||
import (
|
||||
|
||||
76
vendor/golang.org/x/net/http2/frame.go
generated
vendored
76
vendor/golang.org/x/net/http2/frame.go
generated
vendored
@@ -280,6 +280,8 @@ type Framer struct {
|
||||
// lastHeaderStream is non-zero if the last frame was an
|
||||
// unfinished HEADERS/CONTINUATION.
|
||||
lastHeaderStream uint32
|
||||
// lastFrameType holds the type of the last frame for verifying frame order.
|
||||
lastFrameType FrameType
|
||||
|
||||
maxReadSize uint32
|
||||
headerBuf [frameHeaderLen]byte
|
||||
@@ -488,30 +490,41 @@ func terminalReadFrameError(err error) bool {
|
||||
return err != nil
|
||||
}
|
||||
|
||||
// ReadFrame reads a single frame. The returned Frame is only valid
|
||||
// until the next call to ReadFrame.
|
||||
// ReadFrameHeader reads the header of the next frame.
|
||||
// It reads the 9-byte fixed frame header, and does not read any portion of the
|
||||
// frame payload. The caller is responsible for consuming the payload, either
|
||||
// with ReadFrameForHeader or directly from the Framer's io.Reader.
|
||||
//
|
||||
// If the frame is larger than previously set with SetMaxReadFrameSize, the
|
||||
// returned error is ErrFrameTooLarge. Other errors may be of type
|
||||
// ConnectionError, StreamError, or anything else from the underlying
|
||||
// reader.
|
||||
// If the frame is larger than previously set with SetMaxReadFrameSize, it
|
||||
// returns the frame header and ErrFrameTooLarge.
|
||||
//
|
||||
// If ReadFrame returns an error and a non-nil Frame, the Frame's StreamID
|
||||
// indicates the stream responsible for the error.
|
||||
func (fr *Framer) ReadFrame() (Frame, error) {
|
||||
// If the returned FrameHeader.StreamID is non-zero, it indicates the stream
|
||||
// responsible for the error.
|
||||
func (fr *Framer) ReadFrameHeader() (FrameHeader, error) {
|
||||
fr.errDetail = nil
|
||||
if fr.lastFrame != nil {
|
||||
fr.lastFrame.invalidate()
|
||||
}
|
||||
fh, err := readFrameHeader(fr.headerBuf[:], fr.r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return fh, err
|
||||
}
|
||||
if fh.Length > fr.maxReadSize {
|
||||
if fh == invalidHTTP1LookingFrameHeader() {
|
||||
return nil, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", ErrFrameTooLarge)
|
||||
return fh, fmt.Errorf("http2: failed reading the frame payload: %w, note that the frame header looked like an HTTP/1.1 header", ErrFrameTooLarge)
|
||||
}
|
||||
return nil, ErrFrameTooLarge
|
||||
return fh, ErrFrameTooLarge
|
||||
}
|
||||
if err := fr.checkFrameOrder(fh); err != nil {
|
||||
return fh, err
|
||||
}
|
||||
return fh, nil
|
||||
}
|
||||
|
||||
// ReadFrameForHeader reads the payload for the frame with the given FrameHeader.
|
||||
//
|
||||
// It behaves identically to ReadFrame, other than not checking the maximum
|
||||
// frame size.
|
||||
func (fr *Framer) ReadFrameForHeader(fh FrameHeader) (Frame, error) {
|
||||
if fr.lastFrame != nil {
|
||||
fr.lastFrame.invalidate()
|
||||
}
|
||||
payload := fr.getReadBuf(fh.Length)
|
||||
if _, err := io.ReadFull(fr.r, payload); err != nil {
|
||||
@@ -527,9 +540,7 @@ func (fr *Framer) ReadFrame() (Frame, error) {
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
if err := fr.checkFrameOrder(f); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
fr.lastFrame = f
|
||||
if fr.logReads {
|
||||
fr.debugReadLoggerf("http2: Framer %p: read %v", fr, summarizeFrame(f))
|
||||
}
|
||||
@@ -539,6 +550,24 @@ func (fr *Framer) ReadFrame() (Frame, error) {
|
||||
return f, nil
|
||||
}
|
||||
|
||||
// ReadFrame reads a single frame. The returned Frame is only valid
|
||||
// until the next call to ReadFrame or ReadFrameBodyForHeader.
|
||||
//
|
||||
// If the frame is larger than previously set with SetMaxReadFrameSize, the
|
||||
// returned error is ErrFrameTooLarge. Other errors may be of type
|
||||
// ConnectionError, StreamError, or anything else from the underlying
|
||||
// reader.
|
||||
//
|
||||
// If ReadFrame returns an error and a non-nil Frame, the Frame's StreamID
|
||||
// indicates the stream responsible for the error.
|
||||
func (fr *Framer) ReadFrame() (Frame, error) {
|
||||
fh, err := fr.ReadFrameHeader()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return fr.ReadFrameForHeader(fh)
|
||||
}
|
||||
|
||||
// connError returns ConnectionError(code) but first
|
||||
// stashes away a public reason to the caller can optionally relay it
|
||||
// to the peer before hanging up on them. This might help others debug
|
||||
@@ -551,20 +580,19 @@ func (fr *Framer) connError(code ErrCode, reason string) error {
|
||||
// checkFrameOrder reports an error if f is an invalid frame to return
|
||||
// next from ReadFrame. Mostly it checks whether HEADERS and
|
||||
// CONTINUATION frames are contiguous.
|
||||
func (fr *Framer) checkFrameOrder(f Frame) error {
|
||||
last := fr.lastFrame
|
||||
fr.lastFrame = f
|
||||
func (fr *Framer) checkFrameOrder(fh FrameHeader) error {
|
||||
lastType := fr.lastFrameType
|
||||
fr.lastFrameType = fh.Type
|
||||
if fr.AllowIllegalReads {
|
||||
return nil
|
||||
}
|
||||
|
||||
fh := f.Header()
|
||||
if fr.lastHeaderStream != 0 {
|
||||
if fh.Type != FrameContinuation {
|
||||
return fr.connError(ErrCodeProtocol,
|
||||
fmt.Sprintf("got %s for stream %d; expected CONTINUATION following %s for stream %d",
|
||||
fh.Type, fh.StreamID,
|
||||
last.Header().Type, fr.lastHeaderStream))
|
||||
lastType, fr.lastHeaderStream))
|
||||
}
|
||||
if fh.StreamID != fr.lastHeaderStream {
|
||||
return fr.connError(ErrCodeProtocol,
|
||||
@@ -1161,7 +1189,7 @@ var defaultRFC9218Priority = PriorityParam{
|
||||
// PriorityParam struct below is a superset of both schemes. The exported
|
||||
// symbols are from RFC 7540 and the non-exported ones are from RFC 9218.
|
||||
|
||||
// PriorityParam are the stream prioritzation parameters.
|
||||
// PriorityParam are the stream prioritization parameters.
|
||||
type PriorityParam struct {
|
||||
// StreamDep is a 31-bit stream identifier for the
|
||||
// stream that this stream depends on. Zero means no
|
||||
|
||||
104
vendor/golang.org/x/net/http2/transport.go
generated
vendored
104
vendor/golang.org/x/net/http2/transport.go
generated
vendored
@@ -9,6 +9,7 @@ package http2
|
||||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"compress/flate"
|
||||
"compress/gzip"
|
||||
"context"
|
||||
"crypto/rand"
|
||||
@@ -3076,35 +3077,102 @@ type erringRoundTripper struct{ err error }
|
||||
func (rt erringRoundTripper) RoundTripErr() error { return rt.err }
|
||||
func (rt erringRoundTripper) RoundTrip(*http.Request) (*http.Response, error) { return nil, rt.err }
|
||||
|
||||
var errConcurrentReadOnResBody = errors.New("http2: concurrent read on response body")
|
||||
|
||||
// gzipReader wraps a response body so it can lazily
|
||||
// call gzip.NewReader on the first call to Read
|
||||
// get gzip.Reader from the pool on the first call to Read.
|
||||
// After Close is called it puts gzip.Reader to the pool immediately
|
||||
// if there is no Read in progress or later when Read completes.
|
||||
type gzipReader struct {
|
||||
_ incomparable
|
||||
body io.ReadCloser // underlying Response.Body
|
||||
zr *gzip.Reader // lazily-initialized gzip reader
|
||||
zerr error // sticky error
|
||||
mu sync.Mutex // guards zr and zerr
|
||||
zr *gzip.Reader // stores gzip reader from the pool between reads
|
||||
zerr error // sticky gzip reader init error or sentinel value to detect concurrent read and read after close
|
||||
}
|
||||
|
||||
type eofReader struct{}
|
||||
|
||||
func (eofReader) Read([]byte) (int, error) { return 0, io.EOF }
|
||||
func (eofReader) ReadByte() (byte, error) { return 0, io.EOF }
|
||||
|
||||
var gzipPool = sync.Pool{New: func() any { return new(gzip.Reader) }}
|
||||
|
||||
// gzipPoolGet gets a gzip.Reader from the pool and resets it to read from r.
|
||||
func gzipPoolGet(r io.Reader) (*gzip.Reader, error) {
|
||||
zr := gzipPool.Get().(*gzip.Reader)
|
||||
if err := zr.Reset(r); err != nil {
|
||||
gzipPoolPut(zr)
|
||||
return nil, err
|
||||
}
|
||||
return zr, nil
|
||||
}
|
||||
|
||||
// gzipPoolPut puts a gzip.Reader back into the pool.
|
||||
func gzipPoolPut(zr *gzip.Reader) {
|
||||
// Reset will allocate bufio.Reader if we pass it anything
|
||||
// other than a flate.Reader, so ensure that it's getting one.
|
||||
var r flate.Reader = eofReader{}
|
||||
zr.Reset(r)
|
||||
gzipPool.Put(zr)
|
||||
}
|
||||
|
||||
// acquire returns a gzip.Reader for reading response body.
|
||||
// The reader must be released after use.
|
||||
func (gz *gzipReader) acquire() (*gzip.Reader, error) {
|
||||
gz.mu.Lock()
|
||||
defer gz.mu.Unlock()
|
||||
if gz.zerr != nil {
|
||||
return nil, gz.zerr
|
||||
}
|
||||
if gz.zr == nil {
|
||||
gz.zr, gz.zerr = gzipPoolGet(gz.body)
|
||||
if gz.zerr != nil {
|
||||
return nil, gz.zerr
|
||||
}
|
||||
}
|
||||
ret := gz.zr
|
||||
gz.zr, gz.zerr = nil, errConcurrentReadOnResBody
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// release returns the gzip.Reader to the pool if Close was called during Read.
|
||||
func (gz *gzipReader) release(zr *gzip.Reader) {
|
||||
gz.mu.Lock()
|
||||
defer gz.mu.Unlock()
|
||||
if gz.zerr == errConcurrentReadOnResBody {
|
||||
gz.zr, gz.zerr = zr, nil
|
||||
} else { // fs.ErrClosed
|
||||
gzipPoolPut(zr)
|
||||
}
|
||||
}
|
||||
|
||||
// close returns the gzip.Reader to the pool immediately or
|
||||
// signals release to do so after Read completes.
|
||||
func (gz *gzipReader) close() {
|
||||
gz.mu.Lock()
|
||||
defer gz.mu.Unlock()
|
||||
if gz.zerr == nil && gz.zr != nil {
|
||||
gzipPoolPut(gz.zr)
|
||||
gz.zr = nil
|
||||
}
|
||||
gz.zerr = fs.ErrClosed
|
||||
}
|
||||
|
||||
func (gz *gzipReader) Read(p []byte) (n int, err error) {
|
||||
if gz.zerr != nil {
|
||||
return 0, gz.zerr
|
||||
zr, err := gz.acquire()
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if gz.zr == nil {
|
||||
gz.zr, err = gzip.NewReader(gz.body)
|
||||
if err != nil {
|
||||
gz.zerr = err
|
||||
return 0, err
|
||||
}
|
||||
}
|
||||
return gz.zr.Read(p)
|
||||
defer gz.release(zr)
|
||||
|
||||
return zr.Read(p)
|
||||
}
|
||||
|
||||
func (gz *gzipReader) Close() error {
|
||||
if err := gz.body.Close(); err != nil {
|
||||
return err
|
||||
}
|
||||
gz.zerr = fs.ErrClosed
|
||||
return nil
|
||||
gz.close()
|
||||
|
||||
return gz.body.Close()
|
||||
}
|
||||
|
||||
type errorReader struct{ err error }
|
||||
|
||||
65
vendor/golang.org/x/net/http2/writesched.go
generated
vendored
65
vendor/golang.org/x/net/http2/writesched.go
generated
vendored
@@ -185,45 +185,75 @@ func (wr *FrameWriteRequest) replyToWriter(err error) {
|
||||
}
|
||||
|
||||
// writeQueue is used by implementations of WriteScheduler.
|
||||
//
|
||||
// Each writeQueue contains a queue of FrameWriteRequests, meant to store all
|
||||
// FrameWriteRequests associated with a given stream. This is implemented as a
|
||||
// two-stage queue: currQueue[currPos:] and nextQueue. Removing an item is done
|
||||
// by incrementing currPos of currQueue. Adding an item is done by appending it
|
||||
// to the nextQueue. If currQueue is empty when trying to remove an item, we
|
||||
// can swap currQueue and nextQueue to remedy the situation.
|
||||
// This two-stage queue is analogous to the use of two lists in Okasaki's
|
||||
// purely functional queue but without the overhead of reversing the list when
|
||||
// swapping stages.
|
||||
//
|
||||
// writeQueue also contains prev and next, this can be used by implementations
|
||||
// of WriteScheduler to construct data structures that represent the order of
|
||||
// writing between different streams (e.g. circular linked list).
|
||||
type writeQueue struct {
|
||||
s []FrameWriteRequest
|
||||
currQueue []FrameWriteRequest
|
||||
nextQueue []FrameWriteRequest
|
||||
currPos int
|
||||
|
||||
prev, next *writeQueue
|
||||
}
|
||||
|
||||
func (q *writeQueue) empty() bool { return len(q.s) == 0 }
|
||||
func (q *writeQueue) empty() bool {
|
||||
return (len(q.currQueue) - q.currPos + len(q.nextQueue)) == 0
|
||||
}
|
||||
|
||||
func (q *writeQueue) push(wr FrameWriteRequest) {
|
||||
q.s = append(q.s, wr)
|
||||
q.nextQueue = append(q.nextQueue, wr)
|
||||
}
|
||||
|
||||
func (q *writeQueue) shift() FrameWriteRequest {
|
||||
if len(q.s) == 0 {
|
||||
if q.empty() {
|
||||
panic("invalid use of queue")
|
||||
}
|
||||
wr := q.s[0]
|
||||
// TODO: less copy-happy queue.
|
||||
copy(q.s, q.s[1:])
|
||||
q.s[len(q.s)-1] = FrameWriteRequest{}
|
||||
q.s = q.s[:len(q.s)-1]
|
||||
if q.currPos >= len(q.currQueue) {
|
||||
q.currQueue, q.currPos, q.nextQueue = q.nextQueue, 0, q.currQueue[:0]
|
||||
}
|
||||
wr := q.currQueue[q.currPos]
|
||||
q.currQueue[q.currPos] = FrameWriteRequest{}
|
||||
q.currPos++
|
||||
return wr
|
||||
}
|
||||
|
||||
func (q *writeQueue) peek() *FrameWriteRequest {
|
||||
if q.currPos < len(q.currQueue) {
|
||||
return &q.currQueue[q.currPos]
|
||||
}
|
||||
if len(q.nextQueue) > 0 {
|
||||
return &q.nextQueue[0]
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// consume consumes up to n bytes from q.s[0]. If the frame is
|
||||
// entirely consumed, it is removed from the queue. If the frame
|
||||
// is partially consumed, the frame is kept with the consumed
|
||||
// bytes removed. Returns true iff any bytes were consumed.
|
||||
func (q *writeQueue) consume(n int32) (FrameWriteRequest, bool) {
|
||||
if len(q.s) == 0 {
|
||||
if q.empty() {
|
||||
return FrameWriteRequest{}, false
|
||||
}
|
||||
consumed, rest, numresult := q.s[0].Consume(n)
|
||||
consumed, rest, numresult := q.peek().Consume(n)
|
||||
switch numresult {
|
||||
case 0:
|
||||
return FrameWriteRequest{}, false
|
||||
case 1:
|
||||
q.shift()
|
||||
case 2:
|
||||
q.s[0] = rest
|
||||
*q.peek() = rest
|
||||
}
|
||||
return consumed, true
|
||||
}
|
||||
@@ -232,10 +262,15 @@ type writeQueuePool []*writeQueue
|
||||
|
||||
// put inserts an unused writeQueue into the pool.
|
||||
func (p *writeQueuePool) put(q *writeQueue) {
|
||||
for i := range q.s {
|
||||
q.s[i] = FrameWriteRequest{}
|
||||
for i := range q.currQueue {
|
||||
q.currQueue[i] = FrameWriteRequest{}
|
||||
}
|
||||
q.s = q.s[:0]
|
||||
for i := range q.nextQueue {
|
||||
q.nextQueue[i] = FrameWriteRequest{}
|
||||
}
|
||||
q.currQueue = q.currQueue[:0]
|
||||
q.nextQueue = q.nextQueue[:0]
|
||||
q.currPos = 0
|
||||
*p = append(*p, q)
|
||||
}
|
||||
|
||||
|
||||
5
vendor/golang.org/x/net/http2/writesched_priority_rfc7540.go
generated
vendored
5
vendor/golang.org/x/net/http2/writesched_priority_rfc7540.go
generated
vendored
@@ -214,8 +214,8 @@ func (z sortPriorityNodeSiblingsRFC7540) Swap(i, k int) { z[i], z[k] = z[k], z[i
|
||||
func (z sortPriorityNodeSiblingsRFC7540) Less(i, k int) bool {
|
||||
// Prefer the subtree that has sent fewer bytes relative to its weight.
|
||||
// See sections 5.3.2 and 5.3.4.
|
||||
wi, bi := float64(z[i].weight+1), float64(z[i].subtreeBytes)
|
||||
wk, bk := float64(z[k].weight+1), float64(z[k].subtreeBytes)
|
||||
wi, bi := float64(z[i].weight)+1, float64(z[i].subtreeBytes)
|
||||
wk, bk := float64(z[k].weight)+1, float64(z[k].subtreeBytes)
|
||||
if bi == 0 && bk == 0 {
|
||||
return wi >= wk
|
||||
}
|
||||
@@ -302,7 +302,6 @@ func (ws *priorityWriteSchedulerRFC7540) CloseStream(streamID uint32) {
|
||||
|
||||
q := n.q
|
||||
ws.queuePool.put(&q)
|
||||
n.q.s = nil
|
||||
if ws.maxClosedNodesInTree > 0 {
|
||||
ws.addClosedOrIdleNode(&ws.closedNodes, ws.maxClosedNodesInTree, n)
|
||||
} else {
|
||||
|
||||
@@ -39,7 +39,7 @@ type priorityWriteSchedulerRFC9218 struct {
|
||||
prioritizeIncremental bool
|
||||
}
|
||||
|
||||
func newPriorityWriteSchedulerRFC9128() WriteScheduler {
|
||||
func newPriorityWriteSchedulerRFC9218() WriteScheduler {
|
||||
ws := &priorityWriteSchedulerRFC9218{
|
||||
streams: make(map[uint32]streamMetadata),
|
||||
}
|
||||
2
vendor/golang.org/x/sync/errgroup/errgroup.go
generated
vendored
2
vendor/golang.org/x/sync/errgroup/errgroup.go
generated
vendored
@@ -3,7 +3,7 @@
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package errgroup provides synchronization, error propagation, and Context
|
||||
// cancelation for groups of goroutines working on subtasks of a common task.
|
||||
// cancellation for groups of goroutines working on subtasks of a common task.
|
||||
//
|
||||
// [errgroup.Group] is related to [sync.WaitGroup] but adds handling of tasks
|
||||
// returning errors.
|
||||
|
||||
3
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
3
vendor/golang.org/x/sys/cpu/cpu.go
generated
vendored
@@ -92,6 +92,9 @@ var ARM64 struct {
|
||||
HasSHA2 bool // SHA2 hardware implementation
|
||||
HasCRC32 bool // CRC32 hardware implementation
|
||||
HasATOMICS bool // Atomic memory operation instruction set
|
||||
HasHPDS bool // Hierarchical permission disables in translations tables
|
||||
HasLOR bool // Limited ordering regions
|
||||
HasPAN bool // Privileged access never
|
||||
HasFPHP bool // Half precision floating-point instruction set
|
||||
HasASIMDHP bool // Advanced SIMD half precision instruction set
|
||||
HasCPUID bool // CPUID identification scheme registers
|
||||
|
||||
20
vendor/golang.org/x/sys/cpu/cpu_arm64.go
generated
vendored
20
vendor/golang.org/x/sys/cpu/cpu_arm64.go
generated
vendored
@@ -65,10 +65,10 @@ func setMinimalFeatures() {
|
||||
func readARM64Registers() {
|
||||
Initialized = true
|
||||
|
||||
parseARM64SystemRegisters(getisar0(), getisar1(), getpfr0())
|
||||
parseARM64SystemRegisters(getisar0(), getisar1(), getmmfr1(), getpfr0())
|
||||
}
|
||||
|
||||
func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) {
|
||||
func parseARM64SystemRegisters(isar0, isar1, mmfr1, pfr0 uint64) {
|
||||
// ID_AA64ISAR0_EL1
|
||||
switch extractBits(isar0, 4, 7) {
|
||||
case 1:
|
||||
@@ -152,6 +152,22 @@ func parseARM64SystemRegisters(isar0, isar1, pfr0 uint64) {
|
||||
ARM64.HasI8MM = true
|
||||
}
|
||||
|
||||
// ID_AA64MMFR1_EL1
|
||||
switch extractBits(mmfr1, 12, 15) {
|
||||
case 1, 2:
|
||||
ARM64.HasHPDS = true
|
||||
}
|
||||
|
||||
switch extractBits(mmfr1, 16, 19) {
|
||||
case 1:
|
||||
ARM64.HasLOR = true
|
||||
}
|
||||
|
||||
switch extractBits(mmfr1, 20, 23) {
|
||||
case 1, 2, 3:
|
||||
ARM64.HasPAN = true
|
||||
}
|
||||
|
||||
// ID_AA64PFR0_EL1
|
||||
switch extractBits(pfr0, 16, 19) {
|
||||
case 0:
|
||||
|
||||
19
vendor/golang.org/x/sys/cpu/cpu_arm64.s
generated
vendored
19
vendor/golang.org/x/sys/cpu/cpu_arm64.s
generated
vendored
@@ -9,31 +9,34 @@
|
||||
// func getisar0() uint64
|
||||
TEXT ·getisar0(SB),NOSPLIT,$0-8
|
||||
// get Instruction Set Attributes 0 into x0
|
||||
// mrs x0, ID_AA64ISAR0_EL1 = d5380600
|
||||
WORD $0xd5380600
|
||||
MRS ID_AA64ISAR0_EL1, R0
|
||||
MOVD R0, ret+0(FP)
|
||||
RET
|
||||
|
||||
// func getisar1() uint64
|
||||
TEXT ·getisar1(SB),NOSPLIT,$0-8
|
||||
// get Instruction Set Attributes 1 into x0
|
||||
// mrs x0, ID_AA64ISAR1_EL1 = d5380620
|
||||
WORD $0xd5380620
|
||||
MRS ID_AA64ISAR1_EL1, R0
|
||||
MOVD R0, ret+0(FP)
|
||||
RET
|
||||
|
||||
// func getmmfr1() uint64
|
||||
TEXT ·getmmfr1(SB),NOSPLIT,$0-8
|
||||
// get Memory Model Feature Register 1 into x0
|
||||
MRS ID_AA64MMFR1_EL1, R0
|
||||
MOVD R0, ret+0(FP)
|
||||
RET
|
||||
|
||||
// func getpfr0() uint64
|
||||
TEXT ·getpfr0(SB),NOSPLIT,$0-8
|
||||
// get Processor Feature Register 0 into x0
|
||||
// mrs x0, ID_AA64PFR0_EL1 = d5380400
|
||||
WORD $0xd5380400
|
||||
MRS ID_AA64PFR0_EL1, R0
|
||||
MOVD R0, ret+0(FP)
|
||||
RET
|
||||
|
||||
// func getzfr0() uint64
|
||||
TEXT ·getzfr0(SB),NOSPLIT,$0-8
|
||||
// get SVE Feature Register 0 into x0
|
||||
// mrs x0, ID_AA64ZFR0_EL1 = d5380480
|
||||
WORD $0xd5380480
|
||||
MRS ID_AA64ZFR0_EL1, R0
|
||||
MOVD R0, ret+0(FP)
|
||||
RET
|
||||
|
||||
1
vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go
generated
vendored
1
vendor/golang.org/x/sys/cpu/cpu_gc_arm64.go
generated
vendored
@@ -8,5 +8,6 @@ package cpu
|
||||
|
||||
func getisar0() uint64
|
||||
func getisar1() uint64
|
||||
func getmmfr1() uint64
|
||||
func getpfr0() uint64
|
||||
func getzfr0() uint64
|
||||
|
||||
1
vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go
generated
vendored
1
vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go
generated
vendored
@@ -8,4 +8,5 @@ package cpu
|
||||
|
||||
func getisar0() uint64 { return 0 }
|
||||
func getisar1() uint64 { return 0 }
|
||||
func getmmfr1() uint64 { return 0 }
|
||||
func getpfr0() uint64 { return 0 }
|
||||
|
||||
2
vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go
generated
vendored
2
vendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go
generated
vendored
@@ -167,7 +167,7 @@ func doinit() {
|
||||
setMinimalFeatures()
|
||||
return
|
||||
}
|
||||
parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64pfr0)
|
||||
parseARM64SystemRegisters(cpuid.aa64isar0, cpuid.aa64isar1, cpuid.aa64mmfr1, cpuid.aa64pfr0)
|
||||
|
||||
Initialized = true
|
||||
}
|
||||
|
||||
2
vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go
generated
vendored
2
vendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go
generated
vendored
@@ -59,7 +59,7 @@ func doinit() {
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
parseARM64SystemRegisters(isar0, isar1, 0)
|
||||
parseARM64SystemRegisters(isar0, isar1, 0, 0)
|
||||
|
||||
Initialized = true
|
||||
}
|
||||
|
||||
2
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
2
vendor/golang.org/x/sys/unix/mkerrors.sh
generated
vendored
@@ -226,6 +226,7 @@ struct ltchars {
|
||||
#include <linux/cryptouser.h>
|
||||
#include <linux/devlink.h>
|
||||
#include <linux/dm-ioctl.h>
|
||||
#include <linux/elf.h>
|
||||
#include <linux/errqueue.h>
|
||||
#include <linux/ethtool_netlink.h>
|
||||
#include <linux/falloc.h>
|
||||
@@ -529,6 +530,7 @@ ccflags="$@"
|
||||
$2 ~ /^O[CNPFPL][A-Z]+[^_][A-Z]+$/ ||
|
||||
$2 ~ /^(NL|CR|TAB|BS|VT|FF)DLY$/ ||
|
||||
$2 ~ /^(NL|CR|TAB|BS|VT|FF)[0-9]$/ ||
|
||||
$2 ~ /^(DT|EI|ELF|EV|NN|NT|PF|SHF|SHN|SHT|STB|STT|VER)_/ ||
|
||||
$2 ~ /^O?XTABS$/ ||
|
||||
$2 ~ /^TC[IO](ON|OFF)$/ ||
|
||||
$2 ~ /^IN_/ ||
|
||||
|
||||
6
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
6
vendor/golang.org/x/sys/unix/syscall_linux.go
generated
vendored
@@ -2643,3 +2643,9 @@ func SchedGetAttr(pid int, flags uint) (*SchedAttr, error) {
|
||||
|
||||
//sys Cachestat(fd uint, crange *CachestatRange, cstat *Cachestat_t, flags uint) (err error)
|
||||
//sys Mseal(b []byte, flags uint) (err error)
|
||||
|
||||
//sys setMemPolicy(mode int, mask *CPUSet, size int) (err error) = SYS_SET_MEMPOLICY
|
||||
|
||||
func SetMemPolicy(mode int, mask *CPUSet) error {
|
||||
return setMemPolicy(mode, mask, _CPU_SETSIZE)
|
||||
}
|
||||
|
||||
359
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
359
vendor/golang.org/x/sys/unix/zerrors_linux.go
generated
vendored
@@ -853,20 +853,86 @@ const (
|
||||
DM_VERSION_MAJOR = 0x4
|
||||
DM_VERSION_MINOR = 0x32
|
||||
DM_VERSION_PATCHLEVEL = 0x0
|
||||
DT_ADDRRNGHI = 0x6ffffeff
|
||||
DT_ADDRRNGLO = 0x6ffffe00
|
||||
DT_BLK = 0x6
|
||||
DT_CHR = 0x2
|
||||
DT_DEBUG = 0x15
|
||||
DT_DIR = 0x4
|
||||
DT_ENCODING = 0x20
|
||||
DT_FIFO = 0x1
|
||||
DT_FINI = 0xd
|
||||
DT_FLAGS_1 = 0x6ffffffb
|
||||
DT_GNU_HASH = 0x6ffffef5
|
||||
DT_HASH = 0x4
|
||||
DT_HIOS = 0x6ffff000
|
||||
DT_HIPROC = 0x7fffffff
|
||||
DT_INIT = 0xc
|
||||
DT_JMPREL = 0x17
|
||||
DT_LNK = 0xa
|
||||
DT_LOOS = 0x6000000d
|
||||
DT_LOPROC = 0x70000000
|
||||
DT_NEEDED = 0x1
|
||||
DT_NULL = 0x0
|
||||
DT_PLTGOT = 0x3
|
||||
DT_PLTREL = 0x14
|
||||
DT_PLTRELSZ = 0x2
|
||||
DT_REG = 0x8
|
||||
DT_REL = 0x11
|
||||
DT_RELA = 0x7
|
||||
DT_RELACOUNT = 0x6ffffff9
|
||||
DT_RELAENT = 0x9
|
||||
DT_RELASZ = 0x8
|
||||
DT_RELCOUNT = 0x6ffffffa
|
||||
DT_RELENT = 0x13
|
||||
DT_RELSZ = 0x12
|
||||
DT_RPATH = 0xf
|
||||
DT_SOCK = 0xc
|
||||
DT_SONAME = 0xe
|
||||
DT_STRSZ = 0xa
|
||||
DT_STRTAB = 0x5
|
||||
DT_SYMBOLIC = 0x10
|
||||
DT_SYMENT = 0xb
|
||||
DT_SYMTAB = 0x6
|
||||
DT_TEXTREL = 0x16
|
||||
DT_UNKNOWN = 0x0
|
||||
DT_VALRNGHI = 0x6ffffdff
|
||||
DT_VALRNGLO = 0x6ffffd00
|
||||
DT_VERDEF = 0x6ffffffc
|
||||
DT_VERDEFNUM = 0x6ffffffd
|
||||
DT_VERNEED = 0x6ffffffe
|
||||
DT_VERNEEDNUM = 0x6fffffff
|
||||
DT_VERSYM = 0x6ffffff0
|
||||
DT_WHT = 0xe
|
||||
ECHO = 0x8
|
||||
ECRYPTFS_SUPER_MAGIC = 0xf15f
|
||||
EFD_SEMAPHORE = 0x1
|
||||
EFIVARFS_MAGIC = 0xde5e81e4
|
||||
EFS_SUPER_MAGIC = 0x414a53
|
||||
EI_CLASS = 0x4
|
||||
EI_DATA = 0x5
|
||||
EI_MAG0 = 0x0
|
||||
EI_MAG1 = 0x1
|
||||
EI_MAG2 = 0x2
|
||||
EI_MAG3 = 0x3
|
||||
EI_NIDENT = 0x10
|
||||
EI_OSABI = 0x7
|
||||
EI_PAD = 0x8
|
||||
EI_VERSION = 0x6
|
||||
ELFCLASS32 = 0x1
|
||||
ELFCLASS64 = 0x2
|
||||
ELFCLASSNONE = 0x0
|
||||
ELFCLASSNUM = 0x3
|
||||
ELFDATA2LSB = 0x1
|
||||
ELFDATA2MSB = 0x2
|
||||
ELFDATANONE = 0x0
|
||||
ELFMAG = "\177ELF"
|
||||
ELFMAG0 = 0x7f
|
||||
ELFMAG1 = 'E'
|
||||
ELFMAG2 = 'L'
|
||||
ELFMAG3 = 'F'
|
||||
ELFOSABI_LINUX = 0x3
|
||||
ELFOSABI_NONE = 0x0
|
||||
EM_386 = 0x3
|
||||
EM_486 = 0x6
|
||||
EM_68K = 0x4
|
||||
@@ -1152,14 +1218,24 @@ const (
|
||||
ETH_P_WCCP = 0x883e
|
||||
ETH_P_X25 = 0x805
|
||||
ETH_P_XDSA = 0xf8
|
||||
ET_CORE = 0x4
|
||||
ET_DYN = 0x3
|
||||
ET_EXEC = 0x2
|
||||
ET_HIPROC = 0xffff
|
||||
ET_LOPROC = 0xff00
|
||||
ET_NONE = 0x0
|
||||
ET_REL = 0x1
|
||||
EV_ABS = 0x3
|
||||
EV_CNT = 0x20
|
||||
EV_CURRENT = 0x1
|
||||
EV_FF = 0x15
|
||||
EV_FF_STATUS = 0x17
|
||||
EV_KEY = 0x1
|
||||
EV_LED = 0x11
|
||||
EV_MAX = 0x1f
|
||||
EV_MSC = 0x4
|
||||
EV_NONE = 0x0
|
||||
EV_NUM = 0x2
|
||||
EV_PWR = 0x16
|
||||
EV_REL = 0x2
|
||||
EV_REP = 0x14
|
||||
@@ -2276,7 +2352,167 @@ const (
|
||||
NLM_F_REPLACE = 0x100
|
||||
NLM_F_REQUEST = 0x1
|
||||
NLM_F_ROOT = 0x100
|
||||
NN_386_IOPERM = "LINUX"
|
||||
NN_386_TLS = "LINUX"
|
||||
NN_ARC_V2 = "LINUX"
|
||||
NN_ARM_FPMR = "LINUX"
|
||||
NN_ARM_GCS = "LINUX"
|
||||
NN_ARM_HW_BREAK = "LINUX"
|
||||
NN_ARM_HW_WATCH = "LINUX"
|
||||
NN_ARM_PACA_KEYS = "LINUX"
|
||||
NN_ARM_PACG_KEYS = "LINUX"
|
||||
NN_ARM_PAC_ENABLED_KEYS = "LINUX"
|
||||
NN_ARM_PAC_MASK = "LINUX"
|
||||
NN_ARM_POE = "LINUX"
|
||||
NN_ARM_SSVE = "LINUX"
|
||||
NN_ARM_SVE = "LINUX"
|
||||
NN_ARM_SYSTEM_CALL = "LINUX"
|
||||
NN_ARM_TAGGED_ADDR_CTRL = "LINUX"
|
||||
NN_ARM_TLS = "LINUX"
|
||||
NN_ARM_VFP = "LINUX"
|
||||
NN_ARM_ZA = "LINUX"
|
||||
NN_ARM_ZT = "LINUX"
|
||||
NN_AUXV = "CORE"
|
||||
NN_FILE = "CORE"
|
||||
NN_GNU_PROPERTY_TYPE_0 = "GNU"
|
||||
NN_LOONGARCH_CPUCFG = "LINUX"
|
||||
NN_LOONGARCH_CSR = "LINUX"
|
||||
NN_LOONGARCH_HW_BREAK = "LINUX"
|
||||
NN_LOONGARCH_HW_WATCH = "LINUX"
|
||||
NN_LOONGARCH_LASX = "LINUX"
|
||||
NN_LOONGARCH_LBT = "LINUX"
|
||||
NN_LOONGARCH_LSX = "LINUX"
|
||||
NN_MIPS_DSP = "LINUX"
|
||||
NN_MIPS_FP_MODE = "LINUX"
|
||||
NN_MIPS_MSA = "LINUX"
|
||||
NN_PPC_DEXCR = "LINUX"
|
||||
NN_PPC_DSCR = "LINUX"
|
||||
NN_PPC_EBB = "LINUX"
|
||||
NN_PPC_HASHKEYR = "LINUX"
|
||||
NN_PPC_PKEY = "LINUX"
|
||||
NN_PPC_PMU = "LINUX"
|
||||
NN_PPC_PPR = "LINUX"
|
||||
NN_PPC_SPE = "LINUX"
|
||||
NN_PPC_TAR = "LINUX"
|
||||
NN_PPC_TM_CDSCR = "LINUX"
|
||||
NN_PPC_TM_CFPR = "LINUX"
|
||||
NN_PPC_TM_CGPR = "LINUX"
|
||||
NN_PPC_TM_CPPR = "LINUX"
|
||||
NN_PPC_TM_CTAR = "LINUX"
|
||||
NN_PPC_TM_CVMX = "LINUX"
|
||||
NN_PPC_TM_CVSX = "LINUX"
|
||||
NN_PPC_TM_SPR = "LINUX"
|
||||
NN_PPC_VMX = "LINUX"
|
||||
NN_PPC_VSX = "LINUX"
|
||||
NN_PRFPREG = "CORE"
|
||||
NN_PRPSINFO = "CORE"
|
||||
NN_PRSTATUS = "CORE"
|
||||
NN_PRXFPREG = "LINUX"
|
||||
NN_RISCV_CSR = "LINUX"
|
||||
NN_RISCV_TAGGED_ADDR_CTRL = "LINUX"
|
||||
NN_RISCV_VECTOR = "LINUX"
|
||||
NN_S390_CTRS = "LINUX"
|
||||
NN_S390_GS_BC = "LINUX"
|
||||
NN_S390_GS_CB = "LINUX"
|
||||
NN_S390_HIGH_GPRS = "LINUX"
|
||||
NN_S390_LAST_BREAK = "LINUX"
|
||||
NN_S390_PREFIX = "LINUX"
|
||||
NN_S390_PV_CPU_DATA = "LINUX"
|
||||
NN_S390_RI_CB = "LINUX"
|
||||
NN_S390_SYSTEM_CALL = "LINUX"
|
||||
NN_S390_TDB = "LINUX"
|
||||
NN_S390_TIMER = "LINUX"
|
||||
NN_S390_TODCMP = "LINUX"
|
||||
NN_S390_TODPREG = "LINUX"
|
||||
NN_S390_VXRS_HIGH = "LINUX"
|
||||
NN_S390_VXRS_LOW = "LINUX"
|
||||
NN_SIGINFO = "CORE"
|
||||
NN_TASKSTRUCT = "CORE"
|
||||
NN_VMCOREDD = "LINUX"
|
||||
NN_X86_SHSTK = "LINUX"
|
||||
NN_X86_XSAVE_LAYOUT = "LINUX"
|
||||
NN_X86_XSTATE = "LINUX"
|
||||
NSFS_MAGIC = 0x6e736673
|
||||
NT_386_IOPERM = 0x201
|
||||
NT_386_TLS = 0x200
|
||||
NT_ARC_V2 = 0x600
|
||||
NT_ARM_FPMR = 0x40e
|
||||
NT_ARM_GCS = 0x410
|
||||
NT_ARM_HW_BREAK = 0x402
|
||||
NT_ARM_HW_WATCH = 0x403
|
||||
NT_ARM_PACA_KEYS = 0x407
|
||||
NT_ARM_PACG_KEYS = 0x408
|
||||
NT_ARM_PAC_ENABLED_KEYS = 0x40a
|
||||
NT_ARM_PAC_MASK = 0x406
|
||||
NT_ARM_POE = 0x40f
|
||||
NT_ARM_SSVE = 0x40b
|
||||
NT_ARM_SVE = 0x405
|
||||
NT_ARM_SYSTEM_CALL = 0x404
|
||||
NT_ARM_TAGGED_ADDR_CTRL = 0x409
|
||||
NT_ARM_TLS = 0x401
|
||||
NT_ARM_VFP = 0x400
|
||||
NT_ARM_ZA = 0x40c
|
||||
NT_ARM_ZT = 0x40d
|
||||
NT_AUXV = 0x6
|
||||
NT_FILE = 0x46494c45
|
||||
NT_GNU_PROPERTY_TYPE_0 = 0x5
|
||||
NT_LOONGARCH_CPUCFG = 0xa00
|
||||
NT_LOONGARCH_CSR = 0xa01
|
||||
NT_LOONGARCH_HW_BREAK = 0xa05
|
||||
NT_LOONGARCH_HW_WATCH = 0xa06
|
||||
NT_LOONGARCH_LASX = 0xa03
|
||||
NT_LOONGARCH_LBT = 0xa04
|
||||
NT_LOONGARCH_LSX = 0xa02
|
||||
NT_MIPS_DSP = 0x800
|
||||
NT_MIPS_FP_MODE = 0x801
|
||||
NT_MIPS_MSA = 0x802
|
||||
NT_PPC_DEXCR = 0x111
|
||||
NT_PPC_DSCR = 0x105
|
||||
NT_PPC_EBB = 0x106
|
||||
NT_PPC_HASHKEYR = 0x112
|
||||
NT_PPC_PKEY = 0x110
|
||||
NT_PPC_PMU = 0x107
|
||||
NT_PPC_PPR = 0x104
|
||||
NT_PPC_SPE = 0x101
|
||||
NT_PPC_TAR = 0x103
|
||||
NT_PPC_TM_CDSCR = 0x10f
|
||||
NT_PPC_TM_CFPR = 0x109
|
||||
NT_PPC_TM_CGPR = 0x108
|
||||
NT_PPC_TM_CPPR = 0x10e
|
||||
NT_PPC_TM_CTAR = 0x10d
|
||||
NT_PPC_TM_CVMX = 0x10a
|
||||
NT_PPC_TM_CVSX = 0x10b
|
||||
NT_PPC_TM_SPR = 0x10c
|
||||
NT_PPC_VMX = 0x100
|
||||
NT_PPC_VSX = 0x102
|
||||
NT_PRFPREG = 0x2
|
||||
NT_PRPSINFO = 0x3
|
||||
NT_PRSTATUS = 0x1
|
||||
NT_PRXFPREG = 0x46e62b7f
|
||||
NT_RISCV_CSR = 0x900
|
||||
NT_RISCV_TAGGED_ADDR_CTRL = 0x902
|
||||
NT_RISCV_VECTOR = 0x901
|
||||
NT_S390_CTRS = 0x304
|
||||
NT_S390_GS_BC = 0x30c
|
||||
NT_S390_GS_CB = 0x30b
|
||||
NT_S390_HIGH_GPRS = 0x300
|
||||
NT_S390_LAST_BREAK = 0x306
|
||||
NT_S390_PREFIX = 0x305
|
||||
NT_S390_PV_CPU_DATA = 0x30e
|
||||
NT_S390_RI_CB = 0x30d
|
||||
NT_S390_SYSTEM_CALL = 0x307
|
||||
NT_S390_TDB = 0x308
|
||||
NT_S390_TIMER = 0x301
|
||||
NT_S390_TODCMP = 0x302
|
||||
NT_S390_TODPREG = 0x303
|
||||
NT_S390_VXRS_HIGH = 0x30a
|
||||
NT_S390_VXRS_LOW = 0x309
|
||||
NT_SIGINFO = 0x53494749
|
||||
NT_TASKSTRUCT = 0x4
|
||||
NT_VMCOREDD = 0x700
|
||||
NT_X86_SHSTK = 0x204
|
||||
NT_X86_XSAVE_LAYOUT = 0x205
|
||||
NT_X86_XSTATE = 0x202
|
||||
OCFS2_SUPER_MAGIC = 0x7461636f
|
||||
OCRNL = 0x8
|
||||
OFDEL = 0x80
|
||||
@@ -2463,6 +2699,59 @@ const (
|
||||
PERF_RECORD_MISC_USER = 0x2
|
||||
PERF_SAMPLE_BRANCH_PLM_ALL = 0x7
|
||||
PERF_SAMPLE_WEIGHT_TYPE = 0x1004000
|
||||
PF_ALG = 0x26
|
||||
PF_APPLETALK = 0x5
|
||||
PF_ASH = 0x12
|
||||
PF_ATMPVC = 0x8
|
||||
PF_ATMSVC = 0x14
|
||||
PF_AX25 = 0x3
|
||||
PF_BLUETOOTH = 0x1f
|
||||
PF_BRIDGE = 0x7
|
||||
PF_CAIF = 0x25
|
||||
PF_CAN = 0x1d
|
||||
PF_DECnet = 0xc
|
||||
PF_ECONET = 0x13
|
||||
PF_FILE = 0x1
|
||||
PF_IB = 0x1b
|
||||
PF_IEEE802154 = 0x24
|
||||
PF_INET = 0x2
|
||||
PF_INET6 = 0xa
|
||||
PF_IPX = 0x4
|
||||
PF_IRDA = 0x17
|
||||
PF_ISDN = 0x22
|
||||
PF_IUCV = 0x20
|
||||
PF_KCM = 0x29
|
||||
PF_KEY = 0xf
|
||||
PF_LLC = 0x1a
|
||||
PF_LOCAL = 0x1
|
||||
PF_MAX = 0x2e
|
||||
PF_MCTP = 0x2d
|
||||
PF_MPLS = 0x1c
|
||||
PF_NETBEUI = 0xd
|
||||
PF_NETLINK = 0x10
|
||||
PF_NETROM = 0x6
|
||||
PF_NFC = 0x27
|
||||
PF_PACKET = 0x11
|
||||
PF_PHONET = 0x23
|
||||
PF_PPPOX = 0x18
|
||||
PF_QIPCRTR = 0x2a
|
||||
PF_R = 0x4
|
||||
PF_RDS = 0x15
|
||||
PF_ROSE = 0xb
|
||||
PF_ROUTE = 0x10
|
||||
PF_RXRPC = 0x21
|
||||
PF_SECURITY = 0xe
|
||||
PF_SMC = 0x2b
|
||||
PF_SNA = 0x16
|
||||
PF_TIPC = 0x1e
|
||||
PF_UNIX = 0x1
|
||||
PF_UNSPEC = 0x0
|
||||
PF_VSOCK = 0x28
|
||||
PF_W = 0x2
|
||||
PF_WANPIPE = 0x19
|
||||
PF_X = 0x1
|
||||
PF_X25 = 0x9
|
||||
PF_XDP = 0x2c
|
||||
PID_FS_MAGIC = 0x50494446
|
||||
PIPEFS_MAGIC = 0x50495045
|
||||
PPPIOCGNPMODE = 0xc008744c
|
||||
@@ -2758,6 +3047,23 @@ const (
|
||||
PTRACE_SYSCALL_INFO_NONE = 0x0
|
||||
PTRACE_SYSCALL_INFO_SECCOMP = 0x3
|
||||
PTRACE_TRACEME = 0x0
|
||||
PT_AARCH64_MEMTAG_MTE = 0x70000002
|
||||
PT_DYNAMIC = 0x2
|
||||
PT_GNU_EH_FRAME = 0x6474e550
|
||||
PT_GNU_PROPERTY = 0x6474e553
|
||||
PT_GNU_RELRO = 0x6474e552
|
||||
PT_GNU_STACK = 0x6474e551
|
||||
PT_HIOS = 0x6fffffff
|
||||
PT_HIPROC = 0x7fffffff
|
||||
PT_INTERP = 0x3
|
||||
PT_LOAD = 0x1
|
||||
PT_LOOS = 0x60000000
|
||||
PT_LOPROC = 0x70000000
|
||||
PT_NOTE = 0x4
|
||||
PT_NULL = 0x0
|
||||
PT_PHDR = 0x6
|
||||
PT_SHLIB = 0x5
|
||||
PT_TLS = 0x7
|
||||
P_ALL = 0x0
|
||||
P_PGID = 0x2
|
||||
P_PID = 0x1
|
||||
@@ -3091,6 +3397,47 @@ const (
|
||||
SEEK_MAX = 0x4
|
||||
SEEK_SET = 0x0
|
||||
SELINUX_MAGIC = 0xf97cff8c
|
||||
SHF_ALLOC = 0x2
|
||||
SHF_EXCLUDE = 0x8000000
|
||||
SHF_EXECINSTR = 0x4
|
||||
SHF_GROUP = 0x200
|
||||
SHF_INFO_LINK = 0x40
|
||||
SHF_LINK_ORDER = 0x80
|
||||
SHF_MASKOS = 0xff00000
|
||||
SHF_MASKPROC = 0xf0000000
|
||||
SHF_MERGE = 0x10
|
||||
SHF_ORDERED = 0x4000000
|
||||
SHF_OS_NONCONFORMING = 0x100
|
||||
SHF_RELA_LIVEPATCH = 0x100000
|
||||
SHF_RO_AFTER_INIT = 0x200000
|
||||
SHF_STRINGS = 0x20
|
||||
SHF_TLS = 0x400
|
||||
SHF_WRITE = 0x1
|
||||
SHN_ABS = 0xfff1
|
||||
SHN_COMMON = 0xfff2
|
||||
SHN_HIPROC = 0xff1f
|
||||
SHN_HIRESERVE = 0xffff
|
||||
SHN_LIVEPATCH = 0xff20
|
||||
SHN_LOPROC = 0xff00
|
||||
SHN_LORESERVE = 0xff00
|
||||
SHN_UNDEF = 0x0
|
||||
SHT_DYNAMIC = 0x6
|
||||
SHT_DYNSYM = 0xb
|
||||
SHT_HASH = 0x5
|
||||
SHT_HIPROC = 0x7fffffff
|
||||
SHT_HIUSER = 0xffffffff
|
||||
SHT_LOPROC = 0x70000000
|
||||
SHT_LOUSER = 0x80000000
|
||||
SHT_NOBITS = 0x8
|
||||
SHT_NOTE = 0x7
|
||||
SHT_NULL = 0x0
|
||||
SHT_NUM = 0xc
|
||||
SHT_PROGBITS = 0x1
|
||||
SHT_REL = 0x9
|
||||
SHT_RELA = 0x4
|
||||
SHT_SHLIB = 0xa
|
||||
SHT_STRTAB = 0x3
|
||||
SHT_SYMTAB = 0x2
|
||||
SHUT_RD = 0x0
|
||||
SHUT_RDWR = 0x2
|
||||
SHUT_WR = 0x1
|
||||
@@ -3317,6 +3664,16 @@ const (
|
||||
STATX_UID = 0x8
|
||||
STATX_WRITE_ATOMIC = 0x10000
|
||||
STATX__RESERVED = 0x80000000
|
||||
STB_GLOBAL = 0x1
|
||||
STB_LOCAL = 0x0
|
||||
STB_WEAK = 0x2
|
||||
STT_COMMON = 0x5
|
||||
STT_FILE = 0x4
|
||||
STT_FUNC = 0x2
|
||||
STT_NOTYPE = 0x0
|
||||
STT_OBJECT = 0x1
|
||||
STT_SECTION = 0x3
|
||||
STT_TLS = 0x6
|
||||
SYNC_FILE_RANGE_WAIT_AFTER = 0x4
|
||||
SYNC_FILE_RANGE_WAIT_BEFORE = 0x1
|
||||
SYNC_FILE_RANGE_WRITE = 0x2
|
||||
@@ -3553,6 +3910,8 @@ const (
|
||||
UTIME_OMIT = 0x3ffffffe
|
||||
V9FS_MAGIC = 0x1021997
|
||||
VERASE = 0x2
|
||||
VER_FLG_BASE = 0x1
|
||||
VER_FLG_WEAK = 0x2
|
||||
VINTR = 0x0
|
||||
VKILL = 0x3
|
||||
VLNEXT = 0xf
|
||||
|
||||
10
vendor/golang.org/x/sys/unix/zsyscall_linux.go
generated
vendored
10
vendor/golang.org/x/sys/unix/zsyscall_linux.go
generated
vendored
@@ -2238,3 +2238,13 @@ func Mseal(b []byte, flags uint) (err error) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT
|
||||
|
||||
func setMemPolicy(mode int, mask *CPUSet, size int) (err error) {
|
||||
_, _, e1 := Syscall(SYS_SET_MEMPOLICY, uintptr(mode), uintptr(unsafe.Pointer(mask)), uintptr(size))
|
||||
if e1 != 0 {
|
||||
err = errnoErr(e1)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
31
vendor/golang.org/x/sys/unix/ztypes_linux.go
generated
vendored
31
vendor/golang.org/x/sys/unix/ztypes_linux.go
generated
vendored
@@ -3590,6 +3590,8 @@ type Nhmsg struct {
|
||||
Flags uint32
|
||||
}
|
||||
|
||||
const SizeofNhmsg = 0x8
|
||||
|
||||
type NexthopGrp struct {
|
||||
Id uint32
|
||||
Weight uint8
|
||||
@@ -3597,6 +3599,8 @@ type NexthopGrp struct {
|
||||
Resvd2 uint16
|
||||
}
|
||||
|
||||
const SizeofNexthopGrp = 0x8
|
||||
|
||||
const (
|
||||
NHA_UNSPEC = 0x0
|
||||
NHA_ID = 0x1
|
||||
@@ -6332,3 +6336,30 @@ type SockDiagReq struct {
|
||||
}
|
||||
|
||||
const RTM_NEWNVLAN = 0x70
|
||||
|
||||
const (
|
||||
MPOL_BIND = 0x2
|
||||
MPOL_DEFAULT = 0x0
|
||||
MPOL_F_ADDR = 0x2
|
||||
MPOL_F_MEMS_ALLOWED = 0x4
|
||||
MPOL_F_MOF = 0x8
|
||||
MPOL_F_MORON = 0x10
|
||||
MPOL_F_NODE = 0x1
|
||||
MPOL_F_NUMA_BALANCING = 0x2000
|
||||
MPOL_F_RELATIVE_NODES = 0x4000
|
||||
MPOL_F_SHARED = 0x1
|
||||
MPOL_F_STATIC_NODES = 0x8000
|
||||
MPOL_INTERLEAVE = 0x3
|
||||
MPOL_LOCAL = 0x4
|
||||
MPOL_MAX = 0x7
|
||||
MPOL_MF_INTERNAL = 0x10
|
||||
MPOL_MF_LAZY = 0x8
|
||||
MPOL_MF_MOVE_ALL = 0x4
|
||||
MPOL_MF_MOVE = 0x2
|
||||
MPOL_MF_STRICT = 0x1
|
||||
MPOL_MF_VALID = 0x7
|
||||
MPOL_MODE_FLAGS = 0xe000
|
||||
MPOL_PREFERRED = 0x1
|
||||
MPOL_PREFERRED_MANY = 0x5
|
||||
MPOL_WEIGHTED_INTERLEAVE = 0x6
|
||||
)
|
||||
|
||||
15
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
15
vendor/golang.org/x/sys/windows/syscall_windows.go
generated
vendored
@@ -892,8 +892,12 @@ const socket_error = uintptr(^uint32(0))
|
||||
//sys MultiByteToWideChar(codePage uint32, dwFlags uint32, str *byte, nstr int32, wchar *uint16, nwchar int32) (nwrite int32, err error) = kernel32.MultiByteToWideChar
|
||||
//sys getBestInterfaceEx(sockaddr unsafe.Pointer, pdwBestIfIndex *uint32) (errcode error) = iphlpapi.GetBestInterfaceEx
|
||||
//sys GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) = iphlpapi.GetIfEntry2Ex
|
||||
//sys GetIpForwardEntry2(row *MibIpForwardRow2) (errcode error) = iphlpapi.GetIpForwardEntry2
|
||||
//sys GetIpForwardTable2(family uint16, table **MibIpForwardTable2) (errcode error) = iphlpapi.GetIpForwardTable2
|
||||
//sys GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) = iphlpapi.GetUnicastIpAddressEntry
|
||||
//sys FreeMibTable(memory unsafe.Pointer) = iphlpapi.FreeMibTable
|
||||
//sys NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyIpInterfaceChange
|
||||
//sys NotifyRouteChange2(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyRouteChange2
|
||||
//sys NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) = iphlpapi.NotifyUnicastIpAddressChange
|
||||
//sys CancelMibChangeNotify2(notificationHandle Handle) (errcode error) = iphlpapi.CancelMibChangeNotify2
|
||||
|
||||
@@ -916,6 +920,17 @@ type RawSockaddrInet6 struct {
|
||||
Scope_id uint32
|
||||
}
|
||||
|
||||
// RawSockaddrInet is a union that contains an IPv4, an IPv6 address, or an address family. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/ws2ipdef/ns-ws2ipdef-sockaddr_inet.
|
||||
//
|
||||
// A [*RawSockaddrInet] may be converted to a [*RawSockaddrInet4] or [*RawSockaddrInet6] using
|
||||
// unsafe, depending on the address family.
|
||||
type RawSockaddrInet struct {
|
||||
Family uint16
|
||||
Port uint16
|
||||
Data [6]uint32
|
||||
}
|
||||
|
||||
type RawSockaddr struct {
|
||||
Family uint16
|
||||
Data [14]int8
|
||||
|
||||
76
vendor/golang.org/x/sys/windows/types_windows.go
generated
vendored
76
vendor/golang.org/x/sys/windows/types_windows.go
generated
vendored
@@ -2320,6 +2320,82 @@ type MibIfRow2 struct {
|
||||
OutQLen uint64
|
||||
}
|
||||
|
||||
// IP_ADDRESS_PREFIX stores an IP address prefix. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-ip_address_prefix.
|
||||
type IpAddressPrefix struct {
|
||||
Prefix RawSockaddrInet
|
||||
PrefixLength uint8
|
||||
}
|
||||
|
||||
// NL_ROUTE_ORIGIN enumeration from nldef.h or
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_route_origin.
|
||||
const (
|
||||
NlroManual = 0
|
||||
NlroWellKnown = 1
|
||||
NlroDHCP = 2
|
||||
NlroRouterAdvertisement = 3
|
||||
Nlro6to4 = 4
|
||||
)
|
||||
|
||||
// NL_ROUTE_ORIGIN enumeration from nldef.h or
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/nldef/ne-nldef-nl_route_protocol.
|
||||
const (
|
||||
MIB_IPPROTO_OTHER = 1
|
||||
MIB_IPPROTO_LOCAL = 2
|
||||
MIB_IPPROTO_NETMGMT = 3
|
||||
MIB_IPPROTO_ICMP = 4
|
||||
MIB_IPPROTO_EGP = 5
|
||||
MIB_IPPROTO_GGP = 6
|
||||
MIB_IPPROTO_HELLO = 7
|
||||
MIB_IPPROTO_RIP = 8
|
||||
MIB_IPPROTO_IS_IS = 9
|
||||
MIB_IPPROTO_ES_IS = 10
|
||||
MIB_IPPROTO_CISCO = 11
|
||||
MIB_IPPROTO_BBN = 12
|
||||
MIB_IPPROTO_OSPF = 13
|
||||
MIB_IPPROTO_BGP = 14
|
||||
MIB_IPPROTO_IDPR = 15
|
||||
MIB_IPPROTO_EIGRP = 16
|
||||
MIB_IPPROTO_DVMRP = 17
|
||||
MIB_IPPROTO_RPL = 18
|
||||
MIB_IPPROTO_DHCP = 19
|
||||
MIB_IPPROTO_NT_AUTOSTATIC = 10002
|
||||
MIB_IPPROTO_NT_STATIC = 10006
|
||||
MIB_IPPROTO_NT_STATIC_NON_DOD = 10007
|
||||
)
|
||||
|
||||
// MIB_IPFORWARD_ROW2 stores information about an IP route entry. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_row2.
|
||||
type MibIpForwardRow2 struct {
|
||||
InterfaceLuid uint64
|
||||
InterfaceIndex uint32
|
||||
DestinationPrefix IpAddressPrefix
|
||||
NextHop RawSockaddrInet
|
||||
SitePrefixLength uint8
|
||||
ValidLifetime uint32
|
||||
PreferredLifetime uint32
|
||||
Metric uint32
|
||||
Protocol uint32
|
||||
Loopback uint8
|
||||
AutoconfigureAddress uint8
|
||||
Publish uint8
|
||||
Immortal uint8
|
||||
Age uint32
|
||||
Origin uint32
|
||||
}
|
||||
|
||||
// MIB_IPFORWARD_TABLE2 contains a table of IP route entries. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_ipforward_table2.
|
||||
type MibIpForwardTable2 struct {
|
||||
NumEntries uint32
|
||||
Table [1]MibIpForwardRow2
|
||||
}
|
||||
|
||||
// Rows returns the IP route entries in the table.
|
||||
func (t *MibIpForwardTable2) Rows() []MibIpForwardRow2 {
|
||||
return unsafe.Slice(&t.Table[0], t.NumEntries)
|
||||
}
|
||||
|
||||
// MIB_UNICASTIPADDRESS_ROW stores information about a unicast IP address. See
|
||||
// https://learn.microsoft.com/en-us/windows/win32/api/netioapi/ns-netioapi-mib_unicastipaddress_row.
|
||||
type MibUnicastIpAddressRow struct {
|
||||
|
||||
37
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
37
vendor/golang.org/x/sys/windows/zsyscall_windows.go
generated
vendored
@@ -182,13 +182,17 @@ var (
|
||||
procDwmGetWindowAttribute = moddwmapi.NewProc("DwmGetWindowAttribute")
|
||||
procDwmSetWindowAttribute = moddwmapi.NewProc("DwmSetWindowAttribute")
|
||||
procCancelMibChangeNotify2 = modiphlpapi.NewProc("CancelMibChangeNotify2")
|
||||
procFreeMibTable = modiphlpapi.NewProc("FreeMibTable")
|
||||
procGetAdaptersAddresses = modiphlpapi.NewProc("GetAdaptersAddresses")
|
||||
procGetAdaptersInfo = modiphlpapi.NewProc("GetAdaptersInfo")
|
||||
procGetBestInterfaceEx = modiphlpapi.NewProc("GetBestInterfaceEx")
|
||||
procGetIfEntry = modiphlpapi.NewProc("GetIfEntry")
|
||||
procGetIfEntry2Ex = modiphlpapi.NewProc("GetIfEntry2Ex")
|
||||
procGetIpForwardEntry2 = modiphlpapi.NewProc("GetIpForwardEntry2")
|
||||
procGetIpForwardTable2 = modiphlpapi.NewProc("GetIpForwardTable2")
|
||||
procGetUnicastIpAddressEntry = modiphlpapi.NewProc("GetUnicastIpAddressEntry")
|
||||
procNotifyIpInterfaceChange = modiphlpapi.NewProc("NotifyIpInterfaceChange")
|
||||
procNotifyRouteChange2 = modiphlpapi.NewProc("NotifyRouteChange2")
|
||||
procNotifyUnicastIpAddressChange = modiphlpapi.NewProc("NotifyUnicastIpAddressChange")
|
||||
procAddDllDirectory = modkernel32.NewProc("AddDllDirectory")
|
||||
procAssignProcessToJobObject = modkernel32.NewProc("AssignProcessToJobObject")
|
||||
@@ -1624,6 +1628,11 @@ func CancelMibChangeNotify2(notificationHandle Handle) (errcode error) {
|
||||
return
|
||||
}
|
||||
|
||||
func FreeMibTable(memory unsafe.Pointer) {
|
||||
syscall.SyscallN(procFreeMibTable.Addr(), uintptr(memory))
|
||||
return
|
||||
}
|
||||
|
||||
func GetAdaptersAddresses(family uint32, flags uint32, reserved uintptr, adapterAddresses *IpAdapterAddresses, sizePointer *uint32) (errcode error) {
|
||||
r0, _, _ := syscall.SyscallN(procGetAdaptersAddresses.Addr(), uintptr(family), uintptr(flags), uintptr(reserved), uintptr(unsafe.Pointer(adapterAddresses)), uintptr(unsafe.Pointer(sizePointer)))
|
||||
if r0 != 0 {
|
||||
@@ -1664,6 +1673,22 @@ func GetIfEntry2Ex(level uint32, row *MibIfRow2) (errcode error) {
|
||||
return
|
||||
}
|
||||
|
||||
func GetIpForwardEntry2(row *MibIpForwardRow2) (errcode error) {
|
||||
r0, _, _ := syscall.SyscallN(procGetIpForwardEntry2.Addr(), uintptr(unsafe.Pointer(row)))
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetIpForwardTable2(family uint16, table **MibIpForwardTable2) (errcode error) {
|
||||
r0, _, _ := syscall.SyscallN(procGetIpForwardTable2.Addr(), uintptr(family), uintptr(unsafe.Pointer(table)))
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func GetUnicastIpAddressEntry(row *MibUnicastIpAddressRow) (errcode error) {
|
||||
r0, _, _ := syscall.SyscallN(procGetUnicastIpAddressEntry.Addr(), uintptr(unsafe.Pointer(row)))
|
||||
if r0 != 0 {
|
||||
@@ -1684,6 +1709,18 @@ func NotifyIpInterfaceChange(family uint16, callback uintptr, callerContext unsa
|
||||
return
|
||||
}
|
||||
|
||||
func NotifyRouteChange2(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
|
||||
var _p0 uint32
|
||||
if initialNotification {
|
||||
_p0 = 1
|
||||
}
|
||||
r0, _, _ := syscall.SyscallN(procNotifyRouteChange2.Addr(), uintptr(family), uintptr(callback), uintptr(callerContext), uintptr(_p0), uintptr(unsafe.Pointer(notificationHandle)))
|
||||
if r0 != 0 {
|
||||
errcode = syscall.Errno(r0)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func NotifyUnicastIpAddressChange(family uint16, callback uintptr, callerContext unsafe.Pointer, initialNotification bool, notificationHandle *Handle) (errcode error) {
|
||||
var _p0 uint32
|
||||
if initialNotification {
|
||||
|
||||
295
vendor/golang.org/x/tools/go/ast/edge/edge.go
generated
vendored
Normal file
295
vendor/golang.org/x/tools/go/ast/edge/edge.go
generated
vendored
Normal file
@@ -0,0 +1,295 @@
|
||||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package edge defines identifiers for each field of an ast.Node
|
||||
// struct type that refers to another Node.
|
||||
package edge
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
// A Kind describes a field of an ast.Node struct.
|
||||
type Kind uint8
|
||||
|
||||
// String returns a description of the edge kind.
|
||||
func (k Kind) String() string {
|
||||
if k == Invalid {
|
||||
return "<invalid>"
|
||||
}
|
||||
info := fieldInfos[k]
|
||||
return fmt.Sprintf("%v.%s", info.nodeType.Elem().Name(), info.name)
|
||||
}
|
||||
|
||||
// NodeType returns the pointer-to-struct type of the ast.Node implementation.
|
||||
func (k Kind) NodeType() reflect.Type { return fieldInfos[k].nodeType }
|
||||
|
||||
// FieldName returns the name of the field.
|
||||
func (k Kind) FieldName() string { return fieldInfos[k].name }
|
||||
|
||||
// FieldType returns the declared type of the field.
|
||||
func (k Kind) FieldType() reflect.Type { return fieldInfos[k].fieldType }
|
||||
|
||||
// Get returns the direct child of n identified by (k, idx).
|
||||
// n's type must match k.NodeType().
|
||||
// idx must be a valid slice index, or -1 for a non-slice.
|
||||
func (k Kind) Get(n ast.Node, idx int) ast.Node {
|
||||
if k.NodeType() != reflect.TypeOf(n) {
|
||||
panic(fmt.Sprintf("%v.Get(%T): invalid node type", k, n))
|
||||
}
|
||||
v := reflect.ValueOf(n).Elem().Field(fieldInfos[k].index)
|
||||
if idx != -1 {
|
||||
v = v.Index(idx) // asserts valid index
|
||||
} else {
|
||||
// (The type assertion below asserts that v is not a slice.)
|
||||
}
|
||||
return v.Interface().(ast.Node) // may be nil
|
||||
}
|
||||
|
||||
const (
|
||||
Invalid Kind = iota // for nodes at the root of the traversal
|
||||
|
||||
// Kinds are sorted alphabetically.
|
||||
// Numbering is not stable.
|
||||
// Each is named Type_Field, where Type is the
|
||||
// ast.Node struct type and Field is the name of the field
|
||||
|
||||
ArrayType_Elt
|
||||
ArrayType_Len
|
||||
AssignStmt_Lhs
|
||||
AssignStmt_Rhs
|
||||
BinaryExpr_X
|
||||
BinaryExpr_Y
|
||||
BlockStmt_List
|
||||
BranchStmt_Label
|
||||
CallExpr_Args
|
||||
CallExpr_Fun
|
||||
CaseClause_Body
|
||||
CaseClause_List
|
||||
ChanType_Value
|
||||
CommClause_Body
|
||||
CommClause_Comm
|
||||
CommentGroup_List
|
||||
CompositeLit_Elts
|
||||
CompositeLit_Type
|
||||
DeclStmt_Decl
|
||||
DeferStmt_Call
|
||||
Ellipsis_Elt
|
||||
ExprStmt_X
|
||||
FieldList_List
|
||||
Field_Comment
|
||||
Field_Doc
|
||||
Field_Names
|
||||
Field_Tag
|
||||
Field_Type
|
||||
File_Decls
|
||||
File_Doc
|
||||
File_Name
|
||||
ForStmt_Body
|
||||
ForStmt_Cond
|
||||
ForStmt_Init
|
||||
ForStmt_Post
|
||||
FuncDecl_Body
|
||||
FuncDecl_Doc
|
||||
FuncDecl_Name
|
||||
FuncDecl_Recv
|
||||
FuncDecl_Type
|
||||
FuncLit_Body
|
||||
FuncLit_Type
|
||||
FuncType_Params
|
||||
FuncType_Results
|
||||
FuncType_TypeParams
|
||||
GenDecl_Doc
|
||||
GenDecl_Specs
|
||||
GoStmt_Call
|
||||
IfStmt_Body
|
||||
IfStmt_Cond
|
||||
IfStmt_Else
|
||||
IfStmt_Init
|
||||
ImportSpec_Comment
|
||||
ImportSpec_Doc
|
||||
ImportSpec_Name
|
||||
ImportSpec_Path
|
||||
IncDecStmt_X
|
||||
IndexExpr_Index
|
||||
IndexExpr_X
|
||||
IndexListExpr_Indices
|
||||
IndexListExpr_X
|
||||
InterfaceType_Methods
|
||||
KeyValueExpr_Key
|
||||
KeyValueExpr_Value
|
||||
LabeledStmt_Label
|
||||
LabeledStmt_Stmt
|
||||
MapType_Key
|
||||
MapType_Value
|
||||
ParenExpr_X
|
||||
RangeStmt_Body
|
||||
RangeStmt_Key
|
||||
RangeStmt_Value
|
||||
RangeStmt_X
|
||||
ReturnStmt_Results
|
||||
SelectStmt_Body
|
||||
SelectorExpr_Sel
|
||||
SelectorExpr_X
|
||||
SendStmt_Chan
|
||||
SendStmt_Value
|
||||
SliceExpr_High
|
||||
SliceExpr_Low
|
||||
SliceExpr_Max
|
||||
SliceExpr_X
|
||||
StarExpr_X
|
||||
StructType_Fields
|
||||
SwitchStmt_Body
|
||||
SwitchStmt_Init
|
||||
SwitchStmt_Tag
|
||||
TypeAssertExpr_Type
|
||||
TypeAssertExpr_X
|
||||
TypeSpec_Comment
|
||||
TypeSpec_Doc
|
||||
TypeSpec_Name
|
||||
TypeSpec_Type
|
||||
TypeSpec_TypeParams
|
||||
TypeSwitchStmt_Assign
|
||||
TypeSwitchStmt_Body
|
||||
TypeSwitchStmt_Init
|
||||
UnaryExpr_X
|
||||
ValueSpec_Comment
|
||||
ValueSpec_Doc
|
||||
ValueSpec_Names
|
||||
ValueSpec_Type
|
||||
ValueSpec_Values
|
||||
|
||||
maxKind
|
||||
)
|
||||
|
||||
// Assert that the encoding fits in 7 bits,
|
||||
// as the inspector relies on this.
|
||||
// (We are currently at 104.)
|
||||
var _ = [1 << 7]struct{}{}[maxKind]
|
||||
|
||||
type fieldInfo struct {
|
||||
nodeType reflect.Type // pointer-to-struct type of ast.Node implementation
|
||||
name string
|
||||
index int
|
||||
fieldType reflect.Type
|
||||
}
|
||||
|
||||
func info[N ast.Node](fieldName string) fieldInfo {
|
||||
nodePtrType := reflect.TypeFor[N]()
|
||||
f, ok := nodePtrType.Elem().FieldByName(fieldName)
|
||||
if !ok {
|
||||
panic(fieldName)
|
||||
}
|
||||
return fieldInfo{nodePtrType, fieldName, f.Index[0], f.Type}
|
||||
}
|
||||
|
||||
var fieldInfos = [...]fieldInfo{
|
||||
Invalid: {},
|
||||
ArrayType_Elt: info[*ast.ArrayType]("Elt"),
|
||||
ArrayType_Len: info[*ast.ArrayType]("Len"),
|
||||
AssignStmt_Lhs: info[*ast.AssignStmt]("Lhs"),
|
||||
AssignStmt_Rhs: info[*ast.AssignStmt]("Rhs"),
|
||||
BinaryExpr_X: info[*ast.BinaryExpr]("X"),
|
||||
BinaryExpr_Y: info[*ast.BinaryExpr]("Y"),
|
||||
BlockStmt_List: info[*ast.BlockStmt]("List"),
|
||||
BranchStmt_Label: info[*ast.BranchStmt]("Label"),
|
||||
CallExpr_Args: info[*ast.CallExpr]("Args"),
|
||||
CallExpr_Fun: info[*ast.CallExpr]("Fun"),
|
||||
CaseClause_Body: info[*ast.CaseClause]("Body"),
|
||||
CaseClause_List: info[*ast.CaseClause]("List"),
|
||||
ChanType_Value: info[*ast.ChanType]("Value"),
|
||||
CommClause_Body: info[*ast.CommClause]("Body"),
|
||||
CommClause_Comm: info[*ast.CommClause]("Comm"),
|
||||
CommentGroup_List: info[*ast.CommentGroup]("List"),
|
||||
CompositeLit_Elts: info[*ast.CompositeLit]("Elts"),
|
||||
CompositeLit_Type: info[*ast.CompositeLit]("Type"),
|
||||
DeclStmt_Decl: info[*ast.DeclStmt]("Decl"),
|
||||
DeferStmt_Call: info[*ast.DeferStmt]("Call"),
|
||||
Ellipsis_Elt: info[*ast.Ellipsis]("Elt"),
|
||||
ExprStmt_X: info[*ast.ExprStmt]("X"),
|
||||
FieldList_List: info[*ast.FieldList]("List"),
|
||||
Field_Comment: info[*ast.Field]("Comment"),
|
||||
Field_Doc: info[*ast.Field]("Doc"),
|
||||
Field_Names: info[*ast.Field]("Names"),
|
||||
Field_Tag: info[*ast.Field]("Tag"),
|
||||
Field_Type: info[*ast.Field]("Type"),
|
||||
File_Decls: info[*ast.File]("Decls"),
|
||||
File_Doc: info[*ast.File]("Doc"),
|
||||
File_Name: info[*ast.File]("Name"),
|
||||
ForStmt_Body: info[*ast.ForStmt]("Body"),
|
||||
ForStmt_Cond: info[*ast.ForStmt]("Cond"),
|
||||
ForStmt_Init: info[*ast.ForStmt]("Init"),
|
||||
ForStmt_Post: info[*ast.ForStmt]("Post"),
|
||||
FuncDecl_Body: info[*ast.FuncDecl]("Body"),
|
||||
FuncDecl_Doc: info[*ast.FuncDecl]("Doc"),
|
||||
FuncDecl_Name: info[*ast.FuncDecl]("Name"),
|
||||
FuncDecl_Recv: info[*ast.FuncDecl]("Recv"),
|
||||
FuncDecl_Type: info[*ast.FuncDecl]("Type"),
|
||||
FuncLit_Body: info[*ast.FuncLit]("Body"),
|
||||
FuncLit_Type: info[*ast.FuncLit]("Type"),
|
||||
FuncType_Params: info[*ast.FuncType]("Params"),
|
||||
FuncType_Results: info[*ast.FuncType]("Results"),
|
||||
FuncType_TypeParams: info[*ast.FuncType]("TypeParams"),
|
||||
GenDecl_Doc: info[*ast.GenDecl]("Doc"),
|
||||
GenDecl_Specs: info[*ast.GenDecl]("Specs"),
|
||||
GoStmt_Call: info[*ast.GoStmt]("Call"),
|
||||
IfStmt_Body: info[*ast.IfStmt]("Body"),
|
||||
IfStmt_Cond: info[*ast.IfStmt]("Cond"),
|
||||
IfStmt_Else: info[*ast.IfStmt]("Else"),
|
||||
IfStmt_Init: info[*ast.IfStmt]("Init"),
|
||||
ImportSpec_Comment: info[*ast.ImportSpec]("Comment"),
|
||||
ImportSpec_Doc: info[*ast.ImportSpec]("Doc"),
|
||||
ImportSpec_Name: info[*ast.ImportSpec]("Name"),
|
||||
ImportSpec_Path: info[*ast.ImportSpec]("Path"),
|
||||
IncDecStmt_X: info[*ast.IncDecStmt]("X"),
|
||||
IndexExpr_Index: info[*ast.IndexExpr]("Index"),
|
||||
IndexExpr_X: info[*ast.IndexExpr]("X"),
|
||||
IndexListExpr_Indices: info[*ast.IndexListExpr]("Indices"),
|
||||
IndexListExpr_X: info[*ast.IndexListExpr]("X"),
|
||||
InterfaceType_Methods: info[*ast.InterfaceType]("Methods"),
|
||||
KeyValueExpr_Key: info[*ast.KeyValueExpr]("Key"),
|
||||
KeyValueExpr_Value: info[*ast.KeyValueExpr]("Value"),
|
||||
LabeledStmt_Label: info[*ast.LabeledStmt]("Label"),
|
||||
LabeledStmt_Stmt: info[*ast.LabeledStmt]("Stmt"),
|
||||
MapType_Key: info[*ast.MapType]("Key"),
|
||||
MapType_Value: info[*ast.MapType]("Value"),
|
||||
ParenExpr_X: info[*ast.ParenExpr]("X"),
|
||||
RangeStmt_Body: info[*ast.RangeStmt]("Body"),
|
||||
RangeStmt_Key: info[*ast.RangeStmt]("Key"),
|
||||
RangeStmt_Value: info[*ast.RangeStmt]("Value"),
|
||||
RangeStmt_X: info[*ast.RangeStmt]("X"),
|
||||
ReturnStmt_Results: info[*ast.ReturnStmt]("Results"),
|
||||
SelectStmt_Body: info[*ast.SelectStmt]("Body"),
|
||||
SelectorExpr_Sel: info[*ast.SelectorExpr]("Sel"),
|
||||
SelectorExpr_X: info[*ast.SelectorExpr]("X"),
|
||||
SendStmt_Chan: info[*ast.SendStmt]("Chan"),
|
||||
SendStmt_Value: info[*ast.SendStmt]("Value"),
|
||||
SliceExpr_High: info[*ast.SliceExpr]("High"),
|
||||
SliceExpr_Low: info[*ast.SliceExpr]("Low"),
|
||||
SliceExpr_Max: info[*ast.SliceExpr]("Max"),
|
||||
SliceExpr_X: info[*ast.SliceExpr]("X"),
|
||||
StarExpr_X: info[*ast.StarExpr]("X"),
|
||||
StructType_Fields: info[*ast.StructType]("Fields"),
|
||||
SwitchStmt_Body: info[*ast.SwitchStmt]("Body"),
|
||||
SwitchStmt_Init: info[*ast.SwitchStmt]("Init"),
|
||||
SwitchStmt_Tag: info[*ast.SwitchStmt]("Tag"),
|
||||
TypeAssertExpr_Type: info[*ast.TypeAssertExpr]("Type"),
|
||||
TypeAssertExpr_X: info[*ast.TypeAssertExpr]("X"),
|
||||
TypeSpec_Comment: info[*ast.TypeSpec]("Comment"),
|
||||
TypeSpec_Doc: info[*ast.TypeSpec]("Doc"),
|
||||
TypeSpec_Name: info[*ast.TypeSpec]("Name"),
|
||||
TypeSpec_Type: info[*ast.TypeSpec]("Type"),
|
||||
TypeSpec_TypeParams: info[*ast.TypeSpec]("TypeParams"),
|
||||
TypeSwitchStmt_Assign: info[*ast.TypeSwitchStmt]("Assign"),
|
||||
TypeSwitchStmt_Body: info[*ast.TypeSwitchStmt]("Body"),
|
||||
TypeSwitchStmt_Init: info[*ast.TypeSwitchStmt]("Init"),
|
||||
UnaryExpr_X: info[*ast.UnaryExpr]("X"),
|
||||
ValueSpec_Comment: info[*ast.ValueSpec]("Comment"),
|
||||
ValueSpec_Doc: info[*ast.ValueSpec]("Doc"),
|
||||
ValueSpec_Names: info[*ast.ValueSpec]("Names"),
|
||||
ValueSpec_Type: info[*ast.ValueSpec]("Type"),
|
||||
ValueSpec_Values: info[*ast.ValueSpec]("Values"),
|
||||
}
|
||||
502
vendor/golang.org/x/tools/go/ast/inspector/cursor.go
generated
vendored
Normal file
502
vendor/golang.org/x/tools/go/ast/inspector/cursor.go
generated
vendored
Normal file
@@ -0,0 +1,502 @@
|
||||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package inspector
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"iter"
|
||||
"reflect"
|
||||
|
||||
"golang.org/x/tools/go/ast/edge"
|
||||
)
|
||||
|
||||
// A Cursor represents an [ast.Node]. It is immutable.
|
||||
//
|
||||
// Two Cursors compare equal if they represent the same node.
|
||||
//
|
||||
// Call [Inspector.Root] to obtain a valid cursor for the virtual root
|
||||
// node of the traversal.
|
||||
//
|
||||
// Use the following methods to navigate efficiently around the tree:
|
||||
// - for ancestors, use [Cursor.Parent] and [Cursor.Enclosing];
|
||||
// - for children, use [Cursor.Child], [Cursor.Children],
|
||||
// [Cursor.FirstChild], and [Cursor.LastChild];
|
||||
// - for siblings, use [Cursor.PrevSibling] and [Cursor.NextSibling];
|
||||
// - for descendants, use [Cursor.FindByPos], [Cursor.FindNode],
|
||||
// [Cursor.Inspect], and [Cursor.Preorder].
|
||||
//
|
||||
// Use the [Cursor.ChildAt] and [Cursor.ParentEdge] methods for
|
||||
// information about the edges in a tree: which field (and slice
|
||||
// element) of the parent node holds the child.
|
||||
type Cursor struct {
|
||||
in *Inspector
|
||||
index int32 // index of push node; -1 for virtual root node
|
||||
}
|
||||
|
||||
// Root returns a cursor for the virtual root node,
|
||||
// whose children are the files provided to [New].
|
||||
//
|
||||
// Its [Cursor.Node] method return nil.
|
||||
func (in *Inspector) Root() Cursor {
|
||||
return Cursor{in, -1}
|
||||
}
|
||||
|
||||
// At returns the cursor at the specified index in the traversal,
|
||||
// which must have been obtained from [Cursor.Index] on a Cursor
|
||||
// belonging to the same Inspector (see [Cursor.Inspector]).
|
||||
func (in *Inspector) At(index int32) Cursor {
|
||||
if index < 0 {
|
||||
panic("negative index")
|
||||
}
|
||||
if int(index) >= len(in.events) {
|
||||
panic("index out of range for this inspector")
|
||||
}
|
||||
if in.events[index].index < index {
|
||||
panic("invalid index") // (a push, not a pop)
|
||||
}
|
||||
return Cursor{in, index}
|
||||
}
|
||||
|
||||
// Inspector returns the cursor's Inspector.
|
||||
func (c Cursor) Inspector() *Inspector { return c.in }
|
||||
|
||||
// Index returns the index of this cursor position within the package.
|
||||
//
|
||||
// Clients should not assume anything about the numeric Index value
|
||||
// except that it increases monotonically throughout the traversal.
|
||||
// It is provided for use with [At].
|
||||
//
|
||||
// Index must not be called on the Root node.
|
||||
func (c Cursor) Index() int32 {
|
||||
if c.index < 0 {
|
||||
panic("Index called on Root node")
|
||||
}
|
||||
return c.index
|
||||
}
|
||||
|
||||
// Node returns the node at the current cursor position,
|
||||
// or nil for the cursor returned by [Inspector.Root].
|
||||
func (c Cursor) Node() ast.Node {
|
||||
if c.index < 0 {
|
||||
return nil
|
||||
}
|
||||
return c.in.events[c.index].node
|
||||
}
|
||||
|
||||
// String returns information about the cursor's node, if any.
|
||||
func (c Cursor) String() string {
|
||||
if c.in == nil {
|
||||
return "(invalid)"
|
||||
}
|
||||
if c.index < 0 {
|
||||
return "(root)"
|
||||
}
|
||||
return reflect.TypeOf(c.Node()).String()
|
||||
}
|
||||
|
||||
// indices return the [start, end) half-open interval of event indices.
|
||||
func (c Cursor) indices() (int32, int32) {
|
||||
if c.index < 0 {
|
||||
return 0, int32(len(c.in.events)) // root: all events
|
||||
} else {
|
||||
return c.index, c.in.events[c.index].index + 1 // just one subtree
|
||||
}
|
||||
}
|
||||
|
||||
// Preorder returns an iterator over the nodes of the subtree
|
||||
// represented by c in depth-first order. Each node in the sequence is
|
||||
// represented by a Cursor that allows access to the Node, but may
|
||||
// also be used to start a new traversal, or to obtain the stack of
|
||||
// nodes enclosing the cursor.
|
||||
//
|
||||
// The traversal sequence is determined by [ast.Inspect]. The types
|
||||
// argument, if non-empty, enables type-based filtering of events. The
|
||||
// function f if is called only for nodes whose type matches an
|
||||
// element of the types slice.
|
||||
//
|
||||
// If you need control over descent into subtrees,
|
||||
// or need both pre- and post-order notifications, use [Cursor.Inspect]
|
||||
func (c Cursor) Preorder(types ...ast.Node) iter.Seq[Cursor] {
|
||||
mask := maskOf(types)
|
||||
|
||||
return func(yield func(Cursor) bool) {
|
||||
events := c.in.events
|
||||
|
||||
for i, limit := c.indices(); i < limit; {
|
||||
ev := events[i]
|
||||
if ev.index > i { // push?
|
||||
if ev.typ&mask != 0 && !yield(Cursor{c.in, i}) {
|
||||
break
|
||||
}
|
||||
pop := ev.index
|
||||
if events[pop].typ&mask == 0 {
|
||||
// Subtree does not contain types: skip.
|
||||
i = pop + 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Inspect visits the nodes of the subtree represented by c in
|
||||
// depth-first order. It calls f(n) for each node n before it
|
||||
// visits n's children. If f returns true, Inspect invokes f
|
||||
// recursively for each of the non-nil children of the node.
|
||||
//
|
||||
// Each node is represented by a Cursor that allows access to the
|
||||
// Node, but may also be used to start a new traversal, or to obtain
|
||||
// the stack of nodes enclosing the cursor.
|
||||
//
|
||||
// The complete traversal sequence is determined by [ast.Inspect].
|
||||
// The types argument, if non-empty, enables type-based filtering of
|
||||
// events. The function f if is called only for nodes whose type
|
||||
// matches an element of the types slice.
|
||||
func (c Cursor) Inspect(types []ast.Node, f func(c Cursor) (descend bool)) {
|
||||
mask := maskOf(types)
|
||||
events := c.in.events
|
||||
for i, limit := c.indices(); i < limit; {
|
||||
ev := events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
pop := ev.index
|
||||
if ev.typ&mask != 0 && !f(Cursor{c.in, i}) ||
|
||||
events[pop].typ&mask == 0 {
|
||||
// The user opted not to descend, or the
|
||||
// subtree does not contain types:
|
||||
// skip past the pop.
|
||||
i = pop + 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// Enclosing returns an iterator over the nodes enclosing the current
|
||||
// current node, starting with the Cursor itself.
|
||||
//
|
||||
// Enclosing must not be called on the Root node (whose [Cursor.Node] returns nil).
|
||||
//
|
||||
// The types argument, if non-empty, enables type-based filtering of
|
||||
// events: the sequence includes only enclosing nodes whose type
|
||||
// matches an element of the types slice.
|
||||
func (c Cursor) Enclosing(types ...ast.Node) iter.Seq[Cursor] {
|
||||
if c.index < 0 {
|
||||
panic("Cursor.Enclosing called on Root node")
|
||||
}
|
||||
|
||||
mask := maskOf(types)
|
||||
|
||||
return func(yield func(Cursor) bool) {
|
||||
events := c.in.events
|
||||
for i := c.index; i >= 0; i = events[i].parent {
|
||||
if events[i].typ&mask != 0 && !yield(Cursor{c.in, i}) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Parent returns the parent of the current node.
|
||||
//
|
||||
// Parent must not be called on the Root node (whose [Cursor.Node] returns nil).
|
||||
func (c Cursor) Parent() Cursor {
|
||||
if c.index < 0 {
|
||||
panic("Cursor.Parent called on Root node")
|
||||
}
|
||||
|
||||
return Cursor{c.in, c.in.events[c.index].parent}
|
||||
}
|
||||
|
||||
// ParentEdge returns the identity of the field in the parent node
|
||||
// that holds this cursor's node, and if it is a list, the index within it.
|
||||
//
|
||||
// For example, f(x, y) is a CallExpr whose three children are Idents.
|
||||
// f has edge kind [edge.CallExpr_Fun] and index -1.
|
||||
// x and y have kind [edge.CallExpr_Args] and indices 0 and 1, respectively.
|
||||
//
|
||||
// If called on a child of the Root node, it returns ([edge.Invalid], -1).
|
||||
//
|
||||
// ParentEdge must not be called on the Root node (whose [Cursor.Node] returns nil).
|
||||
func (c Cursor) ParentEdge() (edge.Kind, int) {
|
||||
if c.index < 0 {
|
||||
panic("Cursor.ParentEdge called on Root node")
|
||||
}
|
||||
events := c.in.events
|
||||
pop := events[c.index].index
|
||||
return unpackEdgeKindAndIndex(events[pop].parent)
|
||||
}
|
||||
|
||||
// ChildAt returns the cursor for the child of the
|
||||
// current node identified by its edge and index.
|
||||
// The index must be -1 if the edge.Kind is not a slice.
|
||||
// The indicated child node must exist.
|
||||
//
|
||||
// ChildAt must not be called on the Root node (whose [Cursor.Node] returns nil).
|
||||
//
|
||||
// Invariant: c.Parent().ChildAt(c.ParentEdge()) == c.
|
||||
func (c Cursor) ChildAt(k edge.Kind, idx int) Cursor {
|
||||
target := packEdgeKindAndIndex(k, idx)
|
||||
|
||||
// Unfortunately there's no shortcut to looping.
|
||||
events := c.in.events
|
||||
i := c.index + 1
|
||||
for {
|
||||
pop := events[i].index
|
||||
if pop < i {
|
||||
break
|
||||
}
|
||||
if events[pop].parent == target {
|
||||
return Cursor{c.in, i}
|
||||
}
|
||||
i = pop + 1
|
||||
}
|
||||
panic(fmt.Sprintf("ChildAt(%v, %d): no such child of %v", k, idx, c))
|
||||
}
|
||||
|
||||
// Child returns the cursor for n, which must be a direct child of c's Node.
|
||||
//
|
||||
// Child must not be called on the Root node (whose [Cursor.Node] returns nil).
|
||||
func (c Cursor) Child(n ast.Node) Cursor {
|
||||
if c.index < 0 {
|
||||
panic("Cursor.Child called on Root node")
|
||||
}
|
||||
|
||||
if false {
|
||||
// reference implementation
|
||||
for child := range c.Children() {
|
||||
if child.Node() == n {
|
||||
return child
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// optimized implementation
|
||||
events := c.in.events
|
||||
for i := c.index + 1; events[i].index > i; i = events[i].index + 1 {
|
||||
if events[i].node == n {
|
||||
return Cursor{c.in, i}
|
||||
}
|
||||
}
|
||||
}
|
||||
panic(fmt.Sprintf("Child(%T): not a child of %v", n, c))
|
||||
}
|
||||
|
||||
// NextSibling returns the cursor for the next sibling node in the same list
|
||||
// (for example, of files, decls, specs, statements, fields, or expressions) as
|
||||
// the current node. It returns (zero, false) if the node is the last node in
|
||||
// the list, or is not part of a list.
|
||||
//
|
||||
// NextSibling must not be called on the Root node.
|
||||
//
|
||||
// See note at [Cursor.Children].
|
||||
func (c Cursor) NextSibling() (Cursor, bool) {
|
||||
if c.index < 0 {
|
||||
panic("Cursor.NextSibling called on Root node")
|
||||
}
|
||||
|
||||
events := c.in.events
|
||||
i := events[c.index].index + 1 // after corresponding pop
|
||||
if i < int32(len(events)) {
|
||||
if events[i].index > i { // push?
|
||||
return Cursor{c.in, i}, true
|
||||
}
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
|
||||
// PrevSibling returns the cursor for the previous sibling node in the
|
||||
// same list (for example, of files, decls, specs, statements, fields,
|
||||
// or expressions) as the current node. It returns zero if the node is
|
||||
// the first node in the list, or is not part of a list.
|
||||
//
|
||||
// It must not be called on the Root node.
|
||||
//
|
||||
// See note at [Cursor.Children].
|
||||
func (c Cursor) PrevSibling() (Cursor, bool) {
|
||||
if c.index < 0 {
|
||||
panic("Cursor.PrevSibling called on Root node")
|
||||
}
|
||||
|
||||
events := c.in.events
|
||||
i := c.index - 1
|
||||
if i >= 0 {
|
||||
if j := events[i].index; j < i { // pop?
|
||||
return Cursor{c.in, j}, true
|
||||
}
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
|
||||
// FirstChild returns the first direct child of the current node,
|
||||
// or zero if it has no children.
|
||||
func (c Cursor) FirstChild() (Cursor, bool) {
|
||||
events := c.in.events
|
||||
i := c.index + 1 // i=0 if c is root
|
||||
if i < int32(len(events)) && events[i].index > i { // push?
|
||||
return Cursor{c.in, i}, true
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
|
||||
// LastChild returns the last direct child of the current node,
|
||||
// or zero if it has no children.
|
||||
func (c Cursor) LastChild() (Cursor, bool) {
|
||||
events := c.in.events
|
||||
if c.index < 0 { // root?
|
||||
if len(events) > 0 {
|
||||
// return push of final event (a pop)
|
||||
return Cursor{c.in, events[len(events)-1].index}, true
|
||||
}
|
||||
} else {
|
||||
j := events[c.index].index - 1 // before corresponding pop
|
||||
// Inv: j == c.index if c has no children
|
||||
// or j is last child's pop.
|
||||
if j > c.index { // c has children
|
||||
return Cursor{c.in, events[j].index}, true
|
||||
}
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
|
||||
// Children returns an iterator over the direct children of the
|
||||
// current node, if any.
|
||||
//
|
||||
// When using Children, NextChild, and PrevChild, bear in mind that a
|
||||
// Node's children may come from different fields, some of which may
|
||||
// be lists of nodes without a distinguished intervening container
|
||||
// such as [ast.BlockStmt].
|
||||
//
|
||||
// For example, [ast.CaseClause] has a field List of expressions and a
|
||||
// field Body of statements, so the children of a CaseClause are a mix
|
||||
// of expressions and statements. Other nodes that have "uncontained"
|
||||
// list fields include:
|
||||
//
|
||||
// - [ast.ValueSpec] (Names, Values)
|
||||
// - [ast.CompositeLit] (Type, Elts)
|
||||
// - [ast.IndexListExpr] (X, Indices)
|
||||
// - [ast.CallExpr] (Fun, Args)
|
||||
// - [ast.AssignStmt] (Lhs, Rhs)
|
||||
//
|
||||
// So, do not assume that the previous sibling of an ast.Stmt is also
|
||||
// an ast.Stmt, or if it is, that they are executed sequentially,
|
||||
// unless you have established that, say, its parent is a BlockStmt
|
||||
// or its [Cursor.ParentEdge] is [edge.BlockStmt_List].
|
||||
// For example, given "for S1; ; S2 {}", the predecessor of S2 is S1,
|
||||
// even though they are not executed in sequence.
|
||||
func (c Cursor) Children() iter.Seq[Cursor] {
|
||||
return func(yield func(Cursor) bool) {
|
||||
c, ok := c.FirstChild()
|
||||
for ok && yield(c) {
|
||||
c, ok = c.NextSibling()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Contains reports whether c contains or is equal to c2.
|
||||
//
|
||||
// Both Cursors must belong to the same [Inspector];
|
||||
// neither may be its Root node.
|
||||
func (c Cursor) Contains(c2 Cursor) bool {
|
||||
if c.in != c2.in {
|
||||
panic("different inspectors")
|
||||
}
|
||||
events := c.in.events
|
||||
return c.index <= c2.index && events[c2.index].index <= events[c.index].index
|
||||
}
|
||||
|
||||
// FindNode returns the cursor for node n if it belongs to the subtree
|
||||
// rooted at c. It returns zero if n is not found.
|
||||
func (c Cursor) FindNode(n ast.Node) (Cursor, bool) {
|
||||
|
||||
// FindNode is equivalent to this code,
|
||||
// but more convenient and 15-20% faster:
|
||||
if false {
|
||||
for candidate := range c.Preorder(n) {
|
||||
if candidate.Node() == n {
|
||||
return candidate, true
|
||||
}
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
|
||||
// TODO(adonovan): opt: should we assume Node.Pos is accurate
|
||||
// and combine type-based filtering with position filtering
|
||||
// like FindByPos?
|
||||
|
||||
mask := maskOf([]ast.Node{n})
|
||||
events := c.in.events
|
||||
|
||||
for i, limit := c.indices(); i < limit; i++ {
|
||||
ev := events[i]
|
||||
if ev.index > i { // push?
|
||||
if ev.typ&mask != 0 && ev.node == n {
|
||||
return Cursor{c.in, i}, true
|
||||
}
|
||||
pop := ev.index
|
||||
if events[pop].typ&mask == 0 {
|
||||
// Subtree does not contain type of n: skip.
|
||||
i = pop
|
||||
}
|
||||
}
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
|
||||
// FindByPos returns the cursor for the innermost node n in the tree
|
||||
// rooted at c such that n.Pos() <= start && end <= n.End().
|
||||
// (For an *ast.File, it uses the bounds n.FileStart-n.FileEnd.)
|
||||
//
|
||||
// It returns zero if none is found.
|
||||
// Precondition: start <= end.
|
||||
//
|
||||
// See also [astutil.PathEnclosingInterval], which
|
||||
// tolerates adjoining whitespace.
|
||||
func (c Cursor) FindByPos(start, end token.Pos) (Cursor, bool) {
|
||||
if end < start {
|
||||
panic("end < start")
|
||||
}
|
||||
events := c.in.events
|
||||
|
||||
// This algorithm could be implemented using c.Inspect,
|
||||
// but it is about 2.5x slower.
|
||||
|
||||
best := int32(-1) // push index of latest (=innermost) node containing range
|
||||
for i, limit := c.indices(); i < limit; i++ {
|
||||
ev := events[i]
|
||||
if ev.index > i { // push?
|
||||
n := ev.node
|
||||
var nodeEnd token.Pos
|
||||
if file, ok := n.(*ast.File); ok {
|
||||
nodeEnd = file.FileEnd
|
||||
// Note: files may be out of Pos order.
|
||||
if file.FileStart > start {
|
||||
i = ev.index // disjoint, after; skip to next file
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
nodeEnd = n.End()
|
||||
if n.Pos() > start {
|
||||
break // disjoint, after; stop
|
||||
}
|
||||
}
|
||||
// Inv: node.{Pos,FileStart} <= start
|
||||
if end <= nodeEnd {
|
||||
// node fully contains target range
|
||||
best = i
|
||||
} else if nodeEnd < start {
|
||||
i = ev.index // disjoint, before; skip forward
|
||||
}
|
||||
}
|
||||
}
|
||||
if best >= 0 {
|
||||
return Cursor{c.in, best}, true
|
||||
}
|
||||
return Cursor{}, false
|
||||
}
|
||||
311
vendor/golang.org/x/tools/go/ast/inspector/inspector.go
generated
vendored
Normal file
311
vendor/golang.org/x/tools/go/ast/inspector/inspector.go
generated
vendored
Normal file
@@ -0,0 +1,311 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package inspector provides helper functions for traversal over the
|
||||
// syntax trees of a package, including node filtering by type, and
|
||||
// materialization of the traversal stack.
|
||||
//
|
||||
// During construction, the inspector does a complete traversal and
|
||||
// builds a list of push/pop events and their node type. Subsequent
|
||||
// method calls that request a traversal scan this list, rather than walk
|
||||
// the AST, and perform type filtering using efficient bit sets.
|
||||
// This representation is sometimes called a "balanced parenthesis tree."
|
||||
//
|
||||
// Experiments suggest the inspector's traversals are about 2.5x faster
|
||||
// than [ast.Inspect], but it may take around 5 traversals for this
|
||||
// benefit to amortize the inspector's construction cost.
|
||||
// If efficiency is the primary concern, do not use Inspector for
|
||||
// one-off traversals.
|
||||
//
|
||||
// The [Cursor] type provides a more flexible API for efficient
|
||||
// navigation of syntax trees in all four "cardinal directions". For
|
||||
// example, traversals may be nested, so you can find each node of
|
||||
// type A and then search within it for nodes of type B. Or you can
|
||||
// traverse from a node to its immediate neighbors: its parent, its
|
||||
// previous and next sibling, or its first and last child. We
|
||||
// recommend using methods of Cursor in preference to Inspector where
|
||||
// possible.
|
||||
package inspector
|
||||
|
||||
// There are four orthogonal features in a traversal:
|
||||
// 1 type filtering
|
||||
// 2 pruning
|
||||
// 3 postorder calls to f
|
||||
// 4 stack
|
||||
// Rather than offer all of them in the API,
|
||||
// only a few combinations are exposed:
|
||||
// - Preorder is the fastest and has fewest features,
|
||||
// but is the most commonly needed traversal.
|
||||
// - Nodes and WithStack both provide pruning and postorder calls,
|
||||
// even though few clients need it, because supporting two versions
|
||||
// is not justified.
|
||||
// More combinations could be supported by expressing them as
|
||||
// wrappers around a more generic traversal, but this was measured
|
||||
// and found to degrade performance significantly (30%).
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
|
||||
"golang.org/x/tools/go/ast/edge"
|
||||
)
|
||||
|
||||
// An Inspector provides methods for inspecting
|
||||
// (traversing) the syntax trees of a package.
|
||||
type Inspector struct {
|
||||
events []event
|
||||
}
|
||||
|
||||
func packEdgeKindAndIndex(ek edge.Kind, index int) int32 {
|
||||
return int32(uint32(index+1)<<7 | uint32(ek))
|
||||
}
|
||||
|
||||
// unpackEdgeKindAndIndex unpacks the edge kind and edge index (within
|
||||
// an []ast.Node slice) from the parent field of a pop event.
|
||||
func unpackEdgeKindAndIndex(x int32) (edge.Kind, int) {
|
||||
// The "parent" field of a pop node holds the
|
||||
// edge Kind in the lower 7 bits and the index+1
|
||||
// in the upper 25.
|
||||
return edge.Kind(x & 0x7f), int(x>>7) - 1
|
||||
}
|
||||
|
||||
// New returns an Inspector for the specified syntax trees.
|
||||
func New(files []*ast.File) *Inspector {
|
||||
return &Inspector{traverse(files)}
|
||||
}
|
||||
|
||||
// An event represents a push or a pop
|
||||
// of an ast.Node during a traversal.
|
||||
type event struct {
|
||||
node ast.Node
|
||||
typ uint64 // typeOf(node) on push event, or union of typ strictly between push and pop events on pop events
|
||||
index int32 // index of corresponding push or pop event
|
||||
parent int32 // index of parent's push node (push nodes only), or packed edge kind/index (pop nodes only)
|
||||
}
|
||||
|
||||
// TODO: Experiment with storing only the second word of event.node (unsafe.Pointer).
|
||||
// Type can be recovered from the sole bit in typ.
|
||||
// [Tried this, wasn't faster. --adonovan]
|
||||
|
||||
// Preorder visits all the nodes of the files supplied to New in
|
||||
// depth-first order. It calls f(n) for each node n before it visits
|
||||
// n's children.
|
||||
//
|
||||
// The complete traversal sequence is determined by [ast.Inspect].
|
||||
// The types argument, if non-empty, enables type-based filtering of
|
||||
// events. The function f is called only for nodes whose type
|
||||
// matches an element of the types slice.
|
||||
//
|
||||
// The [Cursor.Preorder] method provides a richer alternative interface.
|
||||
// Example:
|
||||
//
|
||||
// for c := range in.Root().Preorder(types) { ... }
|
||||
func (in *Inspector) Preorder(types []ast.Node, f func(ast.Node)) {
|
||||
// Because it avoids postorder calls to f, and the pruning
|
||||
// check, Preorder is almost twice as fast as Nodes. The two
|
||||
// features seem to contribute similar slowdowns (~1.4x each).
|
||||
|
||||
// This function is equivalent to the PreorderSeq call below,
|
||||
// but to avoid the additional dynamic call (which adds 13-35%
|
||||
// to the benchmarks), we expand it out.
|
||||
//
|
||||
// in.PreorderSeq(types...)(func(n ast.Node) bool {
|
||||
// f(n)
|
||||
// return true
|
||||
// })
|
||||
|
||||
mask := maskOf(types)
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
if ev.typ&mask != 0 {
|
||||
f(ev.node)
|
||||
}
|
||||
pop := ev.index
|
||||
if in.events[pop].typ&mask == 0 {
|
||||
// Subtrees do not contain types: skip them and pop.
|
||||
i = pop + 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// Nodes visits the nodes of the files supplied to New in depth-first
|
||||
// order. It calls f(n, true) for each node n before it visits n's
|
||||
// children. If f returns true, Nodes invokes f recursively for each
|
||||
// of the non-nil children of the node, followed by a call of
|
||||
// f(n, false).
|
||||
//
|
||||
// The complete traversal sequence is determined by [ast.Inspect].
|
||||
// The types argument, if non-empty, enables type-based filtering of
|
||||
// events. The function f if is called only for nodes whose type
|
||||
// matches an element of the types slice.
|
||||
//
|
||||
// The [Cursor.Inspect] method provides a richer alternative interface.
|
||||
// Example:
|
||||
//
|
||||
// in.Root().Inspect(types, func(c Cursor) bool {
|
||||
// ...
|
||||
// return true
|
||||
// }
|
||||
func (in *Inspector) Nodes(types []ast.Node, f func(n ast.Node, push bool) (proceed bool)) {
|
||||
mask := maskOf(types)
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
pop := ev.index
|
||||
if ev.typ&mask != 0 {
|
||||
if !f(ev.node, true) {
|
||||
i = pop + 1 // jump to corresponding pop + 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
if in.events[pop].typ&mask == 0 {
|
||||
// Subtrees do not contain types: skip them.
|
||||
i = pop
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
// pop
|
||||
push := ev.index
|
||||
if in.events[push].typ&mask != 0 {
|
||||
f(ev.node, false)
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// WithStack visits nodes in a similar manner to Nodes, but it
|
||||
// supplies each call to f an additional argument, the current
|
||||
// traversal stack. The stack's first element is the outermost node,
|
||||
// an *ast.File; its last is the innermost, n.
|
||||
//
|
||||
// The [Cursor.Inspect] method provides a richer alternative interface.
|
||||
// Example:
|
||||
//
|
||||
// in.Root().Inspect(types, func(c Cursor) bool {
|
||||
// stack := slices.Collect(c.Enclosing())
|
||||
// ...
|
||||
// return true
|
||||
// })
|
||||
func (in *Inspector) WithStack(types []ast.Node, f func(n ast.Node, push bool, stack []ast.Node) (proceed bool)) {
|
||||
mask := maskOf(types)
|
||||
var stack []ast.Node
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
pop := ev.index
|
||||
stack = append(stack, ev.node)
|
||||
if ev.typ&mask != 0 {
|
||||
if !f(ev.node, true, stack) {
|
||||
i = pop + 1
|
||||
stack = stack[:len(stack)-1]
|
||||
continue
|
||||
}
|
||||
}
|
||||
if in.events[pop].typ&mask == 0 {
|
||||
// Subtrees does not contain types: skip them.
|
||||
i = pop
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
// pop
|
||||
push := ev.index
|
||||
if in.events[push].typ&mask != 0 {
|
||||
f(ev.node, false, stack)
|
||||
}
|
||||
stack = stack[:len(stack)-1]
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
|
||||
// traverse builds the table of events representing a traversal.
|
||||
func traverse(files []*ast.File) []event {
|
||||
// Preallocate approximate number of events
|
||||
// based on source file extent of the declarations.
|
||||
// (We use End-Pos not FileStart-FileEnd to neglect
|
||||
// the effect of long doc comments.)
|
||||
// This makes traverse faster by 4x (!).
|
||||
var extent int
|
||||
for _, f := range files {
|
||||
extent += int(f.End() - f.Pos())
|
||||
}
|
||||
// This estimate is based on the net/http package.
|
||||
capacity := min(extent*33/100, 1e6) // impose some reasonable maximum (1M)
|
||||
|
||||
v := &visitor{
|
||||
events: make([]event, 0, capacity),
|
||||
stack: []item{{index: -1}}, // include an extra event so file nodes have a parent
|
||||
}
|
||||
for _, file := range files {
|
||||
walk(v, edge.Invalid, -1, file)
|
||||
}
|
||||
return v.events
|
||||
}
|
||||
|
||||
type visitor struct {
|
||||
events []event
|
||||
stack []item
|
||||
}
|
||||
|
||||
type item struct {
|
||||
index int32 // index of current node's push event
|
||||
parentIndex int32 // index of parent node's push event
|
||||
typAccum uint64 // accumulated type bits of current node's descendants
|
||||
edgeKindAndIndex int32 // edge.Kind and index, bit packed
|
||||
}
|
||||
|
||||
func (v *visitor) push(ek edge.Kind, eindex int, node ast.Node) {
|
||||
var (
|
||||
index = int32(len(v.events))
|
||||
parentIndex = v.stack[len(v.stack)-1].index
|
||||
)
|
||||
v.events = append(v.events, event{
|
||||
node: node,
|
||||
parent: parentIndex,
|
||||
typ: typeOf(node),
|
||||
index: 0, // (pop index is set later by visitor.pop)
|
||||
})
|
||||
v.stack = append(v.stack, item{
|
||||
index: index,
|
||||
parentIndex: parentIndex,
|
||||
edgeKindAndIndex: packEdgeKindAndIndex(ek, eindex),
|
||||
})
|
||||
|
||||
// 2B nodes ought to be enough for anyone!
|
||||
if int32(len(v.events)) < 0 {
|
||||
panic("event index exceeded int32")
|
||||
}
|
||||
|
||||
// 32M elements in an []ast.Node ought to be enough for anyone!
|
||||
if ek2, eindex2 := unpackEdgeKindAndIndex(packEdgeKindAndIndex(ek, eindex)); ek2 != ek || eindex2 != eindex {
|
||||
panic("Node slice index exceeded uint25")
|
||||
}
|
||||
}
|
||||
|
||||
func (v *visitor) pop(node ast.Node) {
|
||||
top := len(v.stack) - 1
|
||||
current := v.stack[top]
|
||||
|
||||
push := &v.events[current.index]
|
||||
parent := &v.stack[top-1]
|
||||
|
||||
push.index = int32(len(v.events)) // make push event refer to pop
|
||||
parent.typAccum |= current.typAccum | push.typ // accumulate type bits into parent
|
||||
|
||||
v.stack = v.stack[:top]
|
||||
|
||||
v.events = append(v.events, event{
|
||||
node: node,
|
||||
typ: current.typAccum,
|
||||
index: current.index,
|
||||
parent: current.edgeKindAndIndex, // see [unpackEdgeKindAndIndex]
|
||||
})
|
||||
}
|
||||
85
vendor/golang.org/x/tools/go/ast/inspector/iter.go
generated
vendored
Normal file
85
vendor/golang.org/x/tools/go/ast/inspector/iter.go
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
// Copyright 2024 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
//go:build go1.23
|
||||
|
||||
package inspector
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"iter"
|
||||
)
|
||||
|
||||
// PreorderSeq returns an iterator that visits all the
|
||||
// nodes of the files supplied to New in depth-first order.
|
||||
// It visits each node n before n's children.
|
||||
// The complete traversal sequence is determined by ast.Inspect.
|
||||
//
|
||||
// The types argument, if non-empty, enables type-based
|
||||
// filtering of events: only nodes whose type matches an
|
||||
// element of the types slice are included in the sequence.
|
||||
func (in *Inspector) PreorderSeq(types ...ast.Node) iter.Seq[ast.Node] {
|
||||
|
||||
// This implementation is identical to Preorder,
|
||||
// except that it supports breaking out of the loop.
|
||||
|
||||
return func(yield func(ast.Node) bool) {
|
||||
mask := maskOf(types)
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
if ev.typ&mask != 0 {
|
||||
if !yield(ev.node) {
|
||||
break
|
||||
}
|
||||
}
|
||||
pop := ev.index
|
||||
if in.events[pop].typ&mask == 0 {
|
||||
// Subtrees do not contain types: skip them and pop.
|
||||
i = pop + 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All[N] returns an iterator over all the nodes of type N.
|
||||
// N must be a pointer-to-struct type that implements ast.Node.
|
||||
//
|
||||
// Example:
|
||||
//
|
||||
// for call := range All[*ast.CallExpr](in) { ... }
|
||||
func All[N interface {
|
||||
*S
|
||||
ast.Node
|
||||
}, S any](in *Inspector) iter.Seq[N] {
|
||||
|
||||
// To avoid additional dynamic call overheads,
|
||||
// we duplicate rather than call the logic of PreorderSeq.
|
||||
|
||||
mask := typeOf((N)(nil))
|
||||
return func(yield func(N) bool) {
|
||||
for i := int32(0); i < int32(len(in.events)); {
|
||||
ev := in.events[i]
|
||||
if ev.index > i {
|
||||
// push
|
||||
if ev.typ&mask != 0 {
|
||||
if !yield(ev.node.(N)) {
|
||||
break
|
||||
}
|
||||
}
|
||||
pop := ev.index
|
||||
if in.events[pop].typ&mask == 0 {
|
||||
// Subtrees do not contain types: skip them and pop.
|
||||
i = pop + 1
|
||||
continue
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
}
|
||||
227
vendor/golang.org/x/tools/go/ast/inspector/typeof.go
generated
vendored
Normal file
227
vendor/golang.org/x/tools/go/ast/inspector/typeof.go
generated
vendored
Normal file
@@ -0,0 +1,227 @@
|
||||
// Copyright 2018 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package inspector
|
||||
|
||||
// This file defines func typeOf(ast.Node) uint64.
|
||||
//
|
||||
// The initial map-based implementation was too slow;
|
||||
// see https://go-review.googlesource.com/c/tools/+/135655/1/go/ast/inspector/inspector.go#196
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"math"
|
||||
)
|
||||
|
||||
const (
|
||||
nArrayType = iota
|
||||
nAssignStmt
|
||||
nBadDecl
|
||||
nBadExpr
|
||||
nBadStmt
|
||||
nBasicLit
|
||||
nBinaryExpr
|
||||
nBlockStmt
|
||||
nBranchStmt
|
||||
nCallExpr
|
||||
nCaseClause
|
||||
nChanType
|
||||
nCommClause
|
||||
nComment
|
||||
nCommentGroup
|
||||
nCompositeLit
|
||||
nDeclStmt
|
||||
nDeferStmt
|
||||
nEllipsis
|
||||
nEmptyStmt
|
||||
nExprStmt
|
||||
nField
|
||||
nFieldList
|
||||
nFile
|
||||
nForStmt
|
||||
nFuncDecl
|
||||
nFuncLit
|
||||
nFuncType
|
||||
nGenDecl
|
||||
nGoStmt
|
||||
nIdent
|
||||
nIfStmt
|
||||
nImportSpec
|
||||
nIncDecStmt
|
||||
nIndexExpr
|
||||
nIndexListExpr
|
||||
nInterfaceType
|
||||
nKeyValueExpr
|
||||
nLabeledStmt
|
||||
nMapType
|
||||
nPackage
|
||||
nParenExpr
|
||||
nRangeStmt
|
||||
nReturnStmt
|
||||
nSelectStmt
|
||||
nSelectorExpr
|
||||
nSendStmt
|
||||
nSliceExpr
|
||||
nStarExpr
|
||||
nStructType
|
||||
nSwitchStmt
|
||||
nTypeAssertExpr
|
||||
nTypeSpec
|
||||
nTypeSwitchStmt
|
||||
nUnaryExpr
|
||||
nValueSpec
|
||||
)
|
||||
|
||||
// typeOf returns a distinct single-bit value that represents the type of n.
|
||||
//
|
||||
// Various implementations were benchmarked with BenchmarkNewInspector:
|
||||
//
|
||||
// GOGC=off
|
||||
// - type switch 4.9-5.5ms 2.1ms
|
||||
// - binary search over a sorted list of types 5.5-5.9ms 2.5ms
|
||||
// - linear scan, frequency-ordered list 5.9-6.1ms 2.7ms
|
||||
// - linear scan, unordered list 6.4ms 2.7ms
|
||||
// - hash table 6.5ms 3.1ms
|
||||
//
|
||||
// A perfect hash seemed like overkill.
|
||||
//
|
||||
// The compiler's switch statement is the clear winner
|
||||
// as it produces a binary tree in code,
|
||||
// with constant conditions and good branch prediction.
|
||||
// (Sadly it is the most verbose in source code.)
|
||||
// Binary search suffered from poor branch prediction.
|
||||
func typeOf(n ast.Node) uint64 {
|
||||
// Fast path: nearly half of all nodes are identifiers.
|
||||
if _, ok := n.(*ast.Ident); ok {
|
||||
return 1 << nIdent
|
||||
}
|
||||
|
||||
// These cases include all nodes encountered by ast.Inspect.
|
||||
switch n.(type) {
|
||||
case *ast.ArrayType:
|
||||
return 1 << nArrayType
|
||||
case *ast.AssignStmt:
|
||||
return 1 << nAssignStmt
|
||||
case *ast.BadDecl:
|
||||
return 1 << nBadDecl
|
||||
case *ast.BadExpr:
|
||||
return 1 << nBadExpr
|
||||
case *ast.BadStmt:
|
||||
return 1 << nBadStmt
|
||||
case *ast.BasicLit:
|
||||
return 1 << nBasicLit
|
||||
case *ast.BinaryExpr:
|
||||
return 1 << nBinaryExpr
|
||||
case *ast.BlockStmt:
|
||||
return 1 << nBlockStmt
|
||||
case *ast.BranchStmt:
|
||||
return 1 << nBranchStmt
|
||||
case *ast.CallExpr:
|
||||
return 1 << nCallExpr
|
||||
case *ast.CaseClause:
|
||||
return 1 << nCaseClause
|
||||
case *ast.ChanType:
|
||||
return 1 << nChanType
|
||||
case *ast.CommClause:
|
||||
return 1 << nCommClause
|
||||
case *ast.Comment:
|
||||
return 1 << nComment
|
||||
case *ast.CommentGroup:
|
||||
return 1 << nCommentGroup
|
||||
case *ast.CompositeLit:
|
||||
return 1 << nCompositeLit
|
||||
case *ast.DeclStmt:
|
||||
return 1 << nDeclStmt
|
||||
case *ast.DeferStmt:
|
||||
return 1 << nDeferStmt
|
||||
case *ast.Ellipsis:
|
||||
return 1 << nEllipsis
|
||||
case *ast.EmptyStmt:
|
||||
return 1 << nEmptyStmt
|
||||
case *ast.ExprStmt:
|
||||
return 1 << nExprStmt
|
||||
case *ast.Field:
|
||||
return 1 << nField
|
||||
case *ast.FieldList:
|
||||
return 1 << nFieldList
|
||||
case *ast.File:
|
||||
return 1 << nFile
|
||||
case *ast.ForStmt:
|
||||
return 1 << nForStmt
|
||||
case *ast.FuncDecl:
|
||||
return 1 << nFuncDecl
|
||||
case *ast.FuncLit:
|
||||
return 1 << nFuncLit
|
||||
case *ast.FuncType:
|
||||
return 1 << nFuncType
|
||||
case *ast.GenDecl:
|
||||
return 1 << nGenDecl
|
||||
case *ast.GoStmt:
|
||||
return 1 << nGoStmt
|
||||
case *ast.Ident:
|
||||
return 1 << nIdent
|
||||
case *ast.IfStmt:
|
||||
return 1 << nIfStmt
|
||||
case *ast.ImportSpec:
|
||||
return 1 << nImportSpec
|
||||
case *ast.IncDecStmt:
|
||||
return 1 << nIncDecStmt
|
||||
case *ast.IndexExpr:
|
||||
return 1 << nIndexExpr
|
||||
case *ast.IndexListExpr:
|
||||
return 1 << nIndexListExpr
|
||||
case *ast.InterfaceType:
|
||||
return 1 << nInterfaceType
|
||||
case *ast.KeyValueExpr:
|
||||
return 1 << nKeyValueExpr
|
||||
case *ast.LabeledStmt:
|
||||
return 1 << nLabeledStmt
|
||||
case *ast.MapType:
|
||||
return 1 << nMapType
|
||||
case *ast.Package:
|
||||
return 1 << nPackage
|
||||
case *ast.ParenExpr:
|
||||
return 1 << nParenExpr
|
||||
case *ast.RangeStmt:
|
||||
return 1 << nRangeStmt
|
||||
case *ast.ReturnStmt:
|
||||
return 1 << nReturnStmt
|
||||
case *ast.SelectStmt:
|
||||
return 1 << nSelectStmt
|
||||
case *ast.SelectorExpr:
|
||||
return 1 << nSelectorExpr
|
||||
case *ast.SendStmt:
|
||||
return 1 << nSendStmt
|
||||
case *ast.SliceExpr:
|
||||
return 1 << nSliceExpr
|
||||
case *ast.StarExpr:
|
||||
return 1 << nStarExpr
|
||||
case *ast.StructType:
|
||||
return 1 << nStructType
|
||||
case *ast.SwitchStmt:
|
||||
return 1 << nSwitchStmt
|
||||
case *ast.TypeAssertExpr:
|
||||
return 1 << nTypeAssertExpr
|
||||
case *ast.TypeSpec:
|
||||
return 1 << nTypeSpec
|
||||
case *ast.TypeSwitchStmt:
|
||||
return 1 << nTypeSwitchStmt
|
||||
case *ast.UnaryExpr:
|
||||
return 1 << nUnaryExpr
|
||||
case *ast.ValueSpec:
|
||||
return 1 << nValueSpec
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func maskOf(nodes []ast.Node) uint64 {
|
||||
if len(nodes) == 0 {
|
||||
return math.MaxUint64 // match all node types
|
||||
}
|
||||
var mask uint64
|
||||
for _, n := range nodes {
|
||||
mask |= typeOf(n)
|
||||
}
|
||||
return mask
|
||||
}
|
||||
341
vendor/golang.org/x/tools/go/ast/inspector/walk.go
generated
vendored
Normal file
341
vendor/golang.org/x/tools/go/ast/inspector/walk.go
generated
vendored
Normal file
@@ -0,0 +1,341 @@
|
||||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package inspector
|
||||
|
||||
// This file is a fork of ast.Inspect to reduce unnecessary dynamic
|
||||
// calls and to gather edge information.
|
||||
//
|
||||
// Consistency with the original is ensured by TestInspectAllNodes.
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go/ast"
|
||||
|
||||
"golang.org/x/tools/go/ast/edge"
|
||||
)
|
||||
|
||||
func walkList[N ast.Node](v *visitor, ek edge.Kind, list []N) {
|
||||
for i, node := range list {
|
||||
walk(v, ek, i, node)
|
||||
}
|
||||
}
|
||||
|
||||
func walk(v *visitor, ek edge.Kind, index int, node ast.Node) {
|
||||
v.push(ek, index, node)
|
||||
|
||||
// walk children
|
||||
// (the order of the cases matches the order
|
||||
// of the corresponding node types in ast.go)
|
||||
switch n := node.(type) {
|
||||
// Comments and fields
|
||||
case *ast.Comment:
|
||||
// nothing to do
|
||||
|
||||
case *ast.CommentGroup:
|
||||
walkList(v, edge.CommentGroup_List, n.List)
|
||||
|
||||
case *ast.Field:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.Field_Doc, -1, n.Doc)
|
||||
}
|
||||
walkList(v, edge.Field_Names, n.Names)
|
||||
if n.Type != nil {
|
||||
walk(v, edge.Field_Type, -1, n.Type)
|
||||
}
|
||||
if n.Tag != nil {
|
||||
walk(v, edge.Field_Tag, -1, n.Tag)
|
||||
}
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.Field_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.FieldList:
|
||||
walkList(v, edge.FieldList_List, n.List)
|
||||
|
||||
// Expressions
|
||||
case *ast.BadExpr, *ast.Ident, *ast.BasicLit:
|
||||
// nothing to do
|
||||
|
||||
case *ast.Ellipsis:
|
||||
if n.Elt != nil {
|
||||
walk(v, edge.Ellipsis_Elt, -1, n.Elt)
|
||||
}
|
||||
|
||||
case *ast.FuncLit:
|
||||
walk(v, edge.FuncLit_Type, -1, n.Type)
|
||||
walk(v, edge.FuncLit_Body, -1, n.Body)
|
||||
|
||||
case *ast.CompositeLit:
|
||||
if n.Type != nil {
|
||||
walk(v, edge.CompositeLit_Type, -1, n.Type)
|
||||
}
|
||||
walkList(v, edge.CompositeLit_Elts, n.Elts)
|
||||
|
||||
case *ast.ParenExpr:
|
||||
walk(v, edge.ParenExpr_X, -1, n.X)
|
||||
|
||||
case *ast.SelectorExpr:
|
||||
walk(v, edge.SelectorExpr_X, -1, n.X)
|
||||
walk(v, edge.SelectorExpr_Sel, -1, n.Sel)
|
||||
|
||||
case *ast.IndexExpr:
|
||||
walk(v, edge.IndexExpr_X, -1, n.X)
|
||||
walk(v, edge.IndexExpr_Index, -1, n.Index)
|
||||
|
||||
case *ast.IndexListExpr:
|
||||
walk(v, edge.IndexListExpr_X, -1, n.X)
|
||||
walkList(v, edge.IndexListExpr_Indices, n.Indices)
|
||||
|
||||
case *ast.SliceExpr:
|
||||
walk(v, edge.SliceExpr_X, -1, n.X)
|
||||
if n.Low != nil {
|
||||
walk(v, edge.SliceExpr_Low, -1, n.Low)
|
||||
}
|
||||
if n.High != nil {
|
||||
walk(v, edge.SliceExpr_High, -1, n.High)
|
||||
}
|
||||
if n.Max != nil {
|
||||
walk(v, edge.SliceExpr_Max, -1, n.Max)
|
||||
}
|
||||
|
||||
case *ast.TypeAssertExpr:
|
||||
walk(v, edge.TypeAssertExpr_X, -1, n.X)
|
||||
if n.Type != nil {
|
||||
walk(v, edge.TypeAssertExpr_Type, -1, n.Type)
|
||||
}
|
||||
|
||||
case *ast.CallExpr:
|
||||
walk(v, edge.CallExpr_Fun, -1, n.Fun)
|
||||
walkList(v, edge.CallExpr_Args, n.Args)
|
||||
|
||||
case *ast.StarExpr:
|
||||
walk(v, edge.StarExpr_X, -1, n.X)
|
||||
|
||||
case *ast.UnaryExpr:
|
||||
walk(v, edge.UnaryExpr_X, -1, n.X)
|
||||
|
||||
case *ast.BinaryExpr:
|
||||
walk(v, edge.BinaryExpr_X, -1, n.X)
|
||||
walk(v, edge.BinaryExpr_Y, -1, n.Y)
|
||||
|
||||
case *ast.KeyValueExpr:
|
||||
walk(v, edge.KeyValueExpr_Key, -1, n.Key)
|
||||
walk(v, edge.KeyValueExpr_Value, -1, n.Value)
|
||||
|
||||
// Types
|
||||
case *ast.ArrayType:
|
||||
if n.Len != nil {
|
||||
walk(v, edge.ArrayType_Len, -1, n.Len)
|
||||
}
|
||||
walk(v, edge.ArrayType_Elt, -1, n.Elt)
|
||||
|
||||
case *ast.StructType:
|
||||
walk(v, edge.StructType_Fields, -1, n.Fields)
|
||||
|
||||
case *ast.FuncType:
|
||||
if n.TypeParams != nil {
|
||||
walk(v, edge.FuncType_TypeParams, -1, n.TypeParams)
|
||||
}
|
||||
if n.Params != nil {
|
||||
walk(v, edge.FuncType_Params, -1, n.Params)
|
||||
}
|
||||
if n.Results != nil {
|
||||
walk(v, edge.FuncType_Results, -1, n.Results)
|
||||
}
|
||||
|
||||
case *ast.InterfaceType:
|
||||
walk(v, edge.InterfaceType_Methods, -1, n.Methods)
|
||||
|
||||
case *ast.MapType:
|
||||
walk(v, edge.MapType_Key, -1, n.Key)
|
||||
walk(v, edge.MapType_Value, -1, n.Value)
|
||||
|
||||
case *ast.ChanType:
|
||||
walk(v, edge.ChanType_Value, -1, n.Value)
|
||||
|
||||
// Statements
|
||||
case *ast.BadStmt:
|
||||
// nothing to do
|
||||
|
||||
case *ast.DeclStmt:
|
||||
walk(v, edge.DeclStmt_Decl, -1, n.Decl)
|
||||
|
||||
case *ast.EmptyStmt:
|
||||
// nothing to do
|
||||
|
||||
case *ast.LabeledStmt:
|
||||
walk(v, edge.LabeledStmt_Label, -1, n.Label)
|
||||
walk(v, edge.LabeledStmt_Stmt, -1, n.Stmt)
|
||||
|
||||
case *ast.ExprStmt:
|
||||
walk(v, edge.ExprStmt_X, -1, n.X)
|
||||
|
||||
case *ast.SendStmt:
|
||||
walk(v, edge.SendStmt_Chan, -1, n.Chan)
|
||||
walk(v, edge.SendStmt_Value, -1, n.Value)
|
||||
|
||||
case *ast.IncDecStmt:
|
||||
walk(v, edge.IncDecStmt_X, -1, n.X)
|
||||
|
||||
case *ast.AssignStmt:
|
||||
walkList(v, edge.AssignStmt_Lhs, n.Lhs)
|
||||
walkList(v, edge.AssignStmt_Rhs, n.Rhs)
|
||||
|
||||
case *ast.GoStmt:
|
||||
walk(v, edge.GoStmt_Call, -1, n.Call)
|
||||
|
||||
case *ast.DeferStmt:
|
||||
walk(v, edge.DeferStmt_Call, -1, n.Call)
|
||||
|
||||
case *ast.ReturnStmt:
|
||||
walkList(v, edge.ReturnStmt_Results, n.Results)
|
||||
|
||||
case *ast.BranchStmt:
|
||||
if n.Label != nil {
|
||||
walk(v, edge.BranchStmt_Label, -1, n.Label)
|
||||
}
|
||||
|
||||
case *ast.BlockStmt:
|
||||
walkList(v, edge.BlockStmt_List, n.List)
|
||||
|
||||
case *ast.IfStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.IfStmt_Init, -1, n.Init)
|
||||
}
|
||||
walk(v, edge.IfStmt_Cond, -1, n.Cond)
|
||||
walk(v, edge.IfStmt_Body, -1, n.Body)
|
||||
if n.Else != nil {
|
||||
walk(v, edge.IfStmt_Else, -1, n.Else)
|
||||
}
|
||||
|
||||
case *ast.CaseClause:
|
||||
walkList(v, edge.CaseClause_List, n.List)
|
||||
walkList(v, edge.CaseClause_Body, n.Body)
|
||||
|
||||
case *ast.SwitchStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.SwitchStmt_Init, -1, n.Init)
|
||||
}
|
||||
if n.Tag != nil {
|
||||
walk(v, edge.SwitchStmt_Tag, -1, n.Tag)
|
||||
}
|
||||
walk(v, edge.SwitchStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.TypeSwitchStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.TypeSwitchStmt_Init, -1, n.Init)
|
||||
}
|
||||
walk(v, edge.TypeSwitchStmt_Assign, -1, n.Assign)
|
||||
walk(v, edge.TypeSwitchStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.CommClause:
|
||||
if n.Comm != nil {
|
||||
walk(v, edge.CommClause_Comm, -1, n.Comm)
|
||||
}
|
||||
walkList(v, edge.CommClause_Body, n.Body)
|
||||
|
||||
case *ast.SelectStmt:
|
||||
walk(v, edge.SelectStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.ForStmt:
|
||||
if n.Init != nil {
|
||||
walk(v, edge.ForStmt_Init, -1, n.Init)
|
||||
}
|
||||
if n.Cond != nil {
|
||||
walk(v, edge.ForStmt_Cond, -1, n.Cond)
|
||||
}
|
||||
if n.Post != nil {
|
||||
walk(v, edge.ForStmt_Post, -1, n.Post)
|
||||
}
|
||||
walk(v, edge.ForStmt_Body, -1, n.Body)
|
||||
|
||||
case *ast.RangeStmt:
|
||||
if n.Key != nil {
|
||||
walk(v, edge.RangeStmt_Key, -1, n.Key)
|
||||
}
|
||||
if n.Value != nil {
|
||||
walk(v, edge.RangeStmt_Value, -1, n.Value)
|
||||
}
|
||||
walk(v, edge.RangeStmt_X, -1, n.X)
|
||||
walk(v, edge.RangeStmt_Body, -1, n.Body)
|
||||
|
||||
// Declarations
|
||||
case *ast.ImportSpec:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.ImportSpec_Doc, -1, n.Doc)
|
||||
}
|
||||
if n.Name != nil {
|
||||
walk(v, edge.ImportSpec_Name, -1, n.Name)
|
||||
}
|
||||
walk(v, edge.ImportSpec_Path, -1, n.Path)
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.ImportSpec_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.ValueSpec:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.ValueSpec_Doc, -1, n.Doc)
|
||||
}
|
||||
walkList(v, edge.ValueSpec_Names, n.Names)
|
||||
if n.Type != nil {
|
||||
walk(v, edge.ValueSpec_Type, -1, n.Type)
|
||||
}
|
||||
walkList(v, edge.ValueSpec_Values, n.Values)
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.ValueSpec_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.TypeSpec:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.TypeSpec_Doc, -1, n.Doc)
|
||||
}
|
||||
walk(v, edge.TypeSpec_Name, -1, n.Name)
|
||||
if n.TypeParams != nil {
|
||||
walk(v, edge.TypeSpec_TypeParams, -1, n.TypeParams)
|
||||
}
|
||||
walk(v, edge.TypeSpec_Type, -1, n.Type)
|
||||
if n.Comment != nil {
|
||||
walk(v, edge.TypeSpec_Comment, -1, n.Comment)
|
||||
}
|
||||
|
||||
case *ast.BadDecl:
|
||||
// nothing to do
|
||||
|
||||
case *ast.GenDecl:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.GenDecl_Doc, -1, n.Doc)
|
||||
}
|
||||
walkList(v, edge.GenDecl_Specs, n.Specs)
|
||||
|
||||
case *ast.FuncDecl:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.FuncDecl_Doc, -1, n.Doc)
|
||||
}
|
||||
if n.Recv != nil {
|
||||
walk(v, edge.FuncDecl_Recv, -1, n.Recv)
|
||||
}
|
||||
walk(v, edge.FuncDecl_Name, -1, n.Name)
|
||||
walk(v, edge.FuncDecl_Type, -1, n.Type)
|
||||
if n.Body != nil {
|
||||
walk(v, edge.FuncDecl_Body, -1, n.Body)
|
||||
}
|
||||
|
||||
case *ast.File:
|
||||
if n.Doc != nil {
|
||||
walk(v, edge.File_Doc, -1, n.Doc)
|
||||
}
|
||||
walk(v, edge.File_Name, -1, n.Name)
|
||||
walkList(v, edge.File_Decls, n.Decls)
|
||||
// don't walk n.Comments - they have been
|
||||
// visited already through the individual
|
||||
// nodes
|
||||
|
||||
default:
|
||||
// (includes *ast.Package)
|
||||
panic(fmt.Sprintf("Walk: unexpected node type %T", n))
|
||||
}
|
||||
|
||||
v.pop(node)
|
||||
}
|
||||
6
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
6
vendor/golang.org/x/tools/go/packages/golist.go
generated
vendored
@@ -364,12 +364,6 @@ type jsonPackage struct {
|
||||
DepsErrors []*packagesinternal.PackageError
|
||||
}
|
||||
|
||||
type jsonPackageError struct {
|
||||
ImportStack []string
|
||||
Pos string
|
||||
Err string
|
||||
}
|
||||
|
||||
func otherFiles(p *jsonPackage) [][]string {
|
||||
return [][]string{p.CFiles, p.CXXFiles, p.MFiles, p.HFiles, p.FFiles, p.SFiles, p.SwigFiles, p.SwigCXXFiles, p.SysoFiles}
|
||||
}
|
||||
|
||||
5
vendor/golang.org/x/tools/internal/event/core/event.go
generated
vendored
5
vendor/golang.org/x/tools/internal/event/core/event.go
generated
vendored
@@ -28,11 +28,6 @@ type Event struct {
|
||||
dynamic []label.Label // dynamically sized storage for remaining labels
|
||||
}
|
||||
|
||||
// eventLabelMap implements label.Map for a the labels of an Event.
|
||||
type eventLabelMap struct {
|
||||
event Event
|
||||
}
|
||||
|
||||
func (ev Event) At() time.Time { return ev.at }
|
||||
|
||||
func (ev Event) Format(f fmt.State, r rune) {
|
||||
|
||||
1
vendor/golang.org/x/tools/internal/gcimporter/iexport.go
generated
vendored
1
vendor/golang.org/x/tools/internal/gcimporter/iexport.go
generated
vendored
@@ -569,7 +569,6 @@ func (p *iexporter) exportName(obj types.Object) (res string) {
|
||||
|
||||
type iexporter struct {
|
||||
fset *token.FileSet
|
||||
out *bytes.Buffer
|
||||
version int
|
||||
|
||||
shallow bool // don't put types from other packages in the index
|
||||
|
||||
49
vendor/golang.org/x/tools/internal/typesinternal/fx.go
generated
vendored
Normal file
49
vendor/golang.org/x/tools/internal/typesinternal/fx.go
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package typesinternal
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"go/token"
|
||||
"go/types"
|
||||
)
|
||||
|
||||
// NoEffects reports whether the expression has no side effects, i.e., it
|
||||
// does not modify the memory state. This function is conservative: it may
|
||||
// return false even when the expression has no effect.
|
||||
func NoEffects(info *types.Info, expr ast.Expr) bool {
|
||||
noEffects := true
|
||||
ast.Inspect(expr, func(n ast.Node) bool {
|
||||
switch v := n.(type) {
|
||||
case nil, *ast.Ident, *ast.BasicLit, *ast.BinaryExpr, *ast.ParenExpr,
|
||||
*ast.SelectorExpr, *ast.IndexExpr, *ast.SliceExpr, *ast.TypeAssertExpr,
|
||||
*ast.StarExpr, *ast.CompositeLit, *ast.ArrayType, *ast.StructType,
|
||||
*ast.MapType, *ast.InterfaceType, *ast.KeyValueExpr:
|
||||
// No effect
|
||||
case *ast.UnaryExpr:
|
||||
// Channel send <-ch has effects
|
||||
if v.Op == token.ARROW {
|
||||
noEffects = false
|
||||
}
|
||||
case *ast.CallExpr:
|
||||
// Type conversion has no effects
|
||||
if !info.Types[v.Fun].IsType() {
|
||||
// TODO(adonovan): Add a case for built-in functions without side
|
||||
// effects (by using callsPureBuiltin from tools/internal/refactor/inline)
|
||||
|
||||
noEffects = false
|
||||
}
|
||||
case *ast.FuncLit:
|
||||
// A FuncLit has no effects, but do not descend into it.
|
||||
return false
|
||||
default:
|
||||
// All other expressions have effects
|
||||
noEffects = false
|
||||
}
|
||||
|
||||
return noEffects
|
||||
})
|
||||
return noEffects
|
||||
}
|
||||
71
vendor/golang.org/x/tools/internal/typesinternal/isnamed.go
generated
vendored
Normal file
71
vendor/golang.org/x/tools/internal/typesinternal/isnamed.go
generated
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2025 The Go Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package typesinternal
|
||||
|
||||
import (
|
||||
"go/types"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// IsTypeNamed reports whether t is (or is an alias for) a
|
||||
// package-level defined type with the given package path and one of
|
||||
// the given names. It returns false if t is nil.
|
||||
//
|
||||
// This function avoids allocating the concatenation of "pkg.Name",
|
||||
// which is important for the performance of syntax matching.
|
||||
func IsTypeNamed(t types.Type, pkgPath string, names ...string) bool {
|
||||
if named, ok := types.Unalias(t).(*types.Named); ok {
|
||||
tname := named.Obj()
|
||||
return tname != nil &&
|
||||
IsPackageLevel(tname) &&
|
||||
tname.Pkg().Path() == pkgPath &&
|
||||
slices.Contains(names, tname.Name())
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsPointerToNamed reports whether t is (or is an alias for) a pointer to a
|
||||
// package-level defined type with the given package path and one of the given
|
||||
// names. It returns false if t is not a pointer type.
|
||||
func IsPointerToNamed(t types.Type, pkgPath string, names ...string) bool {
|
||||
r := Unpointer(t)
|
||||
if r == t {
|
||||
return false
|
||||
}
|
||||
return IsTypeNamed(r, pkgPath, names...)
|
||||
}
|
||||
|
||||
// IsFunctionNamed reports whether obj is a package-level function
|
||||
// defined in the given package and has one of the given names.
|
||||
// It returns false if obj is nil.
|
||||
//
|
||||
// This function avoids allocating the concatenation of "pkg.Name",
|
||||
// which is important for the performance of syntax matching.
|
||||
func IsFunctionNamed(obj types.Object, pkgPath string, names ...string) bool {
|
||||
f, ok := obj.(*types.Func)
|
||||
return ok &&
|
||||
IsPackageLevel(obj) &&
|
||||
f.Pkg().Path() == pkgPath &&
|
||||
f.Type().(*types.Signature).Recv() == nil &&
|
||||
slices.Contains(names, f.Name())
|
||||
}
|
||||
|
||||
// IsMethodNamed reports whether obj is a method defined on a
|
||||
// package-level type with the given package and type name, and has
|
||||
// one of the given names. It returns false if obj is nil.
|
||||
//
|
||||
// This function avoids allocating the concatenation of "pkg.TypeName.Name",
|
||||
// which is important for the performance of syntax matching.
|
||||
func IsMethodNamed(obj types.Object, pkgPath string, typeName string, names ...string) bool {
|
||||
if fn, ok := obj.(*types.Func); ok {
|
||||
if recv := fn.Type().(*types.Signature).Recv(); recv != nil {
|
||||
_, T := ReceiverNamed(recv)
|
||||
return T != nil &&
|
||||
IsTypeNamed(T, pkgPath, typeName) &&
|
||||
slices.Contains(names, fn.Name())
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
8
vendor/golang.org/x/tools/internal/typesinternal/qualifier.go
generated
vendored
8
vendor/golang.org/x/tools/internal/typesinternal/qualifier.go
generated
vendored
@@ -15,6 +15,14 @@ import (
|
||||
// file.
|
||||
// If the same package is imported multiple times, the last appearance is
|
||||
// recorded.
|
||||
//
|
||||
// TODO(adonovan): this function ignores the effect of shadowing. It
|
||||
// should accept a [token.Pos] and a [types.Info] and compute only the
|
||||
// set of imports that are not shadowed at that point, analogous to
|
||||
// [analysisinternal.AddImport]. It could also compute (as a side
|
||||
// effect) the set of additional imports required to ensure that there
|
||||
// is an accessible import for each necessary package, making it
|
||||
// converge even more closely with AddImport.
|
||||
func FileQualifier(f *ast.File, pkg *types.Package) types.Qualifier {
|
||||
// Construct mapping of import paths to their defined names.
|
||||
// It is only necessary to look at renaming imports.
|
||||
|
||||
48
vendor/golang.org/x/tools/internal/typesinternal/types.go
generated
vendored
48
vendor/golang.org/x/tools/internal/typesinternal/types.go
generated
vendored
@@ -2,8 +2,20 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// Package typesinternal provides access to internal go/types APIs that are not
|
||||
// yet exported.
|
||||
// Package typesinternal provides helpful operators for dealing with
|
||||
// go/types:
|
||||
//
|
||||
// - operators for querying typed syntax trees (e.g. [Imports], [IsFunctionNamed]);
|
||||
// - functions for converting types to strings or syntax (e.g. [TypeExpr], FileQualifier]);
|
||||
// - helpers for working with the [go/types] API (e.g. [NewTypesInfo]);
|
||||
// - access to internal go/types APIs that are not yet
|
||||
// exported (e.g. [SetUsesCgo], [ErrorCodeStartEnd], [VarKind]); and
|
||||
// - common algorithms related to types (e.g. [TooNewStdSymbols]).
|
||||
//
|
||||
// See also:
|
||||
// - [golang.org/x/tools/internal/astutil], for operations on untyped syntax;
|
||||
// - [golang.org/x/tools/internal/analysisinernal], for helpers for analyzers;
|
||||
// - [golang.org/x/tools/internal/refactor], for operators to compute text edits.
|
||||
package typesinternal
|
||||
|
||||
import (
|
||||
@@ -13,6 +25,7 @@ import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/tools/go/ast/inspector"
|
||||
"golang.org/x/tools/internal/aliases"
|
||||
)
|
||||
|
||||
@@ -60,6 +73,9 @@ func ErrorCodeStartEnd(err types.Error) (code ErrorCode, start, end token.Pos, o
|
||||
// which is often excessive.)
|
||||
//
|
||||
// If pkg is nil, it is equivalent to [*types.Package.Name].
|
||||
//
|
||||
// TODO(adonovan): all uses of this with TypeString should be
|
||||
// eliminated when https://go.dev/issues/75604 is resolved.
|
||||
func NameRelativeTo(pkg *types.Package) types.Qualifier {
|
||||
return func(other *types.Package) string {
|
||||
if pkg != nil && pkg == other {
|
||||
@@ -153,3 +169,31 @@ func NewTypesInfo() *types.Info {
|
||||
FileVersions: map[*ast.File]string{},
|
||||
}
|
||||
}
|
||||
|
||||
// EnclosingScope returns the innermost block logically enclosing the cursor.
|
||||
func EnclosingScope(info *types.Info, cur inspector.Cursor) *types.Scope {
|
||||
for cur := range cur.Enclosing() {
|
||||
n := cur.Node()
|
||||
// A function's Scope is associated with its FuncType.
|
||||
switch f := n.(type) {
|
||||
case *ast.FuncDecl:
|
||||
n = f.Type
|
||||
case *ast.FuncLit:
|
||||
n = f.Type
|
||||
}
|
||||
if b := info.Scopes[n]; b != nil {
|
||||
return b
|
||||
}
|
||||
}
|
||||
panic("no Scope for *ast.File")
|
||||
}
|
||||
|
||||
// Imports reports whether path is imported by pkg.
|
||||
func Imports(pkg *types.Package, path string) bool {
|
||||
for _, imp := range pkg.Imports() {
|
||||
if imp.Path() == path {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
17
vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go
generated
vendored
17
vendor/golang.org/x/tools/internal/typesinternal/zerovalue.go
generated
vendored
@@ -204,23 +204,12 @@ func ZeroExpr(t types.Type, qual types.Qualifier) (_ ast.Expr, isValid bool) {
|
||||
}
|
||||
}
|
||||
|
||||
// IsZeroExpr uses simple syntactic heuristics to report whether expr
|
||||
// is a obvious zero value, such as 0, "", nil, or false.
|
||||
// It cannot do better without type information.
|
||||
func IsZeroExpr(expr ast.Expr) bool {
|
||||
switch e := expr.(type) {
|
||||
case *ast.BasicLit:
|
||||
return e.Value == "0" || e.Value == `""`
|
||||
case *ast.Ident:
|
||||
return e.Name == "nil" || e.Name == "false"
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// TypeExpr returns syntax for the specified type. References to named types
|
||||
// are qualified by an appropriate (optional) qualifier function.
|
||||
// It may panic for types such as Tuple or Union.
|
||||
//
|
||||
// See also https://go.dev/issues/75604, which will provide a robust
|
||||
// Type-to-valid-Go-syntax formatter.
|
||||
func TypeExpr(t types.Type, qual types.Qualifier) ast.Expr {
|
||||
switch t := t.(type) {
|
||||
case *types.Basic:
|
||||
|
||||
16
vendor/modules.txt
vendored
16
vendor/modules.txt
vendored
@@ -1553,7 +1553,7 @@ go.uber.org/zap/zapcore
|
||||
# go.yaml.in/yaml/v2 v2.4.3
|
||||
## explicit; go 1.15
|
||||
go.yaml.in/yaml/v2
|
||||
# golang.org/x/crypto v0.43.0
|
||||
# golang.org/x/crypto v0.44.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/crypto/argon2
|
||||
golang.org/x/crypto/blake2b
|
||||
@@ -1578,12 +1578,12 @@ golang.org/x/crypto/salsa20/salsa
|
||||
golang.org/x/crypto/sha3
|
||||
golang.org/x/crypto/ssh
|
||||
golang.org/x/crypto/ssh/internal/bcrypt_pbkdf
|
||||
# golang.org/x/mod v0.29.0
|
||||
# golang.org/x/mod v0.30.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/mod/internal/lazyregexp
|
||||
golang.org/x/mod/module
|
||||
golang.org/x/mod/semver
|
||||
# golang.org/x/net v0.46.0
|
||||
# golang.org/x/net v0.47.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/net/bpf
|
||||
golang.org/x/net/context
|
||||
@@ -1612,12 +1612,12 @@ golang.org/x/oauth2/google/internal/stsexchange
|
||||
golang.org/x/oauth2/internal
|
||||
golang.org/x/oauth2/jws
|
||||
golang.org/x/oauth2/jwt
|
||||
# golang.org/x/sync v0.17.0
|
||||
# golang.org/x/sync v0.18.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/sync/errgroup
|
||||
golang.org/x/sync/semaphore
|
||||
golang.org/x/sync/syncmap
|
||||
# golang.org/x/sys v0.37.0
|
||||
# golang.org/x/sys v0.38.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/sys/cpu
|
||||
golang.org/x/sys/unix
|
||||
@@ -1627,7 +1627,7 @@ golang.org/x/sys/windows/svc
|
||||
golang.org/x/sys/windows/svc/debug
|
||||
golang.org/x/sys/windows/svc/eventlog
|
||||
golang.org/x/sys/windows/svc/mgr
|
||||
# golang.org/x/text v0.30.0
|
||||
# golang.org/x/text v0.31.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/text/encoding
|
||||
golang.org/x/text/encoding/internal
|
||||
@@ -1642,8 +1642,10 @@ golang.org/x/text/unicode/norm
|
||||
# golang.org/x/time v0.14.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/time/rate
|
||||
# golang.org/x/tools v0.37.0
|
||||
# golang.org/x/tools v0.38.0
|
||||
## explicit; go 1.24.0
|
||||
golang.org/x/tools/go/ast/edge
|
||||
golang.org/x/tools/go/ast/inspector
|
||||
golang.org/x/tools/go/gcexportdata
|
||||
golang.org/x/tools/go/packages
|
||||
golang.org/x/tools/go/types/objectpath
|
||||
|
||||
Reference in New Issue
Block a user