typecheck

package standard library
go1.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 5, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const LocalDictName = ".dict"

The name used for dictionary parameters or local variables.

Variables

View Source
var HaveInlineBody = func(fn *ir.Func) bool {
	base.Fatalf("HaveInlineBody not overridden")
	panic("unreachable")
}

HaveInlineBody reports whether we have fn's inline body available for inlining.

It's a function literal so that it can be overridden for GOEXPERIMENT=unified.

View Source
var Target *ir.Package

Target is the package being compiled.

Functions

func AddImplicitDots

func AddImplicitDots(n *ir.SelectorExpr) *ir.SelectorExpr

AddImplicitDots finds missing fields in obj.field that will give the shortest unique addressing and modifies the tree with missing field names.

func AssertFixedCall added in go1.21.0

func AssertFixedCall(call *ir.CallExpr)

func AssignConv

func AssignConv(n ir.Node, t *types.Type, context string) ir.Node

func AssignExpr

func AssignExpr(n ir.Node) ir.Node

func AutoLabel

func AutoLabel(prefix string) *types.Sym

AutoLabel generates a new Name node for use with an automatically generated label. prefix is a short mnemonic (e.g. ".s" for switch) to help with debugging. It should begin with "." to avoid conflicts with user labels.

func BaseTypeIndex

func BaseTypeIndex(t *types.Type) int64

func CalcMethods

func CalcMethods(t *types.Type)

CalcMethods calculates all the methods (including embedding) of a non-interface type t.

func Call

func Call(pos src.XPos, callee ir.Node, args []ir.Node, dots bool) ir.Node

func Callee

func Callee(n ir.Node) ir.Node

func CheckFuncStack

func CheckFuncStack()

func ClosureType

func ClosureType(clo *ir.ClosureExpr) *types.Type

ClosureType returns the struct type used to hold all the information needed in the closure for clo (clo must be a OCLOSURE node). The address of a variable of the returned type can be cast to a func.

func Conv

func Conv(n ir.Node, t *types.Type) ir.Node

func ConvNop

func ConvNop(n ir.Node, t *types.Type) ir.Node

ConvNop converts node n to type t using the OCONVNOP op and typechecks the result with ctxExpr.

func ConvertVal added in go1.22.0

func ConvertVal(v constant.Value, t *types.Type, explicit bool) constant.Value

ConvertVal converts v into a representation appropriate for t. If no such representation exists, it returns constant.MakeUnknown() instead.

If explicit is true, then conversions from integer to string are also allowed.

func DeclFunc

func DeclFunc(fn *ir.Func)

DeclFunc declares the parameters for fn and adds it to Target.Funcs.

Before returning, it sets CurFunc to fn. When the caller is done constructing fn, it must call FinishFuncBody to restore CurFunc.

func DefaultLit

func DefaultLit(n ir.Node, t *types.Type) ir.Node

func DotField added in go1.22.0

func DotField(pos src.XPos, x ir.Node, index int) *ir.SelectorExpr

DotField returns a field selector expression that selects the index'th field of the given expression, which must be of struct or pointer-to-struct type.

func Expr

func Expr(n ir.Node) ir.Node

func Exprs

func Exprs(exprs []ir.Node)

func FinishFuncBody

func FinishFuncBody()

FinishFuncBody restores ir.CurFunc to its state before the last call to DeclFunc.

func FixMethodCall added in go1.18

func FixMethodCall(call *ir.CallExpr)

FixMethodCall rewrites a method call t.M(...) into a function call T.M(t, ...).

func FixVariadicCall

func FixVariadicCall(call *ir.CallExpr)

FixVariadicCall rewrites calls to variadic functions to use an explicit ... argument if one is not already present.

func Implements added in go1.21.0

func Implements(t, iface *types.Type) bool

Implements reports whether t implements the interface iface. t can be an interface, a type parameter, or a concrete type.

func ImplementsExplain added in go1.21.0

func ImplementsExplain(t, iface *types.Type) string

ImplementsExplain reports whether t implements the interface iface. t can be an interface, a type parameter, or a concrete type. If t does not implement iface, a non-empty string is returned explaining why.

func IndexConst

func IndexConst(n ir.Node) int64

IndexConst checks if Node n contains a constant expression representable as a non-negative int and returns its value. If n is not a constant expression, not representable as an integer, or negative, it returns -1. If n is too large, it returns -2.

func InitCoverage added in go1.20

func InitCoverage()

InitCoverage loads the definitions for routines called by code coverage instrumentation (similar to InitRuntime above).

func InitRuntime

func InitRuntime()

InitRuntime loads the definitions for the low-level runtime functions, so that the compiler can generate calls to them, but does not make them visible to user code.

func InitUniverse

func InitUniverse()

InitUniverse initializes the universe block.

func LinksymAddr added in go1.20

func LinksymAddr(pos src.XPos, lsym *obj.LSym, typ *types.Type) *ir.AddrExpr

LinksymAddr returns a new expression that evaluates to the address of lsym. typ specifies the type of the addressed memory.

func Lookdot

func Lookdot(n *ir.SelectorExpr, t *types.Type, dostrcmp int) *types.Field

Lookdot looks up field or method n.Sel in the type t and returns the matching field. It transforms the op of node n to ODOTINTER or ODOTMETH, if appropriate. It also may add a StarExpr node to n.X as needed for access to non-pointer methods. If dostrcmp is 0, it matches the field/method with the exact symbol as n.Sel (appropriate for exported fields). If dostrcmp is 1, it matches by name exactly. If dostrcmp is 2, it matches names with case folding.

func Lookdot1

func Lookdot1(errnode ir.Node, s *types.Sym, t *types.Type, fs []*types.Field, dostrcmp int) *types.Field

Lookdot1 looks up the specified method s in the list fs of methods, returning the matching field or nil. If dostrcmp is 0, it matches the symbols. If dostrcmp is 1, it matches by name exactly. If dostrcmp is 2, it matches names with case folding.

func Lookup

func Lookup(name string) *types.Sym

func LookupCoverage added in go1.20

func LookupCoverage(name string) *ir.Name

LookupCoverage looks up the Go function 'name' in package runtime/coverage. This function must follow the internal calling convention.

func LookupNum

func LookupNum(prefix string, n int) *types.Sym

LookupNum returns types.LocalPkg.LookupNum(prefix, n).

func LookupRuntime

func LookupRuntime(name string, types_ ...*types.Type) *ir.Name

LookupRuntime returns a function or variable declared in _builtin/runtime.go. If types_ is non-empty, successive occurrences of the "any" placeholder type will be substituted.

func LookupRuntimeABI

func LookupRuntimeABI(name string, abi obj.ABI) *obj.LSym

LookupRuntimeABI looks up a name in package runtime using the given ABI.

func LookupRuntimeFunc

func LookupRuntimeFunc(name string) *obj.LSym

LookupRuntimeFunc looks up Go function name in package runtime. This function must follow the internal calling convention.

func LookupRuntimeVar

func LookupRuntimeVar(name string) *obj.LSym

LookupRuntimeVar looks up a variable (or assembly function) name in package runtime. If this is a function, it may have a special calling convention.

func MakeDotArgs

func MakeDotArgs(pos src.XPos, typ *types.Type, args []ir.Node) ir.Node

MakeDotArgs package all the arguments that match a ... T parameter into a []T.

func MethodValueType added in go1.18

func MethodValueType(n *ir.SelectorExpr) *types.Type

MethodValueType returns the struct type used to hold all the information needed in the closure for a OMETHVALUE node. The address of a variable of the returned type can be cast to a func.

func NewFuncParams

func NewFuncParams(origs []*types.Field) []*types.Field

Given funarg struct list, return list of fn args.

func NewMethodExpr added in go1.22.0

func NewMethodExpr(pos src.XPos, recv *types.Type, sym *types.Sym) *ir.SelectorExpr

NewMethodExpr returns an OMETHEXPR node representing method expression "recv.sym".

func NewMethodType

func NewMethodType(sig *types.Type, recv *types.Type) *types.Type

f is method type, with receiver. return function type, receiver as first argument (or not).

func NodAddr

func NodAddr(n ir.Node) *ir.AddrExpr

NodAddr returns a node representing &n at base.Pos.

func NodAddrAt

func NodAddrAt(pos src.XPos, n ir.Node) *ir.AddrExpr

NodAddrAt returns a node representing &n at position pos.

func NodNil

func NodNil() ir.Node

func RangeExprType

func RangeExprType(t *types.Type) *types.Type

func RewriteMultiValueCall added in go1.18

func RewriteMultiValueCall(n ir.InitNode, call ir.Node)

RewriteMultiValueCall rewrites multi-valued f() to use temporaries, so the backend wouldn't need to worry about tuple-valued expressions.

func RewriteNonNameCall added in go1.19

func RewriteNonNameCall(n *ir.CallExpr)

RewriteNonNameCall replaces non-Name call expressions with temps, rewriting f()(...) to t0 := f(); t0(...).

func SetBaseTypeIndex added in go1.18

func SetBaseTypeIndex(t *types.Type, i, pi int64)

func Stmt

func Stmt(n ir.Node) ir.Node

func Stmts

func Stmts(stmts []ir.Node)

func TempAt

func TempAt(pos src.XPos, curfn *ir.Func, typ *types.Type) *ir.Name

make a new Node off the books.

func TparamName added in go1.18

func TparamName(exportName string) string

TparamName returns the real name of a type parameter, after stripping its qualifying prefix and reverting blank-name encoding. See TparamExportName for details.

func XDotField added in go1.22.0

func XDotField(pos src.XPos, x ir.Node, sym *types.Sym) *ir.SelectorExpr

XDotMethod returns an expression representing the field selection x.sym. If any implicit field selection are necessary, those are inserted too.

func XDotMethod added in go1.22.0

func XDotMethod(pos src.XPos, x ir.Node, sym *types.Sym, callee bool) *ir.SelectorExpr

XDotMethod returns an expression representing the method value x.sym (i.e., x is a value, not a type). If any implicit field selection are necessary, those are inserted too.

If callee is true, the result is an ODOTMETH/ODOTINTER, otherwise an OMETHVALUE.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL