github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/types/sym.go (about)

     1  // Copyright 2017 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package types
     6  
     7  import (
     8  	"github.com/shogo82148/std/cmd/internal/obj"
     9  )
    10  
    11  // Sym represents an object name in a segmented (pkg, name) namespace.
    12  // Most commonly, this is a Go identifier naming an object declared within a package,
    13  // but Syms are also used to name internal synthesized objects.
    14  //
    15  // As an exception, field and method names that are exported use the Sym
    16  // associated with localpkg instead of the package that declared them. This
    17  // allows using Sym pointer equality to test for Go identifier uniqueness when
    18  // handling selector expressions.
    19  //
    20  // Ideally, Sym should be used for representing Go language constructs,
    21  // while cmd/internal/obj.LSym is used for representing emitted artifacts.
    22  //
    23  // NOTE: In practice, things can be messier than the description above
    24  // for various reasons (historical, convenience).
    25  type Sym struct {
    26  	Linkname string
    27  
    28  	Pkg  *Pkg
    29  	Name string
    30  
    31  	// The unique ONAME, OTYPE, OPACK, or OLITERAL node that this symbol is
    32  	// bound to within the current scope. (Most parts of the compiler should
    33  	// prefer passing the Node directly, rather than relying on this field.)
    34  	//
    35  	// Deprecated: New code should avoid depending on Sym.Def. Add
    36  	// mdempsky@ as a reviewer for any CLs involving Sym.Def.
    37  	Def Object
    38  
    39  	flags bitset8
    40  }
    41  
    42  func (sym *Sym) OnExportList() bool
    43  func (sym *Sym) Uniq() bool
    44  func (sym *Sym) Siggen() bool
    45  func (sym *Sym) Asm() bool
    46  func (sym *Sym) Func() bool
    47  
    48  func (sym *Sym) SetOnExportList(b bool)
    49  func (sym *Sym) SetUniq(b bool)
    50  func (sym *Sym) SetSiggen(b bool)
    51  func (sym *Sym) SetAsm(b bool)
    52  func (sym *Sym) SetFunc(b bool)
    53  
    54  func (sym *Sym) IsBlank() bool
    55  
    56  // Deprecated: This method should not be used directly. Instead, use a
    57  // higher-level abstraction that directly returns the linker symbol
    58  // for a named object. For example, reflectdata.TypeLinksym(t) instead
    59  // of reflectdata.TypeSym(t).Linksym().
    60  func (sym *Sym) Linksym() *obj.LSym
    61  
    62  // Deprecated: This method should not be used directly. Instead, use a
    63  // higher-level abstraction that directly returns the linker symbol
    64  // for a named object. For example, (*ir.Name).LinksymABI(abi) instead
    65  // of (*ir.Name).Sym().LinksymABI(abi).
    66  func (sym *Sym) LinksymABI(abi obj.ABI) *obj.LSym
    67  
    68  // Less reports whether symbol a is ordered before symbol b.
    69  //
    70  // Symbols are ordered exported before non-exported, then by name, and
    71  // finally (for non-exported symbols) by package path.
    72  func (a *Sym) Less(b *Sym) bool
    73  
    74  // IsExported reports whether name is an exported Go symbol (that is,
    75  // whether it begins with an upper-case letter).
    76  func IsExported(name string) bool