.cursor implementation (#12637)

* cursors: first implementation
* added currently failing test
* .cursor works for doubly linked lists
* make -d:useMalloc work again
* added code to nil out refs in a destructor
* it's now called --gc:arc
* renderer.nim: render nkBreakState properly
* make simple closure iterators work without leaking
This commit is contained in:
Andreas Rumpf 2019-11-12 15:05:36 +01:00 • committed by GitHub
commit dfb020b174
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 106 additions and 36 deletions

View file

@ -0,0 +1,38 @@
discard """
output: '''Success
@["a", "b", "c"]
0'''
cmd: '''nim c --gc:destructors $file'''
"""
import os
import math
import lists
import strutils
proc mkleak() =
# allocate 1 MB via linked lists
let numberOfLists = 100
for i in countUp(1, numberOfLists):
var leakList = initDoublyLinkedList[string]()
let numberOfLeaks = 5000
for j in countUp(1, numberOfLeaks):
leakList.append(newString(200))
proc mkManyLeaks() =
for i in 0..0:
mkleak()
echo "Success"
iterator foobar(c: string): seq[string] {.closure.} =
yield @["a", "b", c]
proc tsimpleClosureIterator =
var myc = "c"
for it in foobar(myc):
echo it
let startMem = getOccupiedMem()
mkManyLeaks()
tsimpleClosureIterator()
echo getOccupiedMem() - startMem