typecheck

package standard library
go1.17.9 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2022 License: BSD-3-Clause Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const Go117ExportTypes = go117ExportTypes

Variables

View Source
var (
	NeedITab        = func(t, itype *types.Type) {}
	NeedRuntimeType = func(*types.Type) {}
)
View Source
var DeclContext ir.Class = ir.PEXTERN // PEXTERN/PAUTO
View Source
var (
	// DeclImporter maps from imported identifiers to an importer
	// and offset where that identifier's declaration can be read.
	DeclImporter = map[*types.Sym]iimporterAndOffset{}
)
View Source
var DirtyAddrtaken = false

If DirtyAddrtaken is true, then there are OADDR whose corresponding arguments have not yet been marked as Addrtaken.

View Source
var DotImportRefs map[*ir.Ident]*ir.PkgName

DotImportRefs maps idents introduced by importDot back to the ir.PkgName they were dot-imported through.

View Source
var IncrementalAddrtaken = false

If IncrementalAddrtaken is false, we do not compute Addrtaken for an OADDR Node when it is built. The Addrtaken bits are set in bulk by computeAddrtaken. If IncrementalAddrtaken is true, then when an OADDR Node is built the Addrtaken field of its argument is updated immediately.

View Source
var InitTodoFunc = ir.NewFunc(base.Pos)

Function collecting autotmps generated during typechecking, to be included in the package-level init function.

View Source
var Target *ir.Package

Target is the package being compiled.

View Source
var TypeGen int32

TypeGen tracks the number of function-scoped defined types that have been declared. It's used to generate unique linker symbols for their runtime type descriptors.

View Source
var TypecheckAllowed bool

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 AllImportedBodies

func AllImportedBodies()

AllImportedBodies reads in the bodies of all imported functions and typechecks them, if needed.

func AssignConv

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

func AssignExpr

func AssignExpr(n ir.Node) ir.Node

func Assignop

func Assignop(src, dst *types.Type) (ir.Op, string)

Is type src assignment compatible to type dst? If so, return op code to use in conversion. If not, return OXXX. In this case, the string return parameter may hold a reason why. In all other cases, it'll be the empty string.

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)

func Call

func Call(call *ir.CallExpr)

func Callee

func Callee(n ir.Node) ir.Node

func CheckFuncStack

func CheckFuncStack()

func CheckMapKeys

func CheckMapKeys()

func CheckReturn

func CheckReturn(fn *ir.Func)

CheckReturn makes sure that fn terminates appropriately.

func CheckUnused

func CheckUnused(fn *ir.Func)

CheckUnused checks for any declared variables that weren't used.

func ClosureName

func ClosureName(outerfunc *ir.Func) *types.Sym

ClosureName generates a new unique name for a closure within outerfunc.

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 ComputeAddrtaken

func ComputeAddrtaken(top []ir.Node)

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 Convertop

func Convertop(srcConstant bool, src, dst *types.Type) (ir.Op, string)

Can we convert a value of type src to a value of type dst? If so, return op code to use in conversion (maybe OCONVNOP). If not, return OXXX. In this case, the string return parameter may hold a reason why. In all other cases, it'll be the empty string. srcConstant indicates whether the value of type src is a constant.

func DeclFunc

func DeclFunc(sym *types.Sym, tfn ir.Ntype) *ir.Func

func Declare

func Declare(n *ir.Name, ctxt ir.Class)

Declare records that Node n declares symbol n.Sym in the specified declaration context.

func DeclareUniverse

func DeclareUniverse()

DeclareUniverse makes the universe block visible within the current package.

func DefaultLit

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

func EvalConst

func EvalConst(n ir.Node) ir.Node

EvalConst returns a constant-evaluated expression equivalent to n. If n is not a constant, EvalConst returns n. Otherwise, EvalConst returns a new OLITERAL with the same value as n, and with .Orig pointing back to n.

func Export

func Export(n *ir.Name)

Export marks n for export (or reexport).

func Expr

func Expr(n ir.Node) ir.Node

func Exprs

func Exprs(exprs []ir.Node)

func FakeRecv

func FakeRecv() *types.Field

TODO(mdempsky): Move to package types.

func FinishFuncBody

func FinishFuncBody()

finish the body. called in auto-declaration context. returns in extern-declaration context.

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 Func

func Func(fn *ir.Func)

func FuncBody

func FuncBody(n *ir.Func)

func ImportBody

func ImportBody(fn *ir.Func)

ImportBody reads in the dcls and body of an imported function (which should not yet have been read in).

func ImportedBody

func ImportedBody(fn *ir.Func)

ImportedBody returns immediately if the inlining information for fn is populated. Otherwise, fn must be an imported function. If so, ImportedBody loads in the dcls and body for fn, and typechecks as needed.

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 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 IsCmp

func IsCmp(op ir.Op) bool

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.Fields, 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 LookupNum

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

LookupNum looks up the symbol starting with prefix and ending with the decimal n. If prefix is too long, LookupNum panics.

func LookupRuntime

func LookupRuntime(name string) *ir.Name

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(typ *types.Type, args []ir.Node) ir.Node

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

func MethodValueWrapper

func MethodValueWrapper(dot *ir.SelectorExpr) *ir.Func

MethodValueWrapper returns the DCLFUNC node representing the wrapper function (*-fm) needed for the given method value. If the wrapper function hasn't already been created yet, it's created and added to Target.Decls.

TODO(mdempsky): Move into walk. This isn't part of type checking.

func NewFuncParams

func NewFuncParams(tl *types.Type, mustname bool) []*ir.Field

Given funarg struct list, return list of fn args.

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 NewName

func NewName(s *types.Sym) *ir.Name

newname returns a new ONAME Node associated with symbol s.

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

nodAddrPos returns a node representing &n at position pos.

func NodNil

func NodNil() ir.Node

func OrigBool

func OrigBool(n ir.Node, v bool) ir.Node

func OrigConst

func OrigConst(n ir.Node, v constant.Value) ir.Node

OrigConst returns an OLITERAL with orig n and value v.

func OrigInt

func OrigInt(n ir.Node, v int64) ir.Node

func PartialCallType

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

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

func RangeExprType

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

func ReadImports

func ReadImports(pkg *types.Pkg, in *bio.Reader) (fingerprint goobj.FingerprintType)

func Redeclared

func Redeclared(pos src.XPos, s *types.Sym, where string)

Redeclared emits a diagnostic about symbol s being redeclared at pos.

func Resolve

func Resolve(n ir.Node) (res ir.Node)

Resolve ONONAME to definition, if any.

func StartFuncBody

func StartFuncBody(fn *ir.Func)

declare the function proper and declare the arguments. called in extern-declaration context returns in auto-declaration context.

func Stmt

func Stmt(n ir.Node) ir.Node

func Stmts

func Stmts(stmts []ir.Node)

func SubstArgTypes

func SubstArgTypes(old *ir.Name, types_ ...*types.Type) *ir.Name

SubstArgTypes substitutes the given list of types for successive occurrences of the "any" placeholder in the type syntax expression n.Type. The result of SubstArgTypes MUST be assigned back to old, e.g.

n.Left = SubstArgTypes(n.Left, t1, t2)

func Temp

func Temp(t *types.Type) *ir.Name

func TempAt

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

make a new Node off the books

func WriteExports

func WriteExports(out *bufio.Writer)

Types

This section is empty.

Jump to

Keyboard shortcuts

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