summary refs log tree commit diff stats
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/ast.nim3
-rw-r--r--compiler/condsyms.nim1
-rw-r--r--compiler/vm.nim6
-rw-r--r--compiler/vmdef.nim2
-rw-r--r--compiler/vmgen.nim2
5 files changed, 12 insertions, 2 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index addb2c33b..c3ed33914 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -666,7 +666,8 @@ type
     mInstantiationInfo, mGetTypeInfo,
     mNimvm, mIntDefine, mStrDefine, mBoolDefine, mRunnableExamples,
     mException, mBuiltinType, mSymOwner, mUncheckedArray, mGetImplTransf,
-    mSymIsInstantiationOf
+    mSymIsInstantiationOf, mNodeId
+
 
 # things that we can evaluate safely at compile time, even if not asked for it:
 const
diff --git a/compiler/condsyms.nim b/compiler/condsyms.nim
index 00ce352f2..3dc614a37 100644
--- a/compiler/condsyms.nim
+++ b/compiler/condsyms.nim
@@ -87,6 +87,7 @@ proc initDefines*(symbols: StringTableRef) =
   defineSymbol("nimHasDefault")
   defineSymbol("nimMacrosSizealignof")
   defineSymbol("nimNoZeroExtendMagic")
+  defineSymbol("nimMacrosGetNodeId")
   for f in low(Feature)..high(Feature):
     defineSymbol("nimHas" & $f)
 
diff --git a/compiler/vm.nim b/compiler/vm.nim
index 40d12db97..0496e37ca 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -1472,6 +1472,12 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
         regs[ra].node = copyNode(a)
       else:
         stackTrace(c, tos, pc, errFieldXNotFound & "ident")
+    of opcNodeId:
+      decodeB(rkInt)
+      when defined(useNodeIds):
+        regs[ra].intVal = regs[rb].node.id
+      else:
+        regs[ra].intVal = -1
     of opcNGetType:
       let rb = instr.regB
       let rc = instr.regC
diff --git a/compiler/vmdef.nim b/compiler/vmdef.nim
index 2f6cbcb85..54c18b03a 100644
--- a/compiler/vmdef.nim
+++ b/compiler/vmdef.nim
@@ -99,7 +99,7 @@ type
     opcNNewNimNode, opcNCopyNimNode, opcNCopyNimTree, opcNDel, opcGenSym,
 
     opcNccValue, opcNccInc, opcNcsAdd, opcNcsIncl, opcNcsLen, opcNcsAt,
-    opcNctPut, opcNctLen, opcNctGet, opcNctHasNext, opcNctNext,
+    opcNctPut, opcNctLen, opcNctGet, opcNctHasNext, opcNctNext, opcNodeId,
 
     opcSlurp,
     opcGorge,
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim
index 0b41fed28..898916c64 100644
--- a/compiler/vmgen.nim
+++ b/compiler/vmgen.nim
@@ -1324,6 +1324,8 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
     c.gABx(n, opcNodeToReg, a, a)
     c.genAsgnPatch(arg, a)
     c.freeTemp(a)
+  of mNodeId:
+    c.genUnaryABC(n, dest, opcNodeId)
   else:
     # mGCref, mGCunref,
     globalError(c.config, n.info, "cannot generate code for: " & $m)