compiler/ast/lineinfos

  Source   Edit

This module contains the TMsgKind enum as well as the TLineInfo object.

Types

CompilerVerbosity = enum
  compVerbosityMin = (0, "0"), compVerbosityDefault = (1, "1"),
  compVerbosityHigh = (2, "2"), compVerbosityMax = (3, "3")
verbosity of the compiler, number is used as an array index and the string matches what's passed on the CLI.   Source   Edit
ERecoverableError = object of ValueError
  Source   Edit
ESuggestDone = object of ValueError
  Source   Edit
FileIndex = distinct int32
  Source   Edit
InstantiationInfo = typeof(instantiationInfo())
  Source   Edit
LineColPair = tuple[line: typeof(TLineInfo.line), col: typeof(TLineInfo.col)]
  Source   Edit
Severity {.pure.} = enum
  Hint, Warning, Error
VS Code only supports these three   Source   Edit
TErrorOutput = enum
  eStdOut, eStdErr
  Source   Edit
TFileInfo = object
  fullPath*: AbsoluteFile    ## This is a canonical full filesystem path
  projPath*: RelativeFile    ## This is relative to the project's root
  shortName*: string         ## short name of the module
  quotedName*: Rope          ## cached quoted short name for codegen
                             ## purposes
  quotedFullName*: Rope      ## cached quoted full name for codegen
                             ## purposes
  lines*: seq[string]        ## the source code of the module used for
                             ## better error messages and embedding the
                             ## original source in the generated code
  dirtyFile*: AbsoluteFile   ## the file that is actually read into memory
                             ## and parsed; usually "" but is used
                             ## for 'nimsuggest'
  hash*: string              ## the checksum of the file
  dirty*: bool               ## for 'nimfix' like tooling
  
  Source   Edit
TLineInfo = object
  line*: uint16
  col*: int16
  fileIndex*: FileIndex
This is designed to be as small as possible, because it is used in syntax nodes. We save space here by using two int16 and an int32. On 64 bit and on 32 bit systems this is only 8 bytes.   Source   Edit

Consts

commandLineIdx = -3'i32
  Source   Edit
explanationsBaseUrl = "https://nim-works.github.io/nimskull"
  Source   Edit
InvalidFileIdx = -1'i32
  Source   Edit
trackPosInvalidFileIdx = -2'i32
special marker so that no suggestions are produced within comments and string literals   Source   Edit
unknownLineInfo = (line: 0'u16, col: -1'i16, fileIndex: -1'i32)
  Source   Edit

Procs

proc `==`(a, b: FileIndex): bool {.borrow, ...raises: [], tags: [].}
  Source   Edit
func clampLineCol(line, col: int): LineColPair {.inline, ...raises: [], tags: [].}
  Source   Edit
proc createDocLink(urlSuffix: string): string {....raises: [], tags: [].}
  Source   Edit
proc hash(i: TLineInfo): Hash {....raises: [], tags: [].}
  Source   Edit
func isKnown(info: TLineInfo): bool {....raises: [], tags: [].}
Check if info represents valid source file location   Source   Edit
proc newLineInfo(fileIndex: FileIndex; line, col: int): TLineInfo {.inline,
    ...raises: [], tags: [].}
  Source   Edit
proc raiseRecoverableError(msg: string) {.noinline, ...raises: [ERecoverableError],
    tags: [].}
  Source   Edit

Templates

template instLoc(depth: int = -2): InstantiationInfo

grabs where in the compiler an error was instanced to ease debugging.

whether to use full paths depends on --excessiveStackTrace compiler option.

  Source   Edit