summary refs log tree commit diff stats
path: root/compiler/sighashes.nim
diff options
context:
space:
mode:
authorClyybber <darkmine956@gmail.com>2019-11-28 17:13:04 +0100
committerAndreas Rumpf <rumpf_a@web.de>2019-11-28 17:13:04 +0100
commit7e747d11c66405f08cc7c69e5afc18348663275e (patch)
treed6277a88b503ddd503d8b769bdae6c72fcf3d27b /compiler/sighashes.nim
parentb662842bd04852a751993ed506f9e38155a4e4aa (diff)
downloadNim-7e747d11c66405f08cc7c69e5afc18348663275e.tar.gz
Cosmetic compiler cleanup (#12718)
* Cleanup compiler code base

* Unify add calls

* Unify len invocations

* Unify range operators

* Fix oversight

* Remove {.procvar.} pragma

* initCandidate -> newCandidate where reasonable

* Unify safeLen calls
Diffstat (limited to 'compiler/sighashes.nim')
-rw-r--r--compiler/sighashes.nim44
1 files changed, 22 insertions, 22 deletions
diff --git a/compiler/sighashes.nim b/compiler/sighashes.nim
index 90b7001a5..f94cd5bce 100644
--- a/compiler/sighashes.nim
+++ b/compiler/sighashes.nim
@@ -84,7 +84,7 @@ proc hashTree(c: var MD5Context, n: PNode) =
   of nkStrLit..nkTripleStrLit:
     c &= n.strVal
   else:
-    for i in 0..<n.len: hashTree(c, n.sons[i])
+    for i in 0..<n.len: hashTree(c, n[i])
 
 proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
   if t == nil:
@@ -93,8 +93,8 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
 
   case t.kind
   of tyGenericInvocation:
-    for i in 0 ..< len(t):
-      c.hashType t.sons[i], flags
+    for i in 0..<t.len:
+      c.hashType t[i], flags
   of tyDistinct:
     if CoDistinct in flags:
       if t.sym != nil: c.hashSym(t.sym)
@@ -110,8 +110,8 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
       # We cannot trust the `lastSon` to hold a properly populated and unique
       # value for each instantiation, so we hash the generic parameters here:
       let normalizedType = t.skipGenericAlias
-      for i in 0 .. normalizedType.len - 2:
-        c.hashType t.sons[i], flags
+      for i in 0..<normalizedType.len - 1:
+        c.hashType t[i], flags
     else:
       c.hashType t.lastSon, flags
   of tyAlias, tySink, tyUserTypeClasses, tyInferred:
@@ -132,8 +132,8 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
       let inst = t.typeInst
       t.typeInst = nil
       assert inst.kind == tyGenericInst
-      for i in 0 .. inst.len - 2:
-        c.hashType inst.sons[i], flags
+      for i in 0..<inst.len - 1:
+        c.hashType inst[i], flags
       t.typeInst = inst
       return
     c &= char(t.kind)
@@ -168,8 +168,8 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
           c &= ".empty"
     else:
       c &= t.id
-    if t.len > 0 and t.sons[0] != nil:
-      hashType c, t.sons[0], flags
+    if t.len > 0 and t[0] != nil:
+      hashType c, t[0], flags
   of tyRef, tyPtr, tyGenericBody, tyVar:
     c &= char(t.kind)
     c.hashType t.lastSon, flags
@@ -180,24 +180,24 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
   of tyTuple:
     c &= char(t.kind)
     if t.n != nil and CoType notin flags:
-      assert(len(t.n) == len(t))
-      for i in 0 ..< len(t.n):
-        assert(t.n.sons[i].kind == nkSym)
-        c &= t.n.sons[i].sym.name.s
+      assert(t.n.len == t.len)
+      for i in 0..<t.n.len:
+        assert(t.n[i].kind == nkSym)
+        c &= t.n[i].sym.name.s
         c &= ':'
-        c.hashType(t.sons[i], flags+{CoIgnoreRange})
+        c.hashType(t[i], flags+{CoIgnoreRange})
         c &= ','
     else:
-      for i in 0 ..< len(t): c.hashType t.sons[i], flags+{CoIgnoreRange}
+      for i in 0..<t.len: c.hashType t[i], flags+{CoIgnoreRange}
   of tyRange:
     if CoIgnoreRange notin flags:
       c &= char(t.kind)
       c.hashTree(t.n)
-    c.hashType(t.sons[0], flags)
+    c.hashType(t[0], flags)
   of tyStatic:
     c &= char(t.kind)
     c.hashTree(t.n)
-    c.hashType(t.sons[0], flags)
+    c.hashType(t[0], flags)
   of tyProc:
     c &= char(t.kind)
     c &= (if tfIterator in t.flags: "iterator " else: "proc ")
@@ -209,9 +209,9 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
         c &= ':'
         c.hashType(param.typ, flags)
         c &= ','
-      c.hashType(t.sons[0], flags)
+      c.hashType(t[0], flags)
     else:
-      for i in 0..<t.len: c.hashType(t.sons[i], flags)
+      for i in 0..<t.len: c.hashType(t[i], flags)
     c &= char(t.callConv)
     # purity of functions doesn't have to affect the mangling (which is in fact
     # problematic for HCR - someone could have cached a pointer to another
@@ -223,10 +223,10 @@ proc hashType(c: var MD5Context, t: PType; flags: set[ConsiderFlag]) =
     if tfVarargs in t.flags: c &= ".varargs"
   of tyArray:
     c &= char(t.kind)
-    for i in 0..<t.len: c.hashType(t.sons[i], flags-{CoIgnoreRange})
+    for i in 0..<t.len: c.hashType(t[i], flags-{CoIgnoreRange})
   else:
     c &= char(t.kind)
-    for i in 0..<t.len: c.hashType(t.sons[i], flags)
+    for i in 0..<t.len: c.hashType(t[i], flags)
   if tfNotNil in t.flags and CoType notin flags: c &= "not nil"
 
 when defined(debugSigHashes):
@@ -352,7 +352,7 @@ proc hashBodyTree(graph: ModuleGraph, c: var MD5Context, n: PNode) =
     c &= n.strVal
   else:
     for i in 0..<n.len:
-      hashBodyTree(graph, c, n.sons[i])
+      hashBodyTree(graph, c, n[i])
 
 proc symBodyDigest*(graph: ModuleGraph, sym: PSym): SigHash =
   ## compute unique digest of the proc/func/method symbols