// 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
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)
}
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.
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
func push(pos src.XPos) *Sym {
d := new(Sym)
d.Lastlineno = pos
- d.Link = Dclstack
- Dclstack = d
+ d.Link = dclstack
+ dclstack = d
return d
}
// 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
Fatalf("popdcl: no mark")
}
- Dclstack = d.Link // pop mark
+ dclstack = d.Link // pop mark
Block = d.Block
}
// 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))
}
func IsDclstackValid() bool {
- for d := Dclstack; d != nil; d = d.Link {
+ for d := dclstack; d != nil; d = d.Link {
if d.Name == "" {
return false
}