made tsequtils green again

This commit is contained in:
Araq
2012-05-28 01:17:17 +02:00
parent 22188a0647
commit f3980eb24a
5 changed files with 45 additions and 8 deletions

View File

@@ -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`.

24
tests/run/tdumptree.nim Normal file
View File

@@ -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)

View File

@@ -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

View File

@@ -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

View File

@@ -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