More Node cleanups, these ones touch go.y.
- convert Node.Implicit to bool
- convert Node.Used to bool
Change-Id: I85c7ff9e66cee7122b560adedc995166c874f2f2
Reviewed-on: https://go-review.googlesource.com/7124
Reviewed-by: Keith Randall <khr@golang.org>
                                addr = newname(Lookup(namebuf))
                                addr.Ntype = Nod(OIND, typenod(v.Type), nil)
                                addr.Class = PAUTO
-                               addr.Used = 1
+                               addr.Used = true
                                addr.Curfn = xfunc
                                xfunc.Dcl = list(xfunc.Dcl, addr)
                                v.Heapaddr = addr
 
        clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
        clos.Esc = func_.Esc
-       clos.Right.Implicit = 1
+       clos.Right.Implicit = true
        clos.List = concat(list1(Nod(OCFUNC, func_.Closure.Nname, nil)), func_.Enter)
 
        // Force type conversion from *struct to the func type.
        ptr.Class = PAUTO
        ptr.Addable = 1
        ptr.Ullman = 1
-       ptr.Used = 1
+       ptr.Used = true
        ptr.Curfn = xfunc
        xfunc.Dcl = list(xfunc.Dcl, ptr)
        var body *NodeList
 
        clos := Nod(OCOMPLIT, nil, Nod(OIND, typ, nil))
        clos.Esc = n.Esc
-       clos.Right.Implicit = 1
+       clos.Right.Implicit = true
        clos.List = list1(Nod(OCFUNC, n.Nname.Nname, nil))
        clos.List = list(clos.List, n.Left)
 
 
                src.Class = PAUTO
                src.Curfn = Curfn
                src.Escloopdepth = e.loopdepth
-               src.Used = 1
+               src.Used = true
                src.Lineno = n.Lineno
                n.Escretval = list(n.Escretval, src)
        }
 
                fp += fmt.Sprintf(" isddd(%d)", n.Isddd)
        }
 
-       if n.Implicit != 0 {
-               fp += fmt.Sprintf(" implicit(%d)", n.Implicit)
+       if n.Implicit {
+               fp += fmt.Sprintf(" implicit(%v)", n.Implicit)
        }
 
        if n.Embedded != 0 {
                fp += " assigned"
        }
 
-       if c == 0 && n.Used != 0 {
-               fp += fmt.Sprintf(" used(%d)", n.Used)
+       if c == 0 && n.Used {
+               fp += fmt.Sprintf(" used(%v)", n.Used)
        }
        return fp
 }
                }
 
        case OASOP:
-               if n.Implicit != 0 {
+               if n.Implicit {
                        if n.Etype == OADD {
                                f += fmt.Sprintf("%v++", Nconv(n.Left, 0))
                        } else {
 }
 
 func exprfmt(n *Node, prec int) string {
-       for n != nil && n.Implicit != 0 && (n.Op == OIND || n.Op == OADDR) {
+       for n != nil && n.Implicit && (n.Op == OIND || n.Op == OADDR) {
                n = n.Left
        }
 
                return f
 
        case OCOMPLIT:
-               ptrlit := n.Right != nil && n.Right.Implicit != 0 && n.Right.Type != nil && Isptr[n.Right.Type.Etype]
+               ptrlit := n.Right != nil && n.Right.Implicit && n.Right.Type != nil && Isptr[n.Right.Type.Etype]
                if fmtmode == FErr {
-                       if n.Right != nil && n.Right.Type != nil && n.Implicit == 0 {
+                       if n.Right != nil && n.Right.Type != nil && !n.Implicit {
                                if ptrlit {
                                        return fmt.Sprintf("&%v literal", Tconv(n.Right.Type.Type, 0))
                                } else {
                return f
 
        case OPTRLIT:
-               if fmtmode == FExp && n.Left.Implicit != 0 {
+               if fmtmode == FExp && n.Left.Implicit {
                        return fmt.Sprintf("%v", Nconv(n.Left, 0))
                }
                var f string
        case OSTRUCTLIT:
                if fmtmode == FExp { // requires special handling of field names
                        var f string
-                       if n.Implicit != 0 {
+                       if n.Implicit {
                                f += "{"
                        } else {
                                f += fmt.Sprintf("(%v{", Tconv(n.Type, 0))
                                }
                        }
 
-                       if n.Implicit == 0 {
+                       if !n.Implicit {
                                f += "})"
                                return f
                        }
                if fmtmode == FErr {
                        return fmt.Sprintf("%v literal", Tconv(n.Type, 0))
                }
-               if fmtmode == FExp && n.Implicit != 0 {
+               if fmtmode == FExp && n.Implicit {
                        return fmt.Sprintf("{ %v }", Hconv(n.List, obj.FmtComma))
                }
                var f string
 
 func temp(t *Type) *Node {
        n := Nod(OXXX, nil, nil)
        Tempname(n, t)
-       n.Sym.Def.Used = 1
+       n.Sym.Def.Used = true
        return n.Orig
 }
 
 
                switch($$.Op) {
                case ONAME, ONONAME, OTYPE, OPACK, OLITERAL:
                        $$ = Nod(OPAREN, $$, nil);
-                       $$.Implicit = 1;
+                       $$.Implicit = true;
                        break;
                }
        }
 |      expr LINC
        {
                $$ = Nod(OASOP, $1, Nodintconst(1));
-               $$.Implicit = 1;
+               $$.Implicit = true;
                $$.Etype = OADD;
        }
 |      expr LDEC
        {
                $$ = Nod(OASOP, $1, Nodintconst(1));
-               $$.Implicit = 1;
+               $$.Implicit = true;
                $$.Etype = OSUB;
        }
 
                        // Special case for &T{...}: turn into (*T){...}.
                        $$ = $2;
                        $$.Right = Nod(OIND, $$.Right, nil);
-                       $$.Right.Implicit = 1;
+                       $$.Right.Implicit = true;
                } else {
                        $$ = Nod(OADDR, $2, nil);
                }
                if $1.Op == OPACK {
                        var s *Sym
                        s = restrictlookup($3.Name, $1.Pkg);
-                       $1.Used = 1;
+                       $1.Used = true;
                        $$ = oldname(s);
                        break;
                }
                switch($$.Op) {
                case ONAME, ONONAME, OTYPE, OPACK, OLITERAL:
                        $$ = Nod(OPAREN, $$, nil);
-                       $$.Implicit = 1;
+                       $$.Implicit = true;
                }
        }
 |      '{' start_complit braced_keyval_list '}'
        {
                $$ = oldname($1);
                if $$.Pack != nil {
-                       $$.Pack.Used = 1;
+                       $$.Pack.Used = true;
                }
        }
 
                if $1.Op == OPACK {
                        var s *Sym
                        s = restrictlookup($3.Name, $1.Pkg);
-                       $1.Used = 1;
+                       $1.Used = true;
                        $$ = oldname(s);
                        break;
                }
                $$ = $1;
                n = oldname($1);
                if n.Pack != nil {
-                       n.Pack.Used = 1;
+                       n.Pack.Used = true;
                }
        }
 |      LNAME '.' sym
                        Yyerror("%v is not a package", Sconv($1, 0));
                        pkg = localpkg;
                } else {
-                       $1.Def.Used = 1;
+                       $1.Def.Used = true;
                        pkg = $1.Def.Pkg;
                }
                $$ = restrictlookup($3.Name, pkg);
 
                if p == nil {
                        break
                }
-               if p.As == obj.ATYPE && p.From.Node != nil && p.From.Name == obj.NAME_AUTO && ((p.From.Node).(*Node)).Used == 0 {
+               if p.As == obj.ATYPE && p.From.Node != nil && p.From.Name == obj.NAME_AUTO && !((p.From.Node).(*Node)).Used {
                        *lp = p.Link
                        continue
                }
 
-               if (p.As == obj.AVARDEF || p.As == obj.AVARKILL) && p.To.Node != nil && ((p.To.Node).(*Node)).Used == 0 {
+               if (p.As == obj.AVARDEF || p.As == obj.AVARKILL) && p.To.Node != nil && !((p.To.Node).(*Node)).Used {
                        // Cannot remove VARDEF instruction, because - unlike TYPE handled above -
                        // VARDEFs are interspersed with other code, and a jump might be using the
                        // VARDEF as a target. Replace with a no-op instead. A later pass will remove
                }
 
                if p.From.Node != nil {
-                       ((p.From.Node).(*Node)).Used = 1
+                       ((p.From.Node).(*Node)).Used = true
                }
 
                if p.To.Node != nil {
-                       ((p.To.Node).(*Node)).Used = 1
+                       ((p.To.Node).(*Node)).Used = true
                }
        }
 }
 
        n := newname(var_.Sym)
        n.Type = var_.Type
        n.Class = PAUTO
-       n.Used = 1
+       n.Used = true
        n.Curfn = Curfn // the calling function, not the called one
        n.Addrtaken = var_.Addrtaken
 
        n := newname(Lookup(namebuf))
        n.Type = t.Type
        n.Class = PAUTO
-       n.Used = 1
+       n.Used = true
        n.Curfn = Curfn // the calling function, not the called one
        Curfn.Dcl = list(Curfn.Dcl, n)
        return n
        n := newname(Lookup(namebuf))
        n.Type = t.Type
        n.Class = PAUTO
-       n.Used = 1
+       n.Used = true
        n.Curfn = Curfn // the calling function, not the called one
        Curfn.Dcl = list(Curfn.Dcl, n)
        return n
 
                                // leave s->block set to cause redeclaration
                                // errors if a conflicting top-level name is
                                // introduced by a different file.
-                               if s.Def.Used == 0 && nsyntaxerrors == 0 {
+                               if !s.Def.Used && nsyntaxerrors == 0 {
                                        pkgnotused(int(s.Def.Lineno), s.Def.Pkg.Path, s.Name)
                                }
                                s.Def = nil
                        if s.Def.Sym != s {
                                // throw away top-level name left over
                                // from previous import . "x"
-                               if s.Def.Pack != nil && s.Def.Pack.Used == 0 && nsyntaxerrors == 0 {
+                               if s.Def.Pack != nil && !s.Def.Pack.Used && nsyntaxerrors == 0 {
                                        pkgnotused(int(s.Def.Pack.Lineno), s.Def.Pack.Pkg.Path, "")
-                                       s.Def.Pack.Used = 1
+                                       s.Def.Pack.Used = true
                                }
 
                                s.Def = nil
 
                return 0
        }
 
-       if (a.Used == 0) != (b.Used == 0) {
-               return int(b.Used) - int(a.Used)
+       if a.Used != b.Used {
+               return bool2int(b.Used) - bool2int(a.Used)
        }
 
        ap := bool2int(haspointers(a.Type))
        // Mark the PAUTO's unused.
        for ll := Curfn.Dcl; ll != nil; ll = ll.Next {
                if ll.N.Class == PAUTO {
-                       ll.N.Used = 0
+                       ll.N.Used = false
                }
        }
 
        ll := Curfn.Dcl
 
        n := ll.N
-       if n.Class == PAUTO && n.Op == ONAME && n.Used == 0 {
+       if n.Class == PAUTO && n.Op == ONAME && !n.Used {
                // No locals used at all
                Curfn.Dcl = nil
 
 
        for ll := Curfn.Dcl; ll.Next != nil; ll = ll.Next {
                n = ll.Next.N
-               if n.Class == PAUTO && n.Op == ONAME && n.Used == 0 {
+               if n.Class == PAUTO && n.Op == ONAME && !n.Used {
                        ll.Next = nil
                        Curfn.Dcl.End = ll
                        break
 
                        // remove implicit conversions; the eventual assignment
                        // will reintroduce them.
                        case OAS:
-                               if (n.Right.Op == OCONVNOP || n.Right.Op == OCONVIFACE) && n.Right.Implicit != 0 {
+                               if (n.Right.Op == OCONVNOP || n.Right.Op == OCONVIFACE) && n.Right.Implicit {
                                        n.Right = n.Right.Left
                                }
 
 
                        r := Nod(OCONVNOP, n, nil)
                        r.Type = Types[TBOOL]
                        r.Typecheck = 1
-                       r.Implicit = 1
+                       r.Implicit = true
                        n = r
                }
        }
        r := Nod(op, n, nil)
        r.Type = t
        r.Typecheck = 1
-       r.Implicit = 1
+       r.Implicit = true
        r.Orig = n.Orig
        return r
 }
                        // rebuild elided dots
                        for c := d - 1; c >= 0; c-- {
                                if n.Left.Type != nil && Isptr[n.Left.Type.Etype] {
-                                       n.Left.Implicit = 1
+                                       n.Left.Implicit = true
                                }
                                n.Left = Nod(ODOT, n.Left, newname(dotlist[c].field.Sym))
                        }
 
        Local          uint8
        Dodata         uint8
        Initorder      uint8
-       Used           uint8
+       Used           bool
        Isddd          uint8
        Readonly       bool
-       Implicit       uint8
+       Implicit       bool
        Addrtaken      bool // address taken, even if not moved to heap
        Assigned       bool // is the variable ever assigned to
        Captured       bool // is the variable captured by a closure
 
                                return
                        }
 
-                       n.Used = 1
+                       n.Used = true
                }
 
                if top&Ecall == 0 && isunsafebuiltin(n) {
 
                if t.Etype != TIDEAL && !Eqtype(l.Type, r.Type) {
                        defaultlit2(&l, &r, 1)
-                       if n.Op == OASOP && n.Implicit != 0 {
+                       if n.Op == OASOP && n.Implicit {
                                Yyerror("invalid operation: %v (non-numeric type %v)", Nconv(n, 0), Tconv(l.Type, 0))
                                n.Type = nil
                                return
                        }
 
                        n.Left = Nod(OADDR, n.Left, nil)
-                       n.Left.Implicit = 1
+                       n.Left.Implicit = true
                        typecheck(&n.Left, Erv)
                        l = n.Left
                }
                        }
 
                        n.Left = Nod(OADDR, n.Left, nil)
-                       n.Left.Implicit = 1
+                       n.Left.Implicit = true
                        typecheck(&n.Left, Erv)
                        l = n.Left
                }
                return
        }
        n = Nod(OIND, n, nil)
-       n.Implicit = 1
+       n.Implicit = true
        typecheck(&n, Erv)
        *nn = n
 }
                if t.Etype == TINTER {
                        if Isptr[n.Left.Type.Etype] {
                                n.Left = Nod(OIND, n.Left, nil) // implicitstar
-                               n.Left.Implicit = 1
+                               n.Left.Implicit = true
                                typecheck(&n.Left, Erv)
                        }
 
                        if int(rcvr.Etype) == Tptr && Eqtype(rcvr.Type, tt) {
                                checklvalue(n.Left, "call pointer method on")
                                n.Left = Nod(OADDR, n.Left, nil)
-                               n.Left.Implicit = 1
+                               n.Left.Implicit = true
                                typecheck(&n.Left, Etype|Erv)
                        } else if int(tt.Etype) == Tptr && int(rcvr.Etype) != Tptr && Eqtype(tt.Type, rcvr) {
                                n.Left = Nod(OIND, n.Left, nil)
-                               n.Left.Implicit = 1
+                               n.Left.Implicit = true
                                typecheck(&n.Left, Etype|Erv)
                        } else if int(tt.Etype) == Tptr && int(tt.Type.Etype) == Tptr && Eqtype(derefall(tt), derefall(rcvr)) {
                                Yyerror("calling method %v with receiver %v requires explicit dereference", Nconv(n.Right, 0), Nconv(n.Left, obj.FmtLong))
                                                break
                                        }
                                        n.Left = Nod(OIND, n.Left, nil)
-                                       n.Left.Implicit = 1
+                                       n.Left.Implicit = true
                                        typecheck(&n.Left, Etype|Erv)
                                        tt = tt.Type
                                }
                for ll.Left != nil {
                        ll = ll.Left
                }
-               if ll.Implicit != 0 {
+               if ll.Implicit {
                        if Isptr[ll.Type.Etype] && ll.Type.Sym != nil && ll.Type.Sym.Def != nil && ll.Type.Sym.Def.Op == OTYPE {
                                // It is invalid to automatically dereference a named pointer type when selecting a method.
                                // Make n->left == ll to clarify error message.
 
        if n.Right == nil {
                n.Right = typenod(t)
-               n.Implicit = 1       // don't print
-               n.Right.Implicit = 1 // * is okay
+               n.Implicit = true       // don't print
+               n.Right.Implicit = true // * is okay
        } else if Debug['s'] != 0 {
                typecheck(&n.Right, Etype)
                if n.Right.Type != nil && Eqtype(n.Right.Type, t) {
        if Isptr[t.Etype] {
                // For better or worse, we don't allow pointers as the composite literal type,
                // except when using the &T syntax, which sets implicit on the OIND.
-               if n.Right.Implicit == 0 {
+               if !n.Right.Implicit {
                        Yyerror("invalid pointer type %v for composite literal (use &%v instead)", Tconv(t, 0), Tconv(t.Type, 0))
                        n.Type = nil
                        return
 
 
        // Propagate the used flag for typeswitch variables up to the NONAME in it's definition.
        for l := fn.Dcl; l != nil; l = l.Next {
-               if l.N.Op == ONAME && l.N.Class&^PHEAP == PAUTO && l.N.Defn != nil && l.N.Defn.Op == OTYPESW && l.N.Used != 0 {
-                       l.N.Defn.Left.Used++
+               if l.N.Op == ONAME && l.N.Class&^PHEAP == PAUTO && l.N.Defn != nil && l.N.Defn.Op == OTYPESW && l.N.Used {
+                       l.N.Defn.Left.Used = true
                }
        }
 
        for l := fn.Dcl; l != nil; l = l.Next {
-               if l.N.Op != ONAME || l.N.Class&^PHEAP != PAUTO || l.N.Sym.Name[0] == '&' || l.N.Used != 0 {
+               if l.N.Op != ONAME || l.N.Class&^PHEAP != PAUTO || l.N.Sym.Name[0] == '&' || l.N.Used {
                        continue
                }
                if l.N.Defn != nil && l.N.Defn.Op == OTYPESW {
-                       if l.N.Defn.Left.Used != 0 {
+                       if l.N.Defn.Left.Used {
                                continue
                        }
                        lineno = l.N.Defn.Left.Lineno
                        Yyerror("%v declared and not used", Sconv(l.N.Sym, 0))
-                       l.N.Defn.Left.Used = 1 // suppress repeats
+                       l.N.Defn.Left.Used = true // suppress repeats
                } else {
                        lineno = l.N.Lineno
                        Yyerror("%v declared and not used", Sconv(l.N.Sym, 0))
 
                        switch yyVAL.node.Op {
                        case ONAME, ONONAME, OTYPE, OPACK, OLITERAL:
                                yyVAL.node = Nod(OPAREN, yyVAL.node, nil)
-                               yyVAL.node.Implicit = 1
+                               yyVAL.node.Implicit = true
                                break
                        }
                }
                //line go.y:461
                {
                        yyVAL.node = Nod(OASOP, yyDollar[1].node, Nodintconst(1))
-                       yyVAL.node.Implicit = 1
+                       yyVAL.node.Implicit = true
                        yyVAL.node.Etype = OADD
                }
        case 54:
                //line go.y:467
                {
                        yyVAL.node = Nod(OASOP, yyDollar[1].node, Nodintconst(1))
-                       yyVAL.node.Implicit = 1
+                       yyVAL.node.Implicit = true
                        yyVAL.node.Etype = OSUB
                }
        case 55:
                                // Special case for &T{...}: turn into (*T){...}.
                                yyVAL.node = yyDollar[2].node
                                yyVAL.node.Right = Nod(OIND, yyVAL.node.Right, nil)
-                               yyVAL.node.Right.Implicit = 1
+                               yyVAL.node.Right.Implicit = true
                        } else {
                                yyVAL.node = Nod(OADDR, yyDollar[2].node, nil)
                        }
                        if yyDollar[1].node.Op == OPACK {
                                var s *Sym
                                s = restrictlookup(yyDollar[3].sym.Name, yyDollar[1].node.Pkg)
-                               yyDollar[1].node.Used = 1
+                               yyDollar[1].node.Used = true
                                yyVAL.node = oldname(s)
                                break
                        }
                        switch yyVAL.node.Op {
                        case ONAME, ONONAME, OTYPE, OPACK, OLITERAL:
                                yyVAL.node = Nod(OPAREN, yyVAL.node, nil)
-                               yyVAL.node.Implicit = 1
+                               yyVAL.node.Implicit = true
                        }
                }
        case 143:
                {
                        yyVAL.node = oldname(yyDollar[1].sym)
                        if yyVAL.node.Pack != nil {
-                               yyVAL.node.Pack.Used = 1
+                               yyVAL.node.Pack.Used = true
                        }
                }
        case 163:
                        if yyDollar[1].node.Op == OPACK {
                                var s *Sym
                                s = restrictlookup(yyDollar[3].sym.Name, yyDollar[1].node.Pkg)
-                               yyDollar[1].node.Used = 1
+                               yyDollar[1].node.Used = true
                                yyVAL.node = oldname(s)
                                break
                        }
                        yyVAL.sym = yyDollar[1].sym
                        n = oldname(yyDollar[1].sym)
                        if n.Pack != nil {
-                               n.Pack.Used = 1
+                               n.Pack.Used = true
                        }
                }
        case 237:
                                Yyerror("%v is not a package", Sconv(yyDollar[1].sym, 0))
                                pkg = localpkg
                        } else {
-                               yyDollar[1].sym.Def.Used = 1
+                               yyDollar[1].sym.Def.Used = true
                                pkg = yyDollar[1].sym.Def.Pkg
                        }
                        yyVAL.sym = restrictlookup(yyDollar[3].sym.Name, pkg)