bugfix: 'when' sections in generic objects now work, so TThread[void] compiles
This commit is contained in:
parent
a274f3bf5b
commit
72651de710
13 changed files with 153 additions and 77 deletions
|
|
@ -11,7 +11,7 @@
|
|||
## sparse bit set.
|
||||
## **Note**: Since Nimrod currently does not allow the assignment operator to
|
||||
## be overloaded, ``=`` for int sets performs some rather meaningless shallow
|
||||
## copy.
|
||||
## copy; use ``assign`` to get a deep copy.
|
||||
|
||||
import
|
||||
os, hashes, math
|
||||
|
|
@ -137,6 +137,30 @@ proc initIntSet*: TIntSet =
|
|||
result.counter = 0
|
||||
result.head = nil
|
||||
|
||||
proc assign*(dest: var TIntSet, src: TIntSet) =
|
||||
## copies `src` to `dest`. `dest` does not need to be initialized by
|
||||
## `initIntSet`.
|
||||
dest.counter = src.counter
|
||||
dest.max = src.max
|
||||
newSeq(dest.data, src.data.len)
|
||||
|
||||
var it = src.head
|
||||
while it != nil:
|
||||
|
||||
var h = it.key and dest.max
|
||||
while dest.data[h] != nil: h = nextTry(h, dest.max)
|
||||
assert(dest.data[h] == nil)
|
||||
|
||||
var n: PTrunk
|
||||
new(n)
|
||||
n.next = dest.head
|
||||
n.key = it.key
|
||||
n.bits = it.bits
|
||||
dest.head = n
|
||||
dest.data[h] = n
|
||||
|
||||
it = it.next
|
||||
|
||||
template dollarImpl(): stmt =
|
||||
result = "{"
|
||||
for key in items(s):
|
||||
|
|
@ -174,4 +198,7 @@ when isMainModule:
|
|||
x.incl(1056)
|
||||
for e in items(x): echo e
|
||||
|
||||
var y: TIntSet
|
||||
assign(y, x)
|
||||
for e in items(y): echo e
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,7 @@ proc setStyle*(style: set[TStyle]) =
|
|||
if styleBlink in style: a = a or int16(BACKGROUND_INTENSITY)
|
||||
if styleReverse in style: a = a or 0x4000'i16 # COMMON_LVB_REVERSE_VIDEO
|
||||
if styleUnderscore in style: a = a or 0x8000'i16 # COMMON_LVB_UNDERSCORE
|
||||
discard SetConsoleTextAttribute(conHandle, old or a)
|
||||
discard SetConsoleTextAttribute(conHandle, a)
|
||||
else:
|
||||
for s in items(style):
|
||||
stdout.write("\e[" & $ord(s) & 'm')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue