From 19fd8f5ec19160e96ecd1a1a88960cbe2edee462 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 2 May 2024 12:33:45 +0000 Subject: [PATCH] remove deprecated stuffs since v0.18.1 from macros --- compiler/ast.nim | 4 +- compiler/vm.nim | 28 ----------- compiler/vmdef.nim | 4 +- compiler/vmgen.nim | 8 --- lib/core/macros.nim | 78 ----------------------------- tests/lookups/tgensymgeneric.nim | 4 -- tests/macros/tmacros1.nim | 2 +- tests/showoff/tdrdobbs_examples.nim | 2 +- tests/vm/tstringnil.nim | 2 +- 9 files changed, 6 insertions(+), 126 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index e8fee6c0d1..ae8c8a3ef8 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -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, diff --git a/compiler/vm.nim b/compiler/vm.nim index a775cf584d..4f2adc6c42 100644 --- a/compiler/vm.nim +++ b/compiler/vm.nim @@ -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 diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim index bdb0aeed15..0a2cac58ba 100644 --- a/compiler/vmdef.nim +++ b/compiler/vmdef.nim @@ -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, diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index 366fc7b292..e0e2197da3 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -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) diff --git a/lib/core/macros.nim b/lib/core/macros.nim index bd1de9cd7f..63b291bf43 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -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 = diff --git a/tests/lookups/tgensymgeneric.nim b/tests/lookups/tgensymgeneric.nim index 6e1df4842f..760d1c2265 100644 --- a/tests/lookups/tgensymgeneric.nim +++ b/tests/lookups/tgensymgeneric.nim @@ -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" diff --git a/tests/macros/tmacros1.nim b/tests/macros/tmacros1.nim index c588ff7e64..02cb5f3368 100644 --- a/tests/macros/tmacros1.nim +++ b/tests/macros/tmacros1.nim @@ -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) diff --git a/tests/showoff/tdrdobbs_examples.nim b/tests/showoff/tdrdobbs_examples.nim index c61e177dc3..4b95c12cf4 100644 --- a/tests/showoff/tdrdobbs_examples.nim +++ b/tests/showoff/tdrdobbs_examples.nim @@ -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: diff --git a/tests/vm/tstringnil.nim b/tests/vm/tstringnil.nim index d5dd4f4c95..a8d1d4a78e 100644 --- a/tests/vm/tstringnil.nim +++ b/tests/vm/tstringnil.nim @@ -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()