type Callee … func (callee *Callee) String() string { … } type gobCallee … type returnOperandFlags … const nonTrivialResult … const untypedNilResult … type freeRef … type object … // AnalyzeCallee analyzes a function that is a candidate for inlining // and returns a Callee that describes it. The Callee object, which is // serializable, can be passed to one or more subsequent calls to // Inline, each with a different Caller. // // This design allows separate analysis of callers and callees in the // golang.org/x/tools/go/analysis framework: the inlining information // about a callee can be recorded as a "fact". // // The content should be the actual input to the compiler, not the // apparent source file according to any //line directives that // may be present within it. func AnalyzeCallee(logf func(string, ...any), fset *token.FileSet, pkg *types.Package, info *types.Info, decl *ast.FuncDecl, content []byte) (*Callee, error) { … } // parseCompact parses a Go source file of the form "package _\n func f() { ... }" // and returns the sole function declaration. func parseCompact(content []byte) (*token.FileSet, *ast.FuncDecl, error) { … } type paramInfo … type refInfo … // analyzeParams computes information about parameters of function fn, // including a simple "address taken" escape analysis. // // It returns two new arrays, one of the receiver and parameters, and // the other of the result variables of function fn. // // The input must be well-typed. func analyzeParams(logf func(string, ...any), fset *token.FileSet, info *types.Info, decl *ast.FuncDecl) (params, results []*paramInfo, effects []int, _ falconResult) { … } // isAssignableOperand reports whether the given outer-to-inner stack has an // innermost expression operand for which assignability rules apply, meaning it // is used in a position where its type need only be assignable to the type // implied by its surrounding syntax. // // As this function is intended to be used for inlining analysis, it reports // false in one case where the operand technically need only be assignable: if // the type being assigned to is a call argument and contains type parameters, // then passing a different (yet assignable) type may affect type inference, // and so isAssignableOperand reports false. func isAssignableOperand(info *types.Info, stack []ast.Node) bool { … } // exprContext returns the innermost parent->child expression nodes for the // given outer-to-inner stack, after stripping parentheses. // // If no such context exists, returns (nil, nil). func exprContext(stack []ast.Node) (parent ast.Node, expr ast.Expr) { … } // isSelectionOperand reports whether the innermost node of stack is operand // (x) of a selection x.f. func isSelectionOperand(stack []ast.Node) bool { … } // addShadows returns the shadows set augmented by the set of names // locally shadowed at the location of the reference in the callee // (identified by the stack). The name of the reference itself is // excluded. // // These shadowed names may not be used in a replacement expression // for the reference. func addShadows(shadows map[string]bool, info *types.Info, exclude string, stack []ast.Node) map[string]bool { … } func isField(obj types.Object) bool { … } func isMethod(obj types.Object) bool { … } var _ … var _ … func (callee *Callee) GobEncode() ([]byte, error) { … } func (callee *Callee) GobDecode(data []byte) error { … }