summary refs log tree commit diff stats
path: root/tests/system
Commit message (Expand)AuthorAgeFilesLines
* Revert "printing float values will have one more digit. (#13276) [backport]" ...Timothee Cour2020-02-081-0/+4
* printing float values will have one more digit. (#13276) [backport]Arne Döring2020-02-071-4/+0
* miscellaneous bug fixes (#13291)Timothee Cour2020-01-301-0/+9
* lenVarargs: number of varargs elements (#12907)Timothee Cour2019-12-231-0/+59
* fixes #12315 [backport]; refs #12314 (#12385)Andreas Rumpf2019-10-081-3/+17
* azure: disable failing testsLeorize2019-10-031-4/+1
* fix min/max for float numbers (#12068)Arne Döring2019-09-021-1/+11
* Fix to int to biggest int (#12066)Arne Döring2019-08-271-0/+15
* more enhancements for #11618 (#11976)Andreas Rumpf2019-08-181-0/+27
* fixes #11447Andreas Rumpf2019-07-061-0/+7
* disable talloc2 on 32 bits (#10656)Arne Döring2019-02-131-36/+35
* 32 bit fixes (#10608)Arne Döring2019-02-132-33/+36
* properly deprecate parseopt2 (#10452)Miran2019-01-251-2/+2
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) ...Timothee Cour2019-01-081-0/+11
* fix bug in doAssertRaises when exception==Exception (#10172)Timothee Cour2019-01-041-0/+12
* revives: Move typetraits.`$` to system. Fixes #5827 (#10071)Timothee Cour2018-12-301-0/+14
* testament: joinable is now an explicit concept of a test specAndreas Rumpf2018-12-114-0/+8
* lots of small changesArne Döring2018-12-111-1/+1
* megatest can be executedArne Döring2018-12-111-1/+4
* cleanup tests; don't use non-working 'msg' spec fieldAraq2018-11-231-1/+1
* more eyewashArne Döring2018-11-233-2/+9
* disable tio.nim, it just causes problemsArne Döring2018-11-231-0/+1
* maybe this time?Arne Döring2018-11-231-9/+17
* hopefully this time the tests will compile on the serverArne Döring2018-11-231-3/+0
* updated tests to be executedArne Döring2018-11-231-4/+7
* make run the default action of a test in testerArne Döring2018-11-231-4/+0
* fix segfault when calling shallow() on an empty string (#9782) [backport]Ștefan Talpalaru2018-11-221-0/+7
* Add `toOpenArray[T](ptr UncheckedArray[T])` for clarity. (#9316)c-blake2018-10-121-0/+5
* fixes #9281Araq2018-10-111-0/+15
* fixes #8847Araq2018-09-031-1/+9
* make tests green againAndreas Rumpf2018-08-181-1/+1
* fixes more nil handling regressionsAraq2018-08-131-7/+3
* deprecate isNil for strings and seqsAraq2018-08-081-1/+1
* fixed #7894 (#8496)jcosborn2018-08-016-30/+60
* VM: accessing the string terminator is not allowed anymore; cleanup tests/sys...Andreas Rumpf2018-07-171-7/+10
* Add proc toOpenArray[byte] for strings (#7820)Dmitry Atamanov2018-07-071-0/+16
* test negative range arraynitely2018-06-061-0/+14
* check bounds instead of indexnitely2018-06-051-0/+25
* Added $ for openarrays. Fixes #7940.data-man2018-06-011-0/+1
* correct comparisons for nil strings/seqsAndreas Rumpf2018-04-281-0/+56
* nil in string concats does not produce crashes anymoreAndreas Rumpf2018-04-271-0/+25
* added toOpenArray builtin for zero-copy slices; syntax sugar yet to comeAraq2018-03-241-1/+28
* fix allocator corruption for large sizes (#7338)jcosborn2018-03-174-5/+47
* Fixes #7121 (#7148)pqflx32018-01-311-1/+24
* Improved collection-to-string behavior (#6825)Fabian Keller2017-12-141-4/+4
* fixes #6710Andreas Rumpf2017-11-081-0/+4
* make tests green againAraq2017-11-011-2/+2
* Implementation of high/low for SomeReal (#6570)Fabian Keller2017-10-301-0/+18
* make tests green again; closes #5861Andreas Rumpf2017-10-101-1/+1
* reverted genEchoArne Döring2017-08-081-1/+2
73da8cd25'>^
03ba0f3e2 ^


85e21158d ^
03ba0f3e2 ^
eea2a6360 ^
03ba0f3e2 ^

e4081a720 ^

03ba0f3e2 ^
e6c5622aa ^
03ba0f3e2 ^

1284827df ^
153441db1 ^
a42545ea3 ^
39049e151 ^
153441db1 ^
a42545ea3 ^
153441db1 ^




03ba0f3e2 ^

3a13706d7 ^


e7cdb1d69 ^
03ba0f3e2 ^
92b8fac94 ^
7d6500f1d ^
39049e151 ^
03ba0f3e2 ^
df1ec0939 ^
56b4e3ad9 ^

46b672a6c ^
56b4e3ad9 ^
73c6efdf6 ^
03ba0f3e2 ^
85e21158d ^
03ba0f3e2 ^
39049e151 ^
03ba0f3e2 ^
1284827df ^
153441db1 ^
df1ec0939 ^
39049e151 ^
153441db1 ^
39049e151 ^
153441db1 ^




39049e151 ^
85e21158d ^
03ba0f3e2 ^

b234b082b ^
f7f3a25be ^

39049e151 ^
b234b082b ^
39049e151 ^
03ba0f3e2 ^
39049e151 ^


03ba0f3e2 ^
85e21158d ^

438703f59 ^
03ba0f3e2 ^
39049e151 ^
03ba0f3e2 ^
b234b082b ^
5c33f7651 ^
39049e151 ^
5c33f7651 ^
39049e151 ^







c6235920c ^

39049e151 ^
ab6f79340 ^

6ddd4e6a3 ^
4b0ba5e3f ^
39049e151 ^
1284827df ^
6ddd4e6a3 ^
fab69661a ^
39049e151 ^
ab6f79340 ^

b234b082b ^
6ddd4e6a3 ^
39049e151 ^





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

 
                            
                                         







                                                                           

                        
    
                            


                       
                                                                      
                                          
                                                                   
 
                                                                    
                                  



                                        
                                                  
               
                                                                                      

                            

                                                           
                                                            
                                                                    





                                                
                                            
                                                        

                                        

                     

                                                            
                          
                                                            
                                                                      
                                                              
 
                                                             
                        
                                  


                     
                                                                        
                       
 

               

                                                                               
                                              
             

                                          
                                                                           
                               
                                                           
                                
                                  
                                                                       




                                                             

                                          


                                                           
                                                             
             
                                
                                          
                                                                                
                                 
                                                

                                 
                                                                         
       
           
 
                                                                           
             
                               
             
                                                                         
                             
                                                           
                                                                               
                                
                                                                   




                                                           
 
                                                                      

                          
                                                   

                                              
 
                                                                      
 
                             


                                        
         

                                                 
                               
                            
                                        
       
                                                            
                                            
                                               
         







                                                             

                                                                           
 

                          
                    
                         
 
                                                          
                              
                            
 

                                                
                                                            
                                   





                                                             
#
#
#           The Nim Compiler
#        (c) Copyright 2013 Andreas Rumpf
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## Generates traversal procs for the C backend. Traversal procs are only an
## optimization; the GC works without them too.

# included from cgen.nim

type
  TTraversalClosure = object
    p: BProc
    visitorFrmt: string

proc genTraverseProc(c: TTraversalClosure, accessor: Rope, typ: PType)
proc genCaseRange(p: BProc, branch: PNode)
proc getTemp(p: BProc, t: PType, result: var TLoc; needsInit=false)

proc genTraverseProc(c: TTraversalClosure, accessor: Rope, n: PNode;
                     typ: PType) =
  if n == nil: return
  case n.kind
  of nkRecList:
    for i in countup(0, sonsLen(n) - 1):
      genTraverseProc(c, accessor, n.sons[i], typ)
  of nkRecCase:
    if (n.sons[0].kind != nkSym): internalError(c.p.config, n.info, "genTraverseProc")
    var p = c.p
    let disc = n.sons[0].sym
    if disc.loc.r == nil: fillObjectFields(c.p.module, typ)
    if disc.loc.t == nil:
      internalError(c.p.config, n.info, "genTraverseProc()")
    lineF(p, cpsStmts, "switch ($1.$2) {$n", [accessor, disc.loc.r])
    for i in countup(1, sonsLen(n) - 1):
      let branch = n.sons[i]
      assert branch.kind in {nkOfBranch, nkElse}
      if branch.kind == nkOfBranch:
        genCaseRange(c.p, branch)
      else:
        lineF(p, cpsStmts, "default:$n", [])
      genTraverseProc(c, accessor, lastSon(branch), typ)
      lineF(p, cpsStmts, "break;$n", [])
    lineF(p, cpsStmts, "} $n", [])
  of nkSym:
    let field = n.sym
    if field.typ.kind == tyVoid: return
    if field.loc.r == nil: fillObjectFields(c.p.module, typ)
    if field.loc.t == nil:
      internalError(c.p.config, n.info, "genTraverseProc()")
    genTraverseProc(c, "$1.$2" % [accessor, field.loc.r], field.loc.t)
  else: internalError(c.p.config, n.info, "genTraverseProc()")

proc parentObj(accessor: Rope; m: BModule): Rope {.inline.} =
  if not m.compileToCpp:
    result = "$1.Sup" % [accessor]
  else:
    result = accessor

proc genTraverseProc(c: TTraversalClosure, accessor: Rope, typ: PType) =
  if typ == nil: return

  var p = c.p
  case typ.kind
  of tyGenericInst, tyGenericBody, tyTypeDesc, tyAlias, tyDistinct, tyInferred,
     tySink:
    genTraverseProc(c, accessor, lastSon(typ))
  of tyArray:
    let arraySize = lengthOrd(typ.sons[0])
    var i: TLoc
    getTemp(p, getSysType(c.p.module.g.graph, unknownLineInfo(), tyInt), i)
    let oldCode = p.s(cpsStmts)
    linefmt(p, cpsStmts, "for ($1 = 0; $1 < $2; $1++) {$n",
            i.r, arraySize.rope)
    let oldLen = p.s(cpsStmts).len
    genTraverseProc(c, rfmt(nil, "$1[$2]", accessor, i.r), typ.sons[1])
    if p.s(cpsStmts).len == oldLen:
      # do not emit dummy long loops for faster debug builds:
      p.s(cpsStmts) = oldCode
    else:
      lineF(p, cpsStmts, "}$n", [])
  of tyObject:
    for i in countup(0, sonsLen(typ) - 1):
      var x = typ.sons[i]
      if x != nil: x = x.skipTypes(skipPtrs)
      genTraverseProc(c, accessor.parentObj(c.p.module), x)
    if typ.n != nil: genTraverseProc(c, accessor, typ.n, typ)
  of tyTuple:
    let typ = getUniqueType(typ)
    for i in countup(0, sonsLen(typ) - 1):
      genTraverseProc(c, rfmt(nil, "$1.Field$2", accessor, i.rope), typ.sons[i])
  of tyRef, tyString, tySequence:
    lineCg(p, cpsStmts, c.visitorFrmt, accessor)
  of tyProc:
    if typ.callConv == ccClosure:
      lineCg(p, cpsStmts, c.visitorFrmt, rfmt(nil, "$1.ClE_0", accessor))
  else:
    discard

proc genTraverseProcSeq(c: TTraversalClosure, accessor: Rope, typ: PType) =
  var p = c.p
  assert typ.kind == tySequence
  var i: TLoc
  getTemp(p, getSysType(c.p.module.g.graph, unknownLineInfo(), tyInt), i)
  let oldCode = p.s(cpsStmts)
  lineF(p, cpsStmts, "for ($1 = 0; $1 < $2->$3; $1++) {$n",
      [i.r, accessor, rope(if c.p.module.compileToCpp: "len" else: "Sup.len")])
  let oldLen = p.s(cpsStmts).len
  genTraverseProc(c, "$1->data[$2]" % [accessor, i.r], typ.sons[0])
  if p.s(cpsStmts).len == oldLen:
    # do not emit dummy long loops for faster debug builds:
    p.s(cpsStmts) = oldCode
  else:
    lineF(p, cpsStmts, "}$n", [])

proc genTraverseProc(m: BModule, origTyp: PType; sig: SigHash): Rope =
  var c: TTraversalClosure
  var p = newProc(nil, m)
  result = "Marker_" & getTypeName(m, origTyp, sig)
  var typ = origTyp.skipTypes(abstractInst)
  if typ.kind == tyOpt: typ = optLowering(typ)

  let header = "static N_NIMCALL(void, $1)(void* p, NI op)" % [result]

  let t = getTypeDesc(m, typ)
  lineF(p, cpsLocals, "$1 a;$n", [t])
  lineF(p, cpsInit, "a = ($1)p;$n", [t])

  c.p = p
  c.visitorFrmt = "#nimGCvisit((void*)$1, op);$n"

  assert typ.kind != tyTypeDesc
  if typ.kind == tySequence:
    genTraverseProcSeq(c, "a".rope, typ)
  else:
    if skipTypes(typ.sons[0], typedescInst).kind == tyArray:
      # C's arrays are broken beyond repair:
      genTraverseProc(c, "a".rope, typ.sons[0])
    else:
      genTraverseProc(c, "(*a)".rope, typ.sons[0])

  let generatedProc = "$1 {$n$2$3$4}$n" %
        [header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts)]

  m.s[cfsProcHeaders].addf("$1;$n", [header])
  m.s[cfsProcs].add(generatedProc)

proc genTraverseProcForGlobal(m: BModule, s: PSym; info: TLineInfo): Rope =
  discard genTypeInfo(m, s.loc.t, info)

  var c: TTraversalClosure
  var p = newProc(nil, m)
  var sLoc = s.loc.r
  result = getTempName(m)

  if sfThread in s.flags and emulatedThreadVars(m.config):
    accessThreadLocalVar(p, s)
    sLoc = "NimTV_->" & sLoc

  c.visitorFrmt = "#nimGCvisit((void*)$1, 0);$n"
  c.p = p
  let header = "static N_NIMCALL(void, $1)(void)" % [result]
  genTraverseProc(c, sLoc, s.loc.t)

  let generatedProc = "$1 {$n$2$3$4}$n" %
        [header, p.s(cpsLocals), p.s(cpsInit), p.s(cpsStmts)]

  m.s[cfsProcHeaders].addf("$1;$n", [header])
  m.s[cfsProcs].add(generatedProc)