macros.nim: deprecated ! operator

This commit is contained in:
Andreas Rumpf 2017-11-19 10:08:24 +01:00
commit 4f9e8cf313
2 changed files with 15 additions and 7 deletions

View file

@ -768,8 +768,10 @@ macro `=~`(x: PNode, pat: untyped): bool =
var conds = newTree(nnkBracket) var conds = newTree(nnkBracket)
m(x, pat, conds) m(x, pat, conds)
result = nestList(!"and", conds) when declared(macros.toNimIdent):
result = nestList(toNimIdent"and", conds)
else:
result = nestList(!"and", conds)
proc isMinusOne(n: PNode): bool = proc isMinusOne(n: PNode): bool =
n.kind in {nkCharLit..nkUInt64Lit} and n.intVal == -1 n.kind in {nkCharLit..nkUInt64Lit} and n.intVal == -1

View file

@ -113,7 +113,9 @@ type
type type
NimIdent* = object of RootObj NimIdent* = object of RootObj
## represents a Nim identifier in the AST ## represents a Nim identifier in the AST. **Note**: This is only
## rarely useful, for identifier construction from a string
## use ``ident"abc"``.
NimSymObj = object # hidden NimSymObj = object # hidden
NimSym* = ref NimSymObj NimSym* = ref NimSymObj
@ -129,7 +131,11 @@ const
nnkCallKinds* = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand, nnkCallKinds* = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
nnkCallStrLit} nnkCallStrLit}
proc `!`*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect.} proc `!`*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect, deprecated.}
## constructs an identifier from the string `s`
## **Deprecated since version 0.18.0**: Use ``toNimIdent`` instead.
proc toNimIdent*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect.}
## constructs an identifier from the string `s` ## constructs an identifier from the string `s`
proc `$`*(i: NimIdent): string {.magic: "IdentToStr", noSideEffect.} proc `$`*(i: NimIdent): string {.magic: "IdentToStr", noSideEffect.}
@ -573,7 +579,7 @@ proc newLit*[T](arg: seq[T]): NimNode {.compileTime.} =
proc newLit*(arg: tuple): NimNode {.compileTime.} = proc newLit*(arg: tuple): NimNode {.compileTime.} =
result = nnkPar.newTree result = nnkPar.newTree
for a,b in arg.fieldPairs: for a,b in arg.fieldPairs:
result.add nnkExprColonExpr.newTree( newIdentNode(a), newLit(b) ) result.add nnkExprColonExpr.newTree(newIdentNode(a), newLit(b))
proc newLit*(s: string): NimNode {.compileTime.} = proc newLit*(s: string): NimNode {.compileTime.} =
## produces a new string literal node. ## produces a new string literal node.