parent
a55b90827e
commit
9d51197aa4
4 changed files with 12 additions and 5 deletions
|
|
@ -138,3 +138,5 @@ proc initDefines*(symbols: StringTableRef) =
|
||||||
defineSymbol("nimHasHintAll")
|
defineSymbol("nimHasHintAll")
|
||||||
defineSymbol("nimHasTrace")
|
defineSymbol("nimHasTrace")
|
||||||
defineSymbol("nimHasEffectsOf")
|
defineSymbol("nimHasEffectsOf")
|
||||||
|
|
||||||
|
defineSymbol("nimHasEnforceNoRaises")
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ const
|
||||||
wAsmNoStackFrame, wDiscardable, wNoInit, wCodegenDecl,
|
wAsmNoStackFrame, wDiscardable, wNoInit, wCodegenDecl,
|
||||||
wGensym, wInject, wRaises, wEffectsOf, wTags, wLocks, wDelegator, wGcSafe,
|
wGensym, wInject, wRaises, wEffectsOf, wTags, wLocks, wDelegator, wGcSafe,
|
||||||
wConstructor, wLiftLocals, wStackTrace, wLineTrace, wNoDestroy,
|
wConstructor, wLiftLocals, wStackTrace, wLineTrace, wNoDestroy,
|
||||||
wRequires, wEnsures}
|
wRequires, wEnsures, wEnforceNoRaises}
|
||||||
converterPragmas* = procPragmas
|
converterPragmas* = procPragmas
|
||||||
methodPragmas* = procPragmas+{wBase}-{wImportCpp}
|
methodPragmas* = procPragmas+{wBase}-{wImportCpp}
|
||||||
templatePragmas* = {wDeprecated, wError, wGensym, wInject, wDirty,
|
templatePragmas* = {wDeprecated, wError, wGensym, wInject, wDirty,
|
||||||
|
|
@ -1237,6 +1237,8 @@ proc singlePragma(c: PContext, sym: PSym, n: PNode, i: var int,
|
||||||
pragmaProposition(c, it)
|
pragmaProposition(c, it)
|
||||||
of wEnsures:
|
of wEnsures:
|
||||||
pragmaEnsures(c, it)
|
pragmaEnsures(c, it)
|
||||||
|
of wEnforceNoRaises:
|
||||||
|
sym.flags.incl sfNeverRaises
|
||||||
else: invalidPragma(c, it)
|
else: invalidPragma(c, it)
|
||||||
elif comesFromPush and whichKeyword(ident) != wInvalid:
|
elif comesFromPush and whichKeyword(ident) != wInvalid:
|
||||||
discard "ignore the .push pragma; it doesn't apply"
|
discard "ignore the .push pragma; it doesn't apply"
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ type
|
||||||
wAsmNoStackFrame = "asmNoStackFrame", wImplicitStatic = "implicitStatic",
|
wAsmNoStackFrame = "asmNoStackFrame", wImplicitStatic = "implicitStatic",
|
||||||
wGlobal = "global", wCodegenDecl = "codegenDecl", wUnchecked = "unchecked",
|
wGlobal = "global", wCodegenDecl = "codegenDecl", wUnchecked = "unchecked",
|
||||||
wGuard = "guard", wLocks = "locks", wPartial = "partial", wExplain = "explain",
|
wGuard = "guard", wLocks = "locks", wPartial = "partial", wExplain = "explain",
|
||||||
wLiftLocals = "liftlocals",
|
wLiftLocals = "liftlocals", wEnforceNoRaises = "enforceNoRaises",
|
||||||
|
|
||||||
wAuto = "auto", wBool = "bool", wCatch = "catch", wChar = "char",
|
wAuto = "auto", wBool = "bool", wCatch = "catch", wChar = "char",
|
||||||
wClass = "class", wCompl = "compl", wConst_cast = "const_cast", wDefault = "default",
|
wClass = "class", wCompl = "compl", wConst_cast = "const_cast", wDefault = "default",
|
||||||
|
|
|
||||||
|
|
@ -78,14 +78,17 @@ func addIntImpl(result: var string, x: uint64) {.inline.} =
|
||||||
dec next
|
dec next
|
||||||
addChars(result, tmp, next, tmp.len - next)
|
addChars(result, tmp, next, tmp.len - next)
|
||||||
|
|
||||||
func addInt*(result: var string, x: uint64) =
|
when not defined(nimHasEnforceNoRaises):
|
||||||
|
{.pragma: enforceNoRaises.}
|
||||||
|
|
||||||
|
func addInt*(result: var string, x: uint64) {.enforceNoRaises.} =
|
||||||
when nimvm: addIntImpl(result, x)
|
when nimvm: addIntImpl(result, x)
|
||||||
else:
|
else:
|
||||||
when not defined(js): addIntImpl(result, x)
|
when not defined(js): addIntImpl(result, x)
|
||||||
else:
|
else:
|
||||||
addChars(result, numToString(x))
|
addChars(result, numToString(x))
|
||||||
|
|
||||||
proc addInt*(result: var string; x: int64) =
|
proc addInt*(result: var string; x: int64) {.enforceNoRaises.} =
|
||||||
## Converts integer to its string representation and appends it to `result`.
|
## Converts integer to its string representation and appends it to `result`.
|
||||||
runnableExamples:
|
runnableExamples:
|
||||||
var s = "foo"
|
var s = "foo"
|
||||||
|
|
@ -110,5 +113,5 @@ proc addInt*(result: var string; x: int64) =
|
||||||
addChars(result, numToString(x))
|
addChars(result, numToString(x))
|
||||||
else: impl()
|
else: impl()
|
||||||
|
|
||||||
proc addInt*(result: var string; x: int) {.inline.} =
|
proc addInt*(result: var string; x: int) {.inline, enforceNoRaises.} =
|
||||||
addInt(result, int64(x))
|
addInt(result, int64(x))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue