if s == nil {
Fatalf("newname nil")
}
-
n := nod(ONAME, nil, nil)
n.Sym = s
- n.Type = nil
+ n.Addable = true
+ n.Ullman = 1
+ n.Xoffset = 0
+ return n
+}
+
+// newnoname returns a new ONONAME Node associated with symbol s.
+func newnoname(s *Sym) *Node {
+ if s == nil {
+ Fatalf("newnoname nil")
+ }
+ n := nod(ONONAME, nil, nil)
+ n.Sym = s
n.Addable = true
n.Ullman = 1
n.Xoffset = 0
// Maybe a top-level declaration will come along later to
// define s. resolve will check s.Def again once all input
// source has been processed.
- n = newname(s)
- n.Op = ONONAME
- n.Name.Iota = iota_ // save current iota value in const declarations
+ n = newnoname(s)
+ n.SetIota(iota_) // save current iota value in const declarations
return n
}
// - ODOT, ODOTPTR, and OINDREGSP use it to indicate offset relative to their base address.
// - OSTRUCTKEY uses it to store the named field's offset.
// - OXCASE and OXFALL use it to validate the use of fallthrough.
+ // - ONONAME uses it to store the current value of iota, see Node.Iota
// Possibly still more uses. If you find any, document them.
Xoffset int64
n.E = x
}
+func (n *Node) Iota() int64 {
+ return n.Xoffset
+}
+
+func (n *Node) SetIota(x int64) {
+ n.Xoffset = x
+}
+
// Name holds Node fields used only by named nodes (ONAME, OPACK, OLABEL, some OLITERAL).
type Name struct {
Pack *Node // real package for import . names
Param *Param // additional fields for ONAME
Decldepth int32 // declaration loop depth, increased for every loop or label
Vargen int32 // unique name for ONAME within a function. Function outputs are numbered starting at one.
- Iota int32 // value if this name is iota
Funcdepth int32
Method bool // OCALLMETH name
Readonly bool