s = Lookup("_")
types.BlankSym = s
- s.Block = -100
s.Def = NewName(s)
ir.AsNode(s.Def).SetType(types.Types[types.TBLANK])
ir.BlankNode = ir.AsNode(s.Def)
ir.BlankNode.SetTypecheck(1)
s = types.BuiltinPkg.Lookup("_")
- s.Block = -100
s.Def = NewName(s)
ir.AsNode(s.Def).SetType(types.Types[types.TBLANK])
}
s1.Def = s.Def
- s1.Block = s.Block
}
}
import (
"cmd/compile/internal/base"
- "cmd/internal/src"
)
// Declaration stack & operations
-var blockgen int32 = 1 // max block number
-var Block int32 = 1 // current block number
-
// A dsym stores a symbol's shadowed declaration so that it can be
// restored once the block scope ends.
type dsym struct {
- sym *Sym // sym == nil indicates stack mark
- def Object
- block int32
- lastlineno src.XPos // last declaration for diagnostic
+ sym *Sym // sym == nil indicates stack mark
+ def Object
}
// dclstack maintains a stack of shadowed symbol declarations so that
// it can be shadowed by a new declaration within a nested block scope.
func Pushdcl(s *Sym) {
dclstack = append(dclstack, dsym{
- sym: s,
- def: s.Def,
- block: s.Block,
- lastlineno: s.Lastlineno,
+ sym: s,
+ def: s.Def,
})
}
s := d.sym
if s == nil {
// pop stack mark
- Block = d.block
dclstack = dclstack[:i-1]
return
}
s.Def = d.def
- s.Block = d.block
- s.Lastlineno = d.lastlineno
// Clear dead pointer fields.
d.sym = nil
// Markdcl records the start of a new block scope for declarations.
func Markdcl() {
dclstack = append(dclstack, dsym{
- sym: nil, // stack mark
- block: Block,
+ sym: nil, // stack mark
})
- blockgen++
- Block = blockgen
}
func isDclstackValid() bool {
import (
"cmd/compile/internal/base"
"cmd/internal/obj"
- "cmd/internal/src"
"unicode"
"unicode/utf8"
)
Pkg *Pkg
Name string // object name
- // Def, Block, and Lastlineno are saved and restored by Pushdcl/Popdcl.
-
// The unique ONAME, OTYPE, OPACK, or OLITERAL node that this symbol is
// bound to within the current scope. (Most parts of the compiler should
// prefer passing the Node directly, rather than relying on this field.)
- Def Object
- Block int32 // blocknumber to catch redeclaration
- Lastlineno src.XPos // last declaration for diagnostic
+ //
+ // Def is saved and restored by Pushdcl/Popdcl.
+ //
+ // Deprecated: New code should avoid depending on Sym.Def. Add
+ // mdempsky@ as a reviewer for any CLs involving Sym.Def.
+ Def Object
flags bitset8
}