mirror of
https://github.com/nim-lang/Nim.git
synced 2026-07-14 21:20:42 +00:00
don't deprecate macros.! breaks too much code
This commit is contained in:
@@ -112,7 +112,7 @@ proc `[]`*(n: PNimrodNode, i: int): PNimrodNode {.magic: "NChild".}
|
|||||||
proc `[]=`*(n: PNimrodNode, i: int, child: PNimrodNode) {.magic: "NSetChild".}
|
proc `[]=`*(n: PNimrodNode, i: int, child: PNimrodNode) {.magic: "NSetChild".}
|
||||||
## set `n`'s `i`'th child to `child`.
|
## set `n`'s `i`'th child to `child`.
|
||||||
|
|
||||||
proc `!`*(s: string): TNimrodIdent {.magic: "StrToIdent", deprecated.}
|
proc `!`*(s: string): TNimrodIdent {.magic: "StrToIdent".}
|
||||||
## constructs an identifier from the string `s`
|
## constructs an identifier from the string `s`
|
||||||
|
|
||||||
proc `$`*(i: TNimrodIdent): string {.magic: "IdentToStr".}
|
proc `$`*(i: TNimrodIdent): string {.magic: "IdentToStr".}
|
||||||
@@ -419,7 +419,7 @@ proc newStmtList*(stmts: varargs[PNimrodNode]): PNimrodNode {.compileTime.}=
|
|||||||
## Create a new statement list
|
## Create a new statement list
|
||||||
result = newNimNode(nnkStmtList).add(stmts)
|
result = newNimNode(nnkStmtList).add(stmts)
|
||||||
|
|
||||||
proc newBlockStmt*(label: PNimrodNode; body: PNimrodNode): PNimrodNode {.compileTime.} =
|
proc newBlockStmt*(label, body: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
## Create a new block statement with label
|
## Create a new block statement with label
|
||||||
return newNimNode(nnkBlockStmt).add(label, body)
|
return newNimNode(nnkBlockStmt).add(label, body)
|
||||||
proc newBlockStmt*(body: PNimrodNode): PNimrodNode {.compiletime.} =
|
proc newBlockStmt*(body: PNimrodNode): PNimrodNode {.compiletime.} =
|
||||||
@@ -431,23 +431,22 @@ proc newLetStmt*(name, value: PNimrodNode): PNimrodNode{.compiletime.} =
|
|||||||
return newNimNode(nnkLetSection).add(
|
return newNimNode(nnkLetSection).add(
|
||||||
newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
|
newNimNode(nnkIdentDefs).add(name, newNimNode(nnkEmpty), value))
|
||||||
|
|
||||||
proc newAssignment*(lhs, rhs: PNimrodNode): PNimrodNode {.compileTime, inline.} =
|
proc newAssignment*(lhs, rhs: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
return newNimNode(nnkAsgn).add(lhs, rhs)
|
return newNimNode(nnkAsgn).add(lhs, rhs)
|
||||||
|
|
||||||
proc newDotExpr* (a, b: PNimrodNode): PNimrodNode {.compileTime, inline.} =
|
proc newDotExpr*(a, b: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
## Create new dot expression
|
## Create new dot expression
|
||||||
## a.dot(b) -> `a.b`
|
## a.dot(b) -> `a.b`
|
||||||
return newNimNode(nnkDotExpr).add(a, b)
|
return newNimNode(nnkDotExpr).add(a, b)
|
||||||
|
|
||||||
|
proc newIdentDefs*(name, kind: PNimrodNode;
|
||||||
proc newIdentDefs*(name, kind: PNimrodNode; default = newEmptyNode()): PNimrodNode{.
|
default = newEmptyNode()): PNimrodNode {.compileTime.} =
|
||||||
compileTime.} = newNimNode(nnkIdentDefs).add(name, kind, default)
|
newNimNode(nnkIdentDefs).add(name, kind, default)
|
||||||
|
|
||||||
proc newNilLit*(): PNimrodNode {.compileTime.} =
|
proc newNilLit*(): PNimrodNode {.compileTime.} =
|
||||||
## New nil literal shortcut
|
## New nil literal shortcut
|
||||||
result = newNimNode(nnkNilLit)
|
result = newNimNode(nnkNilLit)
|
||||||
|
|
||||||
|
|
||||||
proc high*(node: PNimrodNode): int {.compileTime.} = len(node) - 1
|
proc high*(node: PNimrodNode): int {.compileTime.} = len(node) - 1
|
||||||
## Return the highest index available for a node
|
## Return the highest index available for a node
|
||||||
proc last*(node: PNimrodNode): PNimrodNode {.compileTime.} = node[node.high]
|
proc last*(node: PNimrodNode): PNimrodNode {.compileTime.} = node[node.high]
|
||||||
@@ -455,15 +454,11 @@ proc last*(node: PNimrodNode): PNimrodNode {.compileTime.} = node[node.high]
|
|||||||
|
|
||||||
|
|
||||||
const
|
const
|
||||||
RoutineNodes* = {
|
RoutineNodes* = {nnkProcDef, nnkMethodDef, nnkDo, nnkLambda}
|
||||||
nnkProcDef, nnkMethodDef, nnkDo, nnkLambda }
|
AtomicNodes* = {nnkNone..nnkNilLit}
|
||||||
AtomicNodes* = {
|
CallNodes* = {nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
|
||||||
nnkNone .. nnkNilLit }
|
|
||||||
CallNodes* = {
|
|
||||||
nnkCall, nnkInfix, nnkPrefix, nnkPostfix, nnkCommand,
|
|
||||||
nnkCallStrLit, nnkHiddenCallConv}
|
nnkCallStrLit, nnkHiddenCallConv}
|
||||||
|
|
||||||
|
|
||||||
from strutils import cmpIgnoreStyle, format
|
from strutils import cmpIgnoreStyle, format
|
||||||
|
|
||||||
proc ExpectKind*(n: PNimrodNode; k: set[TNimrodNodeKind]) {.compileTime.} =
|
proc ExpectKind*(n: PNimrodNode; k: set[TNimrodNodeKind]) {.compileTime.} =
|
||||||
@@ -594,6 +589,7 @@ proc basename*(a: PNimrodNode): PNimrodNode {.compiletime.} =
|
|||||||
of nnkPostfix, nnkPrefix: return a[1]
|
of nnkPostfix, nnkPrefix: return a[1]
|
||||||
else:
|
else:
|
||||||
quit "Do not know how to get basename of ("& treerepr(a) &")\n"& repr(a)
|
quit "Do not know how to get basename of ("& treerepr(a) &")\n"& repr(a)
|
||||||
|
|
||||||
proc `basename=`*(a: PNimrodNode; val: string) {.compileTime.}=
|
proc `basename=`*(a: PNimrodNode; val: string) {.compileTime.}=
|
||||||
case a.kind
|
case a.kind
|
||||||
of nnkIdent: macros.`ident=`(a, !val)
|
of nnkIdent: macros.`ident=`(a, !val)
|
||||||
@@ -601,35 +597,40 @@ proc `basename=`*(a: PNimrodNode; val: string) {.compileTime.}=
|
|||||||
else:
|
else:
|
||||||
quit "Do not know how to get basename of ("& treerepr(a)& ")\n"& repr(a)
|
quit "Do not know how to get basename of ("& treerepr(a)& ")\n"& repr(a)
|
||||||
|
|
||||||
proc postfix*(node: PNimrodNode; op: string): PNimrodNode {.
|
proc postfix*(node: PNimrodNode; op: string): PNimrodNode {.compileTime.} =
|
||||||
compileTime.} = newNimNode(nnkPostfix).add(ident(op), node)
|
newNimNode(nnkPostfix).add(ident(op), node)
|
||||||
proc prefix*(node: PNimrodNode; op: string): PNimrodNode {.
|
|
||||||
compileTime.} = newNimNode(nnkPrefix).add(ident(op), node)
|
proc prefix*(node: PNimrodNode; op: string): PNimrodNode {.compileTime.} =
|
||||||
proc infix*(a: PNimrodNode; op: string; b: PNimrodNode): PNimrodNode {.
|
newNimNode(nnkPrefix).add(ident(op), node)
|
||||||
compileTime.} = newNimNode(nnkInfix).add(ident(op), a, b)
|
|
||||||
|
proc infix*(a: PNimrodNode; op: string;
|
||||||
|
b: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
|
newNimNode(nnkInfix).add(ident(op), a, b)
|
||||||
|
|
||||||
proc unpackPostfix*(node: PNimrodNode): tuple[node: PNimrodNode; op: string] {.
|
proc unpackPostfix*(node: PNimrodNode): tuple[node: PNimrodNode; op: string] {.
|
||||||
compileTime.} =
|
compileTime.} =
|
||||||
node.expectKind nnkPostfix
|
node.expectKind nnkPostfix
|
||||||
result = (node[0], $node[1])
|
result = (node[0], $node[1])
|
||||||
|
|
||||||
proc unpackPrefix*(node: PNimrodNode): tuple[node: PNimrodNode; op: string] {.
|
proc unpackPrefix*(node: PNimrodNode): tuple[node: PNimrodNode; op: string] {.
|
||||||
compileTime.} =
|
compileTime.} =
|
||||||
node.expectKind nnkPrefix
|
node.expectKind nnkPrefix
|
||||||
result = (node[0], $node[1])
|
result = (node[0], $node[1])
|
||||||
proc unpackInfix*(node: PNimrodNode): tuple[left: PNimrodNode; op: string; right: PNimrodNode] {.
|
|
||||||
compileTime.} =
|
proc unpackInfix*(node: PNimrodNode): tuple[left: PNimrodNode; op: string;
|
||||||
|
right: PNimrodNode] {.compileTime.} =
|
||||||
assert node.kind == nnkInfix
|
assert node.kind == nnkInfix
|
||||||
result = (node[0], $node[1], node[2])
|
result = (node[0], $node[1], node[2])
|
||||||
|
|
||||||
proc copy*(node: PNimrodNode): PNimrodNode {.compileTime.} =
|
proc copy*(node: PNimrodNode): PNimrodNode {.compileTime.} =
|
||||||
## An alias for copyNimTree()
|
## An alias for copyNimTree().
|
||||||
return node.copyNimTree()
|
return node.copyNimTree()
|
||||||
|
|
||||||
proc eqIdent* (a, b: string): bool = cmpIgnoreStyle(a, b) == 0
|
proc eqIdent* (a, b: string): bool = cmpIgnoreStyle(a, b) == 0
|
||||||
## Check if two idents are identical
|
## Check if two idents are identical.
|
||||||
|
|
||||||
proc hasArgOfName* (params: PNimrodNode; name: string): bool {.compiletime.}=
|
proc hasArgOfName* (params: PNimrodNode; name: string): bool {.compiletime.}=
|
||||||
## Search nnkFormalParams for an argument
|
## Search nnkFormalParams for an argument.
|
||||||
assert params.kind == nnkFormalParams
|
assert params.kind == nnkFormalParams
|
||||||
for i in 1 .. <params.len:
|
for i in 1 .. <params.len:
|
||||||
template node: expr = params[i]
|
template node: expr = params[i]
|
||||||
@@ -637,7 +638,8 @@ proc hasArgOfName* (params: PNimrodNode; name: string): bool {.compiletime.}=
|
|||||||
return true
|
return true
|
||||||
|
|
||||||
proc addIdentIfAbsent*(dest: PNimrodNode, ident: string) {.compiletime.} =
|
proc addIdentIfAbsent*(dest: PNimrodNode, ident: string) {.compiletime.} =
|
||||||
## Add ident to dest if it is not present. This is intended for use with pragmas
|
## Add ident to dest if it is not present. This is intended for use
|
||||||
|
## with pragmas.
|
||||||
for node in dest.children:
|
for node in dest.children:
|
||||||
case node.kind
|
case node.kind
|
||||||
of nnkIdent:
|
of nnkIdent:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ News
|
|||||||
====
|
====
|
||||||
|
|
||||||
2013-05-20 New website design!
|
2013-05-20 New website design!
|
||||||
===================
|
==============================
|
||||||
|
|
||||||
A brand new website is now live. All thanks go to Philip Witte and
|
A brand new website is now live. All thanks go to Philip Witte and
|
||||||
Dominik Picheta, Philip Witte for the design of the website (together with
|
Dominik Picheta, Philip Witte for the design of the website (together with
|
||||||
@@ -77,7 +77,6 @@ Changes affecting backwards compatibility
|
|||||||
- The expression/statement unification has been implemented. Again this
|
- The expression/statement unification has been implemented. Again this
|
||||||
only affects edge cases and no known real world code.
|
only affects edge cases and no known real world code.
|
||||||
- Changed the async interface of the ``scgi`` module.
|
- Changed the async interface of the ``scgi`` module.
|
||||||
- ``macros.!`` has been deprecated. Use ``macros.ident`` instead.
|
|
||||||
- WideStrings are now garbage collected like other string types.
|
- WideStrings are now garbage collected like other string types.
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user