mirror of
https://github.com/golang/go
synced 2024-11-18 08:34:44 -07:00
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/10527 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
This commit is contained in:
parent
140ef3c59a
commit
ac2bda1b00
@ -246,7 +246,7 @@ import_stmt:
|
||||
|
||||
pack := Nod(OPACK, nil, nil);
|
||||
pack.Sym = my;
|
||||
pack.Pkg = ipkg;
|
||||
pack.Name.Pkg = ipkg;
|
||||
pack.Lineno = int32($1);
|
||||
|
||||
if strings.HasPrefix(my.Name, ".") {
|
||||
@ -1010,7 +1010,7 @@ pexpr_no_paren:
|
||||
{
|
||||
if $1.Op == OPACK {
|
||||
var s *Sym
|
||||
s = restrictlookup($3.Name, $1.Pkg);
|
||||
s = restrictlookup($3.Name, $1.Name.Pkg);
|
||||
$1.Used = true;
|
||||
$$ = oldname(s);
|
||||
break;
|
||||
@ -1299,7 +1299,7 @@ dotname:
|
||||
{
|
||||
if $1.Op == OPACK {
|
||||
var s *Sym
|
||||
s = restrictlookup($3.Name, $1.Pkg);
|
||||
s = restrictlookup($3.Name, $1.Name.Pkg);
|
||||
$1.Used = true;
|
||||
$$ = oldname(s);
|
||||
break;
|
||||
@ -1700,7 +1700,7 @@ packname:
|
||||
pkg = localpkg;
|
||||
} else {
|
||||
$1.Def.Used = true;
|
||||
pkg = $1.Def.Pkg;
|
||||
pkg = $1.Def.Name.Pkg;
|
||||
}
|
||||
$$ = restrictlookup($3.Name, pkg);
|
||||
}
|
||||
|
@ -2577,7 +2577,7 @@ func mkpackage(pkgname string) {
|
||||
// errors if a conflicting top-level name is
|
||||
// introduced by a different file.
|
||||
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
|
||||
continue
|
||||
@ -2587,7 +2587,7 @@ func mkpackage(pkgname string) {
|
||||
// throw away top-level name left over
|
||||
// from previous import . "x"
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -378,7 +378,7 @@ func Nod(op int, nleft *Node, nright *Node) *Node {
|
||||
case ONAME:
|
||||
n.Name = new(Name)
|
||||
n.Param = new(Param)
|
||||
case OLABEL:
|
||||
case OLABEL, OPACK:
|
||||
n.Name = new(Name)
|
||||
case ODCLFIELD:
|
||||
n.Param = new(Param)
|
||||
|
@ -33,9 +33,6 @@ type Node struct {
|
||||
Curfn *Node // function for local variables
|
||||
Param *Param
|
||||
|
||||
// OPACK
|
||||
Pkg *Pkg
|
||||
|
||||
// Escape analysis.
|
||||
Escflowsrc *NodeList // flow(this, src)
|
||||
Escretval *NodeList // on OCALLxxx, list of dummy return values
|
||||
@ -91,9 +88,10 @@ type Node struct {
|
||||
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 {
|
||||
Pack *Node // real package for import . names
|
||||
Pkg *Pkg // pkg for OPACK nodes
|
||||
Heapaddr *Node // temp holding heap address of param
|
||||
Inlvar *Node // ONAME substitute while inlining
|
||||
Defn *Node // initializing assignment
|
||||
|
@ -1272,7 +1272,7 @@ yydefault:
|
||||
|
||||
pack := Nod(OPACK, nil, nil)
|
||||
pack.Sym = my
|
||||
pack.Pkg = ipkg
|
||||
pack.Name.Pkg = ipkg
|
||||
pack.Lineno = int32(yyDollar[1].i)
|
||||
|
||||
if strings.HasPrefix(my.Name, ".") {
|
||||
@ -2169,7 +2169,7 @@ yydefault:
|
||||
{
|
||||
if yyDollar[1].node.Op == OPACK {
|
||||
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
|
||||
yyVAL.node = oldname(s)
|
||||
break
|
||||
@ -2431,7 +2431,7 @@ yydefault:
|
||||
{
|
||||
if yyDollar[1].node.Op == OPACK {
|
||||
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
|
||||
yyVAL.node = oldname(s)
|
||||
break
|
||||
@ -2861,7 +2861,7 @@ yydefault:
|
||||
pkg = localpkg
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user