summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ast.nim2
-rw-r--r--compiler/evals.nim10
2 files changed, 11 insertions, 1 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index e0c3b8e86..c86ba52c6 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -488,7 +488,7 @@ type
     mNNewNimNode, mNCopyNimNode, mNCopyNimTree, mStrToIdent, mIdentToStr,
     mNBindSym, mLocals, mNCallSite,
     mEqIdent, mEqNimrodNode, mNHint, mNWarning, mNError,
-    mInstantiationInfo, mGetTypeInfo
+    mInstantiationInfo, mGetTypeInfo, mNGenSym
 
 # things that we can evaluate safely at compile time, even if not asked for it:
 const
diff --git a/compiler/evals.nim b/compiler/evals.nim
index f89417dc8..6266668f9 100644
--- a/compiler/evals.nim
+++ b/compiler/evals.nim
@@ -1249,6 +1249,16 @@ proc evalMagicOrCall(c: PEvalContext, n: PNode): PNode =
   of mNBindSym:
     # trivial implementation:
     result = n.sons[1]
+  of mNGenSym:
+    evalX(n.sons[1], {efLValue})
+    let k = getOrdValue(result)
+    evalX(n.sons[2], {efLValue})
+    let b = result
+    let name = if b.strVal.len == 0: ":tmp" else: b.strVal
+    if k < 0 or k > ord(high(TSymKind)):
+      internalError(n.info, "request to create a symbol with invalid kind")
+    result = newSymNode(newSym(k.TSymKind, name.getIdent, c.module, n.info))
+    incl(result.sym.flags, sfGenSym)
   of mStrToIdent: 
     result = evalAux(c, n.sons[1], {})
     if isSpecial(result): return