From f3980eb24ad76001671c76ce668f0ee25e481ba0 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 28 May 2012 01:17:17 +0200 Subject: [PATCH] made tsequtils green again --- lib/core/macros.nim | 21 +++++++++++++++------ tests/run/tdumptree.nim | 24 ++++++++++++++++++++++++ tests/run/tsequtils.nim | 2 +- todo.txt | 3 ++- web/news.txt | 3 +++ 5 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 tests/run/tdumptree.nim diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 21f5134e21..b0f237924d 100755 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -217,10 +217,19 @@ template emit*(s: expr): stmt = ## Example: ## ## emit("echo " & '"' & "hello world".toUpper & '"') - ## - block: - const evaluated = s - eval: result = evaluated.parseStmt + ## + block: + const evaluated = s + eval: result = evaluated.parseStmt + when false: + template once(x: expr): expr = + block: + const y = x + y + + macro `payload`(x: stmt): stmt = result = once(s).parseStmt + `payload`() + proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} = ## checks that `n` is of kind `k`. If this is not the case, @@ -323,7 +332,7 @@ proc lispRepr*(n: PNimrodNode): string {.compileTime.} = macro dumpTree*(s: stmt): stmt = echo s[1].treeRepr ## Accepts a block of nimrod code and prints the parsed abstract syntax - ## tree using the `toTree` function. + ## tree using the `toTree` function. Printing is done *at compile time*. ## ## You can use this as a tool to explore the Nimrod's abstract syntax ## tree and to discover what kind of nodes must be created to represent @@ -331,7 +340,7 @@ macro dumpTree*(s: stmt): stmt = echo s[1].treeRepr macro dumpLisp*(s: stmt): stmt = echo s[1].lispRepr ## Accepts a block of nimrod code and prints the parsed abstract syntax - ## tree using the `toLisp` function. + ## tree using the `toLisp` function. Printing is done *at compile time*. ## ## See `dumpTree`. diff --git a/tests/run/tdumptree.nim b/tests/run/tdumptree.nim new file mode 100644 index 0000000000..2a9c7d2051 --- /dev/null +++ b/tests/run/tdumptree.nim @@ -0,0 +1,24 @@ +discard """ +output: '''StmtList + VarSection + IdentDefs + Ident !"x" + nil + Call + DotExpr + Ident !"foo" + Ident !"create" + IntLit 56''' +""" + +import macros + +#emit("type\n TFoo = object\n bar: int") + +#var f: TFoo +#f.bar = 5 +#echo(f.bar) + +dumpTree: + var x = foo.create(56) + diff --git a/tests/run/tsequtils.nim b/tests/run/tsequtils.nim index 2982ca6124..7bc15ef9cc 100644 --- a/tests/run/tsequtils.nim +++ b/tests/run/tsequtils.nim @@ -1,6 +1,6 @@ discard """ file: "tsequtils.nim" -output: '''Zip: [{"a": 1, "b": 2}, {"a": 3, "b": 4}, {"a": 5, "b": 6}] +output: '''Zip: [{"Field0": 1, "Field1": 2}, {"Field0": 3, "Field1": 4}, {"Field0": 5, "Field1": 6}] Filter Iterator: 3 Filter Iterator: 5 Filter Iterator: 7 diff --git a/todo.txt b/todo.txt index 377a57ebe0..5f1d7adde9 100755 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,8 @@ version 0.9.0 ============= -- make templates hygienic by default +- make templates hygienic by default: try to gensym() everything in the 'block' + of a template - ``bind`` for overloaded symbols does not work apparently - ``=`` should be overloadable; requires specialization for ``=`` - fix remaining generics bugs diff --git a/web/news.txt b/web/news.txt index f83c86a25f..3ad0eb4d89 100755 --- a/web/news.txt +++ b/web/news.txt @@ -72,6 +72,9 @@ Changes affecting backwards compatibility - Deprecated ``system.GC_setStrategy``. - ``re.findAll`` and ``pegs.findAll`` don't return *captures* anymore but matching *substrings*. +- RTTI and thus the ``marshall`` module don't contain the proper field names + of tuples anymore. This had to be changed as the old behaviour never + produced consistent results. Compiler Additions