summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2020-03-16 18:49:27 +0100
committerAraq <rumpf_a@web.de>2020-03-16 19:05:33 +0100
commitd375120c424fa94cc58228c2f0285c1b0b32919b (patch)
treed907880ad22dc85b8909031e7f55970c185f3f4b
parent5ba5b5202acdf5e597ef1e83ebae84608669d32b (diff)
downloadNim-d375120c424fa94cc58228c2f0285c1b0b32919b.tar.gz
rename sfAlwaysReturn to sfNeverRaises
-rw-r--r--compiler/ast.nim2
-rw-r--r--compiler/ccgcalls.nim2
-rw-r--r--compiler/enumtostr.nim4
-rw-r--r--compiler/modulegraphs.nim2
4 files changed, 5 insertions, 5 deletions
diff --git a/compiler/ast.nim b/compiler/ast.nim
index 55ad2ba4b..33edcc953 100644
--- a/compiler/ast.nim
+++ b/compiler/ast.nim
@@ -289,7 +289,7 @@ type
     sfTemplateParam   # symbol is a template parameter
     sfCursor          # variable/field is a cursor, see RFC 177 for details
     sfInjectDestructors # whether the proc needs the 'injectdestructors' transformation
-    sfAlwaysReturn    # proc can never raise an exception, not even OverflowError
+    sfNeverRaises     # proc can never raise an exception, not even OverflowError
                       # or out-of-memory
 
   TSymFlags* = set[TSymFlag]
diff --git a/compiler/ccgcalls.nim b/compiler/ccgcalls.nim
index 3e2cf2271..3be3cbb6b 100644
--- a/compiler/ccgcalls.nim
+++ b/compiler/ccgcalls.nim
@@ -559,7 +559,7 @@ proc genNamedParamCall(p: BProc, ri: PNode, d: var TLoc) =
 
 proc canRaiseDisp(p: BProc; n: PNode): bool =
   # we assume things like sysFatal cannot raise themselves
-  if n.kind == nkSym and sfAlwaysReturn in n.sym.flags:
+  if n.kind == nkSym and sfNeverRaises in n.sym.flags:
     result = false
   elif optPanics in p.config.globalOptions or
       (n.kind == nkSym and sfSystemModule in getModule(n.sym).flags):
diff --git a/compiler/enumtostr.nim b/compiler/enumtostr.nim
index 614190ac3..3eb703ade 100644
--- a/compiler/enumtostr.nim
+++ b/compiler/enumtostr.nim
@@ -40,7 +40,7 @@ proc genEnumToStrProc*(t: PType; info: TLineInfo; g: ModuleGraph): PSym =
   n[resultPos] = newSymNode(res)
   result.ast = n
   incl result.flags, sfFromGeneric
-  incl result.flags, sfAlwaysReturn
+  incl result.flags, sfNeverRaises
 
 proc searchObjCaseImpl(obj: PNode; field: PSym): PNode =
   case obj.kind
@@ -102,4 +102,4 @@ proc genCaseObjDiscMapping*(t: PType; field: PSym; info: TLineInfo; g: ModuleGra
   n[resultPos] = newSymNode(res)
   result.ast = n
   incl result.flags, sfFromGeneric
-  incl result.flags, sfAlwaysReturn
+  incl result.flags, sfNeverRaises
diff --git a/compiler/modulegraphs.nim b/compiler/modulegraphs.nim
index d3be4b3b6..dff3f3b58 100644
--- a/compiler/modulegraphs.nim
+++ b/compiler/modulegraphs.nim
@@ -165,7 +165,7 @@ proc stopCompile*(g: ModuleGraph): bool {.inline.} =
 proc createMagic*(g: ModuleGraph; name: string, m: TMagic): PSym =
   result = newSym(skProc, getIdent(g.cache, name), nil, unknownLineInfo, {})
   result.magic = m
-  result.flags = {sfAlwaysReturn}
+  result.flags = {sfNeverRaises}
 
 proc newModuleGraph*(cache: IdentCache; config: ConfigRef): ModuleGraph =
   result = ModuleGraph()
r/bitsets.nim?h=devel&id=9888a29c3de09c73202b2a955e09e2a7b5e56ea4'>9888a29c3 ^
e25474154 ^
c7e1c665a ^

e25474154 ^
9888a29c3 ^
c7e1c665a ^

e25474154 ^
9888a29c3 ^
e25474154 ^

9888a29c3 ^
7e747d11c ^
d68181246 ^
9888a29c3 ^
7e747d11c ^
d68181246 ^
9888a29c3 ^
7e747d11c ^
d68181246 ^
9888a29c3 ^
7e747d11c ^
d68181246 ^
9888a29c3 ^
7e747d11c ^
d68181246 ^
e25474154 ^


9888a29c3 ^
7e747d11c ^
c7e1c665a ^
e25474154 ^

427490a84 ^

c7e1c665a ^

c4d7cc3da ^
88b5dd336 ^
c4d7cc3da ^
88b5dd336 ^







6ae74f61f ^
c4d7cc3da ^
c7e1c665a ^

c4d7cc3da ^

427490a84 ^
9888a29c3 ^
427490a84 ^
c7e1c665a ^
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

 
                            
                                         




                                                   

                                                            
 


                                   
    

                                                                     

                                                                             
     





                                                       
 
                                                 
                                                                      
 
                                                    
                   

                                                        
 
                                                    

                                                         
 
                                               

                   
                                               
                                          
 
                                              
                                               
 
                                                 
                                           
 
                                                   
                                           
 
                                         
                      
                    


                  
                                           
                      
                                   

                  

                                           

                                                   
 
                                        
            







                                       
 
 

                                             

       
 
                                          
              
                                       
#
#
#           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

when defined(nimPreviewSlimSystem):
  import std/assertions

type
  ElemType = byte
  TBitSet* = seq[ElemType]    # we use byte here to avoid issues with
                              # cross-compiling; uint would be more efficient
                              # however
const
  ElemSize* = 8
  One = ElemType(1)
  Zero = ElemType(0)

template modElemSize(arg: untyped): untyped = arg and 7
template divElemSize(arg: untyped): untyped = arg shr 3

proc bitSetIn*(x: TBitSet, e: BiggestInt): bool =
  result = (x[int(e.divElemSize)] and (One shl e.modElemSize)) != Zero

proc bitSetIncl*(x: var TBitSet, elem: BiggestInt) =
  assert(elem >= 0)
  x[int(elem.divElemSize)] = x[int(elem.divElemSize)] or
      (One shl elem.modElemSize)

proc bitSetExcl*(x: var TBitSet, elem: BiggestInt) =
  x[int(elem.divElemSize)] = x[int(elem.divElemSize)] and
      not(One shl elem.modElemSize)

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

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

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

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

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

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

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

# Number of set bits for all values of int8
const populationCount: array[uint8, uint8] = block:
    var arr: array[uint8, uint8]

    proc countSetBits(x: uint8): uint8 =
      return
        ( x and 0b00000001'u8) +
        ((x and 0b00000010'u8) shr 1) +
        ((x and 0b00000100'u8) shr 2) +
        ((x and 0b00001000'u8) shr 3) +
        ((x and 0b00010000'u8) shr 4) +
        ((x and 0b00100000'u8) shr 5) +
        ((x and 0b01000000'u8) shr 6) +
        ((x and 0b10000000'u8) shr 7)


    for it in low(uint8)..high(uint8):
      arr[it] = countSetBits(cast[uint8](it))

    arr

proc bitSetCard*(x: TBitSet): BiggestInt =
  for it in x:
    result.inc int(populationCount[it])