}
case TSTRUCT:
- if t.Funarg {
+ if t.IsFuncArgStruct() {
Fatalf("dowidth fn struct %v", t)
}
w = widstruct(t, t, 0, 1)
// function arg structs should not be checked
// outside of the enclosing function.
- if t.Funarg {
+ if t.IsFuncArgStruct() {
Fatalf("checkwidth %v", t)
}
}
func (p *exporter) paramList(params *Type, numbered bool) {
- if !params.IsStruct() || !params.Funarg {
+ if !params.IsFuncArgStruct() {
Fatalf("exporter: parameter list expected")
}
ll := n.List
if n.List.Len() == 1 {
a := n.List.First()
- if a.Type.IsStruct() && a.Type.Funarg { // f(g()).
+ if a.Type.IsFuncArgStruct() { // f(g())
ll = e.nodeEscState(a).Escretval
}
}
case OTYPE:
t := n.Type
- if !t.IsStruct() || t.Map != nil || t.Funarg {
+ if !t.IsStruct() || t.Map != nil || t.IsFuncArgStruct() {
break
}
fmt.Fprintf(b, "#define %s__size %d\n", t.Sym.Name, int(t.Width))
}
var buf bytes.Buffer
- if t.Funarg {
+ if t.IsFuncArgStruct() {
buf.WriteString("(")
var flag1 FmtFlag
if fmtmode == FTypeId || fmtmode == FErr { // no argument names on function signature, and no "noescape"/"nosplit" tags
switch t := t.(type) {
case *Type:
// entire argument struct, not just one arg
- if !t.IsStruct() || !t.Funarg {
+ if !t.IsFuncArgStruct() {
Fatalf("nodarg: bad type %v", t)
}
n = Nod(ONAME, nil, nil)
// 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.IsStruct() || !n.Type.Funarg {
+ if !n.Type.IsFuncArgStruct() {
Fatalf("copyret %v %d", n.Type, n.Left.Type.Results().NumFields())
}
Chan ChanDir
Trecur uint8 // to detect loops
Printed bool
- Funarg bool // on TSTRUCT and TFIELD
+ Funarg bool // TSTRUCT only: whether this struct represents function parameters
Local bool // created in this file
Deferwidth bool
Broke bool // broken type definition.
t.nname = n
}
+// IsFuncArgStruct reports whether t is a struct representing function parameters.
+func (t *Type) IsFuncArgStruct() bool {
+ return t.Etype == TSTRUCT && t.Funarg
+}
+
func (t *Type) Methods() *Fields {
// TODO(mdempsky): Validate t?
return &t.methods
// Unpack multiple-return result before type-checking.
var funarg *Type
- if t.IsStruct() && t.Funarg {
+ if t.IsFuncArgStruct() {
funarg = t
t = t.Field(0).Type
}
}
t := n.Type
- if t != nil && !t.Funarg && n.Op != OTYPE {
+ if t != nil && !t.IsFuncArgStruct() && n.Op != OTYPE {
switch t.Etype {
case TFUNC, // might have TANY; wait until its called
TANY,
if nl.Len() == 1 {
n = nl.First()
if n.Type != nil {
- if n.Type.IsStruct() && n.Type.Funarg {
+ if n.Type.IsFuncArgStruct() {
if !hasddd(tstruct) {
n1 := tstruct.NumFields()
n2 := n.Type.NumFields()
}
switch r.Op {
case OCALLMETH, OCALLINTER, OCALLFUNC:
- if !r.Type.IsStruct() || !r.Type.Funarg {
+ if !r.Type.IsFuncArgStruct() {
break
}
cr = r.Type.NumFields()
var nn []*Node
// f(g()) where g has multiple return values
- if r != nil && len(lr) <= 1 && r.Type.IsStruct() && r.Type.Funarg {
+ if r != nil && len(lr) <= 1 && r.Type.IsFuncArgStruct() {
// optimization - can do block copy
if eqtypenoname(r.Type, nl) {
arg := nodarg(nl, fp)