From f28b7be6a37d566df64cb944c1687e014be8d083 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 4 Oct 2012 17:24:42 +0300 Subject: fixes #120 --- lib/core/macros.nim | 6 ++---- lib/system.nim | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index c30474b70..be6aecab5 100755 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -234,16 +234,14 @@ proc getAst*(macroOrTemplate: expr): PNimrodNode {.magic: "ExpandToAst".} ## macro FooMacro() = ## var ast = getAst(BarTemplate()) -template emit*(s: expr): stmt = +template emit*(e: expr[string]): stmt = ## accepts a single string argument and treats it as nimrod code ## that should be inserted verbatim in the program ## Example: ## ## emit("echo " & '"' & "hello world".toUpper & '"') ## - block: - const evaluated = s - eval: result = evaluated.parseStmt + eval: result = e.parseStmt proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} = ## checks that `n` is of kind `k`. If this is not the case, diff --git a/lib/system.nim b/lib/system.nim index 99f1e621a..9d7652c94 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -2349,9 +2349,8 @@ template eval*(blk: stmt): stmt = ## executes a block of code at compile time just as if it was a macro ## optionally, the block can return an AST tree that will replace the ## eval expression - block: - macro payload(x: stmt): stmt = blk - payload() + macro payload: stmt {.gensym.} = blk + payload() proc insert*(x: var string, item: string, i = 0) {.noSideEffect.} = ## inserts `item` into `x` at position `i`. -- cgit 1.4.1-2-gfad0