diff options
author | def <dennis@felsin9.de> | 2015-03-17 17:50:32 +0100 |
---|---|---|
committer | def <dennis@felsin9.de> | 2015-03-17 17:50:32 +0100 |
commit | fd4e6299057b0ce59a89553e7c32a9ea62da14db (patch) | |
tree | 45bb61ec52b415ffd07caae7c5b7fc10a0d99577 /tests/usingstmt | |
parent | 8e651fa0d456786df15445e10e14b9d4e96c21ff (diff) | |
download | Nim-fd4e6299057b0ce59a89553e7c32a9ea62da14db.tar.gz |
Rename PNimrodNode to NimNode
Diffstat (limited to 'tests/usingstmt')
-rw-r--r-- | tests/usingstmt/tusingstatement.nim | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/tests/usingstmt/tusingstatement.nim b/tests/usingstmt/tusingstatement.nim index b58478d74..0d76b2423 100644 --- a/tests/usingstmt/tusingstatement.nim +++ b/tests/usingstmt/tusingstatement.nim @@ -3,13 +3,13 @@ discard """ output: "Using test.Closing test." """ -import +import macros # This macro mimics the using statement from C# # # It's kept only as a test for the macro system -# Nim's destructors offer a mechanism for automatic +# Nim's destructors offer a mechanism for automatic # disposal of resources. # macro autoClose(e: expr): stmt {.immediate.} = @@ -20,19 +20,19 @@ macro autoClose(e: expr): stmt {.immediate.} = var args = e var body = e[2] - - var - variables : seq[PNimrodNode] - closingCalls : seq[PNimrodNode] + + var + variables : seq[NimNode] + closingCalls : seq[NimNode] newSeq(variables, 0) newSeq(closingCalls, 0) - + for i in countup(1, args.len-2): if args[i].kind == nnkExprEqExpr: var varName = args[i][0] var varValue = args[i][1] - + var varAssignment = newNimNode(nnkIdentDefs) varAssignment.add(varName) varAssignment.add(newNimNode(nnkEmpty)) # empty means no type @@ -43,7 +43,7 @@ macro autoClose(e: expr): stmt {.immediate.} = else: error "Using statement: Unexpected expression. Got " & $args[i].kind & " instead of assignment." - + var varSection = newNimNode(nnkVarSection) varSection.add(variables) @@ -67,10 +67,10 @@ macro autoClose(e: expr): stmt {.immediate.} = targetAst[0][1][0] = varSection targetAst[0][1][1][0] = body targetAst[0][1][1][1][0] = finallyBlock - + result = targetAst -type +type TResource* = object field*: string |