From f8917e8ad3074035f5c0bc8722fd239c5f3771db Mon Sep 17 00:00:00 2001 From: fowlmouth Date: Sat, 28 Mar 2015 03:19:48 -0500 Subject: add ntys up to ntyNot --- lib/core/macros.nim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/core/macros.nim') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 5583748e0..786b84171 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -88,7 +88,9 @@ type ntyBigNum, ntyConst, ntyMutable, ntyVarargs, ntyIter, - ntyError + ntyError, + ntyBuiltinTypeClass, ntyConcept, ntyConceptInst, ntyComposite, + ntyAnd, ntyOr, ntyNot TNimTypeKinds* {.deprecated.} = set[NimTypeKind] NimSymKind* = enum -- cgit 1.4.1-2-gfad0 From dc3a0bc00965f10c3906b948aee48d1065d1ccdf Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 20 Apr 2015 11:34:18 +0200 Subject: added macros.newTree proc (why didn't we do this earlier?) --- lib/core/macros.nim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/core/macros.nim') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 5583748e0..b78b94bd1 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -355,6 +355,12 @@ proc expectLen*(n: NimNode, len: int) {.compileTime.} = ## macros that check its number of arguments. if n.len != len: error("macro expects a node with " & $len & " children") +proc newTree*(kind: NimNodeKind, + children: varargs[NimNode]): NimNode {.compileTime.} = + ## produces a new node with children. + result = newNimNode(kind) + result.add(children) + proc newCall*(theProc: NimNode, args: varargs[NimNode]): NimNode {.compileTime.} = ## produces a new call node. `theProc` is the proc that is called with -- cgit 1.4.1-2-gfad0 From 43eae0c11326df868c802e9b9f12c3be3d835fd9 Mon Sep 17 00:00:00 2001 From: Araq Date: Mon, 20 Apr 2015 20:40:10 +0200 Subject: macros: added bool literal support --- lib/core/macros.nim | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/core/macros.nim') diff --git a/lib/core/macros.nim b/lib/core/macros.nim index 777d991d4..35f0f61c1 100644 --- a/lib/core/macros.nim +++ b/lib/core/macros.nim @@ -164,6 +164,7 @@ proc kind*(n: NimNode): NimNodeKind {.magic: "NKind", noSideEffect.} ## returns the `kind` of the node `n`. proc intVal*(n: NimNode): BiggestInt {.magic: "NIntVal", noSideEffect.} +proc boolVal*(n: NimNode): bool {.compileTime, noSideEffect.} = n.intVal != 0 proc floatVal*(n: NimNode): BiggestFloat {.magic: "NFloatVal", noSideEffect.} proc symbol*(n: NimNode): NimSym {.magic: "NSymbol", noSideEffect.} proc ident*(n: NimNode): NimIdent {.magic: "NIdent", noSideEffect.} @@ -397,6 +398,11 @@ proc newLit*(i: BiggestInt): NimNode {.compileTime.} = result = newNimNode(nnkIntLit) result.intVal = i +proc newLit*(b: bool): NimNode {.compileTime.} = + ## produces a new boolean literal node. + result = newNimNode(nnkIntLit) + result.intVal = ord(b) + proc newLit*(f: BiggestFloat): NimNode {.compileTime.} = ## produces a new float literal node. result = newNimNode(nnkFloatLit) -- cgit 1.4.1-2-gfad0