package src
import "cmd/internal/src"
Index ¶
- Constants
- type Pos
- func MakePos(base *PosBase, line, col uint) Pos
- func (p Pos) AbsFilename() string
- func (p Pos) After(q Pos) bool
- func (p Pos) Base() *PosBase
- func (p Pos) Before(q Pos) bool
- func (x Pos) Col() uint
- func (p Pos) Filename() string
- func (p Pos) Format(showCol bool) string
- func (p Pos) IsKnown() bool
- func (x Pos) Line() uint
- func (p Pos) RelFilename() string
- func (p Pos) RelLine() uint
- func (p *Pos) SetBase(base *PosBase)
- func (p Pos) String() string
- func (p Pos) SymFilename() string
- type PosBase
- func NewFileBase(filename, absFilename string) *PosBase
- func NewInliningBase(old *PosBase, inlTreeIndex int) *PosBase
- func NewLinePragmaBase(pos Pos, filename string, line uint) *PosBase
- func (b *PosBase) AbsFilename() string
- func (b *PosBase) Filename() string
- func (b *PosBase) InliningIndex() int
- func (b *PosBase) Line() uint
- func (b *PosBase) Pos() *Pos
- func (b *PosBase) SymFilename() string
- type PosTable
- type XPos
Constants ¶
const FileSymPrefix = "gofile.."
Types ¶
type Pos ¶
type Pos struct {
// contains filtered or unexported fields
}
A Pos encodes a source position consisting of a (line, column) number pair and a position base. A zero Pos is a ready to use "unknown" position (nil position base and zero line number).
The (line, column) values refer to a position in a file independent of any position base ("absolute" file position).
The position base is used to determine the "relative" position, that is the filename and line number relative to the position base. If the base refers to the current file, there is no difference between absolute and relative positions. If it refers to a //line pragma, a relative position is relative to that pragma. A position base in turn contains the position at which it was introduced in the current file.
var NoPos Pos
NoPos is a valid unknown position.
func MakePos ¶
MakePos creates a new Pos value with the given base, and (file-absolute) line and column.
func (Pos) AbsFilename ¶
AbsFilename() returns the absolute filename recorded with the position's base.
func (Pos) After ¶
After reports whether the position p comes after q in the source. For positions in different files, ordering is by filename.
func (Pos) Base ¶
Base returns the position base.
func (Pos) Before ¶
Before reports whether the position p comes before q in the source. For positions in different files, ordering is by filename.
func (Pos) Col ¶
func (x Pos) Col() uint
func (Pos) Filename ¶
Filename returns the name of the actual file containing this position.
func (Pos) Format ¶
Format formats a position as "filename:line" or "filename:line:column", controlled by the showCol flag. If the position is relative to a line directive, the original position is appended in square brackets without column (since the column doesn't change).
func (Pos) IsKnown ¶
IsKnown reports whether the position p is known. A position is known if it either has a non-nil position base, or a non-zero line number.
func (Pos) Line ¶
func (x Pos) Line() uint
func (Pos) RelFilename ¶
RelFilename returns the filename recorded with the position's base.
func (Pos) RelLine ¶
RelLine returns the line number relative to the positions's base.
func (*Pos) SetBase ¶
SetBase sets the position base.
func (Pos) String ¶
func (Pos) SymFilename ¶
SymFilename() returns the absolute filename recorded with the position's base, prefixed by FileSymPrefix to make it appropriate for use as a linker symbol.
type PosBase ¶
type PosBase struct {
// contains filtered or unexported fields
}
A PosBase encodes a filename and base line number. Typically, each file and line pragma introduce a PosBase. A nil *PosBase is a ready to use file PosBase for an unnamed file with line numbers starting at 1.
func NewFileBase ¶
NewFileBase returns a new *PosBase for a file with the given (relative and absolute) filenames.
func NewInliningBase ¶
NewInliningBase returns a copy of the old PosBase with the given inlining index. If old == nil, the resulting PosBase has no filename.
func NewLinePragmaBase ¶
NewLinePragmaBase returns a new *PosBase for a line pragma of the form
//line filename:line
at position pos.
func (*PosBase) AbsFilename ¶
AbsFilename returns the absolute filename recorded with the base. If b == nil, the result is the empty string.
func (*PosBase) Filename ¶
Filename returns the filename recorded with the base. If b == nil, the result is the empty string.
func (*PosBase) InliningIndex ¶
InliningIndex returns the index into the global inlining tree recorded with the base. If b == nil or the base has not been inlined, the result is < 0.
func (*PosBase) Line ¶
Line returns the line number recorded with the base. If b == nil, the result is 0.
func (*PosBase) Pos ¶
Pos returns the position at which base is located. If b == nil, the result is the zero position.
func (*PosBase) SymFilename ¶
SymFilename returns the absolute filename recorded with the base, prefixed by FileSymPrefix to make it appropriate for use as a linker symbol. If b is nil, SymFilename returns FileSymPrefix + "??".
type PosTable ¶
type PosTable struct {
// contains filtered or unexported fields
}
A PosTable tracks Pos -> XPos conversions and vice versa. Its zero value is a ready-to-use PosTable.
func (*PosTable) Pos ¶
Pos returns the corresponding Pos for the given p. If p cannot be translated via t, the function panics.
func (*PosTable) XPos ¶
XPos returns the corresponding XPos for the given pos, adding pos to t if necessary.
type XPos ¶
type XPos struct {
// contains filtered or unexported fields
}
XPos is a more compact representation of Pos.
var NoXPos XPos
NoXPos is a valid unknown position.
func (XPos) After ¶
After reports whether the position p comes after q in the source. For positions with different bases, ordering is by base index.
func (XPos) Before ¶
Before reports whether the position p comes before q in the source. For positions with different bases, ordering is by base index.
func (XPos) Col ¶
func (x XPos) Col() uint
func (XPos) IsKnown ¶
IsKnown reports whether the position p is known. XPos.IsKnown() matches Pos.IsKnown() for corresponding positions.
func (XPos) Line ¶
func (x XPos) Line() uint
Source Files ¶
- Version
- v1.9.3
- Published
- Jan 22, 2018
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 3 seconds ago –
Tools for package owners.