This commit is contained in:
Araq 2018-09-03 10:50:39 +02:00
commit b3c3a46317
3 changed files with 11 additions and 7 deletions

View file

@ -1594,15 +1594,17 @@ proc getInt*(a: PNode): BiggestInt =
case a.kind case a.kind
of nkCharLit..nkUInt64Lit: result = a.intVal of nkCharLit..nkUInt64Lit: result = a.intVal
else: else:
raiseRecoverableError("cannot extract number from invalid AST node")
#internalError(a.info, "getInt") #internalError(a.info, "getInt")
doAssert false, "getInt" #doAssert false, "getInt"
#result = 0 #result = 0
proc getFloat*(a: PNode): BiggestFloat = proc getFloat*(a: PNode): BiggestFloat =
case a.kind case a.kind
of nkFloatLiterals: result = a.floatVal of nkFloatLiterals: result = a.floatVal
else: else:
doAssert false, "getFloat" raiseRecoverableError("cannot extract number from invalid AST node")
#doAssert false, "getFloat"
#internalError(a.info, "getFloat") #internalError(a.info, "getFloat")
#result = 0.0 #result = 0.0
@ -1616,7 +1618,8 @@ proc getStr*(a: PNode): string =
else: else:
result = nil result = nil
else: else:
doAssert false, "getStr" raiseRecoverableError("cannot extract string from invalid AST node")
#doAssert false, "getStr"
#internalError(a.info, "getStr") #internalError(a.info, "getStr")
#result = "" #result = ""
@ -1625,7 +1628,8 @@ proc getStrOrChar*(a: PNode): string =
of nkStrLit..nkTripleStrLit: result = a.strVal of nkStrLit..nkTripleStrLit: result = a.strVal
of nkCharLit..nkUInt64Lit: result = $chr(int(a.intVal)) of nkCharLit..nkUInt64Lit: result = $chr(int(a.intVal))
else: else:
doAssert false, "getStrOrChar" raiseRecoverableError("cannot extract string from invalid AST node")
#doAssert false, "getStrOrChar"
#internalError(a.info, "getStrOrChar") #internalError(a.info, "getStrOrChar")
#result = "" #result = ""

View file

@ -223,6 +223,9 @@ type
proc `==`*(a, b: FileIndex): bool {.borrow.} proc `==`*(a, b: FileIndex): bool {.borrow.}
proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} =
raise newException(ERecoverableError, msg)
const const
InvalidFileIDX* = FileIndex(-1) InvalidFileIDX* = FileIndex(-1)

View file

@ -102,9 +102,6 @@ proc newLineInfo*(fileInfoIdx: FileIndex, line, col: int): TLineInfo =
proc newLineInfo*(conf: ConfigRef; filename: string, line, col: int): TLineInfo {.inline.} = proc newLineInfo*(conf: ConfigRef; filename: string, line, col: int): TLineInfo {.inline.} =
result = newLineInfo(fileInfoIdx(conf, filename), line, col) result = newLineInfo(fileInfoIdx(conf, filename), line, col)
proc raiseRecoverableError*(msg: string) {.noinline, noreturn.} =
raise newException(ERecoverableError, msg)
proc concat(strings: openarray[string]): string = proc concat(strings: openarray[string]): string =
var totalLen = 0 var totalLen = 0