}
func (p *exporter) fieldList(t *Type) {
- if p.trace && countfield(t) > 0 {
+ if p.trace && t.NumFields() > 0 {
p.tracef("fields {>")
defer p.tracef("<\n} ")
}
- p.int(countfield(t))
+ p.int(t.NumFields())
for _, f := range t.Fields().Slice() {
if p.trace {
p.tracef("\n")
}
func (p *exporter) methodList(t *Type) {
- if p.trace && countfield(t) > 0 {
+ if p.trace && t.NumFields() > 0 {
p.tracef("methods {>")
defer p.tracef("<\n} ")
}
- p.int(countfield(t))
+ p.int(t.NumFields())
for _, m := range t.Fields().Slice() {
if p.trace {
p.tracef("\n")
// use negative length to indicate unnamed parameters
// (look at the first parameter only since either all
// names are present or all are absent)
- n := countfield(params)
+ n := params.NumFields()
if n > 0 && parName(params.Field(0), numbered) == "" {
n = -n
}
return false
}
t = t.Type
- if t.Sym != nil || t.Etype != TSTRUCT || countfield(t) != 0 {
+ if t.Sym != nil || t.Etype != TSTRUCT || t.NumFields() != 0 {
return false
}
return true
}
// initialize of not completely specified
- if var_.isSimpleName() || n.List.Len() < structcount(t) {
+ if var_.isSimpleName() || n.List.Len() < t.NumFields() {
a := Nod(OAS, var_, nil)
typecheck(&a, Etop)
walkexpr(&a, init)
// introduced by the compiler for variadic functions.
return false
case TSTRUCT:
- if countfield(t) > ssa.MaxStruct {
+ if t.NumFields() > ssa.MaxStruct {
return false
}
for _, t1 := range t.Fields().Slice() {
}
func isnilinter(t *Type) bool {
- return Isinter(t) && countfield(t) == 0
+ return Isinter(t) && t.NumFields() == 0
}
func isideal(t *Type) bool {
case TSTRUCT:
// Struct with 1 field of direct iface type can be direct.
- return countfield(t) == 1 && isdirectiface(t.Field(0).Type)
+ return t.NumFields() == 1 && isdirectiface(t.Field(0).Type)
}
return false
func (t *Type) IsMemory() bool { return false }
func (t *Type) IsFlags() bool { return false }
func (t *Type) IsVoid() bool { return false }
-
-// TODO(mdempsky): Replace all of these with direct calls to t.NumFields().
-func countfield(t *Type) int { return t.NumFields() }
-func downcount(t *Type) int { return t.NumFields() }
-func structcount(t *Type) int { return t.NumFields() }
if n.Type != nil {
if n.Type.Etype == TSTRUCT && n.Type.Funarg {
if !hasddd(tstruct) {
- n1 := downcount(tstruct)
- n2 := downcount(n.Type)
+ n1 := tstruct.NumFields()
+ n2 := n.Type.NumFields()
if n2 > n1 {
goto toomany
}
}
}
- n1 = downcount(tstruct)
+ n1 = tstruct.NumFields()
n2 = nl.Len()
if !hasddd(tstruct) {
if n2 > n1 {
if r.Type.Etype != TSTRUCT || !r.Type.Funarg {
break
}
- cr = structcount(r.Type)
+ cr = r.Type.NumFields()
if cr != cl {
goto mismatch
}
}
if i < nl.Len() || r != nil {
- Yyerror("ascompatet: assignment count mismatch: %d = %d", nl.Len(), structcount(nr))
+ Yyerror("ascompatet: assignment count mismatch: %d = %d", nl.Len(), nr.NumFields())
}
if ullmanOverflow {
}
}
- if t.Etype == TSTRUCT && countfield(t) <= 4 {
+ if t.Etype == TSTRUCT && t.NumFields() <= 4 {
// Struct of four or fewer fields.
// Inline comparisons.
var li *Node
//
// TODO(crawshaw): improve precision of match by working out
// how to check the method name.
- if n := countfield(t.Params()); n != 1 {
+ if n := t.Params().NumFields(); n != 1 {
return
}
- if n := countfield(t.Results()); n != 1 && n != 2 {
+ if n := t.Results().NumFields(); n != 1 && n != 2 {
return
}
p0 := t.Params().Field(0)
res0 := t.Results().Field(0)
var res1 *Field
- if countfield(t.Results()) == 2 {
+ if t.Results().NumFields() == 2 {
res1 = t.Results().Field(1)
}