mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 13:30:33 +00:00
remove deprecated stuffs since v0.18.1 from macros
This commit is contained in:
@@ -523,8 +523,8 @@ type
|
||||
mNccValue, mNccInc, mNcsAdd, mNcsIncl, mNcsLen, mNcsAt,
|
||||
mNctPut, mNctLen, mNctGet, mNctHasNext, mNctNext,
|
||||
|
||||
mNIntVal, mNFloatVal, mNSymbol, mNIdent, mNGetType, mNStrVal, mNSetIntVal,
|
||||
mNSetFloatVal, mNSetSymbol, mNSetIdent, mNSetStrVal, mNLineInfo,
|
||||
mNIntVal, mNFloatVal, mNGetType, mNStrVal, mNSetIntVal,
|
||||
mNSetFloatVal, mNSetStrVal, mNLineInfo,
|
||||
mNNewNimNode, mNCopyNimNode, mNCopyNimTree, mStrToIdent, mNSigHash, mNSizeOf,
|
||||
mNBindSym, mNCallSite,
|
||||
mEqIdent, mEqNimrodNode, mSameNodeType, mGetImpl, mNGenSym,
|
||||
|
||||
@@ -1787,20 +1787,6 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||
case a.kind
|
||||
of nkFloatLit..nkFloat64Lit: regs[ra].floatVal = a.floatVal
|
||||
else: stackTrace(c, tos, pc, errFieldXNotFound & "floatVal")
|
||||
of opcNSymbol:
|
||||
decodeB(rkNode)
|
||||
let a = regs[rb].node
|
||||
if a.kind == nkSym:
|
||||
regs[ra].node = copyNode(a)
|
||||
else:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound & "symbol")
|
||||
of opcNIdent:
|
||||
decodeB(rkNode)
|
||||
let a = regs[rb].node
|
||||
if a.kind == nkIdent:
|
||||
regs[ra].node = copyNode(a)
|
||||
else:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound & "ident")
|
||||
of opcNodeId:
|
||||
decodeB(rkInt)
|
||||
when defined(useNodeIds):
|
||||
@@ -2097,20 +2083,6 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
|
||||
dest.floatVal = regs[rb].floatVal
|
||||
else:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound & "floatVal")
|
||||
of opcNSetSymbol:
|
||||
decodeB(rkNode)
|
||||
var dest = regs[ra].node
|
||||
if dest.kind == nkSym and regs[rb].node.kind == nkSym:
|
||||
dest.sym = regs[rb].node.sym
|
||||
else:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound & "symbol")
|
||||
of opcNSetIdent:
|
||||
decodeB(rkNode)
|
||||
var dest = regs[ra].node
|
||||
if dest.kind == nkIdent and regs[rb].node.kind == nkIdent:
|
||||
dest.ident = regs[rb].node.ident
|
||||
else:
|
||||
stackTrace(c, tos, pc, errFieldXNotFound & "ident")
|
||||
of opcNSetStrVal:
|
||||
decodeB(rkNode)
|
||||
var dest = regs[ra].node
|
||||
|
||||
@@ -119,15 +119,13 @@ type
|
||||
opcNSymKind,
|
||||
opcNIntVal,
|
||||
opcNFloatVal,
|
||||
opcNSymbol,
|
||||
opcNIdent,
|
||||
opcNGetType,
|
||||
opcNStrVal,
|
||||
opcNSigHash,
|
||||
opcNGetSize,
|
||||
|
||||
opcNSetIntVal,
|
||||
opcNSetFloatVal, opcNSetSymbol, opcNSetIdent, opcNSetStrVal,
|
||||
opcNSetFloatVal, opcNSetStrVal,
|
||||
opcNNewNimNode, opcNCopyNimNode, opcNCopyNimTree, opcNDel, opcGenSym,
|
||||
|
||||
opcNccValue, opcNccInc, opcNcsAdd, opcNcsIncl, opcNcsLen, opcNcsAt,
|
||||
|
||||
@@ -1316,8 +1316,6 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||
|
||||
of mNIntVal: genUnaryABC(c, n, dest, opcNIntVal)
|
||||
of mNFloatVal: genUnaryABC(c, n, dest, opcNFloatVal)
|
||||
of mNSymbol: genUnaryABC(c, n, dest, opcNSymbol)
|
||||
of mNIdent: genUnaryABC(c, n, dest, opcNIdent)
|
||||
of mNGetType:
|
||||
let tmp = c.genx(n[1])
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
@@ -1343,12 +1341,6 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||
of mNSetFloatVal:
|
||||
unused(c, n, dest)
|
||||
genBinaryStmt(c, n, opcNSetFloatVal)
|
||||
of mNSetSymbol:
|
||||
unused(c, n, dest)
|
||||
genBinaryStmt(c, n, opcNSetSymbol)
|
||||
of mNSetIdent:
|
||||
unused(c, n, dest)
|
||||
genBinaryStmt(c, n, opcNSetIdent)
|
||||
of mNSetStrVal:
|
||||
unused(c, n, dest)
|
||||
genBinaryStmt(c, n, opcNSetStrVal)
|
||||
|
||||
@@ -115,7 +115,6 @@ type
|
||||
ntyCompositeTypeClass, ntyInferred, ntyAnd, ntyOr, ntyNot,
|
||||
ntyAnything, ntyStatic, ntyFromExpr, ntyOptDeprecated, ntyVoid
|
||||
|
||||
TNimTypeKinds* {.deprecated.} = set[NimTypeKind]
|
||||
NimSymKind* = enum
|
||||
nskUnknown, nskConditional, nskDynLib, nskParam,
|
||||
nskGenericParam, nskTemp, nskModule, nskType, nskVar, nskLet,
|
||||
@@ -125,24 +124,10 @@ type
|
||||
nskEnumField, nskForVar, nskLabel,
|
||||
nskStub
|
||||
|
||||
TNimSymKinds* {.deprecated.} = set[NimSymKind]
|
||||
|
||||
const
|
||||
nnkMutableTy* {.deprecated.} = nnkOutTy
|
||||
nnkSharedTy* {.deprecated.} = nnkSinkAsgn
|
||||
|
||||
type
|
||||
NimIdent* {.deprecated.} = object of RootObj
|
||||
## 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
|
||||
NimSym* {.deprecated.} = ref NimSymObj
|
||||
## Represents a Nim *symbol* in the compiler; a *symbol* is a looked-up
|
||||
## *ident*.
|
||||
|
||||
|
||||
const
|
||||
nnkLiterals* = {nnkCharLit..nnkNilLit}
|
||||
# see matching set CallNodes below
|
||||
@@ -150,26 +135,10 @@ const
|
||||
nnkCallStrLit, nnkHiddenCallConv}
|
||||
nnkPragmaCallKinds = {nnkExprColonExpr, nnkCall, nnkCallStrLit}
|
||||
|
||||
{.push warnings: off.}
|
||||
|
||||
proc toNimIdent*(s: string): NimIdent {.magic: "StrToIdent", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.0: Use 'ident' or 'newIdentNode' instead.".}
|
||||
## Constructs an identifier from the string `s`.
|
||||
|
||||
proc `==`*(a, b: NimIdent): bool {.magic: "EqIdent", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; Use '==' on 'NimNode' instead.".}
|
||||
## Compares two Nim identifiers.
|
||||
|
||||
proc `==`*(a, b: NimNode): bool {.magic: "EqNimrodNode", noSideEffect.}
|
||||
## Compare two Nim nodes. Return true if nodes are structurally
|
||||
## equivalent. This means two independently created nodes can be equal.
|
||||
|
||||
proc `==`*(a, b: NimSym): bool {.magic: "EqNimrodNode", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; Use '==(NimNode, NimNode)' instead.".}
|
||||
## Compares two Nim symbols.
|
||||
|
||||
{.pop.}
|
||||
|
||||
proc sameType*(a, b: NimNode): bool {.magic: "SameNodeType", noSideEffect.} =
|
||||
## Compares two Nim nodes' types. Return true if the types are the same,
|
||||
## e.g. true when comparing alias with original type.
|
||||
@@ -250,25 +219,6 @@ proc strVal*(n: NimNode): string {.magic: "NStrVal", noSideEffect.}
|
||||
## See also:
|
||||
## * `strVal= proc<#strVal=,NimNode,string>`_ for setting the string value.
|
||||
|
||||
{.push warnings: off.} # silence `deprecated`
|
||||
|
||||
proc ident*(n: NimNode): NimIdent {.magic: "NIdent", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; All functionality is defined on 'NimNode'.".}
|
||||
|
||||
proc symbol*(n: NimNode): NimSym {.magic: "NSymbol", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; All functionality is defined on 'NimNode'.".}
|
||||
|
||||
proc getImpl*(s: NimSym): NimNode {.magic: "GetImpl", noSideEffect, deprecated: "use `getImpl: NimNode -> NimNode` instead".}
|
||||
|
||||
proc `$`*(i: NimIdent): string {.magic: "NStrVal", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; Use 'strVal' instead.".}
|
||||
## Converts a Nim identifier to a string.
|
||||
|
||||
proc `$`*(s: NimSym): string {.magic: "NStrVal", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; Use 'strVal' instead.".}
|
||||
## Converts a Nim symbol to a string.
|
||||
|
||||
{.pop.}
|
||||
|
||||
when (NimMajor, NimMinor, NimPatch) >= (1, 3, 5) or defined(nimSymImplTransform):
|
||||
proc getImplTransformed*(symbol: NimNode): NimNode {.magic: "GetImplTransf", noSideEffect.}
|
||||
@@ -371,15 +321,6 @@ proc getTypeImpl*(n: typedesc): NimNode {.magic: "NGetType", noSideEffect.}
|
||||
proc `intVal=`*(n: NimNode, val: BiggestInt) {.magic: "NSetIntVal", noSideEffect.}
|
||||
proc `floatVal=`*(n: NimNode, val: BiggestFloat) {.magic: "NSetFloatVal", noSideEffect.}
|
||||
|
||||
{.push warnings: off.}
|
||||
|
||||
proc `symbol=`*(n: NimNode, val: NimSym) {.magic: "NSetSymbol", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; Generate a new 'NimNode' with 'genSym' instead.".}
|
||||
|
||||
proc `ident=`*(n: NimNode, val: NimIdent) {.magic: "NSetIdent", noSideEffect, deprecated:
|
||||
"Deprecated since version 0.18.1; Generate a new 'NimNode' with 'ident(string)' instead.".}
|
||||
|
||||
{.pop.}
|
||||
|
||||
proc `strVal=`*(n: NimNode, val: string) {.magic: "NSetStrVal", noSideEffect.}
|
||||
## Sets the string value of a string literal or comment.
|
||||
@@ -462,14 +403,6 @@ proc newFloatLitNode*(f: BiggestFloat): NimNode =
|
||||
result = newNimNode(nnkFloatLit)
|
||||
result.floatVal = f
|
||||
|
||||
{.push warnings: off.}
|
||||
|
||||
proc newIdentNode*(i: NimIdent): NimNode {.deprecated: "use ident(string)".} =
|
||||
## Creates an identifier node from `i`.
|
||||
result = newNimNode(nnkIdent)
|
||||
result.ident = i
|
||||
|
||||
{.pop.}
|
||||
|
||||
proc newIdentNode*(i: string): NimNode {.magic: "StrToIdent", noSideEffect.}
|
||||
## Creates an identifier node from `i`. It is simply an alias for
|
||||
@@ -720,17 +653,6 @@ proc newCall*(theProc: NimNode, args: varargs[NimNode]): NimNode =
|
||||
result.add(theProc)
|
||||
result.add(args)
|
||||
|
||||
{.push warnings: off.}
|
||||
|
||||
proc newCall*(theProc: NimIdent, args: varargs[NimNode]): NimNode {.deprecated:
|
||||
"Deprecated since v0.18.1; use 'newCall(string, ...)' or 'newCall(NimNode, ...)' instead".} =
|
||||
## Produces a new call node. `theProc` is the proc that is called with
|
||||
## the arguments `args[0..]`.
|
||||
result = newNimNode(nnkCall)
|
||||
result.add(newIdentNode(theProc))
|
||||
result.add(args)
|
||||
|
||||
{.pop.}
|
||||
|
||||
proc newCall*(theProc: string,
|
||||
args: varargs[NimNode]): NimNode =
|
||||
|
||||
@@ -43,12 +43,8 @@ static:
|
||||
let sym1 = genSym()
|
||||
let sym2 = genSym()
|
||||
let sym3 = sym1
|
||||
let nimsym = sym1.symbol
|
||||
doAssert sym1 == sym1
|
||||
doAssert sym2 != sym3
|
||||
doAssert sym2.symbol != sym3.symbol
|
||||
doAssert sym3 == sym1
|
||||
doAssert sym1.symbol == sym1.symbol
|
||||
doAssert nimsym == nimsym
|
||||
|
||||
echo "true"
|
||||
|
||||
@@ -21,7 +21,7 @@ macro outterMacro*(n, blck: untyped): untyped =
|
||||
"(the_name_you_want)): statements.")
|
||||
result = newNimNode(NimNodeKind.nnkStmtList)
|
||||
var ass : NimNode = newNimNode(nnkAsgn)
|
||||
ass.add(newIdentNode(n[1].ident))
|
||||
ass.add(n[1])
|
||||
ass.add(newStrLitNode(innerProc(4)))
|
||||
result.add(ass)
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ proc matchAgainst(n, pattern: NimNode): NimNode {.compileTime.} =
|
||||
newDotExpr(current, newIdentNode(astToStr(field)))
|
||||
|
||||
template `==@`(n, pattern: untyped): untyped =
|
||||
newCall("==", n@kind, newIdentNode($pat2kind($pattern.ident)))
|
||||
newCall("==", n@kind, newIdentNode($pat2kind(pattern.strVal)))
|
||||
|
||||
case pattern.kind
|
||||
of CallNodes:
|
||||
|
||||
@@ -15,7 +15,7 @@ proc buildSuiteContents(suiteName, suiteDesc, suiteBloc: NimNode): tuple[tests:
|
||||
tests:seq[SuiteTest] = @[]
|
||||
|
||||
for child in suiteBloc.children():
|
||||
case $child[0].ident:
|
||||
case $child[0].strVal:
|
||||
of "test":
|
||||
|
||||
var testObj = SuiteTest()
|
||||
|
||||
Reference in New Issue
Block a user