// ordinary ones in the symbol table; see oldname.
// unhook them.
// make the list of pointers for the closure call.
- for _, v := range func_.Func.Cvars() {
+ for _, v := range func_.Func.Cvars.Slice() {
v.Name.Param.Closure.Name.Param.Closure = v.Name.Param.Outer
v.Name.Param.Outerexpr = oldname(v.Sym)
}
}
func typecheckclosure(func_ *Node, top int) {
- for _, ln := range func_.Func.Cvars() {
+ for _, ln := range func_.Func.Cvars.Slice() {
n := ln.Name.Param.Closure
if !n.Name.Captured {
n.Name.Captured = true
func_ := xfunc.Func.Closure
func_.Func.Enter.Set(nil)
- for _, v := range func_.Func.Cvars() {
+ for _, v := range func_.Func.Cvars.Slice() {
if v.Type == nil {
// if v->type is nil, it means v looked like it was
// going to be used in the closure but wasn't.
var addr *Node
var fld *Type
- for _, v := range func_.Func.Cvars() {
+ for _, v := range func_.Func.Cvars.Slice() {
if v.Op == OXXX {
continue
}
offset := int64(Widthptr)
var addr *Node
var cv *Node
- for _, v := range func_.Func.Cvars() {
+ for _, v := range func_.Func.Cvars.Slice() {
if v.Op == OXXX {
continue
}
func walkclosure(func_ *Node, init **NodeList) *Node {
// If no closure vars, don't bother wrapping.
- if len(func_.Func.Cvars()) == 0 {
+ if len(func_.Func.Cvars.Slice()) == 0 {
return func_.Func.Closure.Func.Nname
}
typ.List = list1(Nod(ODCLFIELD, newname(Lookup(".F")), typenod(Types[TUINTPTR])))
var typ1 *Node
- for _, v := range func_.Func.Cvars() {
+ for _, v := range func_.Func.Cvars.Slice() {
if v.Op == OXXX {
continue
}
Shortname *Node
Enter Nodes
Exit Nodes
- cvars *[]*Node // closure params
+ Cvars Nodes // closure params
Dcl []*Node // autodcl for this func/closure
Inldcl *[]*Node // copy of dcl for use in inlining
Closgen int
Needctxt bool // function uses context register (has closure variables)
}
-// Cvars returns the closure variables for this Func.
-// These are referenced variables that are defined in enclosing
-// functions.
-// The cvars field is a pointer to save space, since most Func values
-// have no cvars.
-func (f *Func) Cvars() []*Node {
- if f.cvars == nil {
- return nil
- }
- return *f.cvars
-}
-
-// AppendCvar appends a new closure variable.
-func (f *Func) CvarAppend(n *Node) {
- if f.cvars == nil {
- f.cvars = &[]*Node{n}
- } else {
- *f.cvars = append(*f.cvars, n)
- }
-}
-
type Op uint8
// Node ops.