}
func isInlineable(n *Node) bool {
- if exportInlined && n != nil && n.Func != nil && len(n.Func.Inl.Slice()) != 0 {
+ if exportInlined && n != nil && n.Func != nil && n.Func.Inl.Len() != 0 {
// when lazily typechecking inlined bodies, some re-exported ones may not have been typechecked yet.
// currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
if Debug['l'] < 2 {
if Debug['E'] > 0 {
fmt.Printf("import [%q] func %v \n", importpkg.Path, n)
- if Debug['m'] > 2 && len(n.Func.Inl.Slice()) != 0 {
+ if Debug['m'] > 2 && n.Func.Inl.Len() != 0 {
fmt.Printf("inl body: %v\n", n.Func.Inl)
}
}
if Debug['E'] > 0 {
fmt.Printf("import [%q] meth %v \n", importpkg.Path, n)
- if Debug['m'] > 2 && len(n.Func.Inl.Slice()) != 0 {
+ if Debug['m'] > 2 && n.Func.Inl.Len() != 0 {
fmt.Printf("inl body: %v\n", n.Func.Inl)
}
}
xfunc.Nbody.Set(func_.Nbody.Slice())
xfunc.Func.Dcl = append(func_.Func.Dcl, xfunc.Func.Dcl...)
func_.Func.Dcl = nil
- if len(xfunc.Nbody.Slice()) == 0 {
+ if xfunc.Nbody.Len() == 0 {
Fatalf("empty body - won't generate any code")
}
xfunc = typecheck(xfunc, Etop)
if ln.Type != nil && !haspointers(ln.Type) {
break
}
- if len(Curfn.Nbody.Slice()) == 0 && !Curfn.Noescape {
+ if Curfn.Nbody.Len() == 0 && !Curfn.Noescape {
ln.Esc = EscHeap
} else {
ln.Esc = EscNone // prime for escflood later
nE := e.nodeEscState(n)
if fn != nil && fn.Op == ONAME && fn.Class == PFUNC &&
- fn.Name.Defn != nil && len(fn.Name.Defn.Nbody.Slice()) != 0 && fn.Name.Param.Ntype != nil && fn.Name.Defn.Esc < EscFuncTagged {
+ fn.Name.Defn != nil && fn.Name.Defn.Nbody.Len() != 0 && fn.Name.Param.Ntype != nil && fn.Name.Defn.Esc < EscFuncTagged {
if Debug['m'] > 3 {
fmt.Printf("%v::esccall:: %v in recursive group\n", linestr(lineno), Nconv(n, FmtShort))
}
// External functions are assumed unsafe,
// unless //go:noescape is given before the declaration.
- if len(func_.Nbody.Slice()) == 0 {
+ if func_.Nbody.Len() == 0 {
if func_.Noescape {
for _, t := range func_.Type.Params().Fields().Slice() {
if haspointers(t.Type) {
dumpexporttype(t)
if t.Etype == TFUNC && n.Class == PFUNC {
- if n.Func != nil && len(n.Func.Inl.Slice()) != 0 {
+ if n.Func != nil && n.Func.Inl.Len() != 0 {
// when lazily typechecking inlined bodies, some re-exported ones may not have been typechecked yet.
// currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
if Debug['l'] < 2 {
if f.Nointerface {
exportf("\t//go:nointerface\n")
}
- if f.Type.Nname() != nil && len(f.Type.Nname().Func.Inl.Slice()) != 0 { // nname was set by caninl
+ if f.Type.Nname() != nil && f.Type.Nname().Func.Inl.Len() != 0 { // nname was set by caninl
// when lazily typechecking inlined bodies, some re-exported ones may not have been typechecked yet.
// currently that can leave unresolved ONONAMEs in import-dot-ed packages in the wrong package
if fmtmode == FErr {
return "func literal"
}
- if len(n.Nbody.Slice()) != 0 {
+ if n.Nbody.Len() != 0 {
return fmt.Sprintf("%v { %v }", n.Type, n.Nbody)
}
return fmt.Sprintf("%v { %v }", n.Type, n.Name.Param.Closure.Nbody)
fmt.Fprintf(&buf, "%v-rlist%v", Oconv(n.Op, 0), n.Rlist)
}
- if len(n.Nbody.Slice()) != 0 {
+ if n.Nbody.Len() != 0 {
indent(&buf)
fmt.Fprintf(&buf, "%v-body%v", Oconv(n.Op, 0), n.Nbody)
}
}
// If fn has no body (is defined outside of Go), cannot inline it.
- if len(fn.Nbody.Slice()) == 0 {
+ if fn.Nbody.Len() == 0 {
return
}
switch n.Op {
// Call is okay if inlinable and we have the budget for the body.
case OCALLFUNC:
- if n.Left.Func != nil && len(n.Left.Func.Inl.Slice()) != 0 {
+ if n.Left.Func != nil && n.Left.Func.Inl.Len() != 0 {
*budget -= int(n.Left.Func.InlCost)
break
}
if n.Left.Op == ONAME && n.Left.Left != nil && n.Left.Left.Op == OTYPE && n.Left.Right != nil && n.Left.Right.Op == ONAME { // methods called as functions
- if n.Left.Sym.Def != nil && len(n.Left.Sym.Def.Func.Inl.Slice()) != 0 {
+ if n.Left.Sym.Def != nil && n.Left.Sym.Def.Func.Inl.Len() != 0 {
*budget -= int(n.Left.Sym.Def.Func.InlCost)
break
}
if n.Left.Type.Nname() == nil {
Fatalf("no function definition for [%p] %v\n", n.Left.Type, Tconv(n.Left.Type, FmtSign))
}
- if len(n.Left.Type.Nname().Func.Inl.Slice()) != 0 {
+ if n.Left.Type.Nname().Func.Inl.Len() != 0 {
*budget -= int(n.Left.Type.Nname().Func.InlCost)
break
}
if Debug['m'] > 3 {
fmt.Printf("%v:call to func %v\n", n.Line(), Nconv(n.Left, FmtSign))
}
- if n.Left.Func != nil && len(n.Left.Func.Inl.Slice()) != 0 && !isIntrinsicCall1(n) { // normal case
+ if n.Left.Func != nil && n.Left.Func.Inl.Len() != 0 && !isIntrinsicCall1(n) { // normal case
n = mkinlcall(n, n.Left, n.Isddd)
} else if n.Left.Op == ONAME && n.Left.Left != nil && n.Left.Left.Op == OTYPE && n.Left.Right != nil && n.Left.Right.Op == ONAME { // methods called as functions
if n.Left.Sym.Def != nil {
// n.Left = mkinlcall1(n.Left, fn, isddd)
func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
// For variadic fn.
- if len(fn.Func.Inl.Slice()) == 0 {
+ if fn.Func.Inl.Len() == 0 {
return n
}
// Typecheck imported function bodies if debug['l'] > 1,
// otherwise lazily when used or re-exported.
for _, n := range importlist {
- if len(n.Func.Inl.Slice()) != 0 {
+ if n.Func.Inl.Len() != 0 {
saveerrors()
typecheckinl(n)
}
}
case OCLOSURE:
- if n.Noescape && len(n.Func.Cvars.Slice()) > 0 {
+ if n.Noescape && n.Func.Cvars.Len() > 0 {
prealloc[n] = ordertemp(Types[TUINT8], order, false) // walk will fill in correct type
}
if Debug['E'] > 0 {
fmt.Printf("import [%q] func %v \n", importpkg.Path, s2)
- if Debug['m'] > 2 && len(s2.Func.Inl.Slice()) != 0 {
+ if Debug['m'] > 2 && s2.Func.Inl.Len() != 0 {
fmt.Printf("inl body:%v\n", s2.Func.Inl)
}
}
Curfn = fn
dowidth(Curfn.Type)
- if len(fn.Nbody.Slice()) == 0 {
+ if fn.Nbody.Len() == 0 {
if pure_go || strings.HasPrefix(fn.Func.Nname.Sym.Name, "init.") {
Yyerror("missing function body for %q", fn.Func.Nname.Sym.Name)
return
}
func checkreturn(fn *Node) {
- if fn.Type.Results().NumFields() != 0 && len(fn.Nbody.Slice()) != 0 {
+ if fn.Type.Results().NumFields() != 0 && fn.Nbody.Len() != 0 {
markbreaklist(fn.Nbody, nil)
if !fn.Nbody.isterminating() {
yyerrorl(fn.Func.Endlineno, "missing return at end of function")
}
heapmoves()
- if Debug['W'] != 0 && len(Curfn.Func.Enter.Slice()) > 0 {
+ if Debug['W'] != 0 && Curfn.Func.Enter.Len() > 0 {
s := fmt.Sprintf("enter %v", Curfn.Func.Nname.Sym)
dumplist(s, Curfn.Func.Enter)
}