// Nodes
type Node interface {
+ Line() uint32
aNode()
}
func (*node) aNode() {}
+func (n *node) Line() uint32 {
+ return n.line
+}
+
func (n *node) init(p *parser) {
n.pos = uint32(p.pos)
n.line = uint32(p.line)
}
FuncDecl struct {
- Attr map[string]bool // go:attr map
- Recv *Field // nil means regular function
- Name *Name
- Type *FuncType
- Body []Stmt // nil means no body (forward declaration)
+ Attr map[string]bool // go:attr map
+ Recv *Field // nil means regular function
+ Name *Name
+ Type *FuncType
+ Body []Stmt // nil means no body (forward declaration)
+ EndLine uint32 // TODO(mdempsky): Cleaner solution.
decl
}
)
// func Type { Body }
FuncLit struct {
- Type *FuncType
- Body []Stmt
+ Type *FuncType
+ Body []Stmt
+ EndLine uint32 // TODO(mdempsky): Cleaner solution.
expr
}
SliceExpr struct {
X Expr
Index [3]Expr
+ // Full indicates whether this is a simple or full slice expression.
+ // In a valid AST, this is equivalent to Index[2] != nil.
+ // TODO(mdempsky): This is only needed to report the "3-index
+ // slice of string" error when Index[2] is missing.
+ Full bool
expr
}
f.Type = p.funcType()
f.Body = p.funcBody()
+ f.EndLine = uint32(p.line)
+
// TODO(gri) deal with function properties
// if noescape && body != nil {
// p.error("can only use //go:noescape with external func implementations")
f.init(p)
f.Type = t
f.Body = p.funcBody()
+ f.EndLine = uint32(p.line)
p.xnest--
p.fnest--
return f
t.Index[1] = p.expr()
}
if p.got(_Colon) {
+ t.Full = true
// x[i:j:...]
if t.Index[1] == nil {
p.error("middle index required in 3-index slice")