// directClosureCall rewrites a direct call of a function literal into // a normal function call with closure variables passed as arguments. // This avoids allocation of a closure object. // // For illustration, the following call: // // func(a int) { // println(byval) // byref++ // }(42) // // becomes: // // func(byval int, &byref *int, a int) { // println(byval) // (*&byref)++ // }(byval, &byref, 42) func directClosureCall(n *ir.CallExpr) { … } func walkClosure(clo *ir.ClosureExpr, init *ir.Nodes) ir.Node { … } // closureArgs returns a slice of expressions that can be used to // initialize the given closure's free variables. These correspond // one-to-one with the variables in clo.Func.ClosureVars, and will be // either an ONAME node (if the variable is captured by value) or an // OADDR-of-ONAME node (if not). func closureArgs(clo *ir.ClosureExpr) []ir.Node { … } func walkMethodValue(n *ir.SelectorExpr, init *ir.Nodes) ir.Node { … } // methodValueWrapper returns the ONAME 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 typecheck.Target.Decls. func methodValueWrapper(dot *ir.SelectorExpr) *ir.Name { … }