1
0
mirror of https://github.com/golang/go synced 2024-11-23 20:40:07 -07:00

cmd/compile: remove uses of types.Dclstack - not needed anymore

Follow-up on https://go-review.googlesource.com/#/c/39998/.

Change-Id: I8830eebd7ea7e02b7edda99e67b6d43529401201
Reviewed-on: https://go-review.googlesource.com/40974
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
Robert Griesemer 2017-04-18 15:21:02 -07:00
parent 912a638b0c
commit 48163968b2
3 changed files with 10 additions and 16 deletions

View File

@ -1161,9 +1161,7 @@ func (p *importer) node() *Node {
// unreachable - not emitted by exporter
case OGOTO, OLABEL:
n := nodl(p.pos(), op, newname(p.expr().Sym), nil)
n.Sym = types.Dclstack // context, for goto restrictions
return n
return nodl(p.pos(), op, newname(p.expr().Sym), nil)
case OEND:
return nil

View File

@ -725,9 +725,6 @@ func (p *noder) stmt(stmt syntax.Stmt) *Node {
if stmt.Label != nil {
n.Left = p.newname(stmt.Label)
}
if op == OGOTO {
n.Sym = types.Dclstack // context, for goto restriction
}
if op == OXFALL {
n.Xoffset = int64(types.Block)
}
@ -909,7 +906,6 @@ func (p *noder) commClauses(clauses []*syntax.CommClause) []*Node {
func (p *noder) labeledStmt(label *syntax.LabeledStmt) *Node {
lhs := p.nod(label, OLABEL, p.newname(label.Label), nil)
lhs.Sym = types.Dclstack // context, for goto restriction
var ls *Node
if label.Stmt != nil { // TODO(mdempsky): Should always be present.

View File

@ -14,19 +14,19 @@ import (
var blockgen int32 = 1 // max block number
var Block int32 // current block number
// Dclstack maintains a stack of shadowed symbol declarations so that
// dclstack maintains a stack of shadowed symbol declarations so that
// popdcl can restore their declarations when a block scope ends.
// The stack is maintained as a linked list, using Sym's Link field.
//
// In practice, the "stack" actually ends up forming a tree: goto and label
// statements record the current state of Dclstack so that checkgoto can
// statements record the current state of dclstack so that checkgoto can
// validate that a goto statement does not jump over any declarations or
// into a new block scope.
//
// Finally, the Syms in this list are not "real" Syms as they don't actually
// represent object names. Sym is just a convenient type for saving shadowed
// Sym definitions, and only a subset of its fields are actually used.
var Dclstack *Sym
var dclstack *Sym
func dcopy(a, b *Sym) {
a.Pkg = b.Pkg
@ -39,8 +39,8 @@ func dcopy(a, b *Sym) {
func push(pos src.XPos) *Sym {
d := new(Sym)
d.Lastlineno = pos
d.Link = Dclstack
Dclstack = d
d.Link = dclstack
dclstack = d
return d
}
@ -54,7 +54,7 @@ func Pushdcl(s *Sym, pos src.XPos) {
// Popdcl pops the innermost block scope and restores all symbol declarations
// to their previous state.
func Popdcl() {
d := Dclstack
d := dclstack
for ; d != nil && d.Name != ""; d = d.Link {
s := d.Pkg.Lookup(d.Name)
lno := s.Lastlineno
@ -66,7 +66,7 @@ func Popdcl() {
Fatalf("popdcl: no mark")
}
Dclstack = d.Link // pop mark
dclstack = d.Link // pop mark
Block = d.Block
}
@ -83,7 +83,7 @@ func Markdcl(lineno src.XPos) {
// keep around for debugging
func DumpDclstack() {
i := 0
for d := Dclstack; d != nil; d = d.Link {
for d := dclstack; d != nil; d = d.Link {
fmt.Printf("%6d %p", i, d)
if d.Name != "" {
fmt.Printf(" '%s' %v\n", d.Name, d.Pkg.Lookup(d.Name))
@ -95,7 +95,7 @@ func DumpDclstack() {
}
func IsDclstackValid() bool {
for d := Dclstack; d != nil; d = d.Link {
for d := dclstack; d != nil; d = d.Link {
if d.Name == "" {
return false
}