noder

Imports

Imports #

"bytes"
"fmt"
"io"
"cmd/compile/internal/base"
"cmd/internal/bio"
"fmt"
"internal/buildcfg"
"internal/types/errors"
"regexp"
"sort"
"cmd/compile/internal/base"
"cmd/compile/internal/rangefunc"
"cmd/compile/internal/syntax"
"cmd/compile/internal/types2"
"cmd/internal/src"
"fmt"
"internal/buildcfg"
"strings"
"cmd/compile/internal/ir"
"cmd/compile/internal/syntax"
"internal/buildcfg"
"internal/pkgbits"
"io"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/types"
"cmd/internal/goobj"
"cmd/internal/obj"
"cmd/compile/internal/base"
"cmd/compile/internal/syntax"
"cmd/internal/src"
"fmt"
"cmd/compile/internal/syntax"
"encoding/hex"
"fmt"
"go/constant"
"internal/buildcfg"
"internal/pkgbits"
"path/filepath"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/dwarfgen"
"cmd/compile/internal/inline"
"cmd/compile/internal/inline/interleaved"
"cmd/compile/internal/ir"
"cmd/compile/internal/objw"
"cmd/compile/internal/reflectdata"
"cmd/compile/internal/staticinit"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/hash"
"cmd/internal/obj"
"cmd/internal/objabi"
"cmd/internal/src"
"cmd/compile/internal/types"
"cmd/compile/internal/types2"
"internal/pkgbits"
"go/constant"
"cmd/compile/internal/ir"
"cmd/compile/internal/syntax"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/compile/internal/types2"
"cmd/internal/src"
"errors"
"fmt"
"internal/buildcfg"
"internal/exportdata"
"internal/pkgbits"
"os"
pathpkg "path"
"runtime"
"strings"
"unicode"
"unicode/utf8"
"cmd/compile/internal/base"
"cmd/compile/internal/importer"
"cmd/compile/internal/ir"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/compile/internal/types2"
"cmd/internal/bio"
"cmd/internal/goobj"
"cmd/internal/objabi"
"errors"
"fmt"
"internal/buildcfg"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"unicode"
"unicode/utf8"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/syntax"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/internal/objabi"
"cmp"
"fmt"
"internal/buildcfg"
"internal/pkgbits"
"internal/types/errors"
"io"
"runtime"
"slices"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/inline"
"cmd/compile/internal/ir"
"cmd/compile/internal/pgoir"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/compile/internal/types2"
"cmd/internal/src"
"fmt"
"go/constant"
"go/token"
"go/version"
"internal/buildcfg"
"internal/pkgbits"
"os"
"strings"
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
"cmd/compile/internal/syntax"
"cmd/compile/internal/types"
"cmd/compile/internal/types2"

Constants & Variables

allowedStdPragmas var #

pragmas that are allowed in the std lib, but don't have a syntax.Pragma value (see lex.go) associated with them.

var allowedStdPragmas = map[string]bool{...}

anyTypeName var #

var anyTypeName = *ast.TypeAssertExpr

assignBlank const #

const assignBlank codeAssign = iota

assignDef const #

const assignDef

assignExpr const #

const assignExpr

basics var #

var basics = [...]**types.Type{...}

binOps var #

var binOps = [...]ir.Op{...}

bodyReader var #

bodyReader tracks where the serialized IR for a local or imported, generic function's body can be found.

var bodyReader = map[*ir.Func]pkgReaderIndex{...}

comparableTypeName var #

var comparableTypeName = *ast.TypeAssertExpr

declEnd const #

const declEnd codeDecl = iota

declFunc const #

const declFunc

declMethod const #

const declMethod

declOther const #

const declOther

declVar const #

const declVar

dictParamName const #

dictParamName is the name of the synthetic dictionary parameter added to shaped functions. N.B., this variable name is known to Delve: https://github.com/go-delve/delve/blob/cb91509630529e6055be845688fd21eb89ae8714/pkg/proc/eval.go#L28

const dictParamName = typecheck.LocalDictName

dirs var #

var dirs = [...]types.ChanDir{...}

exprAlignof const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprAlignof

exprAssert const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprAssert

exprBinaryOp const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprBinaryOp

exprCall const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprCall

exprCompLit const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprCompLit

exprConst const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprConst codeExpr = iota

exprConvert const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprConvert

exprFieldVal const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprFieldVal

exprFuncInst const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprFuncInst

exprFuncLit const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprFuncLit

exprGlobal const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprGlobal

exprIndex const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprIndex

exprLocal const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprLocal

exprMake const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprMake

exprMethodExpr const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprMethodExpr

exprMethodVal const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprMethodVal

exprNew const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprNew

exprOffsetof const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprOffsetof

exprRecv const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprRecv

exprReshape const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprReshape

exprRuntimeBuiltin const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprRuntimeBuiltin

exprSizeof const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprSizeof

exprSlice const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprSlice

exprUnaryOp const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprUnaryOp

exprZero const #

TODO(mdempsky): Split expr into addr, for lvalues.

const exprZero

funcPragmas const #

const funcPragmas = *ast.BinaryExpr

haveMethodValueWrappers var #

haveMethodValueWrappers lists methods for which we know we already have method value wrappers, because we found it in an imported package.

var haveMethodValueWrappers []methodValueWrapper

haveWrapperTypes var #

haveWrapperTypes lists types for which we know we already have method wrappers, because we found the type in an imported package.

var haveWrapperTypes []*types.Type

importBodyReader var #

importBodyReader tracks where the serialized IR for an imported, static (i.e., non-generic) function body can be read.

var importBodyReader = map[*types.Sym]pkgReaderIndex{...}

inlgen var #

var inlgen = 0

localPkgReader var #

localPkgReader holds the package reader used for reading the local package. It exists so the unified IR linker can refer back to it later.

var localPkgReader *pkgReader

needMethodValueWrappers var #

needMethodValueWrappers lists methods for which we may need to generate method value wrappers.

var needMethodValueWrappers []methodValueWrapper

needWrapperTypes var #

needWrapperTypes lists types for which we may need to generate method wrappers.

var needWrapperTypes []*types.Type

objReader var #

objReader maps qualified identifiers (represented as *types.Sym) to a pkgReader and corresponding index that can be used for reading that object's definition.

var objReader = map[*types.Sym]pkgReaderIndex{...}

renameinitgen var #

A function named init is a special case. It is called by the initialization before main is run. To make it unique within a package and also uncallable, the name, normally "pkg.init", is altered to "pkg.init.0".

var renameinitgen int

runeTypeName var #

var runeTypeName = *ast.TypeAssertExpr

stmtAssign const #

const stmtAssign

stmtAssignOp const #

const stmtAssignOp

stmtBlock const #

const stmtBlock

stmtBranch const #

const stmtBranch

stmtCall const #

const stmtCall

stmtEnd const #

const stmtEnd codeStmt = iota

stmtExpr const #

const stmtExpr

stmtFor const #

const stmtFor

stmtIf const #

const stmtIf

stmtIncDec const #

const stmtIncDec

stmtLabel const #

const stmtLabel

stmtReturn const #

const stmtReturn

stmtSelect const #

const stmtSelect

stmtSend const #

const stmtSend

stmtSwitch const #

const stmtSwitch

todoBodies var #

todoBodies holds the list of function bodies that still need to be constructed.

var todoBodies []*ir.Func

todoDicts var #

todoDicts holds the list of dictionaries that still need their runtime dictionary objects constructed.

var todoDicts []func()

unOps var #

var unOps = [...]ir.Op{...}

versionErrorRx var #

var versionErrorRx = *ast.CallExpr

Type Aliases

codeAssign type #

type codeAssign int

codeDecl type #

A codeDecl distinguishes among declaration encodings.

type codeDecl int

codeExpr type #

A codeExpr distinguishes among expression encodings.

type codeExpr int

codeStmt type #

A codeStmt distinguishes among statement encodings.

type codeStmt int

index type #

type index pkgbits.Index

Interfaces

ImplicitNode interface #

type ImplicitNode interface {
ir.Node
SetImplicit(x bool)
}

ender interface #

type ender interface {
End() syntax.Pos
}

poser interface #

type poser interface {
Pos() syntax.Pos
}

Structs

WasmExport struct #

WasmExport stores metadata associated with the //go:wasmexport pragma

type WasmExport struct {
Pos syntax.Pos
Name string
}

WasmImport struct #

WasmImport stores metadata associated with the //go:wasmimport pragma

type WasmImport struct {
Pos syntax.Pos
Module string
Name string
}

cycleFinder struct #

A cycleFinder detects anonymous interface cycles (go.dev/issue/56103).

type cycleFinder struct {
cyclic map[*types2.Interface]bool
}

declCollector struct #

declCollector is a visitor type that collects compiler-needed information about declarations that types2 doesn't track. Notably, it maps declared types and functions back to their declaration statement, keeps track of implicit type parameters, and assigns unique type "generation" numbers to local defined types.

type declCollector struct {
pw *pkgWriter
typegen *int
file *fileImports
withinFunc bool
implicits []*types2.TypeParam
}

derivedInfo struct #

A derivedInfo represents a reference to an encoded generic Go type.

type derivedInfo struct {
idx index
}

fileImports struct #

type fileImports struct {
importedEmbed bool
importedUnsafe bool
}

gcimports struct #

type gcimports struct {
ctxt *types2.Context
packages map[string]*types2.Package
}

itabInfo struct #

type itabInfo struct {
typ typeInfo
iface typeInfo
}

linker struct #

A linker combines a package's stub export data with any referenced elements from imported packages into a single, self-contained export data file.

type linker struct {
pw pkgbits.PkgEncoder
pkgs map[string]index
decls map[*types.Sym]index
bodies map[*types.Sym]index
}

linkname struct #

linkname records a //go:linkname directive.

type linkname struct {
pos syntax.Pos
local string
remote string
}

methodValueWrapper struct #

type methodValueWrapper struct {
rcvr *types.Type
method *types.Field
}

noder struct #

noder transforms package syntax's AST into a Node tree.

type noder struct {
file *syntax.File
linknames []linkname
pragcgobuf [][]string
err chan syntax.Error
}

objInfo struct #

An objInfo represents a reference to an encoded, instantiated (if applicable) Go object.

type objInfo struct {
idx index
explicits []typeInfo
}

pkgReader struct #

A pkgReader reads Unified IR export data.

type pkgReader struct {
pkgbits.PkgDecoder
posBases []*src.PosBase
pkgs []*types.Pkg
typs []*types.Type
newindex []index
}

pkgReaderIndex struct #

A pkgReaderIndex compactly identifies an index (and its corresponding dictionary) within a package's export data.

type pkgReaderIndex struct {
pr *pkgReader
idx index
dict *readerDict
methodSym *types.Sym
synthetic func(pos src.XPos, r *reader)
}

pkgWriter struct #

A pkgWriter constructs Unified IR export data from the results of running the types2 type checker on a Go compilation unit.

type pkgWriter struct {
pkgbits.PkgEncoder
m posMap
curpkg *types2.Package
info *types2.Info
rangeFuncBodyClosures map[*syntax.FuncLit]bool
posBasesIdx map[*syntax.PosBase]index
pkgsIdx map[*types2.Package]index
typsIdx map[types2.Type]index
objsIdx map[types2.Object]index
funDecls map[*types2.Func]*syntax.FuncDecl
typDecls map[*types2.TypeName]typeDeclGen
linknames map[types2.Object]string
cgoPragmas [][]string
}

posMap struct #

A posMap handles mapping from syntax.Pos to src.XPos.

type posMap struct {
bases map[*syntax.PosBase]*src.PosBase
cache struct{...}
}

posVar struct #

type posVar struct {
pos syntax.Pos
var_ *types2.Var
}

pragmaEmbed struct #

type pragmaEmbed struct {
Pos syntax.Pos
Patterns []string
}

pragmaPos struct #

type pragmaPos struct {
Flag ir.PragmaFlag
Pos syntax.Pos
}

pragmas struct #

*pragmas is the value stored in a syntax.pragmas during parsing.

type pragmas struct {
Flag ir.PragmaFlag
Pos []pragmaPos
Embeds []pragmaEmbed
WasmImport *WasmImport
WasmExport *WasmExport
}

reader struct #

A reader provides APIs for reading an individual element.

type reader struct {
pkgbits.Decoder
p *pkgReader
dict *readerDict
curfn *ir.Func
locals []*ir.Name
closureVars []*ir.Name
funarghack bool
methodSym *types.Sym
dictParam *ir.Name
synthetic func(pos src.XPos, r *reader)
scopeVars []int
marker dwarfgen.ScopeMarker
lastCloseScopePos src.XPos
inlCaller *ir.Func
inlCall *ir.CallExpr
inlFunc *ir.Func
inlTreeIndex int
inlPosBases map[*src.PosBase]*src.PosBase
suppressInlPos int
delayResults bool
retlabel *types.Sym
}

readerDict struct #

A readerDict represents an instantiated "compile-time dictionary," used for resolving any derived types needed for instantiating a generic object. A compile-time dictionary can either be "shaped" or "non-shaped." Shaped compile-time dictionaries are only used for instantiating shaped type definitions and function bodies, while non-shaped compile-time dictionaries are used for instantiating runtime dictionaries.

type readerDict struct {
shaped bool
baseSym *types.Sym
shapedObj *ir.Name
targs []*types.Type
implicits int
derived []derivedInfo
derivedTypes []*types.Type
typeParamMethodExprs []readerMethodExprInfo
subdicts []objInfo
rtypes []typeInfo
itabs []itabInfo
}

readerMethodExprInfo struct #

type readerMethodExprInfo struct {
typeParamIdx int
method *types.Sym
}

selectorInfo struct #

A selectorInfo represents a reference to an encoded field or method name (i.e., objects that can only be accessed using selector expressions).

type selectorInfo struct {
pkgIdx index
nameIdx index
}

typeDeclGen struct #

type typeDeclGen struct {
*syntax.TypeDecl
gen int
implicits []*types2.TypeParam
}

typeInfo struct #

A typeInfo represents a reference to an encoded Go type. If derived is true, then the typeInfo represents a generic Go type that contains type parameters. In this case, idx is an index into the readerDict.derived{,Types} arrays. Otherwise, the typeInfo represents a non-generic Go type, and idx is an index into the reader.typs array instead.

type typeInfo struct {
idx index
derived bool
}

writer struct #

A writer provides APIs for writing out an individual element.

type writer struct {
p *pkgWriter
pkgbits.Encoder
sig *types2.Signature
localsIdx map[*types2.Var]int
closureVars []posVar
closureVarsIdx map[*types2.Var]int
dict *writerDict
derived bool
}

writerDict struct #

A writerDict tracks types and objects that are used by a declaration.

type writerDict struct {
implicits []*types2.TypeParam
derived []derivedInfo
derivedIdx map[types2.Type]index
typeParamMethodExprs []writerMethodExprInfo
subdicts []objInfo
rtypes []typeInfo
itabs []itabInfo
}

writerMethodExprInfo struct #

type writerMethodExprInfo struct {
typeParamIdx int
methodInfo selectorInfo
}

Functions

Addr function #

func Addr(pos src.XPos, x ir.Node) *ir.AddrExpr

Deref function #

func Deref(pos src.XPos, typ *types.Type, x ir.Node) *ir.StarExpr

FixValue function #

FixValue returns val after converting and truncating it as appropriate for typ.

func FixValue(typ *types.Type, val constant.Value) constant.Value

Implicit function #

Implicit returns n after marking it as Implicit.

func Implicit(n ImplicitNode) ImplicitNode

Import method #

func (m *gcimports) Import(path string) (*types2.Package, error)

ImportFrom method #

func (m *gcimports) ImportFrom(path string, srcDir string, mode types2.ImportMode) (*types2.Package, error)

LoadPackage function #

func LoadPackage(filenames []string)

LookupFunc function #

LookupFunc returns the ir.Func for an arbitrary full symbol name if that function exists in the set of available export data. This allows lookup of arbitrary functions and methods that aren't otherwise referenced by the local package and thus haven't been read yet. TODO(prattmic): Does not handle instantiation of generic types. Currently profiles don't contain the original type arguments, so we won't be able to create the runtime dictionaries. TODO(prattmic): Hit rate of this function is usually fairly low, and errors are only used when debug logging is enabled. Consider constructing cheaper errors by default.

func LookupFunc(fullName string) (*ir.Func, error)

MakeWrappers function #

MakeWrappers constructs all wrapper methods needed for the target compilation unit.

func MakeWrappers(target *ir.Package)

Marker method #

func (c codeStmt) Marker() pkgbits.SyncMarker

Marker method #

func (c codeExpr) Marker() pkgbits.SyncMarker

Marker method #

func (c codeDecl) Marker() pkgbits.SyncMarker

Marker method #

func (c codeAssign) Marker() pkgbits.SyncMarker

PostLookupCleanup function #

PostLookupCleanup performs cleanup operations needed after a series of calls to LookupFunc, specifically invoking readBodies to post-process any funcs on the "todoBodies" list that were added as a result of the lookup operations.

func PostLookupCleanup()

Renameinit function #

func Renameinit() *types.Sym

String method #

func (p posVar) String() string

Value method #

func (c codeAssign) Value() int

Value method #

func (c codeExpr) Value() int

Value method #

func (c codeDecl) Value() int

Value method #

func (c codeStmt) Value() int

Visit method #

func (c *declCollector) Visit(n syntax.Node) syntax.Visitor

WriteExports function #

func WriteExports(out *bio.Writer)

addBody method #

addBody reads a function body reference from the element bitstream, and associates it with fn.

func (r *reader) addBody(fn *ir.Func, method *types.Sym)

addFingerprint function #

addFingerprint reads the linker fingerprint included at the end of the exportdata.

func addFingerprint(path string, data string) error

addLocal method #

func (r *reader) addLocal(name *ir.Name)

addLocal method #

addLocal records the declaration of a new local variable.

func (w *writer) addLocal(obj *types2.Var)

addTailCall function #

func addTailCall(pos src.XPos, fn *ir.Func, recv ir.Node, method *types.Field)

anyDerived method #

anyDerived reports whether any of info's explicit type arguments are derived types.

func (info objInfo) anyDerived() bool

asPragmaFlag function #

func asPragmaFlag(p syntax.Pragma) ir.PragmaFlag

asReader method #

func (pri pkgReaderIndex) asReader(k pkgbits.RelocKind, marker pkgbits.SyncMarker) *reader

asWasmExport function #

func asWasmExport(p syntax.Pragma) *WasmExport

asWasmImport function #

func asWasmImport(p syntax.Pragma) *WasmImport

assert function #

func assert(p bool)

assign method #

func (w *writer) assign(expr syntax.Expr)

assign method #

assign returns an assignee expression. It also reports whether the returned expression is a newly declared variable.

func (r *reader) assign() (ir.Node, bool)

assignList method #

func (r *reader) assignList() ([]*ir.Name, []ir.Node)

assignList method #

func (w *writer) assignList(expr syntax.Expr)

assignStmt method #

assignStmt writes out an assignment for "lhs = rhs".

func (w *writer) assignStmt(pos poser, lhs0 syntax.Expr, rhs0 syntax.Expr)

block function #

func block(stmts []ir.Node) ir.Node

blockStmt method #

func (w *writer) blockStmt(stmt *syntax.BlockStmt)

blockStmt method #

func (r *reader) blockStmt() []ir.Node

bodyIdx method #

bodyIdx returns the index for the given function body (specified by block), adding it to the export data

func (pw *pkgWriter) bodyIdx(sig *types2.Signature, block *syntax.BlockStmt, dict *writerDict) (idx index, closureVars []posVar)

bodyReaderFor function #

bodyReaderFor returns the pkgReaderIndex for reading fn's serialized IR, and whether one was found.

func bodyReaderFor(fn *ir.Func) (pri pkgReaderIndex, ok bool)

callShaped method #

callShaped emits a tail call to r.shapedFn, passing along the arguments to the current function.

func (r *reader) callShaped(pos src.XPos)

checkEmbed function #

func checkEmbed(decl *syntax.VarDecl, haveEmbed bool, withinFunc bool) error

checkFiles function #

checkFiles configures and runs the types2 checker on the given parsed source files and then returns the result. The map result value indicates which closures are generated from the bodies of range function loops.

func checkFiles(m posMap, noders []*noder) (*types2.Package, *types2.Info, map[*syntax.FuncLit]bool)

checkImportPath function #

func checkImportPath(path string, allowSpace bool) error

checkPragmas method #

func (pw *pkgWriter) checkPragmas(p syntax.Pragma, allowed ir.PragmaFlag, embedOK bool)

checkUnusedDuringParse method #

func (p *noder) checkUnusedDuringParse(pragma *pragmas)

closeAnotherScope method #

closeAnotherScope is like closeScope, but it reuses the same mark position as the last closeScope call. This is useful for "for" and "if" statements, as their implicit blocks always end at the same position as an explicit block.

func (r *reader) closeAnotherScope()

closeAnotherScope method #

func (w *writer) closeAnotherScope()

closeScope method #

func (w *writer) closeScope(pos syntax.Pos)

closeScope method #

func (r *reader) closeScope()

collectDecls method #

func (pw *pkgWriter) collectDecls(noders []*noder)

compLit method #

func (r *reader) compLit() ir.Node

compLit method #

func (w *writer) compLit(lit *syntax.CompositeLit)

convRTTI method #

convRTTI returns expressions appropriate for populating an ir.ConvExpr's TypeWord and SrcRType fields, respectively.

func (r *reader) convRTTI(pos src.XPos) (typeWord ir.Node, srcRType ir.Node)

convRTTI method #

convRTTI writes information so that the reader can construct expressions for converting from src to dst.

func (w *writer) convRTTI(src types2.Type, dst types2.Type)

convertExpr method #

func (w *writer) convertExpr(dst types2.Type, expr syntax.Expr, implicit bool)

curry method #

curry returns a function literal that calls fun with arg0 and (optionally) arg1, accepting additional arguments to the function literal as necessary to satisfy fun's signature. If nilCheck is true and arg0 is an interface value, then it's checked to be non-nil as an initial step at the point of evaluating the function literal itself.

func (r *reader) curry(origPos src.XPos, ifaceHack bool, fun ir.Node, arg0 ir.Node, arg1 ir.Node) ir.Node

declStmt method #

func (w *writer) declStmt(decl syntax.Decl)

declareParams method #

func (w *writer) declareParams(sig *types2.Signature)

declareParams method #

func (r *reader) declareParams()

deref2 function #

deref2 does a single deref of types2 type t, if it is a pointer type.

func deref2(t types2.Type) types2.Type

dictNameOf method #

dictNameOf returns the runtime dictionary corresponding to dict.

func (pr *pkgReader) dictNameOf(dict *readerDict) *ir.Name

dictWord method #

dictWord returns an expression to return the specified uintptr-typed word from the dictionary parameter.

func (r *reader) dictWord(pos src.XPos, idx int) ir.Node

distinctVars method #

func (w *writer) distinctVars(stmt *syntax.ForStmt) bool

doObj method #

doObj writes the RelocObj definition for obj to w, and the RelocObjExt definition to wext.

func (w *writer) doObj(wext *writer, obj types2.Object) pkgbits.CodeObj

doPkg method #

doPkg reads a package definition from the bitstream.

func (r *reader) doPkg() *types.Pkg

doTyp method #

func (r *reader) doTyp() *types.Type

end method #

func (m *posMap) end(p ender) src.XPos

equals method #

equals reports whether info and other represent the same Go object (i.e., same base object and identical type arguments, if any).

func (info objInfo) equals(other objInfo) bool

error method #

error is called concurrently if files are parsed concurrently.

func (p *noder) error(err error)

errorf method #

errorf reports a user error about thing p.

func (pw *pkgWriter) errorf(p poser, msg string, args ...interface{})

expandInline function #

expandInline reads in an extra copy of IR to populate fn.Inl.Dcl.

func expandInline(fn *ir.Func, pri pkgReaderIndex)

exportBody method #

exportBody exports the given function or method's body, if appropriate. local indicates whether it's a local function or method available on a locally declared type. (Due to cross-package type aliases, a method may be imported, but still available on a locally declared type.)

func (l *linker) exportBody(obj *ir.Name, local bool)

expr method #

expr writes the given expression into the function body bitstream.

func (w *writer) expr(expr syntax.Expr)

expr method #

expr reads and returns a typechecked expression.

func (r *reader) expr() (res ir.Node)

exprList method #

func (w *writer) exprList(expr syntax.Expr)

exprList method #

func (r *reader) exprList() []ir.Node

exprType method #

func (r *reader) exprType() ir.Node

exprType method #

func (w *writer) exprType(iface types2.Type, typ syntax.Expr)

exprs method #

func (r *reader) exprs() []ir.Node

exprs method #

func (w *writer) exprs(exprs []syntax.Expr)

fatalf method #

fatalf reports an internal compiler error about thing p.

func (pw *pkgWriter) fatalf(p poser, msg string, args ...interface{})

fieldIndex function #

fieldIndex returns the index of the struct field named by key.

func fieldIndex(info *types2.Info, str *types2.Struct, key *syntax.Name) int

finishWrapperFunc function #

func finishWrapperFunc(fn *ir.Func, target *ir.Package)

forStmt method #

func (r *reader) forStmt(label *types.Sym) ir.Node

forStmt method #

func (w *writer) forStmt(stmt *syntax.ForStmt)

freePackage function #

freePackage ensures the given package is garbage collected.

func freePackage(pkg *types2.Package)

funcBody method #

func (pri pkgReaderIndex) funcBody(fn *ir.Func)

funcBody method #

funcBody reads a function body definition from the element bitstream, and populates fn with it.

func (r *reader) funcBody(fn *ir.Func)

funcExt method #

func (r *reader) funcExt(name *ir.Name, method *types.Sym)

funcExt method #

func (w *writer) funcExt(obj *types2.Func)

funcInst method #

funcInst reads an instantiated function reference, and returns three (possibly nil) expressions related to it: baseFn is always non-nil: it's either a function of the appropriate type already, or it has an extra dictionary parameter as the first parameter. If dictPtr is non-nil, then it's a dictionary argument that must be passed as the first argument to baseFn. If wrapperFn is non-nil, then it's either the same as baseFn (if dictPtr is nil), or it's semantically equivalent to currying baseFn to pass dictPtr. (wrapperFn is nil when dictPtr is an expression that needs to be computed dynamically.) For callers that are creating a call to the returned function, it's best to emit a call to baseFn, and include dictPtr in the arguments list as appropriate. For callers that want to return the function without invoking it, they may return wrapperFn if it's non-nil; but otherwise, they need to create their own wrapper.

func (r *reader) funcInst(pos src.XPos) (wrapperFn ir.Node, baseFn ir.Node, dictPtr ir.Node)

funcInst method #

funcInst writes a reference to an instantiated function.

func (w *writer) funcInst(obj *types2.Func, targs *types2.TypeList)

funcLit method #

func (w *writer) funcLit(expr *syntax.FuncLit)

funcLit method #

func (r *reader) funcLit() ir.Node

hasCycle method #

hasCycle reports whether typ is part of an anonymous interface cycle.

func (f *cycleFinder) hasCycle(typ *types2.Interface) bool

hasFallthrough function #

hasFallthrough reports whether stmts ends in a fallthrough statement.

func hasFallthrough(stmts []syntax.Stmt) bool

hasImplicitTypeParams method #

hasImplicitTypeParams reports whether obj is a defined type with implicit type parameters (e.g., declared within a generic function or method).

func (pw *pkgWriter) hasImplicitTypeParams(obj *types2.TypeName) bool

hasTypeParams method #

func (dict *readerDict) hasTypeParams() bool

hasTypeParams method #

func (r *reader) hasTypeParams() bool

idealType function #

func idealType(tv syntax.TypeAndValue) types2.Type

ifStmt method #

func (r *reader) ifStmt() ir.Node

ifStmt method #

func (w *writer) ifStmt(stmt *syntax.IfStmt)

implicitConvExpr method #

implicitConvExpr is like expr, but if dst is non-nil and different from expr's type, then an implicit conversion operation is inserted at expr's position.

func (w *writer) implicitConvExpr(dst types2.Type, expr syntax.Expr)

importedDef method #

importedDef reports whether r is reading from an imported and non-generic element. If a type was found in an imported package, then we can assume that package (or one of its transitive dependencies) already generated method wrappers for it. Exception: If we're instantiating an imported generic type or function, we might be instantiating it with type arguments not previously seen before. TODO(mdempsky): Distinguish when a generic function or type was instantiated in an imported package so that we can add types to haveWrapperTypes instead.

func (r *reader) importedDef() bool

initDefn method #

initDefn marks the given names as declared by defn and populates its Init field with ODCL nodes. It then reports whether any names were so declared, which can be used to initialize defn.Def.

func (r *reader) initDefn(defn ir.InitNode, names []*ir.Name) bool

inlClosureFunc method #

inlClosureFunc constructs a new closure function, but correctly handles inlining.

func (r *reader) inlClosureFunc(origPos src.XPos, sig *types.Type, why ir.Op) *ir.Func

inlPos method #

inlPos returns the inlining-adjusted src.XPos corresponding to xpos, which must be a non-inlined position. When not inlining, this is just xpos.

func (r *reader) inlPos(xpos src.XPos) src.XPos

inlPosBase method #

inlPosBase returns the inlining-adjusted src.PosBase corresponding to oldBase, which must be a non-inlined position. When not inlining, this is just oldBase.

func (r *reader) inlPosBase(oldBase *src.PosBase) *src.PosBase

inlReturn method #

inlReturn returns a statement that can substitute for the given return statement when inlining.

func (r *reader) inlReturn(ret *ir.ReturnStmt, retvars []*ir.Name) *ir.BlockStmt

interfaceType method #

func (w *writer) interfaceType(typ *types2.Interface)

interfaceType method #

func (r *reader) interfaceType() *types.Type

isBuiltin method #

isBuiltin reports whether expr is a (possibly parenthesized) referenced to the specified built-in function.

func (pw *pkgWriter) isBuiltin(expr syntax.Expr, builtin string) bool

isCgoGeneratedFile function #

isCgoGeneratedFile reports whether pos is in a file generated by cgo, which is to say a file with name beginning with "_cgo_". Such files are allowed to contain cgo directives, and for security reasons (primarily misuse of linker flags), other files are not. See golang.org/issue/23672. Note that cmd/go ignores files whose names start with underscore, so the only _cgo_ files we will see from cmd/go are generated by cgo. It's easy to bypass this check by calling the compiler directly; we only protect against uses by cmd/go.

func isCgoGeneratedFile(pos syntax.Pos) bool

isDefinedType function #

isDefinedType reports whether obj is a defined type.

func isDefinedType(obj types2.Object) bool

isDriveLetter function #

func isDriveLetter(b byte) bool

isGlobal function #

isGlobal reports whether obj was declared at package scope. Caveat: blank objects are not declared.

func isGlobal(obj types2.Object) bool

isInterface function #

isInterface reports whether typ is known to be an interface type. If typ is a type parameter, then isInterface reports an internal compiler error instead.

func isInterface(typ types2.Type) bool

isNil function #

isNil reports whether expr is a (possibly parenthesized) reference to the predeclared nil value.

func isNil(p *pkgWriter, expr syntax.Expr) bool

isNotInHeap function #

isNotInHeap reports whether typ is or contains an element of type internal/runtime/sys.NotInHeap.

func isNotInHeap(typ types2.Type) bool

isPkgQual function #

isPkgQual reports whether the given selector expression is a package-qualified identifier.

func isPkgQual(info *types2.Info, sel *syntax.SelectorExpr) bool

isPtrTo function #

isPtrTo reports whether from is the type *to.

func isPtrTo(from types2.Type, to types2.Type) bool

isQuoted function #

func isQuoted(s string) bool

isSpace function #

func isSpace(c rune) bool

isTuple function #

isTuple reports whether typ is a tuple type.

func isTuple(typ types2.Type) bool

isTypeParam function #

func isTypeParam(t types2.Type) bool

isUntyped function #

isUntyped reports whether typ is an untyped type.

func isUntyped(typ types2.Type) bool

islocalname function #

is this path a local name? begins with ./ or ../ or /

func islocalname(name string) bool

itab method #

func (w *writer) itab(typ types2.Type, iface types2.Type)

itab method #

itab returns a (typ, iface) pair of types. typRType and ifaceRType are expressions that evaluate to the *runtime._type for typ and iface, respectively. If typ is a concrete type and iface is a non-empty interface type, then itab is an expression that evaluates to the *runtime.itab for the pair. Otherwise, itab is nil.

func (r *reader) itab(pos src.XPos) (typ *types.Type, typRType ir.Node, iface *types.Type, ifaceRType ir.Node, itab ir.Node)

itabIdx method #

itabIdx returns the index where the given encoded type pair's *runtime.itab value appears within this dictionary's itabs section, adding it if necessary.

func (dict *writerDict) itabIdx(typInfo typeInfo, ifaceInfo typeInfo) int

itabsOffset method #

itabsOffset returns the offset of the runtime dictionary's itabs section, in words.

func (dict *readerDict) itabsOffset() int

label method #

func (r *reader) label() *types.Sym

label method #

func (w *writer) label(label *syntax.Name)

lastFieldType function #

func lastFieldType(fields []*syntax.Field) syntax.Expr

lastNonEmptyStmt function #

lastNonEmptyStmt returns the last non-empty statement in list, if any.

func lastNonEmptyStmt(stmts []syntax.Stmt) syntax.Stmt

linkname method #

func (w *writer) linkname(obj types2.Object)

linkname method #

func (l *linker) linkname(w *pkgbits.Encoder, name *ir.Name)

linkname method #

func (r *reader) linkname(name *ir.Name)

localIdent method #

func (r *reader) localIdent() *types.Sym

localIdent method #

localIdent writes the name of a locally declared object (i.e., objects that can only be accessed by non-qualified name, within the context of a particular function).

func (w *writer) localIdent(obj types2.Object)

lookupFunction function #

func lookupFunction(pkg *types.Pkg, symName string) (*ir.Func, error)

lookupMethod function #

func lookupMethod(pkg *types.Pkg, symName string) (*ir.Func, error)

lookupObj function #

lookupObj returns the object that expr refers to, if any. If expr is an explicit instantiation of a generic object, then the instance object is returned as well.

func lookupObj(p *pkgWriter, expr syntax.Expr) (obj types2.Object, inst types2.Instance)

lsymIdx method #

func (l *linker) lsymIdx(w *pkgbits.Encoder, linkname string, lsym *obj.LSym) bool

makeSrcPosBase method #

makeSrcPosBase translates from a *syntax.PosBase to a *src.PosBase.

func (m *posMap) makeSrcPosBase(b0 *syntax.PosBase) *src.PosBase

makeXPos method #

func (m *posMap) makeXPos(pos syntax.Pos) src.XPos

mangle method #

func (dict *readerDict) mangle(sym *types.Sym) *types.Sym

maybeTypeAndValue method #

func (pw *pkgWriter) maybeTypeAndValue(x syntax.Expr) (syntax.TypeAndValue, bool)

method method #

func (w *writer) method(wext *writer, meth *types2.Func)

method method #

func (r *reader) method(rext *reader) *types.Field

methodExpr method #

methodExpr writes out a reference to the method selected by expr. sel should be the corresponding types2.Selection, and recv the type produced after any implicit addressing, dereferencing, and field selection. (Note: recv might differ from sel.Obj()'s receiver parameter in the case of interface types, and is needed for handling type parameter methods.)

func (w *writer) methodExpr(expr *syntax.SelectorExpr, recv types2.Type, sel *types2.Selection)

methodExpr method #

methodExpr reads a method expression reference, and returns three (possibly nil) expressions related to it: baseFn is always non-nil: it's either a function of the appropriate type already, or it has an extra dictionary parameter as the second parameter (i.e., immediately after the promoted receiver parameter). If dictPtr is non-nil, then it's a dictionary argument that must be passed as the second argument to baseFn. If wrapperFn is non-nil, then it's either the same as baseFn (if dictPtr is nil), or it's semantically equivalent to currying baseFn to pass dictPtr. (wrapperFn is nil when dictPtr is an expression that needs to be computed dynamically.) For callers that are creating a call to the returned method, it's best to emit a call to baseFn, and include dictPtr in the arguments list as appropriate. For callers that want to return a method expression without invoking it, they may return wrapperFn if it's non-nil; but otherwise, they need to create their own wrapper.

func (r *reader) methodExpr() (wrapperFn ir.Node, baseFn ir.Node, dictPtr ir.Node)

methodExprWrap method #

methodExprWrap returns a function literal that changes method's first parameter's type to recv, and uses implicits/deref/addr to select the appropriate receiver parameter to pass to method.

func (r *reader) methodExprWrap(origPos src.XPos, recv *types.Type, implicits []int, deref bool, addr bool, method ir.Node, dictPtr ir.Node) ir.Node

methodWrapper function #

func methodWrapper(derefs int, tbase *types.Type, method *types.Field, target *ir.Package)

multiExpr method #

multiExpr writes a sequence of expressions, where the i'th value is implicitly converted to dstType(i). It also handles when exprs is a single, multi-valued expression (e.g., the multi-valued argument in an f(g()) call, or the RHS operand in a comma-ok assignment).

func (w *writer) multiExpr(pos poser, dstType func(int) types2.Type, exprs []syntax.Expr)

multiExpr method #

func (r *reader) multiExpr() []ir.Node

namedType method #

namedType writes a use of the given named type into the bitstream.

func (w *writer) namedType(obj *types2.TypeName, targs *types2.TypeList)

namesAsExpr function #

namesAsExpr returns a list of names as a syntax.Expr.

func namesAsExpr(names []*syntax.Name) syntax.Expr

needWrapper method #

needWrapper records that wrapper methods may be needed at link time.

func (r *reader) needWrapper(typ *types.Type)

newPkgReader function #

func newPkgReader(pr pkgbits.PkgDecoder) *pkgReader

newPkgWriter function #

newPkgWriter returns an initialized pkgWriter for the specified package.

func newPkgWriter(m posMap, pkg *types2.Package, info *types2.Info, otherInfo map[*syntax.FuncLit]bool) *pkgWriter

newReader method #

func (pr *pkgReader) newReader(k pkgbits.RelocKind, idx index, marker pkgbits.SyncMarker) *reader

newWrapperFunc function #

func newWrapperFunc(pos src.XPos, sym *types.Sym, wrapper *types.Type, method *types.Field) *ir.Func

newWrapperType function #

newWrapperType returns a copy of the given signature type, but with the receiver parameter type substituted with recvType. If recvType is nil, newWrapperType returns a signature without a receiver parameter.

func newWrapperType(recvType *types.Type, method *types.Field) *types.Type

newWriter method #

func (pw *pkgWriter) newWriter(k pkgbits.RelocKind, marker pkgbits.SyncMarker) *writer

numWords method #

numWords returns the total number of words that comprise dict's runtime dictionary variable.

func (dict *readerDict) numWords() int64

obj method #

obj writes a use of the given object into the bitstream. If obj is a generic object, then explicits are the explicit type arguments used to instantiate it (i.e., used to substitute the object's own declared type parameters).

func (w *writer) obj(obj types2.Object, explicits *types2.TypeList)

obj method #

obj reads an instantiated object reference from the bitstream.

func (r *reader) obj() ir.Node

objDict method #

objDict writes the dictionary needed for reading the given object.

func (w *writer) objDict(obj types2.Object, dict *writerDict)

objDictIdx method #

objDictIdx reads and returns the specified object dictionary.

func (pr *pkgReader) objDictIdx(sym *types.Sym, idx index, implicits []*types.Type, explicits []*types.Type, shaped bool) (*readerDict, error)

objDictName method #

func (pr *pkgReader) objDictName(idx index, implicits []*types.Type, explicits []*types.Type) *ir.Name

objIdx method #

objIdx returns the specified object, instantiated with the given type arguments, if any. If shaped is true, then the shaped variant of the object is returned instead.

func (pr *pkgReader) objIdx(idx index, implicits []*types.Type, explicits []*types.Type, shaped bool) ir.Node

objIdx method #

objIdx returns the index for the given Object, adding it to the export data as needed.

func (pw *pkgWriter) objIdx(obj types2.Object) index

objIdxMayFail method #

objIdxMayFail is equivalent to objIdx, but returns an error rather than failing the build if this object requires type arguments and the incorrect number of type arguments were passed. Other sources of internal failure (such as duplicate definitions) still fail the build.

func (pr *pkgReader) objIdxMayFail(idx index, implicits []*types.Type, explicits []*types.Type, shaped bool) (ir.Node, error)

objInfo method #

objInfo writes a use of the given encoded object into the bitstream.

func (w *writer) objInfo(info objInfo)

objInfo method #

objInfo reads an instantiated object reference from the bitstream and returns the encoded reference to it, without instantiating it.

func (r *reader) objInfo() objInfo

objInstIdx method #

objInstIdx returns the encoded, instantiated object. If shaped is true, then the shaped variant of the object is returned instead.

func (pr *pkgReader) objInstIdx(info objInfo, dict *readerDict, shaped bool) ir.Node

objInstIdx method #

objInstIdx returns the indices for an object and a corresponding list of type arguments used to instantiate it, adding them to the export data as needed.

func (pw *pkgWriter) objInstIdx(obj types2.Object, explicits *types2.TypeList, dict *writerDict) objInfo

objTypeParams function #

objTypeParams returns the type parameters on the given object.

func objTypeParams(obj types2.Object) *types2.TypeParamList

op method #

func (r *reader) op() ir.Op

op method #

op writes an Op into the bitstream.

func (w *writer) op(op ir.Op)

openPackage function #

func openPackage(path string) (*os.File, error)

openScope method #

func (w *writer) openScope(pos syntax.Pos)

openScope method #

func (r *reader) openScope()

optExpr method #

func (r *reader) optExpr() ir.Node

optExpr method #

func (w *writer) optExpr(expr syntax.Expr)

optLabel method #

func (r *reader) optLabel() *types.Sym

optLabel method #

func (w *writer) optLabel(label *syntax.Name)

origPos method #

origPos reads a position from the bitstream, and returns both the original raw position and an inlining-adjusted position.

func (r *reader) origPos() (origPos src.XPos, inlPos src.XPos)

param method #

func (r *reader) param() *types.Field

param method #

func (w *writer) param(param *types2.Var)

params method #

func (r *reader) params() []*types.Field

params method #

func (w *writer) params(typ *types2.Tuple)

parseGoEmbed function #

parseGoEmbed parses the text following "//go:embed" to extract the glob patterns. It accepts unquoted space-separated patterns as well as double-quoted and back-quoted Go strings. go/build/read.go also processes these strings and contains similar logic.

func parseGoEmbed(args string) ([]string, error)

pkg method #

pkg writes a use of the given Package into the element bitstream.

func (w *writer) pkg(pkg *types2.Package)

pkg method #

pkg reads a package reference from the bitstream.

func (r *reader) pkg() *types.Pkg

pkgDecl method #

func (w *writer) pkgDecl(decl syntax.Decl)

pkgDecls method #

func (r *reader) pkgDecls(target *ir.Package)

pkgIdx method #

pkgIdx returns the specified package from the export data, reading it first if needed.

func (pr *pkgReader) pkgIdx(idx index) *types.Pkg

pkgIdx method #

pkgIdx returns the index for the given package, adding it to the package export data if needed.

func (pw *pkgWriter) pkgIdx(pkg *types2.Package) index

pkgInit method #

func (r *reader) pkgInit(self *types.Pkg, target *ir.Package)

pkgInit method #

func (w *writer) pkgInit(noders []*noder)

pkgInitOrder method #

pkgInitOrder creates a synthetic init function to handle any package-scope initialization statements.

func (r *reader) pkgInitOrder(target *ir.Package)

pkgInitOrder method #

func (w *writer) pkgInitOrder()

pkgObjs method #

func (r *reader) pkgObjs(target *ir.Package) []*ir.Name

pkgObjs method #

func (w *writer) pkgObjs(names ...*syntax.Name)

pkgRef method #

func (w *writer) pkgRef(idx index)

pos method #

func (m *posMap) pos(p poser) src.XPos

pos method #

pos writes the position of p into the element bitstream.

func (w *writer) pos(p poser)

pos method #

pos reads a position from the bitstream.

func (r *reader) pos() src.XPos

pos0 method #

func (r *reader) pos0() src.Pos

posBase method #

posBase writes a reference to the given PosBase into the element bitstream.

func (w *writer) posBase(b *syntax.PosBase)

posBase method #

posBase reads a position base from the bitstream.

func (r *reader) posBase() *src.PosBase

posBaseIdx method #

posBaseIdx returns the specified position base, reading it first if needed.

func (pr *pkgReader) posBaseIdx(idx index) *src.PosBase

posBaseIdx method #

posBaseIdx returns the index for the given PosBase.

func (pw *pkgWriter) posBaseIdx(b *syntax.PosBase) index

pragcgo method #

pragcgo is called concurrently if files are parsed concurrently.

func (p *noder) pragcgo(pos syntax.Pos, text string)

pragma method #

pragma is called concurrently if files are parsed concurrently.

func (p *noder) pragma(pos syntax.Pos, blankLine bool, text string, old syntax.Pragma) syntax.Pragma

pragmaFields function #

pragmaFields is similar to strings.FieldsFunc(s, isSpace) but does not split when inside double quoted regions and always splits before the start and after the end of a double quoted region. pragmaFields does not recognize escaped quotes. If a quote in s is not closed the part after the opening quote will not be returned as a field.

func pragmaFields(s string) []string

pragmaFlag method #

func (l *linker) pragmaFlag(w *pkgbits.Encoder, pragma ir.PragmaFlag)

pragmaFlag method #

func (w *writer) pragmaFlag(p ir.PragmaFlag)

pragmaFlag function #

func pragmaFlag(verb string) ir.PragmaFlag

pragmaFlag method #

func (r *reader) pragmaFlag() ir.PragmaFlag

qualifiedIdent method #

qualifiedIdent writes out the name of an object declared at package scope. (For now, it's also used to refer to local defined types.)

func (w *writer) qualifiedIdent(obj types2.Object)

qualifiedIdent method #

func (r *reader) qualifiedIdent() (pkg *types.Pkg, sym *types.Sym)

readBodies function #

readBodies iteratively expands all pending dictionaries and function bodies. If duringInlining is true, then the inline.InlineDecls is called as necessary on instantiations of imported generic functions, so their inlining costs can be computed.

func readBodies(target *ir.Package, duringInlining bool)

readExportData function #

readExportData returns the contents of GC-created unified export data.

func readExportData(f *os.File) (data string, err error)

readImportFile function #

readImportFile reads the import file for the given package path and returns its types.Pkg representation. If packages is non-nil, the types2.Package representation is also returned.

func readImportFile(path string, target *ir.Package, env *types2.Context, packages map[string]*types2.Package) (pkg1 *types.Pkg, pkg2 *types2.Package, err error)

readPackage function #

readPackage reads package export data from pr to populate importpkg. localStub indicates whether pr is reading the stub export data for the local package, as opposed to relocated export data for an import.

func readPackage(pr *pkgReader, importpkg *types.Pkg, localStub bool)

recvBase function #

recvBase returns the base type for the given receiver parameter.

func recvBase(recv *types2.Var) *types2.Named

recvExpr method #

recvExpr writes out expr.X, but handles any implicit addressing, dereferencing, and field selections appropriate for the method selection.

func (w *writer) recvExpr(expr *syntax.SelectorExpr, sel *types2.Selection) types2.Type

relocAll method #

relocAll ensures that all elements specified by pr and relocs are copied into the output export data file, and returns the corresponding indices in the output.

func (l *linker) relocAll(pr *pkgReader, relocs []pkgbits.RelocEnt) []pkgbits.RelocEnt

relocCommon method #

relocCommon copies the specified element from pr into w, recursively relocating any referenced elements as well.

func (l *linker) relocCommon(pr *pkgReader, w *pkgbits.Encoder, k pkgbits.RelocKind, idx index)

relocFuncExt method #

func (l *linker) relocFuncExt(w *pkgbits.Encoder, name *ir.Name)

relocIdx method #

relocIdx ensures a single element is copied into the output export data file, and returns the corresponding index in the output.

func (l *linker) relocIdx(pr *pkgReader, k pkgbits.RelocKind, idx index) index

relocObj method #

relocObj copies the specified object from pr into the output export data file, rewriting its compiler-private extension data (e.g., adding inlining cost and escape analysis results for functions).

func (l *linker) relocObj(pr *pkgReader, idx index) index

relocPkg method #

relocPkg copies the specified package from pr into the output export data file, rewriting its import path to match how it was imported. TODO(mdempsky): Since CL 391014, we already have the compilation unit's import path, so there should be no need to rewrite packages anymore.

func (l *linker) relocPkg(pr *pkgReader, idx index) index

relocString method #

relocString copies the specified string from pr into the output export data file, deduplicating it against other strings.

func (l *linker) relocString(pr *pkgReader, idx index) index

relocTypeExt method #

func (l *linker) relocTypeExt(w *pkgbits.Encoder, name *ir.Name)

relocVarExt method #

func (l *linker) relocVarExt(w *pkgbits.Encoder, name *ir.Name)

resolveImportPath function #

resolveImportPath resolves an import path as it appears in a Go source file to the package's full path.

func resolveImportPath(path string) (string, error)

rttiWord method #

rttiWord is like dictWord, but converts it to *byte (the type used internally to represent *runtime._type and *runtime.itab).

func (r *reader) rttiWord(pos src.XPos, idx int) ir.Node

rtype method #

rtype writes information so that the reader can construct an expression of type *runtime._type representing typ.

func (w *writer) rtype(typ types2.Type)

rtype method #

rtype reads a type reference from the element bitstream, and returns an expression of type *runtime._type representing that type.

func (r *reader) rtype(pos src.XPos) ir.Node

rtype0 method #

func (r *reader) rtype0(pos src.XPos) (typ *types.Type, rtype ir.Node)

rtypeIdx method #

rtypeIdx returns the index where the given encoded type's *runtime._type value appears within this dictionary's rtypes section, adding it if necessary.

func (dict *writerDict) rtypeIdx(newInfo typeInfo) int

rtypeInfo method #

func (w *writer) rtypeInfo(info typeInfo)

rtypesOffset method #

rtypesOffset returns the offset of the runtime dictionary's rtypes section, in words.

func (dict *readerDict) rtypesOffset() int

safeArg function #

safeArg reports whether arg is a "safe" command-line argument, meaning that when it appears in a command-line, it probably doesn't have some special meaning other than its own name. This is copied from SafeArg in cmd/go/internal/load/pkg.go.

func safeArg(name string) bool

selectStmt method #

func (r *reader) selectStmt(label *types.Sym) ir.Node

selectStmt method #

func (w *writer) selectStmt(stmt *syntax.SelectStmt)

selector method #

func (r *reader) selector() *types.Sym

selector method #

selector writes the name of a field or method (i.e., objects that can only be accessed using selector expressions).

func (w *writer) selector(obj types2.Object)

selectorIdx method #

func (pw *pkgWriter) selectorIdx(obj types2.Object) selectorInfo

selectorInfo method #

func (w *writer) selectorInfo(info selectorInfo)

setBasePos function #

func setBasePos(pos src.XPos)

setType function #

func setType(n ir.Node, typ *types.Type)

setValue function #

func setValue(name *ir.Name, val constant.Value)

shapeSig function #

shapeSig returns a copy of fn's signature, except adding a dictionary parameter and promoting the receiver parameter (if any) to a normal parameter. The parameter types.Fields are all copied too, so their Nname fields can be initialized for use by the shape function.

func shapeSig(fn *ir.Func, dict *readerDict) *types.Type

shapedMethodExpr function #

shapedMethodExpr returns the specified method on the given shaped type.

func shapedMethodExpr(pos src.XPos, obj *ir.Name, sym *types.Sym) *ir.SelectorExpr

shapify function #

shapify returns the shape type for targ. If basic is true, then the type argument is used to instantiate a type parameter whose constraint is a basic interface.

func shapify(targ *types.Type, basic bool) *types.Type

signature method #

func (r *reader) signature(recv *types.Field) *types.Type

signature method #

func (w *writer) signature(sig *types2.Signature)

sliceElem function #

func sliceElem(typ types2.Type) types2.Type

splitAlias function #

splitAlias is like splitNamed, but for an alias type.

func splitAlias(typ *types2.Alias) (*types2.TypeName, *types2.TypeList)

splitNamed function #

splitNamed decomposes a use of a defined type into its original type definition and the type arguments used to instantiate it.

func splitNamed(typ *types2.Named) (*types2.TypeName, *types2.TypeList)

staticBool method #

staticBool analyzes a boolean expression and reports whether it's always true (positive result), always false (negative result), or unknown (zero). It also simplifies the expression while preserving semantics, if possible.

func (pw *pkgWriter) staticBool(ep *syntax.Expr) int

stmt method #

func (r *reader) stmt() ir.Node

stmt method #

stmt writes the given statement into the function body bitstream.

func (w *writer) stmt(stmt syntax.Stmt)

stmt1 method #

func (w *writer) stmt1(stmt syntax.Stmt)

stmt1 method #

func (r *reader) stmt1(tag codeStmt, out *ir.Nodes) ir.Node

stmts method #

func (r *reader) stmts() ir.Nodes

stmts method #

func (w *writer) stmts(stmts []syntax.Stmt)

structType method #

func (w *writer) structType(typ *types2.Struct)

structType method #

func (r *reader) structType() *types.Type

subdictIdx method #

subdictIdx returns the index where the given encoded object's runtime dictionary appears within this dictionary's subdictionary section, adding it if necessary.

func (dict *writerDict) subdictIdx(newInfo objInfo) int

subdictsOffset method #

subdictsOffset returns the offset of the runtime dictionary's subdictionary section, in words.

func (dict *readerDict) subdictsOffset() int

switchStmt method #

func (r *reader) switchStmt(label *types.Sym) ir.Node

switchStmt method #

func (w *writer) switchStmt(stmt *syntax.SwitchStmt)

syntheticArgs method #

syntheticArgs returns the recvs and params arguments passed to the current function.

func (r *reader) syntheticArgs() ir.Nodes

syntheticBody method #

syntheticBody adds a synthetic body to r.curfn if appropriate, and reports whether it did.

func (r *reader) syntheticBody(pos src.XPos) bool

syntheticClosure method #

syntheticClosure constructs a synthetic function literal for currying dictionary arguments. origPos is the position used for the closure, which must be a non-inlined position. typ is the function literal's signature type. captures is a list of expressions that need to be evaluated at the point of function literal evaluation and captured by the function literal. If ifaceHack is true and captures[1] is an interface type, it's checked to be non-nil after evaluation. addBody is a callback function to populate the function body. The list of captured values passed back has the captured variables for use within the function literal, corresponding to the expressions in captures.

func (r *reader) syntheticClosure(origPos src.XPos, typ *types.Type, ifaceHack bool, captures ir.Nodes, addBody func(pos src.XPos, r *reader, captured []ir.Node)) ir.Node

syntheticSig function #

syntheticSig duplicates and returns the params and results lists for sig, but renaming anonymous parameters so they can be assigned ir.Names.

func syntheticSig(sig *types.Type) (params []*types.Field, results []*types.Field)

syntheticTailCall method #

syntheticTailCall emits a tail call to fn, passing the given arguments list.

func (r *reader) syntheticTailCall(pos src.XPos, fn ir.Node, args ir.Nodes)

temp method #

temp returns a new autotemp of the specified type.

func (r *reader) temp(pos src.XPos, typ *types.Type) *ir.Name

tempCopy method #

tempCopy declares and returns a new autotemp initialized to the value of expr.

func (r *reader) tempCopy(pos src.XPos, expr ir.Node, init *ir.Nodes) *ir.Name

terminates method #

terminates reports whether stmt terminates normal control flow (i.e., does not merely advance to the following statement).

func (pw *pkgWriter) terminates(stmt syntax.Stmt) bool

trimFilename function #

trimFilename returns the "trimmed" filename of b, which is the absolute filename after applying -trimpath processing. This filename form is suitable for use in object files and export data. If b's filename has already been trimmed (i.e., because it was read in from an imported package's export data), then the filename is returned unchanged.

func trimFilename(b *syntax.PosBase) string

typ method #

typ writes a use of the given type into the bitstream.

func (w *writer) typ(typ types2.Type)

typ method #

func (r *reader) typ() *types.Type

typIdx method #

typIdx returns the index where the export data description of type can be read back in. If no such index exists yet, it's created. typIdx also reports whether typ is a derived type; that is, whether its identity depends on type parameters.

func (pw *pkgWriter) typIdx(typ types2.Type, dict *writerDict) typeInfo

typIdx method #

typIdx returns the specified type. If info specifies a derived type, it's resolved within the given dictionary. If wrapped is true, then method wrappers will be generated, if appropriate.

func (pr *pkgReader) typIdx(info typeInfo, dict *readerDict, wrapped bool) *types.Type

typInfo method #

func (r *reader) typInfo() typeInfo

typInfo method #

typInfo writes a use of the given type (specified as a typeInfo instead) into the bitstream.

func (w *writer) typInfo(info typeInfo)

typListIdx method #

typListIdx returns a list of the specified types, resolving derived types within the given dictionary.

func (pr *pkgReader) typListIdx(infos []typeInfo, dict *readerDict) []*types.Type

typWrapped method #

typWrapped is like typ, but allows suppressing generation of unnecessary wrappers as a compile-time optimization.

func (r *reader) typWrapped(wrapped bool) *types.Type

typeAndValue method #

func (pw *pkgWriter) typeAndValue(x syntax.Expr) syntax.TypeAndValue

typeExprEndPos function #

typeExprEndPos returns the position that noder would leave base.Pos after parsing the given type expression. Deprecated: This function exists to emulate position semantics from Go 1.17, necessary for compatibility with the backend DWARF generation logic that assigns variables to their appropriate scope.

func typeExprEndPos(expr0 syntax.Expr) syntax.Pos

typeExt method #

func (w *writer) typeExt(obj *types2.TypeName)

typeExt method #

func (r *reader) typeExt(name *ir.Name)

typeOf method #

typeOf returns the Type of the given value expression.

func (pw *pkgWriter) typeOf(expr syntax.Expr) types2.Type

typeParamIndex method #

typeParamIndex returns the index of the given type parameter within the dictionary. This may differ from typ.Index() when there are implicit type parameters due to defined types declared within a generic function or method.

func (dict *writerDict) typeParamIndex(typ *types2.TypeParam) int

typeParamMethodExprIdx method #

typeParamMethodExprIdx returns the index where the given encoded method expression function pointer appears within this dictionary's type parameters method expressions section, adding it if necessary.

func (dict *writerDict) typeParamMethodExprIdx(typeParamIdx int, methodInfo selectorInfo) int

typeParamMethodExprsOffset method #

typeParamMethodExprsOffset returns the offset of the runtime dictionary's type parameter method expressions section, in words.

func (dict *readerDict) typeParamMethodExprsOffset() int

typeParamNames method #

func (r *reader) typeParamNames()

typeParamNames method #

func (w *writer) typeParamNames(tparams *types2.TypeParamList)

typed function #

typed returns n after setting its type to typ.

func typed(typ *types.Type, n ir.Node) ir.Node

unexpected method #

unexpected reports a fatal error about a thing of unexpected dynamic type.

func (pw *pkgWriter) unexpected(what string, p poser)

unified function #

unified constructs the local package's Internal Representation (IR) from its syntax tree (AST). The pipeline contains 2 steps: 1. Generate the export data "stub". 2. Generate the IR from the export data above. The package data "stub" at step (1) contains everything from the local package, but nothing that has been imported. When we're actually writing out export data to the output files (see writeNewExport), we run the "linker", which: - Updates compiler extensions data (e.g. inlining cost, escape analysis results). - Handles re-exporting any transitive dependencies. - Prunes out any unnecessary details (e.g. non-inlineable functions, because any downstream importers only care about inlinable functions). The source files are typechecked twice: once before writing the export data using types2, and again after reading the export data using gc/typecheck. The duplication of work will go away once we only use the types2 type checker, removing the gc/typecheck step. For now, it is kept because: - It reduces the engineering costs in maintaining a fork of typecheck (e.g. no need to backport fixes like CL 327651). - It makes it easier to pass toolstash -cmp. - Historically, we would always re-run the typechecker after importing a package, even though we know the imported data is valid. It's not ideal, but it's not causing any problems either. - gc/typecheck is still in charge of some transformations, such as rewriting multi-valued function calls or transforming ir.OINDEX to ir.OINDEXMAP. Using the syntax tree with types2, which has a complete representation of generics, the unified IR has the full typed AST needed for introspection during step (1). In other words, we have all the necessary information to build the generic IR form (see writer.captureVars for an example).

func unified(m posMap, noders []*noder)

unifiedHaveInlineBody function #

unifiedHaveInlineBody reports whether we have the function body for fn, so we can inline it.

func unifiedHaveInlineBody(fn *ir.Func) bool

unifiedInlineCall function #

unifiedInlineCall implements inline.NewInline by re-reading the function body from its Unified IR export data.

func unifiedInlineCall(callerfn *ir.Func, call *ir.CallExpr, fn *ir.Func, inlIndex int) *ir.InlinedCallExpr

unionType method #

func (r *reader) unionType() *types.Type

unionType method #

func (w *writer) unionType(typ *types2.Union)

useLocal method #

func (r *reader) useLocal() *ir.Name

useLocal method #

useLocal writes a reference to the given local or free variable into the bitstream.

func (w *writer) useLocal(pos syntax.Pos, obj *types2.Var)

usedLocals function #

usedLocals returns a set of local variables that are used within body.

func usedLocals(body []ir.Node) ir.NameSet

varDictIndex method #

varDictIndex populates name.DictIndex if name is a derived type.

func (r *reader) varDictIndex(name *ir.Name)

varDictIndex method #

varDictIndex writes out information for populating DictIndex for the ir.Name that will represent obj.

func (w *writer) varDictIndex(obj *types2.Var)

varExt method #

func (w *writer) varExt(obj *types2.Var)

varExt method #

func (r *reader) varExt(name *ir.Name)

varType method #

varType returns the type of dict's runtime dictionary variable.

func (dict *readerDict) varType() *types.Type

visit method #

visit recursively walks typ0 to check any referenced interface types.

func (f *cycleFinder) visit(typ0 types2.Type) bool

withTParams method #

func (c *declCollector) withTParams(obj types2.Object) *declCollector

wrapMethodValue function #

func wrapMethodValue(recvType *types.Type, method *types.Field, target *ir.Package, needed bool)

wrapType function #

func wrapType(typ *types.Type, target *ir.Package, seen map[string]*types.Type, needed bool)

writePkgStub function #

writePkgStub type checks the given parsed source files, writes an export data package stub representing them, and returns the result.

func writePkgStub(m posMap, noders []*noder) string

writeUnifiedExport function #

writeUnifiedExport writes to `out` the finalized, self-contained Unified IR export data file for the current compilation unit.

func writeUnifiedExport(out io.Writer)

Generated with Arrow