github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/cmd/compile/internal/typecheck/func.go (about) 1 // Copyright 2009 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 typecheck 6 7 import ( 8 "github.com/shogo82148/std/cmd/compile/internal/ir" 9 "github.com/shogo82148/std/cmd/compile/internal/types" 10 "github.com/shogo82148/std/cmd/internal/src" 11 ) 12 13 // MakeDotArgs package all the arguments that match a ... T parameter into a []T. 14 func MakeDotArgs(pos src.XPos, typ *types.Type, args []ir.Node) ir.Node 15 16 // FixVariadicCall rewrites calls to variadic functions to use an 17 // explicit ... argument if one is not already present. 18 func FixVariadicCall(call *ir.CallExpr) 19 20 // FixMethodCall rewrites a method call t.M(...) into a function call T.M(t, ...). 21 func FixMethodCall(call *ir.CallExpr) 22 23 func AssertFixedCall(call *ir.CallExpr) 24 25 // ClosureType returns the struct type used to hold all the information 26 // needed in the closure for clo (clo must be a OCLOSURE node). 27 // The address of a variable of the returned type can be cast to a func. 28 func ClosureType(clo *ir.ClosureExpr) *types.Type 29 30 // MethodValueType returns the struct type used to hold all the information 31 // needed in the closure for a OMETHVALUE node. The address of a variable of 32 // the returned type can be cast to a func. 33 func MethodValueType(n *ir.SelectorExpr) *types.Type 34 35 // ClosureStructIter iterates through a slice of closure variables returning 36 // their type and offset in the closure struct. 37 type ClosureStructIter struct { 38 closureVars []*ir.Name 39 offset int64 40 next int 41 } 42 43 // NewClosureStructIter creates a new ClosureStructIter for closureVars. 44 func NewClosureStructIter(closureVars []*ir.Name) *ClosureStructIter 45 46 // Next returns the next name, type and offset of the next closure variable. 47 // A nil name is returned after the last closure variable. 48 func (iter *ClosureStructIter) Next() (n *ir.Name, typ *types.Type, offset int64)