]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: remove Local flags on Type and Node
authorMatthew Dempsky <mdempsky@google.com>
Wed, 27 Sep 2017 20:27:22 +0000 (13:27 -0700)
committerMatthew Dempsky <mdempsky@google.com>
Wed, 4 Oct 2017 17:55:43 +0000 (17:55 +0000)
These are redundant with checking x.Sym.Pkg == localpkg.

Passes toolstash-check -all.

Change-Id: Iebe25f7932cd15a036141b468ad75c239abcdcf7
Reviewed-on: https://go-review.googlesource.com/66670
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/gc/closure.go
src/cmd/compile/internal/gc/dcl.go
src/cmd/compile/internal/gc/noder.go
src/cmd/compile/internal/gc/reflect.go
src/cmd/compile/internal/gc/select.go
src/cmd/compile/internal/gc/syntax.go
src/cmd/compile/internal/gc/typecheck.go
src/cmd/compile/internal/types/type.go

index 93997b069a873ca55889ca38c6a8ad64901c9318..d3af16e1764d93ea9c20ce1a20f054e81a51c5dd 100644 (file)
@@ -495,7 +495,6 @@ func walkclosure(func_ *Node, init *Nodes) *Node {
        }
        typ := tostruct(fields)
        typ.SetNoalg(true)
-       typ.SetLocal(true)
 
        clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
        clos.Esc = func_.Esc
@@ -689,7 +688,6 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
                namedfield("R", n.Left.Type),
        })
        typ.SetNoalg(true)
-       typ.SetLocal(true)
 
        clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil))
        clos.Esc = n.Esc
index 37d281d10641f5d26395ff782dc0eb742271e404..2351f931f3f001026df9dc4903328277fc685ae9 100644 (file)
@@ -975,7 +975,7 @@ func addmethod(msym *types.Sym, t *types.Type, local, nointerface bool) {
                return
        }
 
-       if local && !mt.Local() {
+       if local && mt.Sym.Pkg != localpkg {
                yyerror("cannot define new methods on non-local type %v", mt)
                return
        }
index 17b826bf3846c2c896e065cbe6c90f21f522fdf3..4db50117c4a1c637222c347888b31421ea04f0c1 100644 (file)
@@ -322,7 +322,6 @@ func (p *noder) typeDecl(decl *syntax.TypeDecl) *Node {
        n := p.declName(decl.Name)
        n.Op = OTYPE
        declare(n, dclcontext)
-       n.SetLocal(true)
 
        // decl.Type may be nil but in that case we got a syntax error during parsing
        typ := p.typeExprOrNil(decl.Type)
index 0023f65a10d497560bf50086e3d87ce2433581d8..e45e5e9a443efebf5d472ce32d2df4532da16535 100644 (file)
@@ -166,7 +166,6 @@ func bmap(t *types.Type) *types.Type {
 
        // link up fields
        bucket.SetNoalg(true)
-       bucket.SetLocal(t.Local())
        bucket.SetFields(field[:])
        dowidth(bucket)
 
@@ -262,7 +261,6 @@ func hmap(t *types.Type) *types.Type {
 
        hmap := types.New(TSTRUCT)
        hmap.SetNoalg(true)
-       hmap.SetLocal(t.Local())
        hmap.SetFields(fields)
        dowidth(hmap)
 
@@ -1167,7 +1165,7 @@ func dtypesym(t *types.Type) *types.Sym {
 
        if myimportpath != "runtime" || (tbase != types.Types[tbase.Etype] && tbase != types.Bytetype && tbase != types.Runetype && tbase != types.Errortype) { // int, float, etc
                // named types from other files are defined only by those files
-               if tbase.Sym != nil && !tbase.Local() {
+               if tbase.Sym != nil && tbase.Sym.Pkg != localpkg {
                        return s
                }
                // TODO(mdempsky): Investigate whether this can happen.
index 320cd9a47efb07bcf3e68cf689c6744243a15b1f..319d32b256e6254d613040de311385f25cbd2551 100644 (file)
@@ -342,7 +342,6 @@ func selecttype(size int64) *types.Type {
                namedfield("releasetime", types.Types[TUINT64]),
        })
        scase.SetNoalg(true)
-       scase.SetLocal(true)
 
        sel := tostruct([]*Node{
                namedfield("tcase", types.Types[TUINT16]),
@@ -354,7 +353,6 @@ func selecttype(size int64) *types.Type {
                namedfield("pollorderarr", types.NewArray(types.Types[TUINT16], size)),
        })
        sel.SetNoalg(true)
-       sel.SetLocal(true)
 
        return sel
 }
index db8597e22325571ad141f472c67c13bbb6f8e058..2fc63edd25d8040114829d9b746a9ac0a47d5299 100644 (file)
@@ -86,7 +86,6 @@ const (
        _, nodeAddrtaken // address taken, even if not moved to heap
        _, nodeImplicit
        _, nodeIsddd    // is the argument variadic
-       _, nodeLocal    // type created in this file (see also Type.Local)
        _, nodeDiag     // already printed error about this
        _, nodeColas    // OAS resulting from :=
        _, nodeNonNil   // guaranteed to be non-nil
@@ -113,7 +112,6 @@ func (n *Node) Assigned() bool              { return n.flags&nodeAssigned != 0 }
 func (n *Node) Addrtaken() bool             { return n.flags&nodeAddrtaken != 0 }
 func (n *Node) Implicit() bool              { return n.flags&nodeImplicit != 0 }
 func (n *Node) Isddd() bool                 { return n.flags&nodeIsddd != 0 }
-func (n *Node) Local() bool                 { return n.flags&nodeLocal != 0 }
 func (n *Node) Diag() bool                  { return n.flags&nodeDiag != 0 }
 func (n *Node) Colas() bool                 { return n.flags&nodeColas != 0 }
 func (n *Node) NonNil() bool                { return n.flags&nodeNonNil != 0 }
@@ -139,7 +137,6 @@ func (n *Node) SetAssigned(b bool)              { n.flags.set(nodeAssigned, b) }
 func (n *Node) SetAddrtaken(b bool)             { n.flags.set(nodeAddrtaken, b) }
 func (n *Node) SetImplicit(b bool)              { n.flags.set(nodeImplicit, b) }
 func (n *Node) SetIsddd(b bool)                 { n.flags.set(nodeIsddd, b) }
-func (n *Node) SetLocal(b bool)                 { n.flags.set(nodeLocal, b) }
 func (n *Node) SetDiag(b bool)                  { n.flags.set(nodeDiag, b) }
 func (n *Node) SetColas(b bool)                 { n.flags.set(nodeColas, b) }
 func (n *Node) SetNonNil(b bool)                { n.flags.set(nodeNonNil, b) }
index 523007f3b6b455c03e3c4a85781f48d378110fb2..39570f1cf406fd539086a8485e9646435bbfeeef 100644 (file)
@@ -3524,7 +3524,6 @@ func copytype(n *Node, t *types.Type) {
 
        t = n.Type
        t.Sym = n.Sym
-       t.SetLocal(n.Local())
        if n.Name != nil {
                t.Vargen = n.Name.Vargen
        }
index 92b5d2da95b3ca566726021580f1a773f7834772..fbf0d88fb4abd2d54e7020a38d7a967d75d398f6 100644 (file)
@@ -162,22 +162,19 @@ type Type struct {
 }
 
 const (
-       typeLocal     = 1 << iota // created in this file
-       typeNotInHeap             // type cannot be heap allocated
+       typeNotInHeap = 1 << iota // type cannot be heap allocated
        typeBroke                 // broken type definition
        typeNoalg                 // suppress hash and eq algorithm generation
        typeDeferwidth
        typeRecur
 )
 
-func (t *Type) Local() bool      { return t.flags&typeLocal != 0 }
 func (t *Type) NotInHeap() bool  { return t.flags&typeNotInHeap != 0 }
 func (t *Type) Broke() bool      { return t.flags&typeBroke != 0 }
 func (t *Type) Noalg() bool      { return t.flags&typeNoalg != 0 }
 func (t *Type) Deferwidth() bool { return t.flags&typeDeferwidth != 0 }
 func (t *Type) Recur() bool      { return t.flags&typeRecur != 0 }
 
-func (t *Type) SetLocal(b bool)      { t.flags.set(typeLocal, b) }
 func (t *Type) SetNotInHeap(b bool)  { t.flags.set(typeNotInHeap, b) }
 func (t *Type) SetBroke(b bool)      { t.flags.set(typeBroke, b) }
 func (t *Type) SetNoalg(b bool)      { t.flags.set(typeNoalg, b) }