Passes toolstash-check.
Change-Id: Id62bacff13fbd30de62b925d97a4e7bee1c66120
Reviewed-on: https://go-review.googlesource.com/59331
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
call := nod(OCALL, nodSym(OXDOT, ptr, meth), nil)
call.List.Set(callargs)
call.SetIsddd(ddd)
- if t0.Results().NumFields() == 0 {
+ if t0.NumResults() == 0 {
body = append(body, call)
} else {
n := nod(OAS2, nil, nil)
case ORETURN:
retList := n.List
- if retList.Len() == 1 && Curfn.Type.Results().NumFields() > 1 {
+ if retList.Len() == 1 && Curfn.Type.NumResults() > 1 {
// OAS2FUNC in disguise
// esccall already done on n.List.First()
// tie e.nodeEscState(n.List.First()).Retval to Curfn.Func.Dcl PPARAMOUT's
}
buf = append(buf, tmodeString(t.Params(), mode, depth)...)
- switch t.Results().NumFields() {
+ switch t.NumResults() {
case 0:
// nothing to do
}
func (n *Node) checkInitFuncSignature() {
- ft := n.Type.FuncType()
- if ft.Receiver.Fields().Len()+ft.Params.Fields().Len()+ft.Results.Fields().Len() > 0 {
+ if n.Type.NumRecvs()+n.Type.NumParams()+n.Type.NumResults() > 0 {
Fatalf("init function cannot have receiver, params, or results: %v (%v)", n, n.Type)
}
}
}
// call must return multiple values
- return n.Left.Type.Results().NumFields() > 1
+ return n.Left.Type.NumResults() > 1
}
// Copyret emits t1, t2, ... = n, where n is a function call,
// and then returns the list t1, t2, ....
func copyret(n *Node, order *Order) []*Node {
if !n.Type.IsFuncArgStruct() {
- Fatalf("copyret %v %d", n.Type, n.Left.Type.Results().NumFields())
+ Fatalf("copyret %v %d", n.Type, n.Left.Type.NumResults())
}
var l1 []*Node
nptr := int(Curfn.Type.ArgWidth() / int64(Widthptr))
bv := bvalloc(int32(nptr) * 2)
nbitmap := 1
- if Curfn.Type.Results().NumFields() > 0 {
+ if Curfn.Type.NumResults() > 0 {
nbitmap = 2
}
off := duint32(lsym, 0, uint32(nbitmap))
onebitwalktype1(Curfn.Type.Recvs(), &xoffset, bv)
}
- if Curfn.Type.Params().NumFields() > 0 {
+ if Curfn.Type.NumParams() > 0 {
xoffset = 0
onebitwalktype1(Curfn.Type.Params(), &xoffset, bv)
}
off = dbvec(lsym, off, bv)
- if Curfn.Type.Results().NumFields() > 0 {
+ if Curfn.Type.NumResults() > 0 {
xoffset = 0
onebitwalktype1(Curfn.Type.Results(), &xoffset, bv)
off = dbvec(lsym, off, bv)
}
ot = dcommontype(lsym, ot, t)
- inCount := t.Recvs().NumFields() + t.Params().NumFields()
- outCount := t.Results().NumFields()
+ inCount := t.NumRecvs() + t.NumParams()
+ outCount := t.NumResults()
if isddd {
outCount |= 1 << 15
}
ot += 4 // align for *rtype
}
- dataAdd := (inCount + t.Results().NumFields()) * Widthptr
+ dataAdd := (inCount + t.NumResults()) * Widthptr
ot = dextratype(lsym, ot, t, dataAdd)
// Array of rtype pointers follows funcType.
call := nod(OCALL, dot, nil)
call.List.Set(args)
call.SetIsddd(isddd)
- if method.Type.Results().NumFields() > 0 {
+ if method.Type.NumResults() > 0 {
n := nod(ORETURN, nil, nil)
n.List.Set1(call)
call = n
typecheckaste(OCALL, n.Left, n.Isddd(), t.Params(), n.List, func() string { return fmt.Sprintf("argument to %v", n.Left) })
ok |= Etop
- if t.Results().NumFields() == 0 {
+ if t.NumResults() == 0 {
break OpSwitch
}
ok |= Erv
- if t.Results().NumFields() == 1 {
+ if t.NumResults() == 1 {
n.Type = l.Type.Results().Field(0).Type
if n.Op == OCALLFUNC && n.Left.Op == ONAME && isRuntimePkg(n.Left.Sym.Pkg) && n.Left.Sym.Name == "getg" {
// Bail. This error will be reported elsewhere.
return n
}
- if t.Results().NumFields() != 2 {
- yyerror("invalid operation: complex expects two arguments, %v returns %d results", n.List.First(), t.Results().NumFields())
+ if t.NumResults() != 2 {
+ yyerror("invalid operation: complex expects two arguments, %v returns %d results", n.List.First(), t.NumResults())
n.Type = nil
return n
}
// checkreturn makes sure that fn terminates appropriately.
func checkreturn(fn *Node) {
- if fn.Type.Results().NumFields() != 0 && fn.Nbody.Len() != 0 {
+ if fn.Type.NumResults() != 0 && fn.Nbody.Len() != 0 {
markbreaklist(fn.Nbody, nil)
if !fn.Nbody.isterminating() {
yyerrorl(fn.Func.Endlineno, "missing return at end of function")
// Update type of OCALLFUNC node.
// Output arguments had not changed, but their offsets could.
- if n.Left.Type.Results().NumFields() == 1 {
+ if n.Left.Type.NumResults() == 1 {
n.Type = n.Left.Type.Results().Field(0).Type
} else {
n.Type = n.Left.Type.Results()
Fatalf("mkcall %v %v", fn, fn.Type)
}
- n := fn.Type.Params().NumFields()
+ n := fn.Type.NumParams()
if n != len(va) {
Fatalf("vmkcall %v needs %v args got %v", fn, n, len(va))
}
r := nod(OCALL, fn, nil)
r.List.Set(va)
- if fn.Type.Results().NumFields() > 0 {
+ if fn.Type.NumResults() > 0 {
r = typecheck(r, Erv|Efnstruct)
} else {
r = typecheck(r, Etop)
//
// TODO(crawshaw): improve precision of match by working out
// how to check the method name.
- if n := t.Params().NumFields(); n != 1 {
+ if n := t.NumParams(); n != 1 {
return
}
- if n := t.Results().NumFields(); n != 1 && n != 2 {
+ if n := t.NumResults(); n != 1 && n != 2 {
return
}
p0 := t.Params().Field(0)
res0 := t.Results().Field(0)
var res1 *types.Field
- if t.Results().NumFields() == 2 {
+ if t.NumResults() == 2 {
res1 = t.Results().Field(1)
}
func (t *Type) Params() *Type { return t.FuncType().Params }
func (t *Type) Results() *Type { return t.FuncType().Results }
+func (t *Type) NumRecvs() int { return t.FuncType().Receiver.NumFields() }
+func (t *Type) NumParams() int { return t.FuncType().Params.NumFields() }
+func (t *Type) NumResults() int { return t.FuncType().Results.NumFields() }
+
// Recv returns the receiver of function type t, if any.
func (t *Type) Recv() *Field {
s := t.Recvs()