CL produced mechanically using gofmt -w -r.
Passes toolstash -cmp.
Change-Id: Ib2e8710ebd844e2149125b41c335b71a02fcab53
Reviewed-on: https://go-review.googlesource.com/21338
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
// A special case to make write barriers more efficient.
// Comparing the first field of a named struct can be done directly.
base := n1
- if n1.Op == gc.ODOT && n1.Left.Type.Etype == gc.TSTRUCT && n1.Left.Type.Field(0).Sym == n1.Sym {
+ if n1.Op == gc.ODOT && n1.Left.Type.IsStruct() && n1.Left.Type.Field(0).Sym == n1.Sym {
base = n1.Left
}
// ispaddedfield reports whether the i'th field of struct type t is followed
// by padding.
func ispaddedfield(t *Type, i int) bool {
- if t.Etype != TSTRUCT {
+ if !t.IsStruct() {
Fatalf("ispaddedfield called non-struct %v", t)
}
end := t.Width
p.typ(t.Orig)
// interfaces don't have associated methods
- if t.Orig.Etype == TINTER {
+ if t.Orig.IsInterface() {
return
}
}
func (p *exporter) paramList(params *Type, numbered bool) {
- if params.Etype != TSTRUCT || !params.Funarg {
+ if !params.IsStruct() || !params.Funarg {
Fatalf("exporter: parameter list expected")
}
importtype(t, t0) // parser.go:hidden_import
// interfaces don't have associated methods
- if t0.Etype == TINTER {
+ if t0.IsInterface() {
break
}
}
v := uint64(nr.Val().U.(*Mpint).Int64())
var n2 Node
- if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ if nl.Type.IsSlice() || nl.Type.IsString() {
if Debug['B'] == 0 && !n.Bounded {
n1 = n3
n1.Op = OINDREG
// check bounds
if Isconst(nl, CTSTR) {
Nodconst(&n4, Types[TUINT32], int64(len(nl.Val().U.(string))))
- } else if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ } else if nl.Type.IsSlice() || nl.Type.IsString() {
n1 = n3
n1.Op = OINDREG
n1.Type = Types[Tptr]
p1 := Thearch.Gins(Thearch.Optoas(OAS, Types[Tptr]), nil, &n3)
Datastring(nl.Val().U.(string), &p1.From)
p1.From.Type = obj.TYPE_ADDR
- } else if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ } else if nl.Type.IsSlice() || nl.Type.IsString() {
n1 = n3
n1.Op = OINDREG
n1.Type = Types[Tptr]
Fatalf("constant string constant index") // front end should handle
}
v := uint64(nr.Val().U.(*Mpint).Int64())
- if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ if nl.Type.IsSlice() || nl.Type.IsString() {
if Debug['B'] == 0 && !n.Bounded {
nlen := n3
nlen.Type = Types[TUINT32]
var nlen Node
if Isconst(nl, CTSTR) {
Nodconst(&nlen, t, int64(len(nl.Val().U.(string))))
- } else if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ } else if nl.Type.IsSlice() || nl.Type.IsString() {
nlen = n3
nlen.Type = t
nlen.Xoffset += int64(Array_nel)
// Load base pointer in n3.
Regalloc(&tmp, Types[Tptr], &n3)
- if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ if nl.Type.IsSlice() || nl.Type.IsString() {
n3.Type = Types[Tptr]
n3.Xoffset += int64(Array_array)
Thearch.Gmove(&n3, &tmp)
Fatalf("constant string constant index") // front end should handle
}
v := uint64(nr.Val().U.(*Mpint).Int64())
- if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ if nl.Type.IsSlice() || nl.Type.IsString() {
if Debug['B'] == 0 && !n.Bounded {
p1 := Thearch.Ginscmp(OGT, Types[Simtype[TUINT]], &nlen, Nodintconst(int64(v)), +1)
Ginscall(Panicindex, -1)
}
if Isconst(nl, CTSTR) {
Nodconst(&nlen, t, int64(len(nl.Val().U.(string))))
- } else if nl.Type.IsSlice() || nl.Type.Etype == TSTRING {
+ } else if nl.Type.IsSlice() || nl.Type.IsString() {
// nlen already initialized
} else {
Nodconst(&nlen, t, nl.Type.Bound)
}
}
- if n.Type.Etype != TBOOL {
+ if !n.Type.IsBoolean() {
Fatalf("bgen: bad type %v for %v", n.Type, Oconv(n.Op, 0))
}
if Isptr[rcvrtype.Etype] {
basetype = basetype.Elem()
}
- if basetype.Etype != TINTER && basetype.Sym == nil {
+ if !basetype.IsInterface() && basetype.Sym == nil {
Fatalf("missing base type for %v", rcvrtype)
}
switch n.Op {
default:
if n.Type == idealbool {
- if t.Etype == TBOOL {
+ if t.IsBoolean() {
n.Type = t
} else {
n.Type = Types[TBOOL]
case OCONV_ | CTNIL_,
OARRAYBYTESTR_ | CTNIL_:
- if n.Type.Etype == TSTRING {
+ if n.Type.IsString() {
v = tostr(v)
nl.Type = n.Type
break
case CTBOOL:
t1 := Types[TBOOL]
- if t != nil && t.Etype == TBOOL {
+ if t != nil && t.IsBoolean() {
t1 = t
}
n = convlit1(n, t1, false, reuse)
return l, r
}
- if l.Type.Etype == TBOOL {
+ if l.Type.IsBoolean() {
l = convlit(l, Types[TBOOL])
r = convlit(r, Types[TBOOL])
}
if t.Sym == nil && Isptr[t.Etype] {
t = t.Elem()
- if t.Etype == TINTER {
+ if t.IsInterface() {
Yyerror("embedded type cannot be a pointer to interface")
}
}
}
func tostruct0(t *Type, l []*Node) {
- if t == nil || t.Etype != TSTRUCT {
+ if t == nil || !t.IsStruct() {
Fatalf("struct expected")
}
}
func tointerface0(t *Type, l []*Node) *Type {
- if t == nil || t.Etype != TINTER {
+ if t == nil || !t.IsInterface() {
Fatalf("interface expected")
}
for _, n := range l {
f := interfacefield(n)
- if n.Left == nil && f.Type.Etype == TINTER {
+ if n.Left == nil && f.Type.IsInterface() {
// embedded interface, inline methods
for _, t1 := range f.Type.Fields().Slice() {
f = newField()
return false
}
t = t.Elem()
- if t.Sym != nil || t.Etype != TSTRUCT || t.NumFields() != 0 {
+ if t.Sym != nil || !t.IsStruct() || t.NumFields() != 0 {
return false
}
return true
return
}
- if t.Etype == TINTER {
+ if t.IsInterface() {
Yyerror("invalid receiver type %v (%v is an interface type)", pa, t)
return
}
return
}
- if pa.Etype == TSTRUCT {
+ if pa.IsStruct() {
for _, f := range pa.Fields().Slice() {
if f.Sym == msym {
Yyerror("type %v has both field and method named %v", pa, msym)
ll := n.List
if n.List.Len() == 1 {
a := n.List.First()
- if a.Type.Etype == TSTRUCT && a.Type.Funarg { // f(g()).
+ if a.Type.IsStruct() && a.Type.Funarg { // f(g()).
ll = e.nodeEscState(a).Escretval
}
}
case OTYPE:
t := n.Type
- if t.Etype != TSTRUCT || t.Map != nil || t.Funarg {
+ if !t.IsStruct() || t.Map != nil || t.Funarg {
break
}
fmt.Fprintf(b, "#define %s__size %d\n", t.Sym.Name, int(t.Width))
return "chan<- " + t.Elem().String()
}
- if t.Elem() != nil && t.Elem().Etype == TCHAN && t.Elem().Sym == nil && t.Elem().Chan == Crecv {
+ if t.Elem() != nil && t.Elem().IsChan() && t.Elem().Sym == nil && t.Elem().Chan == Crecv {
return "chan (" + t.Elem().String() + ")"
}
return "chan " + t.Elem().String()
if n.Type != nil && n.Type.Etype != TIDEAL && n.Type.Etype != TNIL && n.Type != idealbool && n.Type != idealstring {
// Need parens when type begins with what might
// be misinterpreted as a unary operator: * or <-.
- if Isptr[n.Type.Etype] || (n.Type.Etype == TCHAN && n.Type.Chan == Crecv) {
+ if Isptr[n.Type.Etype] || (n.Type.IsChan() && n.Type.Chan == Crecv) {
return fmt.Sprintf("(%v)(%v)", n.Type, Vconv(n.Val(), 0))
} else {
return fmt.Sprintf("%v(%v)", n.Type, Vconv(n.Val(), 0))
// A special case to make write barriers more efficient.
// Taking the address of the first field of a named struct
// is the same as taking the address of the struct.
- if n.Left.Type.Etype != TSTRUCT || n.Left.Type.Field(0).Sym != n.Sym {
+ if !n.Left.Type.IsStruct() || n.Left.Type.Field(0).Sym != n.Sym {
Debug['h'] = 1
Dump("naddr", n)
Fatalf("naddr: bad %v %v", Oconv(n.Op, 0), Ctxt.Dconv(a))
switch t := t.(type) {
case *Type:
// entire argument struct, not just one arg
- if t.Etype != TSTRUCT || !t.Funarg {
+ if !t.IsStruct() || !t.Funarg {
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.Etype != TSTRUCT || !n.Type.Funarg {
+ if !n.Type.IsStruct() || !n.Type.Funarg {
Fatalf("copyret %v %d", n.Type, n.Left.Type.Results().NumFields())
}
// make copy.
r := n.Right
- if r.Type.Etype == TSTRING && r.Type != Types[TSTRING] {
+ if r.Type.IsString() && r.Type != Types[TSTRING] {
r = Nod(OCONV, r, nil)
r.Type = Types[TSTRING]
r = typecheck(r, Erv)
n.Left = orderexpr(n.Left, order, nil)
n.Right = orderexpr(n.Right, order, nil)
t := n.Left.Type
- if t.Etype == TSTRUCT || t.IsArray() {
+ if t.IsStruct() || t.IsArray() {
// for complex comparisons, we need both args to be
// addressable so we can pass them to the runtime.
n.Left = orderaddrtemp(n.Left, order)
}
instrumentnode(&n.Right, init, 0, 0)
- if n.Left.Type.Etype != TSTRING {
+ if !n.Left.Type.IsString() {
callinstr(&n, init, wr, skip)
}
goto ret
Fatalf("instrument: %v badwidth", t)
}
f = mkcall(name, nil, init, uintptraddr(n), Nodintconst(w))
- } else if flag_race != 0 && (t.Etype == TSTRUCT || t.IsArray()) {
+ } else if flag_race != 0 && (t.IsStruct() || t.IsArray()) {
name := "racereadrange"
if wr != 0 {
name = "racewriterange"
anylit(ctxt, n.Left, var_, init)
case OSTRUCTLIT:
- if t.Etype != TSTRUCT {
+ if !t.IsStruct() {
Fatalf("anylit: not struct")
}
arraylit(ctxt, 3, n, var_, init)
case OMAPLIT:
- if t.Etype != TMAP {
+ if !t.IsMap() {
Fatalf("anylit: not map")
}
maplit(ctxt, n, var_, init)
func fieldIdx(n *Node) int {
t := n.Left.Type
f := n.Sym
- if t.Etype != TSTRUCT {
+ if !t.IsStruct() {
panic("ODOT's LHS is not a struct")
}
}
// need a type name
- if t.Sym == nil && (mustname != 0 || t.Etype != TSTRUCT) {
+ if t.Sym == nil && (mustname != 0 || !t.IsStruct()) {
return nil
}
// For deciding whether the result struct from g can be copied
// directly when compiling f(g()).
func eqtypenoname(t1 *Type, t2 *Type) bool {
- if t1 == nil || t2 == nil || t1.Etype != TSTRUCT || t2.Etype != TSTRUCT {
+ if t1 == nil || t2 == nil || !t1.IsStruct() || !t2.IsStruct() {
return false
}
}
// 3. dst is an interface type and src implements dst.
- if dst.Etype == TINTER && src.Etype != TNIL {
+ if dst.IsInterface() && src.Etype != TNIL {
var missing, have *Field
var ptr int
if implements(src, dst, &missing, &have, &ptr) {
return 0
}
- if src.Etype == TINTER && dst.Etype != TBLANK {
+ if src.IsInterface() && dst.Etype != TBLANK {
var missing, have *Field
var ptr int
if why != nil && implements(dst, src, &missing, &have, &ptr) {
// 4. src is a bidirectional channel value, dst is a channel type,
// src and dst have identical element types, and
// either src or dst is not a named type.
- if src.Etype == TCHAN && src.Chan == Cboth && dst.Etype == TCHAN {
+ if src.IsChan() && src.Chan == Cboth && dst.IsChan() {
if Eqtype(src.Elem(), dst.Elem()) && (src.Sym == nil || dst.Sym == nil) {
return OCONVNOP
}
// than assignments. If interfaces are involved, stop now
// with the good message from assignop.
// Otherwise clear the error.
- if src.Etype == TINTER || dst.Etype == TINTER {
+ if src.IsInterface() || dst.IsInterface() {
return 0
}
if why != nil {
// 6. src is an integer or has type []byte or []rune
// and dst is a string type.
- if Isint[src.Etype] && dst.Etype == TSTRING {
+ if Isint[src.Etype] && dst.IsString() {
return ORUNESTR
}
- if src.IsSlice() && dst.Etype == TSTRING {
+ if src.IsSlice() && dst.IsString() {
if src.Elem().Etype == bytetype.Etype {
return OARRAYBYTESTR
}
// 7. src is a string and dst is []byte or []rune.
// String to slice.
- if src.Etype == TSTRING && dst.IsSlice() {
+ if src.IsString() && dst.IsSlice() {
if dst.Elem().Etype == bytetype.Etype {
return OSTRARRAYBYTE
}
// Convert ideal bool from comparison to plain bool
// if the next step is non-bool (like interface{}).
- if n.Type == idealbool && t.Etype != TBOOL {
+ if n.Type == idealbool && !t.IsBoolean() {
if n.Op == ONAME || n.Op == OLITERAL {
r := Nod(OCONVNOP, n, nil)
r.Type = Types[TBOOL]
// common mistake: *struct and *interface.
if tl != nil && tr != nil && Isptr[tl.Etype] && Isptr[tr.Etype] {
- if tl.Elem().Etype == TSTRUCT && tr.Elem().Etype == TINTER {
+ if tl.Elem().IsStruct() && tr.Elem().IsInterface() {
fmt_ += "\n\t(*struct vs *interface)"
- } else if tl.Elem().Etype == TINTER && tr.Elem().Etype == TSTRUCT {
+ } else if tl.Elem().IsInterface() && tr.Elem().IsStruct() {
fmt_ += "\n\t(*interface vs *struct)"
}
}
}
c := 0
- if u.Etype == TSTRUCT || u.Etype == TINTER {
+ if u.IsStruct() || u.IsInterface() {
for _, f := range u.Fields().Slice() {
if f.Sym == s || (ignorecase && f.Type.Etype == TFUNC && f.Type.Recv() != nil && strings.EqualFold(f.Sym.Name, s.Name)) {
if save != nil {
if Isptr[u.Etype] {
u = u.Elem()
}
- if u.Etype != TSTRUCT && u.Etype != TINTER {
+ if !u.IsStruct() && !u.IsInterface() {
goto out
}
u = u.Elem()
}
- if u.Etype == TINTER {
+ if u.IsInterface() {
for _, f := range u.Fields().Slice() {
if f.Sym.Flags&SymUniq != 0 {
continue
u = u.Elem()
}
- if u.Etype != TSTRUCT && u.Etype != TINTER {
+ if !u.IsStruct() && !u.IsInterface() {
goto out
}
testdclstack()
// wrappers where T is anonymous (struct or interface) can be duplicated.
- if rcvr.Etype == TSTRUCT || rcvr.Etype == TINTER || Isptr[rcvr.Etype] && rcvr.Elem().Etype == TSTRUCT {
+ if rcvr.IsStruct() || rcvr.IsInterface() || Isptr[rcvr.Etype] && rcvr.Elem().IsStruct() {
fn.Func.Dupok = true
}
fn = typecheck(fn, Etop)
// could sort these first
// and then do one loop.
- if t.Etype == TINTER {
+ if t.IsInterface() {
for _, im := range iface.Fields().Slice() {
for _, tm := range t.Fields().Slice() {
if tm.Sym == im.Sym {
top = Etype
n.Left.Right = typecheck(n.Left.Right, Erv)
t = n.Left.Right.Type
- if t != nil && t.Etype != TINTER {
+ if t != nil && !t.IsInterface() {
Yyerror("cannot type switch on non-interface value %v", Nconv(n.Left.Right, FmtLong))
}
} else {
nilonly = "slice"
case t.Etype == TARRAY && t.IsArray() && algtype1(t, nil) == ANOEQ:
Yyerror("cannot switch on %v", Nconv(n.Left, FmtLong))
- case t.Etype == TSTRUCT && algtype1(t, &badtype) == ANOEQ:
+ case t.IsStruct() && algtype1(t, &badtype) == ANOEQ:
Yyerror("cannot switch on %v (struct containing %v cannot be compared)", Nconv(n.Left, FmtLong), badtype)
case t.Etype == TFUNC:
nilonly = "func"
- case t.Etype == TMAP:
+ case t.IsMap():
nilonly = "map"
}
}
// reset to original type
n1 = n.Left.Right
ls[i1] = n1
- case n1.Type.Etype != TINTER && t.Etype == TINTER && !implements(n1.Type, t, &missing, &have, &ptr):
+ case !n1.Type.IsInterface() && t.IsInterface() && !implements(n1.Type, t, &missing, &have, &ptr):
if have != nil && !missing.Broke && !have.Broke {
Yyerror("impossible type switch case: %v cannot have dynamic type %v"+" (wrong type for %v method)\n\thave %v%v\n\twant %v%v", Nconv(n.Left.Right, FmtLong), n1.Type, missing.Sym, have.Sym, Tconv(have.Type, FmtShort), missing.Sym, Tconv(missing.Type, FmtShort))
} else if !missing.Broke {
return n
}
- if l.Type.Etype == TMAP && !isnil(l) && !isnil(r) {
+ if l.Type.IsMap() && !isnil(l) && !isnil(r) {
Yyerror("invalid operation: %v (map can only be compared to nil)", n)
n.Type = nil
return n
}
var badtype *Type
- if l.Type.Etype == TSTRUCT && algtype1(l.Type, &badtype) == ANOEQ {
+ if l.Type.IsStruct() && algtype1(l.Type, &badtype) == ANOEQ {
Yyerror("invalid operation: %v (struct containing %v cannot be compared)", n, badtype)
n.Type = nil
return n
break OpSwitch
}
- if Isptr[t.Etype] && t.Elem().Etype != TINTER {
+ if Isptr[t.Etype] && !t.Elem().IsInterface() {
t = t.Elem()
if t == nil {
n.Type = nil
}
}
- if n.Type != nil && n.Type.Etype != TINTER {
+ if n.Type != nil && !n.Type.IsInterface() {
var missing, have *Field
var ptr int
if !implements(n.Type, t, &missing, &have, &ptr) {
case TSTRING, TARRAY:
n.Right = indexlit(n.Right)
- if t.Etype == TSTRING {
+ if t.IsString() {
n.Type = bytetype
} else {
n.Type = t.Elem()
n.Type = nil
return n
}
- if t.Etype != TCHAN {
+ if !t.IsChan() {
Yyerror("invalid operation: %v (receive from non-chan type %v)", n, t)
n.Type = nil
return n
n.Type = nil
return n
}
- if t.Etype != TCHAN {
+ if !t.IsChan() {
Yyerror("invalid operation: %v (send to non-chan type %v)", n, t)
n.Type = nil
return n
n.Type = nil
return n
}
- if t.Etype != TCHAN {
+ if !t.IsChan() {
Yyerror("invalid operation: %v (non-chan type %v)", n, t)
n.Type = nil
return n
typecheckslice(args.Slice(), Erv)
l := args.First()
r := args.Second()
- if l.Type != nil && l.Type.Etype != TMAP {
+ if l.Type != nil && !l.Type.IsMap() {
Yyerror("first argument to delete must be map; have %v", Tconv(l.Type, FmtLong))
n.Type = nil
return n
}
// copy([]byte, string)
- if n.Left.Type.IsSlice() && n.Right.Type.Etype == TSTRING {
+ if n.Left.Type.IsSlice() && n.Right.Type.IsString() {
if Eqtype(n.Left.Type.Elem(), bytetype) {
break OpSwitch
}
n.Type = nil
return n
}
- if t.Etype != TINTER {
+ if !t.IsInterface() {
Fatalf("OITAB of %v", t)
}
n.Type = Ptrto(Types[TUINTPTR])
n.Type = nil
return n
}
- if !t.IsSlice() && t.Etype != TSTRING {
+ if !t.IsSlice() && !t.IsString() {
Fatalf("OSPTR of %v", t)
}
- if t.Etype == TSTRING {
+ if t.IsString() {
n.Type = Ptrto(Types[TUINT8])
} else {
n.Type = Ptrto(t.Elem())
n.Left = typecheck(n.Left, Erv)
if n.Left != nil {
t := n.Left.Type
- if t != nil && t.Etype != TBOOL {
+ if t != nil && !t.IsBoolean() {
Yyerror("non-bool %v used as for condition", Nconv(n.Left, FmtLong))
}
}
n.Left = typecheck(n.Left, Erv)
if n.Left != nil {
t := n.Left.Type
- if t != nil && t.Etype != TBOOL {
+ if t != nil && !t.IsBoolean() {
Yyerror("non-bool %v used as if condition", Nconv(n.Left, FmtLong))
}
}
func looktypedot(n *Node, t *Type, dostrcmp int) bool {
s := n.Sym
- if t.Etype == TINTER {
+ if t.IsInterface() {
f1 := lookdot1(n, s, t, t.Fields(), dostrcmp)
if f1 == nil {
return false
dowidth(t)
var f1 *Field
- if t.Etype == TSTRUCT || t.Etype == TINTER {
+ if t.IsStruct() || t.IsInterface() {
f1 = lookdot1(n, s, t, t.Fields(), dostrcmp)
}
if obj.Fieldtrack_enabled > 0 {
dotField[typeSym{t.Orig, s}] = f1
}
- if t.Etype == TINTER {
+ if t.IsInterface() {
if Isptr[n.Left.Type.Etype] {
n.Left = Nod(OIND, n.Left, nil) // implicitstar
n.Left.Implicit = true
if nl.Len() == 1 {
n = nl.First()
if n.Type != nil {
- if n.Type.Etype == TSTRUCT && n.Type.Funarg {
+ if n.Type.IsStruct() && n.Type.Funarg {
if !hasddd(tstruct) {
n1 := tstruct.NumFields()
n2 := n.Type.NumFields()
if n.Left.Type != nil && n.Left.Type.IsArray() {
return islvalue(n.Left)
}
- if n.Left.Type != nil && n.Left.Type.Etype == TSTRING {
+ if n.Left.Type != nil && n.Left.Type.IsString() {
return false
}
fallthrough
}
switch r.Op {
case OCALLMETH, OCALLINTER, OCALLFUNC:
- if r.Type.Etype != TSTRUCT || !r.Type.Funarg {
+ if !r.Type.IsStruct() || !r.Type.Funarg {
break
}
cr = r.Type.NumFields()
l.Type = r.Type
}
l := n.List.Second()
- if l.Type != nil && l.Type.Etype != TBOOL {
+ if l.Type != nil && !l.Type.IsBoolean() {
checkassignto(Types[TBOOL], l)
}
if l.Name != nil && l.Name.Defn == n && l.Name.Param.Ntype == nil {
}
r = typecheck(r, Erv)
- if n.Type.Etype != TBOOL {
+ if !n.Type.IsBoolean() {
Fatalf("cmp %v", n.Type)
}
r.Type = n.Type
var nn []*Node
// f(g()) where g has multiple return values
- if r != nil && len(lr) <= 1 && r.Type.Etype == TSTRUCT && r.Type.Funarg {
+ if r != nil && len(lr) <= 1 && r.Type.IsStruct() && r.Type.Funarg {
// optimization - can do block copy
if eqtypenoname(r.Type, nl) {
arg := nodarg(nl, fp)
}
func chanfn(name string, n int, t *Type) *Node {
- if t.Etype != TCHAN {
+ if !t.IsChan() {
Fatalf("chanfn %v", t)
}
fn := syslook(name)
}
func mapfn(name string, t *Type) *Node {
- if t.Etype != TMAP {
+ if !t.IsMap() {
Fatalf("mapfn %v", t)
}
fn := syslook(name)
}
func mapfndel(name string, t *Type) *Node {
- if t.Etype != TMAP {
+ if !t.IsMap() {
Fatalf("mapfn %v", t)
}
fn := syslook(name)
nptr1.Etype = 1
nptr2 := l2
var fn *Node
- if l2.Type.Etype == TSTRING {
+ if l2.Type.IsString() {
fn = syslook("slicestringcopy")
} else {
fn = syslook("slicecopy")
if runtimecall {
var fn *Node
- if n.Right.Type.Etype == TSTRING {
+ if n.Right.Type.IsString() {
fn = syslook("slicestringcopy")
} else {
fn = syslook("slicecopy")
}
}
- if t.Etype == TSTRUCT && t.NumFields() <= 4 {
+ if t.IsStruct() && t.NumFields() <= 4 {
// Struct of four or fewer fields.
// Inline comparisons.
var li *Node
return
}
} else {
- if p0.Type.Etype != TSTRING {
+ if !p0.Type.IsString() {
return
}
- if res1.Type.Etype != TBOOL {
+ if !res1.Type.IsBoolean() {
return
}
}
// A special case to make write barriers more efficient.
// Comparing the first field of a named struct can be done directly.
base := n1
- if n1.Op == gc.ODOT && n1.Left.Type.Etype == gc.TSTRUCT && n1.Left.Type.Field(0).Sym == n1.Sym {
+ if n1.Op == gc.ODOT && n1.Left.Type.IsStruct() && n1.Left.Type.Field(0).Sym == n1.Sym {
base = n1.Left
}