fixed #96 as good as technically possible (debug frames are allocated on the C stack)

This commit is contained in:
Araq 2012-01-29 01:53:09 +01:00
commit 9083f01fd2
3 changed files with 10 additions and 10 deletions

View file

@ -35,12 +35,12 @@ proc reverse*[T](a: var openArray[T]) =
reverse(a, 0, a.high) reverse(a, 0, a.high)
const const
onlySafeCode = true onlySafeCode = false
proc merge[T](a, b: var openArray[T], lo, m, hi: int, proc merge[T](a, b: var openArray[T], lo, m, hi: int,
cmp: proc (x, y: T): int, order: TSortOrder) = cmp: proc (x, y: T): int, order: TSortOrder) =
template `<-` (a, b: expr) = template `<-` (a, b: expr) =
when true: when false:
a = b a = b
elif onlySafeCode: elif onlySafeCode:
shallowCopy(a, b) shallowCopy(a, b)

View file

@ -2129,16 +2129,16 @@ template assert*(cond: expr, msg = "") =
## Use ``assert`` for debugging purposes only. ## Use ``assert`` for debugging purposes only.
bind raiseAssert, InstantiationInfo bind raiseAssert, InstantiationInfo
when compileOption("assertions"): when compileOption("assertions"):
if not cond:
{.line.}: {.line.}:
if not cond:
raiseAssert(astToStr(cond) & ' ' & msg) raiseAssert(astToStr(cond) & ' ' & msg)
template doAssert*(cond: expr, msg = "") = template doAssert*(cond: expr, msg = "") =
## same as `assert` but is always turned on and not affected by the ## same as `assert` but is always turned on and not affected by the
## ``--assertions`` command line switch. ## ``--assertions`` command line switch.
bind raiseAssert, InstantiationInfo bind raiseAssert, InstantiationInfo
if not cond:
{.line: InstantiationInfo().}: {.line: InstantiationInfo().}:
if not cond:
raiseAssert(astToStr(cond) & ' ' & msg) raiseAssert(astToStr(cond) & ' ' & msg)

View file

@ -28,8 +28,8 @@ when isMainModule:
var data: seq[string] = @[] var data: seq[string] = @[]
var L = random(59) var L = random(59)
for i in 0..1: for i in 0..10_000:
echo "loop: ", i #echo "loop: ", i
#newSeq(data, L) #newSeq(data, L)
setLen(data, L) setLen(data, L)
for j in 0 .. L-1: for j in 0 .. L-1:
@ -39,13 +39,13 @@ when isMainModule:
var copy = data var copy = data
for j in 0 .. L-1: for j in 0 .. L-1:
assert getRefcount(copy[j]) == 1 assert getRefcount(copy[j]) == 1
assert(cast[pointer](copy[j]) != cast[pointer](data[i])) assert(cast[pointer](copy[j]) != cast[pointer](data[j]))
bubblesort(data, system.cmp, order) bubblesort(data, system.cmp, order)
if not sorted(data, order): if not sorted(data, order):
quit "bubblesort failed" quit "bubblesort failed"
sort(copy, cmp, order) #sort(copy, cmp, order)
for j in 0 .. L-1: for j in 0 .. L-1:
let rc = getRefcount(data[j]) let rc = getRefcount(data[j])
if rc != 1: if rc != 1: