mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
go/types, types2: rename loaded namedState to lazyLoaded
This is a minor renaming to help differentiate the two kinds of loading that can happen for named types (eager and lazy). Use of the term "loaded" suggests that it might also apply to types which are eagerly-loaded, which is not the case. This change uses "lazyLoaded" instead to mark this difference. Change-Id: Iee170024246d9adf3eed978bde2b0500f6d490b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/713282 Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
8401512a9b
commit
9fcdc814b2
2 changed files with 20 additions and 20 deletions
|
|
@ -142,7 +142,7 @@ type instance struct {
|
||||||
// according to the below diagram:
|
// according to the below diagram:
|
||||||
//
|
//
|
||||||
// unresolved
|
// unresolved
|
||||||
// loaded
|
// lazyLoaded
|
||||||
// resolved
|
// resolved
|
||||||
// └── hasMethods
|
// └── hasMethods
|
||||||
// └── hasUnder
|
// └── hasUnder
|
||||||
|
|
@ -158,9 +158,9 @@ type instance struct {
|
||||||
// set left-to-right, they are:
|
// set left-to-right, they are:
|
||||||
//
|
//
|
||||||
// 0000 | unresolved
|
// 0000 | unresolved
|
||||||
// 1000 | loaded
|
// 1000 | lazyLoaded
|
||||||
// 1100 | resolved, which implies loaded
|
// 1100 | resolved, which implies lazyLoaded
|
||||||
// 1110 | hasMethods, which implies resolved (which in turn implies loaded)
|
// 1110 | hasMethods, which implies resolved (which in turn implies lazyLoaded)
|
||||||
// 1101 | hasUnder, which implies resolved ...
|
// 1101 | hasUnder, which implies resolved ...
|
||||||
// 1111 | both hasMethods and hasUnder which implies resolved ...
|
// 1111 | both hasMethods and hasUnder which implies resolved ...
|
||||||
//
|
//
|
||||||
|
|
@ -169,9 +169,9 @@ type stateMask uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// before resolved, type parameters, RHS, underlying, and methods might be unavailable
|
// before resolved, type parameters, RHS, underlying, and methods might be unavailable
|
||||||
resolved stateMask = 1 << iota // methods might be unexpanded (for instances)
|
lazyLoaded stateMask = 1 << iota // methods are available, but constraints might be unexpanded (for generic types)
|
||||||
|
resolved // methods might be unexpanded (for instances)
|
||||||
hasMethods // methods are all expanded (for instances)
|
hasMethods // methods are all expanded (for instances)
|
||||||
loaded // methods are available, but constraints might be unexpanded (for generic types)
|
|
||||||
hasUnder // underlying type is available
|
hasUnder // underlying type is available
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -213,7 +213,7 @@ func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
|
||||||
// All others:
|
// All others:
|
||||||
// Effectively, nothing happens.
|
// Effectively, nothing happens.
|
||||||
func (n *Named) resolve() *Named {
|
func (n *Named) resolve() *Named {
|
||||||
if n.stateHas(resolved | loaded) { // avoid locking below
|
if n.stateHas(resolved | lazyLoaded) { // avoid locking below
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -223,7 +223,7 @@ func (n *Named) resolve() *Named {
|
||||||
defer n.mu.Unlock()
|
defer n.mu.Unlock()
|
||||||
|
|
||||||
// only atomic for consistency; we are holding the mutex
|
// only atomic for consistency; we are holding the mutex
|
||||||
if n.stateHas(resolved | loaded) {
|
if n.stateHas(resolved | lazyLoaded) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,7 +267,7 @@ func (n *Named) resolve() *Named {
|
||||||
n.fromRHS = underlying // for cycle detection
|
n.fromRHS = underlying // for cycle detection
|
||||||
n.methods = methods
|
n.methods = methods
|
||||||
|
|
||||||
n.setState(loaded) // avoid deadlock calling delayed functions
|
n.setState(lazyLoaded) // avoid deadlock calling delayed functions
|
||||||
for _, f := range delayed {
|
for _, f := range delayed {
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
|
|
@ -716,7 +716,7 @@ func (n *Named) expandRHS() (rhs Type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!n.stateHas(resolved))
|
assert(!n.stateHas(resolved))
|
||||||
assert(n.inst.orig.stateHas(resolved | loaded))
|
assert(n.inst.orig.stateHas(resolved | lazyLoaded))
|
||||||
|
|
||||||
if n.inst.ctxt == nil {
|
if n.inst.ctxt == nil {
|
||||||
n.inst.ctxt = NewContext()
|
n.inst.ctxt = NewContext()
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ type instance struct {
|
||||||
// according to the below diagram:
|
// according to the below diagram:
|
||||||
//
|
//
|
||||||
// unresolved
|
// unresolved
|
||||||
// loaded
|
// lazyLoaded
|
||||||
// resolved
|
// resolved
|
||||||
// └── hasMethods
|
// └── hasMethods
|
||||||
// └── hasUnder
|
// └── hasUnder
|
||||||
|
|
@ -161,9 +161,9 @@ type instance struct {
|
||||||
// set left-to-right, they are:
|
// set left-to-right, they are:
|
||||||
//
|
//
|
||||||
// 0000 | unresolved
|
// 0000 | unresolved
|
||||||
// 1000 | loaded
|
// 1000 | lazyLoaded
|
||||||
// 1100 | resolved, which implies loaded
|
// 1100 | resolved, which implies lazyLoaded
|
||||||
// 1110 | hasMethods, which implies resolved (which in turn implies loaded)
|
// 1110 | hasMethods, which implies resolved (which in turn implies lazyLoaded)
|
||||||
// 1101 | hasUnder, which implies resolved ...
|
// 1101 | hasUnder, which implies resolved ...
|
||||||
// 1111 | both hasMethods and hasUnder which implies resolved ...
|
// 1111 | both hasMethods and hasUnder which implies resolved ...
|
||||||
//
|
//
|
||||||
|
|
@ -172,9 +172,9 @@ type stateMask uint32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// before resolved, type parameters, RHS, underlying, and methods might be unavailable
|
// before resolved, type parameters, RHS, underlying, and methods might be unavailable
|
||||||
resolved stateMask = 1 << iota // methods might be unexpanded (for instances)
|
lazyLoaded stateMask = 1 << iota // methods are available, but constraints might be unexpanded (for generic types)
|
||||||
|
resolved // methods might be unexpanded (for instances)
|
||||||
hasMethods // methods are all expanded (for instances)
|
hasMethods // methods are all expanded (for instances)
|
||||||
loaded // methods are available, but constraints might be unexpanded (for generic types)
|
|
||||||
hasUnder // underlying type is available
|
hasUnder // underlying type is available
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -216,7 +216,7 @@ func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
|
||||||
// All others:
|
// All others:
|
||||||
// Effectively, nothing happens.
|
// Effectively, nothing happens.
|
||||||
func (n *Named) resolve() *Named {
|
func (n *Named) resolve() *Named {
|
||||||
if n.stateHas(resolved | loaded) { // avoid locking below
|
if n.stateHas(resolved | lazyLoaded) { // avoid locking below
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -226,7 +226,7 @@ func (n *Named) resolve() *Named {
|
||||||
defer n.mu.Unlock()
|
defer n.mu.Unlock()
|
||||||
|
|
||||||
// only atomic for consistency; we are holding the mutex
|
// only atomic for consistency; we are holding the mutex
|
||||||
if n.stateHas(resolved | loaded) {
|
if n.stateHas(resolved | lazyLoaded) {
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -270,7 +270,7 @@ func (n *Named) resolve() *Named {
|
||||||
n.fromRHS = underlying // for cycle detection
|
n.fromRHS = underlying // for cycle detection
|
||||||
n.methods = methods
|
n.methods = methods
|
||||||
|
|
||||||
n.setState(loaded) // avoid deadlock calling delayed functions
|
n.setState(lazyLoaded) // avoid deadlock calling delayed functions
|
||||||
for _, f := range delayed {
|
for _, f := range delayed {
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
|
|
@ -719,7 +719,7 @@ func (n *Named) expandRHS() (rhs Type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(!n.stateHas(resolved))
|
assert(!n.stateHas(resolved))
|
||||||
assert(n.inst.orig.stateHas(resolved | loaded))
|
assert(n.inst.orig.stateHas(resolved | lazyLoaded))
|
||||||
|
|
||||||
if n.inst.ctxt == nil {
|
if n.inst.ctxt == nil {
|
||||||
n.inst.ctxt = NewContext()
|
n.inst.ctxt = NewContext()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue