diff options
author | Robert Griesemer <gri@golang.org> | 2016-11-29 16:13:09 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2016-12-09 00:42:42 +0000 |
commit | 8d20b25779d4ce32e8eaeb52374fba1e74f7df57 (patch) | |
tree | 1dd10782d5b321986850604da0bc743789ee31b8 /src/cmd/compile/internal/syntax/nodes.go | |
parent | eaca0e0529b780f4c862a97aa47008aa1b403adf (diff) | |
download | go-8d20b25779d4ce32e8eaeb52374fba1e74f7df57.tar.gz go-8d20b25779d4ce32e8eaeb52374fba1e74f7df57.zip |
[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>
Diffstat (limited to 'src/cmd/compile/internal/syntax/nodes.go')
-rw-r--r-- | src/cmd/compile/internal/syntax/nodes.go | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes.go b/src/cmd/compile/internal/syntax/nodes.go index fadba84bce..4cf8cc4202 100644 --- a/src/cmd/compile/internal/syntax/nodes.go +++ b/src/cmd/compile/internal/syntax/nodes.go @@ -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 (*node) aNode() {} - -func (n *node) Line() uint32 { - return n.line +func (n *node) Pos() *Pos { + return &n.pos } +func (*node) aNode() {} + 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 } |