$86 GRAYBYTE WORDPRESS FILE MANAGER $96

SERVER : vnpttt-amd7f72-h1.vietnix.vn #1 SMP Fri May 24 12:42:50 UTC 2024
SERVER IP : 103.200.23.149 | ADMIN IP 216.73.216.22
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/lib/golang/src/go/types/

HOME
Current File : /lib/golang/src/go/types//selection.go
// Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
// Source: ../../cmd/compile/internal/types2/selection.go

// Copyright 2013 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.

// This file implements Selections.

package types

import (
	"bytes"
	"fmt"
)

// SelectionKind describes the kind of a selector expression x.f
// (excluding qualified identifiers).
//
// If x is a struct or *struct, a selector expression x.f may denote a
// sequence of selection operations x.a.b.c.f. The SelectionKind
// describes the kind of the final (explicit) operation; all the
// previous (implicit) operations are always field selections.
// Each element of Indices specifies an implicit field (a, b, c)
// by its index in the struct type of the field selection operand.
//
// For a FieldVal operation, the final selection refers to the field
// specified by Selection.Obj.
//
// For a MethodVal operation, the final selection refers to a method.
// If the "pointerness" of the method's declared receiver does not
// match that of the effective receiver after implicit field
// selection, then an & or * operation is implicitly applied to the
// receiver variable or value.
// So, x.f denotes (&x.a.b.c).f when f requires a pointer receiver but
// x.a.b.c is a non-pointer variable; and it denotes (*x.a.b.c).f when
// f requires a non-pointer receiver but x.a.b.c is a pointer value.
//
// All pointer indirections, whether due to implicit or explicit field
// selections or * operations inserted for "pointerness", panic if
// applied to a nil pointer, so a method call x.f() may panic even
// before the function call.
//
// By contrast, a MethodExpr operation T.f is essentially equivalent
// to a function literal of the form:
//
//	func(x T, args) (results) { return x.f(args) }
//
// Consequently, any implicit field selections and * operations
// inserted for "pointerness" are not evaluated until the function is
// called, so a T.f or (*T).f expression never panics.
type SelectionKind int

const (
	FieldVal   SelectionKind = iota // x.f is a struct field selector
	MethodVal                       // x.f is a method selector
	MethodExpr                      // x.f is a method expression
)

// A Selection describes a selector expression x.f.
// For the declarations:
//
//	type T struct{ x int; E }
//	type E struct{}
//	func (e E) m() {}
//	var p *T
//
// the following relations exist:
//
//	Selector    Kind          Recv    Obj    Type       Index     Indirect
//
//	p.x         FieldVal      T       x      int        {0}       true
//	p.m         MethodVal     *T      m      func()     {1, 0}    true
//	T.m         MethodExpr    T       m      func(T)    {1, 0}    false
type Selection struct {
	kind     SelectionKind
	recv     Type   // type of x
	obj      Object // object denoted by x.f
	index    []int  // path from x to x.f
	indirect bool   // set if there was any pointer indirection on the path
}

// Kind returns the selection kind.
func (s *Selection) Kind() SelectionKind { return s.kind }

// Recv returns the type of x in x.f.
func (s *Selection) Recv() Type { return s.recv }

// Obj returns the object denoted by x.f; a *Var for
// a field selection, and a *Func in all other cases.
func (s *Selection) Obj() Object { return s.obj }

// Type returns the type of x.f, which may be different from the type of f.
// See Selection for more information.
func (s *Selection) Type() Type {
	switch s.kind {
	case MethodVal:
		// The type of x.f is a method with its receiver type set
		// to the type of x.
		sig := *s.obj.(*Func).typ.(*Signature)
		recv := *sig.recv
		recv.typ = s.recv
		sig.recv = &recv
		return &sig

	case MethodExpr:
		// The type of x.f is a function (without receiver)
		// and an additional first argument with the same type as x.
		// TODO(gri) Similar code is already in call.go - factor!
		// TODO(gri) Compute this eagerly to avoid allocations.
		sig := *s.obj.(*Func).typ.(*Signature)
		arg0 := *sig.recv
		sig.recv = nil
		arg0.typ = s.recv
		var params []*Var
		if sig.params != nil {
			params = sig.params.vars
		}
		sig.params = NewTuple(append([]*Var{&arg0}, params...)...)
		return &sig
	}

	// In all other cases, the type of x.f is the type of x.
	return s.obj.Type()
}

// Index describes the path from x to f in x.f.
// The last index entry is the field or method index of the type declaring f;
// either:
//
//  1. the list of declared methods of a named type; or
//  2. the list of methods of an interface type; or
//  3. the list of fields of a struct type.
//
// The earlier index entries are the indices of the embedded fields implicitly
// traversed to get from (the type of) x to f, starting at embedding depth 0.
func (s *Selection) Index() []int { return s.index }

// Indirect reports whether any pointer indirection was required to get from
// x to f in x.f.
//
// Beware: Indirect spuriously returns true (Go issue #8353) for a
// MethodVal selection in which the receiver argument and parameter
// both have type *T so there is no indirection.
// Unfortunately, a fix is too risky.
func (s *Selection) Indirect() bool { return s.indirect }

func (s *Selection) String() string { return SelectionString(s, nil) }

// SelectionString returns the string form of s.
// The Qualifier controls the printing of
// package-level objects, and may be nil.
//
// Examples:
//
//	"field (T) f int"
//	"method (T) f(X) Y"
//	"method expr (T) f(X) Y"
func SelectionString(s *Selection, qf Qualifier) string {
	var k string
	switch s.kind {
	case FieldVal:
		k = "field "
	case MethodVal:
		k = "method "
	case MethodExpr:
		k = "method expr "
	default:
		panic("unreachable")
	}
	var buf bytes.Buffer
	buf.WriteString(k)
	buf.WriteByte('(')
	WriteType(&buf, s.Recv(), qf)
	fmt.Fprintf(&buf, ") %s", s.obj.Name())
	if T := s.Type(); s.kind == FieldVal {
		buf.WriteByte(' ')
		WriteType(&buf, T, qf)
	} else {
		WriteSignature(&buf, T.(*Signature), qf)
	}
	return buf.String()
}

Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Dec 2025 6.06 PM
root / root
0755
README.md
0.133 KB
4 Dec 2025 6.06 PM
root / root
0644
alias.go
6.063 KB
4 Dec 2025 6.06 PM
root / root
0644
api.go
17.887 KB
4 Dec 2025 6.06 PM
root / root
0644
api_predicates.go
3.451 KB
4 Dec 2025 6.06 PM
root / root
0644
array.go
0.905 KB
4 Dec 2025 6.06 PM
root / root
0644
assignments.go
16.889 KB
4 Dec 2025 6.06 PM
root / root
0644
badlinkname.go
0.686 KB
4 Dec 2025 6.06 PM
root / root
0644
basic.go
1.605 KB
4 Dec 2025 6.06 PM
root / root
0644
builtins.go
29.413 KB
4 Dec 2025 6.06 PM
root / root
0644
call.go
33.833 KB
4 Dec 2025 6.06 PM
root / root
0644
chan.go
1.009 KB
4 Dec 2025 6.06 PM
root / root
0644
check.go
21.786 KB
4 Dec 2025 6.06 PM
root / root
0644
const.go
7.618 KB
4 Dec 2025 6.06 PM
root / root
0644
context.go
4.429 KB
4 Dec 2025 6.06 PM
root / root
0644
conversions.go
9.082 KB
4 Dec 2025 6.06 PM
root / root
0644
decl.go
31.035 KB
4 Dec 2025 6.06 PM
root / root
0644
errors.go
8.49 KB
4 Dec 2025 6.06 PM
root / root
0644
errsupport.go
4.528 KB
4 Dec 2025 6.06 PM
root / root
0644
eval.go
3.069 KB
4 Dec 2025 6.06 PM
root / root
0644
expr.go
39.407 KB
4 Dec 2025 6.06 PM
root / root
0644
exprstring.go
4.781 KB
4 Dec 2025 6.06 PM
root / root
0644
format.go
4.031 KB
4 Dec 2025 6.06 PM
root / root
0644
gccgosizes.go
1.143 KB
4 Dec 2025 6.06 PM
root / root
0644
gcsizes.go
4.357 KB
4 Dec 2025 6.06 PM
root / root
0644
generate.go
0.263 KB
4 Dec 2025 6.06 PM
root / root
0644
gotype.go
8.33 KB
4 Dec 2025 6.06 PM
root / root
0644
index.go
11.772 KB
4 Dec 2025 6.06 PM
root / root
0644
infer.go
27.142 KB
4 Dec 2025 6.06 PM
root / root
0644
initorder.go
10.131 KB
4 Dec 2025 6.06 PM
root / root
0644
instantiate.go
13.211 KB
4 Dec 2025 6.06 PM
root / root
0644
interface.go
8.155 KB
4 Dec 2025 6.06 PM
root / root
0644
iter.go
3.873 KB
4 Dec 2025 6.06 PM
root / root
0644
labels.go
7.295 KB
4 Dec 2025 6.06 PM
root / root
0644
literals.go
12.77 KB
4 Dec 2025 6.06 PM
root / root
0644
lookup.go
22.653 KB
4 Dec 2025 6.06 PM
root / root
0644
map.go
0.763 KB
4 Dec 2025 6.06 PM
root / root
0644
methodset.go
7.058 KB
4 Dec 2025 6.06 PM
root / root
0644
mono.go
9.194 KB
4 Dec 2025 6.06 PM
root / root
0644
named.go
24.34 KB
4 Dec 2025 6.06 PM
root / root
0644
object.go
22.06 KB
4 Dec 2025 6.06 PM
root / root
0644
objset.go
1.028 KB
4 Dec 2025 6.06 PM
root / root
0644
operand.go
12.16 KB
4 Dec 2025 6.06 PM
root / root
0644
package.go
3.05 KB
4 Dec 2025 6.06 PM
root / root
0644
pointer.go
0.743 KB
4 Dec 2025 6.06 PM
root / root
0644
predicates.go
17.609 KB
4 Dec 2025 6.06 PM
root / root
0644
range.go
9.338 KB
4 Dec 2025 6.06 PM
root / root
0644
recording.go
4.648 KB
4 Dec 2025 6.06 PM
root / root
0644
resolver.go
25.255 KB
4 Dec 2025 6.06 PM
root / root
0644
return.go
4.232 KB
4 Dec 2025 6.06 PM
root / root
0644
scope.go
7.632 KB
4 Dec 2025 6.06 PM
root / root
0644
scope2.go
2.554 KB
4 Dec 2025 6.06 PM
root / root
0644
selection.go
5.906 KB
4 Dec 2025 6.06 PM
root / root
0644
signature.go
17.81 KB
4 Dec 2025 6.06 PM
root / root
0644
sizes.go
8.939 KB
4 Dec 2025 6.06 PM
root / root
0644
slice.go
0.685 KB
4 Dec 2025 6.06 PM
root / root
0644
stmt.go
23.696 KB
4 Dec 2025 6.06 PM
root / root
0644
struct.go
6.149 KB
4 Dec 2025 6.06 PM
root / root
0644
subst.go
10.411 KB
4 Dec 2025 6.06 PM
root / root
0644
termlist.go
3.894 KB
4 Dec 2025 6.06 PM
root / root
0644
tuple.go
1.028 KB
4 Dec 2025 6.06 PM
root / root
0644
type.go
0.528 KB
4 Dec 2025 6.06 PM
root / root
0644
typelists.go
1.967 KB
4 Dec 2025 6.06 PM
root / root
0644
typeparam.go
5.224 KB
4 Dec 2025 6.06 PM
root / root
0644
typeset.go
13.31 KB
4 Dec 2025 6.06 PM
root / root
0644
typestring.go
12.479 KB
4 Dec 2025 6.06 PM
root / root
0644
typeterm.go
3.643 KB
4 Dec 2025 6.06 PM
root / root
0644
typexpr.go
16.179 KB
4 Dec 2025 6.06 PM
root / root
0644
under.go
4.331 KB
4 Dec 2025 6.06 PM
root / root
0644
unify.go
27.898 KB
4 Dec 2025 6.06 PM
root / root
0644
union.go
6.225 KB
4 Dec 2025 6.06 PM
root / root
0644
universe.go
9.354 KB
4 Dec 2025 6.06 PM
root / root
0644
util.go
1.9 KB
4 Dec 2025 6.06 PM
root / root
0644
validtype.go
10.345 KB
4 Dec 2025 6.06 PM
root / root
0644
version.go
2.036 KB
4 Dec 2025 6.06 PM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME
Static GIF