diff options
author | Araq <rumpf_a@web.de> | 2012-02-24 19:20:34 +0100 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2012-02-24 19:20:34 +0100 |
commit | d72b00cf15402b050f4a1ca7e5e73a5968550d0c (patch) | |
tree | bda5e87d6d9b22eb824d4201fc6b944ca44815a2 /lib/system.nim | |
parent | 8273ebcc289ab079b1e35ea6cac803c6f40efb27 (diff) | |
parent | a3f16968a75e3a9b254b6fac7820fea83debd1e8 (diff) | |
download | Nim-d72b00cf15402b050f4a1ca7e5e73a5968550d0c.tar.gz |
Merge branch 'master' of github.com:Araq/Nimrod
Diffstat (limited to 'lib/system.nim')
-rwxr-xr-x | lib/system.nim | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/system.nim b/lib/system.nim index b75f9022d..bfaa5eb8f 100755 --- a/lib/system.nim +++ b/lib/system.nim @@ -2213,6 +2213,20 @@ proc shallow*(s: var string) {.noSideEffect, inline.} = var s = cast[PGenericSeq](s) s.reserved = s.reserved or seqShallowFlag +template static*(e: expr): expr = + ## evaluates a given expression `e` at compile-time + ## even if it has side effects + block: + const res = e + res + +template eval*(blk: stmt): stmt = + ## executes a block of code at compile time just as if it was a macro + ## optonally, the block can return an AST tree that will replace the + ## eval expression + block: + macro payload(x: stmt): stmt = blk + payload() when defined(initDebugger): initDebugger() |