Commit ac2bda1b authored by Russ Cox's avatar Russ Cox

cmd/compile: move Node.Pkg to Node.Name.Pkg

$ sizeof -p cmd/compile/internal/gc Node
Node 224
$

Change-Id: Id0969e8df99c43a5f6f8d77a38f20a71a467e7c6
Reviewed-on: https://go-review.googlesource.com/10527Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 140ef3c5
...@@ -246,7 +246,7 @@ import_stmt: ...@@ -246,7 +246,7 @@ import_stmt:
pack := Nod(OPACK, nil, nil); pack := Nod(OPACK, nil, nil);
pack.Sym = my; pack.Sym = my;
pack.Pkg = ipkg; pack.Name.Pkg = ipkg;
pack.Lineno = int32($1); pack.Lineno = int32($1);
if strings.HasPrefix(my.Name, ".") { if strings.HasPrefix(my.Name, ".") {
...@@ -1010,7 +1010,7 @@ pexpr_no_paren: ...@@ -1010,7 +1010,7 @@ pexpr_no_paren:
{ {
if $1.Op == OPACK { if $1.Op == OPACK {
var s *Sym var s *Sym
s = restrictlookup($3.Name, $1.Pkg); s = restrictlookup($3.Name, $1.Name.Pkg);
$1.Used = true; $1.Used = true;
$$ = oldname(s); $$ = oldname(s);
break; break;
...@@ -1299,7 +1299,7 @@ dotname: ...@@ -1299,7 +1299,7 @@ dotname:
{ {
if $1.Op == OPACK { if $1.Op == OPACK {
var s *Sym var s *Sym
s = restrictlookup($3.Name, $1.Pkg); s = restrictlookup($3.Name, $1.Name.Pkg);
$1.Used = true; $1.Used = true;
$$ = oldname(s); $$ = oldname(s);
break; break;
...@@ -1700,7 +1700,7 @@ packname: ...@@ -1700,7 +1700,7 @@ packname:
pkg = localpkg; pkg = localpkg;
} else { } else {
$1.Def.Used = true; $1.Def.Used = true;
pkg = $1.Def.Pkg; pkg = $1.Def.Name.Pkg;
} }
$$ = restrictlookup($3.Name, pkg); $$ = restrictlookup($3.Name, pkg);
} }
......
...@@ -2577,7 +2577,7 @@ func mkpackage(pkgname string) { ...@@ -2577,7 +2577,7 @@ func mkpackage(pkgname string) {
// errors if a conflicting top-level name is // errors if a conflicting top-level name is
// introduced by a different file. // introduced by a different file.
if !s.Def.Used && nsyntaxerrors == 0 { if !s.Def.Used && nsyntaxerrors == 0 {
pkgnotused(int(s.Def.Lineno), s.Def.Pkg.Path, s.Name) pkgnotused(int(s.Def.Lineno), s.Def.Name.Pkg.Path, s.Name)
} }
s.Def = nil s.Def = nil
continue continue
...@@ -2587,7 +2587,7 @@ func mkpackage(pkgname string) { ...@@ -2587,7 +2587,7 @@ func mkpackage(pkgname string) {
// throw away top-level name left over // throw away top-level name left over
// from previous import . "x" // from previous import . "x"
if s.Def.Name != nil && s.Def.Name.Pack != nil && !s.Def.Name.Pack.Used && nsyntaxerrors == 0 { if s.Def.Name != nil && s.Def.Name.Pack != nil && !s.Def.Name.Pack.Used && nsyntaxerrors == 0 {
pkgnotused(int(s.Def.Name.Pack.Lineno), s.Def.Name.Pack.Pkg.Path, "") pkgnotused(int(s.Def.Name.Pack.Lineno), s.Def.Name.Pack.Name.Pkg.Path, "")
s.Def.Name.Pack.Used = true s.Def.Name.Pack.Used = true
} }
......
...@@ -378,7 +378,7 @@ func Nod(op int, nleft *Node, nright *Node) *Node { ...@@ -378,7 +378,7 @@ func Nod(op int, nleft *Node, nright *Node) *Node {
case ONAME: case ONAME:
n.Name = new(Name) n.Name = new(Name)
n.Param = new(Param) n.Param = new(Param)
case OLABEL: case OLABEL, OPACK:
n.Name = new(Name) n.Name = new(Name)
case ODCLFIELD: case ODCLFIELD:
n.Param = new(Param) n.Param = new(Param)
......
...@@ -33,9 +33,6 @@ type Node struct { ...@@ -33,9 +33,6 @@ type Node struct {
Curfn *Node // function for local variables Curfn *Node // function for local variables
Param *Param Param *Param
// OPACK
Pkg *Pkg
// Escape analysis. // Escape analysis.
Escflowsrc *NodeList // flow(this, src) Escflowsrc *NodeList // flow(this, src)
Escretval *NodeList // on OCALLxxx, list of dummy return values Escretval *NodeList // on OCALLxxx, list of dummy return values
...@@ -91,9 +88,10 @@ type Node struct { ...@@ -91,9 +88,10 @@ type Node struct {
Hasbreak bool // has break statement Hasbreak bool // has break statement
} }
// Name holds Node fields used only by ONAME nodes. // Name holds Node fields used only by named nodes (ONAME, OPACK, some OLITERAL).
type Name struct { type Name struct {
Pack *Node // real package for import . names Pack *Node // real package for import . names
Pkg *Pkg // pkg for OPACK nodes
Heapaddr *Node // temp holding heap address of param Heapaddr *Node // temp holding heap address of param
Inlvar *Node // ONAME substitute while inlining Inlvar *Node // ONAME substitute while inlining
Defn *Node // initializing assignment Defn *Node // initializing assignment
......
...@@ -1272,7 +1272,7 @@ yydefault: ...@@ -1272,7 +1272,7 @@ yydefault:
pack := Nod(OPACK, nil, nil) pack := Nod(OPACK, nil, nil)
pack.Sym = my pack.Sym = my
pack.Pkg = ipkg pack.Name.Pkg = ipkg
pack.Lineno = int32(yyDollar[1].i) pack.Lineno = int32(yyDollar[1].i)
if strings.HasPrefix(my.Name, ".") { if strings.HasPrefix(my.Name, ".") {
...@@ -2169,7 +2169,7 @@ yydefault: ...@@ -2169,7 +2169,7 @@ yydefault:
{ {
if yyDollar[1].node.Op == OPACK { if yyDollar[1].node.Op == OPACK {
var s *Sym var s *Sym
s = restrictlookup(yyDollar[3].sym.Name, yyDollar[1].node.Pkg) s = restrictlookup(yyDollar[3].sym.Name, yyDollar[1].node.Name.Pkg)
yyDollar[1].node.Used = true yyDollar[1].node.Used = true
yyVAL.node = oldname(s) yyVAL.node = oldname(s)
break break
...@@ -2431,7 +2431,7 @@ yydefault: ...@@ -2431,7 +2431,7 @@ yydefault:
{ {
if yyDollar[1].node.Op == OPACK { if yyDollar[1].node.Op == OPACK {
var s *Sym var s *Sym
s = restrictlookup(yyDollar[3].sym.Name, yyDollar[1].node.Pkg) s = restrictlookup(yyDollar[3].sym.Name, yyDollar[1].node.Name.Pkg)
yyDollar[1].node.Used = true yyDollar[1].node.Used = true
yyVAL.node = oldname(s) yyVAL.node = oldname(s)
break break
...@@ -2861,7 +2861,7 @@ yydefault: ...@@ -2861,7 +2861,7 @@ yydefault:
pkg = localpkg pkg = localpkg
} else { } else {
yyDollar[1].sym.Def.Used = true yyDollar[1].sym.Def.Used = true
pkg = yyDollar[1].sym.Def.Pkg pkg = yyDollar[1].sym.Def.Name.Pkg
} }
yyVAL.sym = restrictlookup(yyDollar[3].sym.Name, pkg) yyVAL.sym = restrictlookup(yyDollar[3].sym.Name, pkg)
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment