summary refs log tree commit diff stats
path: root/compiler/vm.nim
diff options
context:
space:
mode:
authorAdam Strzelecki <ono@java.pl>2015-07-01 20:11:09 +0200
committerAdam Strzelecki <ono@java.pl>2015-07-03 11:11:10 +0200
commit1a0417fbe0d2fe61c05a68f14858b0da0e596c02 (patch)
treea5cb4f81baa1b766543b1db0bc54c6ba93b762a3 /compiler/vm.nim
parent60ac5e3e76fe24e015782a081da3f04f0000ea5f (diff)
downloadNim-1a0417fbe0d2fe61c05a68f14858b0da0e596c02.tar.gz
macros: Introduce sameType(a, b) for node types
Previously introduced node comparison `==` was working somehow wrong on nodes
returned from getType(a), comparing just ids of the symbols.

Recently introduced `==` change 47dce2688633fad840a2f5e4073c531f1cd640ca
started comparing symbol nodes pointer-wise, thus strictly. Since getType(a)
always creates new symbol pointing to the type, comparing two such nodes using
`==` always returns false, even they point to the same type.

That is why we need a new sameType macro to be able to tell if these nodes
point to the same type.
Diffstat (limited to 'compiler/vm.nim')
-rw-r--r--compiler/vm.nim3
1 files changed, 3 insertions, 0 deletions
diff --git a/compiler/vm.nim b/compiler/vm.nim
index a8972f420..6d496d6e1 100644
--- a/compiler/vm.nim
+++ b/compiler/vm.nim
@@ -692,6 +692,9 @@ proc rawExecute(c: PCtx, start: int, tos: PStackFrame): TFullReg =
       regs[ra].intVal =
         ord(exprStructuralEquivalent(regs[rb].node, regs[rc].node,
                                      strictSymEquality=true))
+    of opcSameNodeType:
+      decodeBC(rkInt)
+      regs[ra].intVal = ord(regs[rb].node.typ.sameTypeOrNil regs[rc].node.typ)
     of opcXor:
       decodeBC(rkInt)
       regs[ra].intVal = ord(regs[rb].intVal != regs[rc].intVal)