summary refs log tree commit diff stats
path: root/nimsuggest
Commit message (Expand)AuthorAgeFilesLines
* Fix nimsuggest not showing suggestions for imported tuples (#22241)Jake Leahy2023-07-103-0/+22
* Create compiler and nimsuggest packages (#22118)Ivan Yonchovski2023-06-182-7/+12
* Improve nimsuggest (#21825)Juan Carlos2023-05-111-1/+1
* fixes #19863; move sha1, md5 to nimble packages for 2.0 (#21702)ringabout2023-05-021-1/+2
* Fix infinite recursion introduced in 7031ea6 [backport 1.6] (#21555)Peter Munch-Ellingsen2023-03-201-1/+1
* replaces implicit passes array registed at runtime with explicit function cal...ringabout2023-03-031-1/+1
* fixes #19795; fixes #11852; fixes #19974; remove parsing pipeline, Nim now pa...ringabout2023-02-221-1/+1
* Implemented basic macro expand functionality (#20579)Ivan Yonchovski2023-01-274-51/+206
* Fix nimsuggest not suggesting fields in when theres static parameters (#21189)Jake Leahy2022-12-281-0/+18
* Nimsuggest now defines the backends symbol (#21083)Jake Leahy2022-12-123-2/+13
* fix bugs with dot & call operators [backport] (#20931)metagn2022-11-281-2/+0
* rename `std/threads` to `std/typedthreads` (#20850)ringabout2022-11-161-1/+1
* Fix typo in nimsuggest.nim (#20767)Ikko Ashimine2022-11-051-1/+1
* fixes #20526; use `nimPreviewSlimSystem` for documentation build (#20714)ringabout2022-11-011-0/+3
* put std/threads under the umbrella of nimPreviewSlimSystem (#20711)ringabout2022-10-311-0/+2
* fixes #19162; enable `strictEffects` for v2 (#19380)ringabout2022-10-151-1/+1
* 'lock levels' are deprecated, now a noop (#20539)ringabout2022-10-118-24/+24
* Fix/improve handling of forward declarations in nimsuggest (#20493)Ivan Yonchovski2022-10-063-9/+114
* moderate system cleanup & refactor (#20355)metagn2022-09-282-4/+4
* defaults to ORC (#19972)ringabout2022-09-231-12/+2
* Partially Revert "Change nim's nimble files to make it installable" (#20296)ringabout2022-09-021-0/+8
* Change nim's nimble files to make it installable (#20179)Ivan Yonchovski2022-08-311-8/+0
* [nimsuggest] fix def call on identifier 2 times on the line (#20228)Ivan Yonchovski2022-08-303-38/+49
* Use module actual file instead of PSym.info (#19956)Ivan Yonchovski2022-07-151-0/+7
* Implement type command (#19944)Ivan Yonchovski2022-07-153-2/+44
* Initial implementation of nimsuggest v3 (#19826)Ivan Yonchovski2022-06-133-15/+257
* Make sure that field usage preserves the original line info (#19751)Ivan Yonchovski2022-04-291-0/+15
* [nimsuggest] return the type when on symbol in let/var (#19639)Ivan Yonchovski2022-04-071-0/+7
* fix stricteffects (nimsuggest/sexp) (#19405)flywind2022-01-181-1/+1
* [backport] use old style hints in .cfg files (#18917)Miran2021-09-291-1/+1
* improvements to `addInt` and `$` for integer types (#18592)Timothee Cour2021-08-191-1/+1
* fix #18385 followup, by building nimsuggest with -d:release during testing (#...Timothee Cour2021-07-291-4/+11
* improvements to hint:processing: show import stack, distinguish nims, show in...Timothee Cour2021-06-303-3/+3
* change `--hint[X] => --hint:X` in nim repo (avoids shell quoting issues) (#18...Timothee Cour2021-05-261-1/+1
* disable tmacro_highlight on i386, refs #17945 (#17949)Timothee Cour2021-05-061-0/+4
* improve nimsuggest/tester, minor improvements to koch.nim (#17879)Timothee Cour2021-04-291-10/+12
* add `--processing:dots|filenames|off` to customize `hintProcessing` (#17817)Timothee Cour2021-04-235-6/+11
* fixed dot operator recursive loop & macro suggest (#16922)Saem Ghani2021-02-152-12/+1
* tables module uses runnableExamples (#16994)flywind2021-02-131-0/+2
* compilesettings: add libpath (#16997)Timothee Cour2021-02-121-2/+4
* nimsuggest prioritize non-deprecated suggestions (#16816)Saem Ghani2021-01-292-10/+12
* regression test for nim-lang/nimsuggest#58 (#16817)Saem Ghani2021-01-251-0/+22
* fixed nim-lang/nimsuggest#48 type aware sug (#16814)Saem Ghani2021-01-252-3/+29
* Deprecate TaintedString (#15423)Juan Carlos2021-01-151-1/+1
* fixes nim-lang/nimsuggest#103 con dot exprs (#16657)Saem Ghani2021-01-121-2/+32
* fixed nim-lang/nimsuggest#82 pure enum field sug (#16676)Saem Ghani2021-01-111-0/+18
* IC: next steps (#16550)Andreas Rumpf2021-01-071-1/+1
* fixes nim-lang/nimsuggest#119 outline includes (#16608)Saem Ghani2021-01-061-2/+8
* nimsuggest: fix and re-enable old tests (#16401)Saem Ghani2020-12-2719-376/+292
* use hexchar in stdlib (#16290)flywind2020-12-171-8/+2
/system/deepcopy.nim?h=devel&id=01ae0d28d47ef4cdd26e1f1f04e40aa9ae6ffe2b'>^
9673e4f2d ^
e83d11e8f ^
9673e4f2d ^

1aa359feb ^

721bf7188 ^
1088814e5 ^




a64d73302 ^
9673e4f2d ^
e83d11e8f ^

734443d72 ^
e83d11e8f ^
2316c71e0 ^

8875ca750 ^
e83d11e8f ^


734443d72 ^




e83d11e8f ^
ad608838b ^

e83d11e8f ^

ad608838b ^
9673e4f2d ^
a64d73302 ^
9673e4f2d ^

1088814e5 ^


9673e4f2d ^
1088814e5 ^
9673e4f2d ^
a64d73302 ^
9673e4f2d ^
c94647aec ^
caa7f42e8 ^
e83d11e8f ^


caa7f42e8 ^
9673e4f2d ^
c94647aec ^
a64d73302 ^
9673e4f2d ^





fc0fda14a ^

9673e4f2d ^
1aa359feb ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187

 
                                  
                                         




                                                   


                       
                                              













































                                                               
     

                               

             
                                                    
                                                                

                        
                                                   




                                                                          
                             



                                                                       
                                           

                                                   
                                                                              
     

                               







                                              
                                                           

                                  
                                   





                                                  
                                                       

                          
                                                                  
                                                                   
                                     
                     


                                                                         
                      
                                                 


                                         
                                               
             
                                               

                                             

                                                                             
           




                                             
                                            
         

                         
                                 
                               

                                                      
                                                


                                                       




                                                        
                                                         

                                                                                       

                                                
                                             
           
                                              

                                                       


                                                   
         
                                 
       
                               
 
                                                                         
              


                                        
             
 
                                                                            
                             





                                                            

                               
                    

                                                                   
#
#
#            Nim's Runtime Library
#        (c) Copyright 2015 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

type
  PtrTable = ptr object
    counter, max: int
    data: array[0xff_ffff, (pointer, pointer)]

template hashPtr(key: pointer): int = cast[int](key) shr 8
template allocPtrTable: untyped =
  cast[PtrTable](alloc0(sizeof(int)*2 + sizeof(pointer)*2*cap))

proc rehash(t: PtrTable): PtrTable =
  let cap = (t.max+1) * 2
  result = allocPtrTable()
  result.counter = t.counter
  result.max = cap-1
  for i in 0..t.max:
    let k = t.data[i][0]
    if k != nil:
      var h = hashPtr(k)
      while result.data[h and result.max][0] != nil: inc h
      result.data[h and result.max] = t.data[i]
  dealloc t

proc initPtrTable(): PtrTable =
  const cap = 32
  result = allocPtrTable()
  result.counter = 0
  result.max = cap-1

template deinit(t: PtrTable) = dealloc(t)

proc get(t: PtrTable; key: pointer): pointer =
  var h = hashPtr(key)
  while true:
    let k = t.data[h and t.max][0]
    if k == nil: break
    if k == key:
      return t.data[h and t.max][1]
    inc h

proc put(t: var PtrTable; key, val: pointer) =
  if (t.max+1) * 2 < t.counter * 3: t = rehash(t)
  var h = hashPtr(key)
  while t.data[h and t.max][0] != nil: inc h
  t.data[h and t.max] = (key, val)
  inc t.counter

proc genericDeepCopyAux(dest, src: pointer, mt: PNimType;
                        tab: var PtrTable) {.benign.}
proc genericDeepCopyAux(dest, src: pointer, n: ptr TNimNode;
                        tab: var PtrTable) {.benign.} =
  var
    d = cast[ByteAddress](dest)
    s = cast[ByteAddress](src)
  case n.kind
  of nkSlot:
    genericDeepCopyAux(cast[pointer](d +% n.offset),
                       cast[pointer](s +% n.offset), n.typ, tab)
  of nkList:
    for i in 0..n.len-1:
      genericDeepCopyAux(dest, src, n.sons[i], tab)
  of nkCase:
    var dd = selectBranch(dest, n)
    var m = selectBranch(src, n)
    # reset if different branches are in use; note different branches also
    # imply that's not self-assignment (``x = x``)!
    if m != dd and dd != nil:
      genericResetAux(dest, dd)
    copyMem(cast[pointer](d +% n.offset), cast[pointer](s +% n.offset),
            n.typ.size)
    if m != nil:
      genericDeepCopyAux(dest, src, m, tab)
  of nkNone: sysAssert(false, "genericDeepCopyAux")

proc genericDeepCopyAux(dest, src: pointer, mt: PNimType; tab: var PtrTable) =
  var
    d = cast[ByteAddress](dest)
    s = cast[ByteAddress](src)
  sysAssert(mt != nil, "genericDeepCopyAux 2")
  case mt.kind
  of tyString:
    var x = cast[PPointer](dest)
    var s2 = cast[PPointer](s)[]
    if s2 == nil:
      unsureAsgnRef(x, s2)
    else:
      unsureAsgnRef(x, copyDeepString(cast[NimString](s2)))
  of tySequence:
    var s2 = cast[PPointer](src)[]
    var seq = cast[PGenericSeq](s2)
    var x = cast[PPointer](dest)
    if s2 == nil:
      unsureAsgnRef(x, s2)
      return
    sysAssert(dest != nil, "genericDeepCopyAux 3")
    unsureAsgnRef(x, newSeq(mt, seq.len))
    var dst = cast[ByteAddress](cast[PPointer](dest)[])
    for i in 0..seq.len-1:
      genericDeepCopyAux(
        cast[pointer](dst +% i *% mt.base.size +% GenericSeqSize),
        cast[pointer](cast[ByteAddress](s2) +% i *% mt.base.size +%
                     GenericSeqSize),
        mt.base, tab)
  of tyObject:
    # we need to copy m_type field for tyObject, as it could be empty for
    # sequence reallocations:
    if mt.base != nil:
      genericDeepCopyAux(dest, src, mt.base, tab)
    else:
      var pint = cast[ptr PNimType](dest)
      pint[] = cast[ptr PNimType](src)[]
    genericDeepCopyAux(dest, src, mt.node, tab)
  of tyTuple:
    genericDeepCopyAux(dest, src, mt.node, tab)
  of tyArray, tyArrayConstr:
    for i in 0..(mt.size div mt.base.size)-1:
      genericDeepCopyAux(cast[pointer](d +% i *% mt.base.size),
                         cast[pointer](s +% i *% mt.base.size), mt.base, tab)
  of tyRef:
    let s2 = cast[PPointer](src)[]
    if s2 == nil:
      unsureAsgnRef(cast[PPointer](dest), s2)
    elif mt.base.deepcopy != nil:
      let z = mt.base.deepcopy(s2)
      unsureAsgnRef(cast[PPointer](dest), z)
    else:
      let z = tab.get(s2)
      if z == nil:
        when declared(usrToCell):
          let x = usrToCell(s2)
          let realType = x.typ
          let z = newObj(realType, realType.base.size)
          unsureAsgnRef(cast[PPointer](dest), z)
          tab.put(s2, z)
          genericDeepCopyAux(z, s2, realType.base, tab)
        else:
          when false:
            # addition check disabled
            let x = usrToCell(s2)
            let realType = x.typ
            sysAssert realType == mt, " types do differ"
          # this version should work for any possible GC:
          let typ = if mt.base.kind == tyObject: cast[ptr PNimType](s2)[] else: mt.base
          let z = newObj(mt, typ.size)
          unsureAsgnRef(cast[PPointer](dest), z)
          tab.put(s2, z)
          genericDeepCopyAux(z, s2, typ, tab)
      else:
        unsureAsgnRef(cast[PPointer](dest), z)
  of tyPtr:
    # no cycle check here, but also not really required
    let s2 = cast[PPointer](src)[]
    if s2 != nil and mt.base.deepcopy != nil:
      cast[PPointer](dest)[] = mt.base.deepcopy(s2)
    else:
      cast[PPointer](dest)[] = s2
  else:
    copyMem(dest, src, mt.size)

proc genericDeepCopy(dest, src: pointer, mt: PNimType) {.compilerproc.} =
  GC_disable()
  var tab = initPtrTable()
  genericDeepCopyAux(dest, src, mt, tab)
  deinit tab
  GC_enable()

proc genericSeqDeepCopy(dest, src: pointer, mt: PNimType) {.compilerproc.} =
  # also invoked for 'string'
  var src = src
  genericDeepCopy(dest, addr(src), mt)

proc genericDeepCopyOpenArray(dest, src: pointer, len: int,
                            mt: PNimType) {.compilerproc.} =
  var
    d = cast[ByteAddress](dest)
    s = cast[ByteAddress](src)
  for i in 0..len-1:
    genericDeepCopy(cast[pointer](d +% i *% mt.base.size),
                    cast[pointer](s +% i *% mt.base.size), mt.base)