# compiler/msgs

Dark Mode

- Index

Search:
Group by:
Source Edit

# Imports

options, ropes, lineinfos, pathutils, strutils2

# Types

    InstantiationInfo = typeof(instantiationInfo())

  Source Edit

    MsgFlag = enum
      msgStdout,                ## force writing to stdout, even stderr is default
      msgSkipHook,              ## skip message hook even if it is present
      msgNoUnitSep               ## the message is a complete "paragraph".

  flags altering msgWriteln behavior Source Edit

    MsgFlags = set[MsgFlag]

  Source Edit

    TErrorHandling = enum
      doNothing, doAbort, doRaise

  Source Edit

# Consts

    ColOffset = 1

  Source Edit

    commandLineDesc = "command line"

  Source Edit

    gCmdLineInfo = (line: 1'u, col: 1, fileIndex: -3)

  Source Edit

# Procs

    proc `$`(conf: ConfigRef; info: TLineInfo): string {.
        ...raises: [Exception, KeyError, OSError], tags: [RootEffect, ReadDirEffect].}

  Source Edit

    proc `$`(info: TLineInfo): string {.error.}

  Source Edit

    proc `==`(a, b: TLineInfo): bool {....raises: [], tags: [].}

  Source Edit

    proc `??`(conf: ConfigRef; info: TLineInfo; filename: string): bool {.
        ...raises: [], tags: [].}

  Source Edit

    proc exactEquals(a, b: TLineInfo): bool {....raises: [], tags: [].}

  Source Edit

    proc fileInfoIdx(conf: ConfigRef; filename: AbsoluteFile): FileIndex {.
        ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}

  Source Edit

    proc fileInfoIdx(conf: ConfigRef; filename: AbsoluteFile; isKnownFile: var bool): FileIndex {.
        ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}

  Source Edit

    proc fileInfoKnown(conf: ConfigRef; filename: AbsoluteFile): bool {....raises: [],
        tags: [ReadDirEffect].}

  Source Edit

    proc flushDot(conf: ConfigRef) {....raises: [IOError], tags: [WriteIOEffect].}

  safe to call multiple times Source Edit

    proc formatMsg(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string): string {.
        ...raises: [Exception, KeyError, OSError, ValueError],
        tags: [RootEffect, ReadDirEffect].}

  Source Edit

    proc genSuccessX(conf: ConfigRef) {....raises: [ValueError, OSError, Exception,
        KeyError, IOError, ERecoverableError], tags: [TimeEffect, RootEffect,
        ReadDirEffect, WriteIOEffect, ReadIOEffect, ReadEnvEffect].}

  Source Edit

    proc getHash(conf: ConfigRef; fileIdx: FileIndex): string {....raises: [], tags: [].}

  Source Edit

    proc getInfoContext(conf: ConfigRef; index: int): TLineInfo {....raises: [],
        tags: [].}

  Source Edit

    proc getInfoContextLen(conf: ConfigRef): int {....raises: [], tags: [].}

  Source Edit

    proc liMessage(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg: string;
                   eh: TErrorHandling; info2: InstantiationInfo; isRaw = false) {.
        noinline, ...raises: [Exception, ValueError, KeyError, OSError, IOError,
                           ERecoverableError], tags: [RootEffect, ReadDirEffect,
        WriteIOEffect, ReadIOEffect, ReadEnvEffect].}

  Source Edit

    proc listHints(conf: ConfigRef) {....raises: [Exception, IOError, ValueError],
                                      tags: [RootEffect, WriteIOEffect].}

  Source Edit

    proc listWarnings(conf: ConfigRef) {....raises: [Exception, IOError, ValueError],
                                         tags: [RootEffect, WriteIOEffect].}

  Source Edit

    proc log(s: string) {....raises: [IOError],
                          tags: [ReadEnvEffect, ReadIOEffect, WriteIOEffect].}

  Source Edit

    proc makeCString(s: string): Rope {....raises: [], tags: [].}

  Source Edit

    proc msgKindToString(kind: TMsgKind): string {....raises: [], tags: [].}

  Source Edit

    proc msgQuit(x: int8) {....raises: [], tags: [].}

  Source Edit

    proc msgQuit(x: string) {....raises: [], tags: [].}

  Source Edit

    proc msgWriteln(conf: ConfigRef; s: string; flags: MsgFlags = {}) {.
        ...raises: [Exception, IOError], tags: [RootEffect, WriteIOEffect].}

  Writes given message string to stderr by default. If `--stdout` option is given, writes to stdout instead. If message hook is present, then it is used to output message rather than stderr/stdout. This behavior can be altered by given optional flags. Source Edit

    proc newLineInfo(conf: ConfigRef; filename: AbsoluteFile; line, col: int): TLineInfo {.
        inline, ...raises: [KeyError, Exception], tags: [ReadDirEffect, RootEffect].}

  Source Edit

    proc newLineInfo(fileInfoIdx: FileIndex; line, col: int): TLineInfo {.
        ...raises: [], tags: [].}

  Source Edit

    proc numLines(conf: ConfigRef; fileIdx: FileIndex): int {....raises: [],
        tags: [ReadIOEffect].}

  xxx there's an off by 1 error that should be fixed; if a file ends with "foo" or "foon" it will return same number of lines (ie, a trailing empty line is discounted) Source Edit

    proc popInfoContext(conf: ConfigRef) {....raises: [], tags: [].}

  Source Edit

    proc pushInfoContext(conf: ConfigRef; info: TLineInfo; detail: string = "") {.
        ...raises: [], tags: [].}

  Source Edit

    proc quotedFilename(conf: ConfigRef; i: TLineInfo): Rope {....raises: [], tags: [].}

  Source Edit

    proc setDirtyFile(conf: ConfigRef; fileIdx: FileIndex; filename: AbsoluteFile) {.
        ...raises: [], tags: [].}

  Source Edit

    proc setHash(conf: ConfigRef; fileIdx: FileIndex; hash: string) {....raises: [],
        tags: [].}

  Source Edit

    proc setInfoContextLen(conf: ConfigRef; L: int) {....raises: [], tags: [].}

  Source Edit

    proc sourceLine(conf: ConfigRef; i: TLineInfo): string {....raises: [],
        tags: [ReadIOEffect].}

  1-based index (matches editor line numbers); 1st line is for i.line = 1 last valid line is `numLines` inclusive Source Edit

    proc suggestQuit() {....raises: [ESuggestDone], tags: [].}

  Source Edit

    proc suggestWriteln(conf: ConfigRef; s: string) {....raises: [IOError, Exception],
        tags: [WriteIOEffect, RootEffect].}

  Source Edit

    proc toCChar(c: char; result: var string) {.inline, ...raises: [], tags: [].}

  Source Edit

    proc toColumn(info: TLineInfo): int {.inline, ...raises: [], tags: [].}

  Source Edit

    proc toFileLineCol(conf: ConfigRef; info: TLineInfo): string {.inline,
        ...raises: [Exception, KeyError, OSError], tags: [RootEffect, ReadDirEffect].}

  Source Edit

    proc toFilenameOption(conf: ConfigRef; fileIdx: FileIndex; opt: FilenameOption): string {.
        ...raises: [Exception, KeyError, OSError], tags: [RootEffect, ReadDirEffect].}

  Source Edit

    proc toFullPath(conf: ConfigRef; fileIdx: FileIndex): string {....raises: [],
        tags: [].}

  Source Edit

    proc toFullPathConsiderDirty(conf: ConfigRef; fileIdx: FileIndex): AbsoluteFile {.
        ...raises: [], tags: [].}

  Source Edit

    proc toLinenumber(info: TLineInfo): int {.inline, ...raises: [], tags: [].}

  Source Edit

    proc toMsgFilename(conf: ConfigRef; fileIdx: FileIndex): string {.
        ...raises: [Exception, KeyError, OSError], tags: [RootEffect, ReadDirEffect].}

  Source Edit

    proc toProjPath(conf: ConfigRef; fileIdx: FileIndex): string {....raises: [],
        tags: [].}

  Source Edit

    proc uniqueModuleName(conf: ConfigRef; fid: FileIndex): string {.
        ...raises: [Exception], tags: [RootEffect].}

  The unique module name is guaranteed to only contain {'A'..'Z', 'a'..'z', '0'..'9', '_'} so that it is useful as a C identifier snippet. Source Edit

    proc warningDeprecated(conf: ConfigRef; info: TLineInfo = gCmdLineInfo; msg = "") {.
        inline, ...raises: [Exception, ValueError, KeyError, OSError, IOError,
                         ERecoverableError], tags: [RootEffect, ReadDirEffect,
        WriteIOEffect, ReadIOEffect, ReadEnvEffect].}

  Source Edit

# Templates

    template fatal(conf: ConfigRef; info: TLineInfo; arg = ""; msg = errFatal)

  Source Edit

    template globalAssert(conf: ConfigRef; cond: untyped;
                          info: TLineInfo = unknownLineInfo; arg = "")

  avoids boilerplate Source Edit

    template globalError(conf: ConfigRef; info: TLineInfo; arg: string)

  Source Edit

    template globalError(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg = "")

  `local` means compilation keeps going until errorMax is reached (via `doNothing`), `global` means it stops. Source Edit

    template instLoc(): InstantiationInfo

  Source Edit

    template internalAssert(conf: ConfigRef; e: bool)

  Source Edit

    template internalError(conf: ConfigRef; errMsg: string)

  Source Edit

    template internalError(conf: ConfigRef; info: TLineInfo; errMsg: string)

  Source Edit

    template lintReport(conf: ConfigRef; info: TLineInfo; beau, got: string;
                        extraMsg = "")

  Source Edit

    template localError(conf: ConfigRef; info: TLineInfo; arg: string)

  Source Edit

    template localError(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg = "")

  Source Edit

    template message(conf: ConfigRef; info: TLineInfo; msg: TMsgKind; arg = "")

  Source Edit

    template rawMessage(conf: ConfigRef; msg: TMsgKind; arg: string)

  Source Edit

    template rawMessage(conf: ConfigRef; msg: TMsgKind; args: openArray[string])

  Source Edit

    template toFilename(conf: ConfigRef; fileIdx: FileIndex): string

  Source Edit

    template toFilename(conf: ConfigRef; info: TLineInfo): string

  Source Edit

    template toFullPath(conf: ConfigRef; info: TLineInfo): string

  Source Edit

    template toFullPathConsiderDirty(conf: ConfigRef; info: TLineInfo): string

  Source Edit

    template toMsgFilename(conf: ConfigRef; info: TLineInfo): string

  Source Edit

    template toProjPath(conf: ConfigRef; info: TLineInfo): string

  Source Edit