mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.inline] cmd/compile/internal/syntax: introduce general position info for nodes
Reviewed in and cherry-picked from https://go-review.googlesource.com/#/c/33758/. Minor adjustments in noder.go to fix merge. Change-Id: Ibe429e327c7f8554f8ac205c61ce3738013aed98 Reviewed-on: https://go-review.googlesource.com/34231 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
eaca0e0529
commit
8d20b25779
11 changed files with 380 additions and 111 deletions
|
|
@ -8,7 +8,7 @@ package syntax
|
|||
// Nodes
|
||||
|
||||
type Node interface {
|
||||
Line() uint32
|
||||
Pos() *Pos
|
||||
aNode()
|
||||
init(p *parser)
|
||||
}
|
||||
|
|
@ -16,19 +16,17 @@ type Node interface {
|
|||
type node struct {
|
||||
// commented out for now since not yet used
|
||||
// doc *Comment // nil means no comment(s) attached
|
||||
pos uint32
|
||||
line uint32
|
||||
pos Pos
|
||||
}
|
||||
|
||||
func (n *node) Pos() *Pos {
|
||||
return &n.pos
|
||||
}
|
||||
|
||||
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)
|
||||
n.pos = MakePos(nil, p.line, p.col)
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
@ -38,7 +36,7 @@ func (n *node) init(p *parser) {
|
|||
type File struct {
|
||||
PkgName *Name
|
||||
DeclList []Decl
|
||||
Lines int
|
||||
Lines uint
|
||||
node
|
||||
}
|
||||
|
||||
|
|
@ -102,7 +100,7 @@ type (
|
|||
Type *FuncType
|
||||
Body []Stmt // nil means no body (forward declaration)
|
||||
Pragma Pragma // TODO(mdempsky): Cleaner solution.
|
||||
EndLine uint32 // TODO(mdempsky): Cleaner solution.
|
||||
EndLine uint // TODO(mdempsky): Cleaner solution.
|
||||
decl
|
||||
}
|
||||
)
|
||||
|
|
@ -142,8 +140,8 @@ type (
|
|||
CompositeLit struct {
|
||||
Type Expr // nil means no literal type
|
||||
ElemList []Expr
|
||||
NKeys int // number of elements with keys
|
||||
EndLine uint32 // TODO(mdempsky): Cleaner solution.
|
||||
NKeys int // number of elements with keys
|
||||
EndLine uint // TODO(mdempsky): Cleaner solution.
|
||||
expr
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +155,7 @@ type (
|
|||
FuncLit struct {
|
||||
Type *FuncType
|
||||
Body []Stmt
|
||||
EndLine uint32 // TODO(mdempsky): Cleaner solution.
|
||||
EndLine uint // TODO(mdempsky): Cleaner solution.
|
||||
expr
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue