Documentation ¶
Index ¶
- Constants
- type 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, showOrig 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
- type PosTable
- type XPos
Constants ¶
const FileSymPrefix = "gofile.."
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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) Before ¶
Before reports whether the position p comes before q in the source. For positions in different files, ordering is by filename.
func (Pos) Format ¶
Format formats a position as "filename:line" or "filename:line:column", controlled by the showCol flag. A position relative to a line directive is always formatted without column information. In that case, if showOrig is set, the original position (again controlled by showCol) is appended in square brackets: "filename:line[origfile:origline:origcolumn]".
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) RelFilename ¶
RelFilename returns the filename recorded with the position's base.
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.
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.