hintMsgOrigin now works in VM code (#14678)
* `hintMsgOrigin` now works in VM code * remove a simplification for now
This commit is contained in:
parent
faedb14a16
commit
de5cde473a
2 changed files with 11 additions and 13 deletions
|
|
@ -13,7 +13,7 @@ import
|
||||||
import std/private/miscdollars
|
import std/private/miscdollars
|
||||||
import strutils2
|
import strutils2
|
||||||
|
|
||||||
type InstantiationInfo = typeof(instantiationInfo())
|
type InstantiationInfo* = typeof(instantiationInfo())
|
||||||
template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
|
template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
|
||||||
|
|
||||||
template flushDot(conf, stdorr) =
|
template flushDot(conf, stdorr) =
|
||||||
|
|
@ -385,7 +385,7 @@ proc getMessageStr(msg: TMsgKind, arg: string): string =
|
||||||
result = msgKindToString(msg) % [arg]
|
result = msgKindToString(msg) % [arg]
|
||||||
|
|
||||||
type
|
type
|
||||||
TErrorHandling = enum doNothing, doAbort, doRaise
|
TErrorHandling* = enum doNothing, doAbort, doRaise
|
||||||
|
|
||||||
proc log*(s: string) =
|
proc log*(s: string) =
|
||||||
var f: File
|
var f: File
|
||||||
|
|
@ -485,7 +485,7 @@ proc formatMsg*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string): s
|
||||||
else: ErrorTitle
|
else: ErrorTitle
|
||||||
conf.toFileLineCol(info) & " " & title & getMessageStr(msg, arg)
|
conf.toFileLineCol(info) & " " & title & getMessageStr(msg, arg)
|
||||||
|
|
||||||
proc liMessage(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
proc liMessage*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string,
|
||||||
eh: TErrorHandling, info2: InstantiationInfo, isRaw = false) {.noinline.} =
|
eh: TErrorHandling, info2: InstantiationInfo, isRaw = false) {.noinline.} =
|
||||||
var
|
var
|
||||||
title: string
|
title: string
|
||||||
|
|
|
||||||
|
|
@ -72,20 +72,18 @@ proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int; recursionLimit=100) =
|
||||||
msgWriteln(c.config, s)
|
msgWriteln(c.config, s)
|
||||||
|
|
||||||
proc stackTraceImpl(c: PCtx, tos: PStackFrame, pc: int,
|
proc stackTraceImpl(c: PCtx, tos: PStackFrame, pc: int,
|
||||||
msg: string, lineInfo: TLineInfo) =
|
msg: string, lineInfo: TLineInfo, infoOrigin: InstantiationInfo) {.noinline.} =
|
||||||
|
# noinline to avoid code bloat
|
||||||
msgWriteln(c.config, "stack trace: (most recent call last)")
|
msgWriteln(c.config, "stack trace: (most recent call last)")
|
||||||
stackTraceAux(c, tos, pc)
|
stackTraceAux(c, tos, pc)
|
||||||
# XXX test if we want 'globalError' for every mode
|
let action = if c.mode == emRepl: doRaise else: doNothing
|
||||||
if c.mode == emRepl: globalError(c.config, lineInfo, msg)
|
# XXX test if we want 'globalError' for every mode
|
||||||
else: localError(c.config, lineInfo, msg)
|
let lineInfo = if lineInfo == TLineInfo.default: c.debug[pc] else: lineInfo
|
||||||
|
liMessage(c.config, lineInfo, errGenerated, msg, action, infoOrigin)
|
||||||
|
|
||||||
template stackTrace(c: PCtx, tos: PStackFrame, pc: int,
|
template stackTrace(c: PCtx, tos: PStackFrame, pc: int,
|
||||||
msg: string, lineInfo: TLineInfo) =
|
msg: string, lineInfo: TLineInfo = TLineInfo.default) =
|
||||||
stackTraceImpl(c, tos, pc, msg, lineInfo)
|
stackTraceImpl(c, tos, pc, msg, lineInfo, instantiationInfo(-2, fullPaths = true))
|
||||||
return
|
|
||||||
|
|
||||||
template stackTrace(c: PCtx, tos: PStackFrame, pc: int, msg: string) =
|
|
||||||
stackTraceImpl(c, tos, pc, msg, c.debug[pc])
|
|
||||||
return
|
return
|
||||||
|
|
||||||
proc bailOut(c: PCtx; tos: PStackFrame) =
|
proc bailOut(c: PCtx; tos: PStackFrame) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue