diff options
author | Zahary Karadjov <zahary@gmail.com> | 2013-12-19 01:06:38 +0200 |
---|---|---|
committer | Zahary Karadjov <zahary@gmail.com> | 2013-12-19 01:06:38 +0200 |
commit | 027f30610e44633b661befcca1b5dd39e9eaa283 (patch) | |
tree | 45841cac06bf79c512b050791697ce68b36b58ed /lib/core | |
parent | 7120491d055c04d838d9539fdf0c42003637ec2d (diff) | |
download | Nim-027f30610e44633b661befcca1b5dd39e9eaa283.tar.gz |
static params: expr[T] is now static[T]
This introduces tyStatic and successfully bootstraps and handles few simple test cases. Static params within macros are no longer treated as PNimrodNodes - they are now equivalent to constants of the designated type.
Diffstat (limited to 'lib/core')
-rw-r--r-- | lib/core/macros.nim | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/core/macros.nim b/lib/core/macros.nim index d01d4ebee..44a3a34c3 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -59,7 +59,8 @@ type nnkBindStmt, nnkMixinStmt, nnkUsingStmt, nnkCommentStmt, nnkStmtListExpr, nnkBlockExpr, nnkStmtListType, nnkBlockType, nnkTypeOfExpr, nnkObjectTy, - nnkTupleTy, nnkTypeClassTy, nnkRecList, nnkRecCase, nnkRecWhen, + nnkTupleTy, nnkTypeClassTy, nnkStaticTy, + nnkRecList, nnkRecCase, nnkRecWhen, nnkRefTy, nnkPtrTy, nnkVarTy, nnkConstTy, nnkMutableTy, nnkDistinctTy, @@ -285,14 +286,15 @@ proc quote*(bl: stmt, op = "``"): PNimrodNode {.magic: "QuoteAst".} ## if not `ex`: ## echo `info` & ": Check failed: " & `expString` -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 & '"') - ## - eval: result = e.parseStmt +when not defined(booting): + template emit*(e: static[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 & '"') + ## + eval: result = e.parseStmt proc expectKind*(n: PNimrodNode, k: TNimrodNodeKind) {.compileTime.} = ## checks that `n` is of kind `k`. If this is not the case, |