summary refs log tree commit diff stats
path: root/tests/generics
Commit message (Expand)AuthorAgeFilesLines
* No longer segfault when using a typeclass with a self referencing type (#19467)Jason Beetham2022-02-021-0/+12
* Fixed concept constraints for static types (#19391)Jason Beetham2022-01-151-25/+62
* Generic parameters now can constrain statics in type definitions (#19362)Jason Beetham2022-01-141-0/+42
* style usages part one (openarray => openArray) (#19321)flywind2022-01-042-3/+3
* Alternative to #18928 (#18931)Jason Beetham2021-09-301-1/+51
* semtypinst: don't wrap type nodes from expressions in static[T] (#18860)alaviss2021-09-171-0/+17
* Fixed #18838 (#18841) [backport]Jason Beetham2021-09-131-1/+35
* Generic pointer procs now error if no types supplied (#18832)Jason Beetham2021-09-111-0/+28
* Fixes implicit and explicit generics in procedures (#18808)Jason Beetham2021-09-061-0/+45
* Fix recursive generic typed defs (#18809)Jason Beetham2021-09-061-0/+12
* improve several tests in testament (#18635)Timothee Cour2021-08-081-2/+2
* typo: nonexistant => nonexistent (#17918)Timothee Cour2021-05-021-4/+4
* semLambda removed, semProcAux reworked (#17379)Saem Ghani2021-03-171-0/+26
* `std/options`: `$some(3)` is now `"some(3)"`, etc. (#17147)Timothee Cour2021-02-241-3/+3
* Deprecate TaintedString (#15423)Juan Carlos2021-01-151-3/+3
* use doAssert in tests (#16486)flywind2020-12-283-31/+31
* testament: error instead of silently overwrite a spec (#16166)Timothee Cour2020-11-291-4/+16
* make megatest consistent with unjoined tests wrt newlines, honor newlines in ...Timothee Cour2020-11-281-8/+0
* Clarify the sense in which Nim supports recursive iterators in the (#15834)c-blake2020-11-041-2/+2
* add testcase for #6060 (#15366)flywind2020-09-211-0/+11
* An optimizer for ARC (#14962)Andreas Rumpf2020-07-151-640/+0
* Fix #14990 (#14991)Clyybber2020-07-151-0/+11
* Reenable a few testsClyybber2020-07-141-4/+3
* Closes #10396Clyybber2020-07-141-0/+55
* Closes #8426Clyybber2020-07-141-0/+14
* add full tests from #9463 (#14975)jcosborn2020-07-141-11/+161
* add testcase for #5926 (#14965)flywind2020-07-111-0/+22
* add testcase for #4668 (#14946)flywind2020-07-091-0/+16
* Add test-cases to some fixed issues to close them (#14795)Danil Yarantsev2020-06-241-0/+18
* Remove the uses of {.procvar.} pragma (#14359)Kaushal Modi2020-05-151-1/+1
* Add tests for #8481, #6490 and #4061 (#14083)Clyybber2020-04-231-0/+13
* faster CIs (#13803)Miran2020-03-301-36/+12
* fix deprecations and other warnings (#13748)Miran2020-03-251-1/+1
* fix #13524 astToStr now works inside generics (#13681)Timothee Cour2020-03-181-0/+6
* fixes #13519Araq2020-03-111-0/+21
* fixes #13378 [backport] (#13392)Andreas Rumpf2020-02-111-0/+16
* Revert "printing float values will have one more digit. (#13276) [backport]" ...Timothee Cour2020-02-082-8/+9
* printing float values will have one more digit. (#13276) [backport]Arne Döring2020-02-072-9/+8
* fixes #13110 (#13197)Andreas Rumpf2020-01-191-1/+4
* [backport] fix #12528, fix #12525: incorrect generic type resolution for defa...Andreas Rumpf2019-10-281-0/+14
* Refactor json macro (#12391)Arne Döring2019-10-171-0/+73
* ungeneric unsigned ops (#12230)Jasper Jenkins2019-10-111-8/+0
* fixes subtype relation regressionAraq2019-05-221-1/+1
* fixes #11239Araq2019-05-221-1/+1
* fixes #6732 (#11255)Andreas Rumpf2019-05-151-0/+21
* fixes #88 (#11243)Andreas Rumpf2019-05-151-2/+25
* 32 bit fixes (#10608)Arne Döring2019-02-131-0/+2
* Propagate tfGcSafe flag to generic instantiations (#10620)LemonBoy2019-02-131-0/+11
* Fix for issue #10342. better message for generic subclass instantiation (#10354)Ray Imber2019-01-222-1/+12
* add `isNamedTuple`; make $(1, 2) be (1, 2) instead of (Field0: 1, Field1: 2) ...Timothee Cour2019-01-081-1/+1
pre>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

 
                            
                                         




                                                   

                                                            
 
    



                                                                             
     

                              









                                                  

                
                                                


                                                                            
                                                   



                                                          
                                                   


                                                           
                                              

                   
                                              
                                                   

                                             
                                                        

                                                
                                                    

                                                  
                                                    



                                        


                  


                                          

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

# this unit handles Nim sets; it implements bit sets
# the code here should be reused in the Nim standard library

type
  TBitSet* = seq[int8]        # we use byte here to avoid issues with
                              # cross-compiling; uint would be more efficient
                              # however

const
  ElemSize* = sizeof(int8) * 8

proc bitSetInit*(b: var TBitSet, length: int)
proc bitSetUnion*(x: var TBitSet, y: TBitSet)
proc bitSetDiff*(x: var TBitSet, y: TBitSet)
proc bitSetSymDiff*(x: var TBitSet, y: TBitSet)
proc bitSetIntersect*(x: var TBitSet, y: TBitSet)
proc bitSetIncl*(x: var TBitSet, elem: BiggestInt)
proc bitSetExcl*(x: var TBitSet, elem: BiggestInt)
proc bitSetIn*(x: TBitSet, e: BiggestInt): bool
proc bitSetEquals*(x, y: TBitSet): bool
proc bitSetContains*(x, y: TBitSet): bool
# implementation

proc bitSetIn(x: TBitSet, e: BiggestInt): bool =
  result = (x[int(e div ElemSize)] and toU8(int(1 shl (e mod ElemSize)))) !=
      toU8(0)

proc bitSetIncl(x: var TBitSet, elem: BiggestInt) =
  assert(elem >= 0)
  x[int(elem div ElemSize)] = x[int(elem div ElemSize)] or
      toU8(int(1 shl (elem mod ElemSize)))

proc bitSetExcl(x: var TBitSet, elem: BiggestInt) =
  x[int(elem div ElemSize)] = x[int(elem div ElemSize)] and
      not toU8(int(1 shl (elem mod ElemSize)))

proc bitSetInit(b: var TBitSet, length: int) =
  newSeq(b, length)

proc bitSetUnion(x: var TBitSet, y: TBitSet) =
  for i in countup(0, high(x)): x[i] = x[i] or y[i]

proc bitSetDiff(x: var TBitSet, y: TBitSet) =
  for i in countup(0, high(x)): x[i] = x[i] and not y[i]

proc bitSetSymDiff(x: var TBitSet, y: TBitSet) =
  for i in countup(0, high(x)): x[i] = x[i] xor y[i]

proc bitSetIntersect(x: var TBitSet, y: TBitSet) =
  for i in countup(0, high(x)): x[i] = x[i] and y[i]

proc bitSetEquals(x, y: TBitSet): bool =
  for i in countup(0, high(x)):
    if x[i] != y[i]:
      return false
  result = true

proc bitSetContains(x, y: TBitSet): bool =
  for i in countup(0, high(x)):
    if (x[i] and not y[i]) != int8(0):
      return false
  result = true