summary refs log tree commit diff stats
path: root/compiler/trees.nim
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/trees.nim')
-rw-r--r--compiler/trees.nim15
1 files changed, 15 insertions, 0 deletions
diff --git a/compiler/trees.nim b/compiler/trees.nim
index 05c060595..eb88f8d67 100644
--- a/compiler/trees.nim
+++ b/compiler/trees.nim
@@ -54,6 +54,21 @@ proc exprStructuralEquivalent*(a, b: PNode; strictSymEquality=false): bool =
                                           strictSymEquality): return
         result = true
 
+proc sameLocation*(a, b: PNode): bool = 
+  if a == b: true
+  elif a == nil or b == nil: false
+  elif a.kind == b.kind:
+    case a.kind:
+      of nkCheckedFieldExpr, nkDerefExpr, nkHiddenDeref,
+        nkAddr, nkHiddenAddr, nkObjDownConv, nkObjUpConv:
+        sameLocation(a[0], b[0])  
+      of nkDotExpr, nkBracketExpr:
+        sameLocation(a[0], b[0]) and sameLocation(a[1], b[1])    
+      of nkHiddenStdConv, nkHiddenSubConv: sameLocation(a[1], b[1])
+      of nkNone..nkNilLit: exprStructuralEquivalent(a, b, strictSymEquality = true)
+      else: false
+  else: false
+
 proc sameTree*(a, b: PNode): bool =
   if a == b:
     result = true