var declare_typegen int
-func declare(n *Node, ctxt uint8) {
+func declare(n *Node, ctxt Class) {
if ctxt == PDISCARD {
return
}
s.Def = n
n.Name.Vargen = int32(gen)
n.Name.Funcdepth = Funcdepth
- n.Class = uint8(ctxt)
+ n.Class = ctxt
autoexport(n, ctxt)
}
-func addvar(n *Node, t *Type, ctxt uint8) {
+func addvar(n *Node, t *Type, ctxt Class) {
if n == nil || n.Sym == nil || (n.Op != ONAME && n.Op != ONONAME) || t == nil {
Fatalf("addvar: n=%v t=%v nil", n, t)
}
return sym.Pkg == localpkg && exportname(sym.Name)
}
-func autoexport(n *Node, ctxt uint8) {
+func autoexport(n *Node, ctxt Class) {
if n == nil || n.Sym == nil {
return
}
Cboth = Crecv | Csend
)
-// declaration context
+// The Class of a variable/function describes the "storage class"
+// of a variable or function. During parsing, storage classes are
+// called declaration contexts.
+type Class uint8
+
const (
- Pxxx = uint8(iota)
- PEXTERN // global variable
- PAUTO // local variables
- PPARAM // input arguments
- PPARAMOUT // output results
- PPARAMREF // closure variable reference
- PFUNC // global function
+ Pxxx Class = iota
+ PEXTERN // global variable
+ PAUTO // local variables
+ PPARAM // input arguments
+ PPARAMOUT // output results
+ PPARAMREF // closure variable reference
+ PFUNC // global function
PDISCARD // discard during parse of duplicate import
- PHEAP = uint8(1 << 7) // an extra bit to identify an escaped variable
+ PHEAP = 1 << 7 // an extra bit to identify an escaped variable
)
const (
var funcsyms []*Node
-var dclcontext uint8 // PEXTERN/PAUTO
+var dclcontext Class // PEXTERN/PAUTO
var incannedimport int
return
}
var a *Node
- var class uint8
+ var class Class
for l := fn.Func.Dcl; l != nil; l = l.Next {
a = l.N
class = a.Class &^ PHEAP
Addable bool // addressable
Etype uint8 // op for OASOP, etype for OTYPE, exclam for export, 6g saved reg
Bounded bool // bounds check unnecessary
- Class uint8 // PPARAM, PAUTO, PEXTERN, etc
+ Class Class // PPARAM, PAUTO, PEXTERN, etc
Embedded uint8 // ODCLFIELD embedded type
Colas bool // OAS resulting from :=
Diag uint8 // already printed error about this
// so that reorder3 can fix up conflicts
var rl *NodeList
- var cl uint8
+ var cl Class
for ll := Curfn.Func.Dcl; ll != nil; ll = ll.Next {
cl = ll.N.Class &^ PHEAP
if cl == PAUTO {