mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-20 22:35:24 +00:00
hintMsgOrigin now works in VM code (#14678)
* `hintMsgOrigin` now works in VM code * remove a simplification for now
This commit is contained in:
@@ -13,7 +13,7 @@ import
|
||||
import std/private/miscdollars
|
||||
import strutils2
|
||||
|
||||
type InstantiationInfo = typeof(instantiationInfo())
|
||||
type InstantiationInfo* = typeof(instantiationInfo())
|
||||
template instLoc(): InstantiationInfo = instantiationInfo(-2, fullPaths = true)
|
||||
|
||||
template flushDot(conf, stdorr) =
|
||||
@@ -385,7 +385,7 @@ proc getMessageStr(msg: TMsgKind, arg: string): string =
|
||||
result = msgKindToString(msg) % [arg]
|
||||
|
||||
type
|
||||
TErrorHandling = enum doNothing, doAbort, doRaise
|
||||
TErrorHandling* = enum doNothing, doAbort, doRaise
|
||||
|
||||
proc log*(s: string) =
|
||||
var f: File
|
||||
@@ -485,7 +485,7 @@ proc formatMsg*(conf: ConfigRef; info: TLineInfo, msg: TMsgKind, arg: string): s
|
||||
else: ErrorTitle
|
||||
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.} =
|
||||
var
|
||||
title: string
|
||||
|
||||
@@ -72,20 +72,18 @@ proc stackTraceAux(c: PCtx; x: PStackFrame; pc: int; recursionLimit=100) =
|
||||
msgWriteln(c.config, s)
|
||||
|
||||
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)")
|
||||
stackTraceAux(c, tos, pc)
|
||||
# XXX test if we want 'globalError' for every mode
|
||||
if c.mode == emRepl: globalError(c.config, lineInfo, msg)
|
||||
else: localError(c.config, lineInfo, msg)
|
||||
let action = if c.mode == emRepl: doRaise else: doNothing
|
||||
# XXX test if we want 'globalError' for every mode
|
||||
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,
|
||||
msg: string, lineInfo: TLineInfo) =
|
||||
stackTraceImpl(c, tos, pc, msg, lineInfo)
|
||||
return
|
||||
|
||||
template stackTrace(c: PCtx, tos: PStackFrame, pc: int, msg: string) =
|
||||
stackTraceImpl(c, tos, pc, msg, c.debug[pc])
|
||||
msg: string, lineInfo: TLineInfo = TLineInfo.default) =
|
||||
stackTraceImpl(c, tos, pc, msg, lineInfo, instantiationInfo(-2, fullPaths = true))
|
||||
return
|
||||
|
||||
proc bailOut(c: PCtx; tos: PStackFrame) =
|
||||
|
||||
Reference in New Issue
Block a user