tests/gc/gcleak4.nim
This commit is contained in:
parent
869a5aa90d
commit
d257f7fd36
3 changed files with 13 additions and 4 deletions
|
|
@ -558,10 +558,10 @@ The template body does not open a new scope. To open a new scope use a ``block``
|
||||||
statement:
|
statement:
|
||||||
|
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
template declareInScope(x: expr, t: typeDesc): stmt =
|
template declareInScope(x: expr, t: typeDesc): stmt {.immediate.} =
|
||||||
var x: t
|
var x: t
|
||||||
|
|
||||||
template declareInNewScope(x: expr, t: typeDesc): stmt =
|
template declareInNewScope(x: expr, t: typeDesc): stmt {.immediate.} =
|
||||||
# open a new scope:
|
# open a new scope:
|
||||||
block:
|
block:
|
||||||
var x: t
|
var x: t
|
||||||
|
|
@ -572,6 +572,8 @@ statement:
|
||||||
declareInNewScope(b, int)
|
declareInNewScope(b, int)
|
||||||
b = 42 # does not work, `b` is unknown
|
b = 42 # does not work, `b` is unknown
|
||||||
|
|
||||||
|
(The manual explains why the ``immediate`` pragma is needed for these
|
||||||
|
templates.)
|
||||||
|
|
||||||
If there is a ``stmt`` parameter it should be the last in the template
|
If there is a ``stmt`` parameter it should be the last in the template
|
||||||
declaration. The reason is that statements can be passed to a template
|
declaration. The reason is that statements can be passed to a template
|
||||||
|
|
@ -580,7 +582,7 @@ via a special ``:`` syntax:
|
||||||
.. code-block:: nimrod
|
.. code-block:: nimrod
|
||||||
|
|
||||||
template withFile(f: expr, filename: string, mode: TFileMode,
|
template withFile(f: expr, filename: string, mode: TFileMode,
|
||||||
body: stmt): stmt =
|
body: stmt): stmt {.immediate.} =
|
||||||
block:
|
block:
|
||||||
let fn = filename
|
let fn = filename
|
||||||
var f: TFile
|
var f: TFile
|
||||||
|
|
|
||||||
|
|
@ -632,7 +632,12 @@ proc genericHashAux(dest: Pointer, mt: PNimType, shallow: bool,
|
||||||
else:
|
else:
|
||||||
result = h
|
result = h
|
||||||
var s = cast[ppointer](dest)[]
|
var s = cast[ppointer](dest)[]
|
||||||
if s != nil: result = genericHashAux(s, mt.base, shallow, result)
|
if s != nil:
|
||||||
|
result = result !& genericHashAux(s, mt.base, shallow, result)
|
||||||
|
# hash the object header:
|
||||||
|
#const headerSize = sizeof(int)*2
|
||||||
|
#result = result !& hash(cast[pointer](cast[int](s) -% headerSize),
|
||||||
|
# headerSize)
|
||||||
else:
|
else:
|
||||||
result = h !& hash(dest, mt.size) # hash raw bits
|
result = h !& hash(dest, mt.size) # hash raw bits
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,8 @@ proc usrToCell(usr: pointer): PCell {.inline.} =
|
||||||
result = cast[PCell](cast[TAddress](usr)-%TAddress(sizeof(TCell)))
|
result = cast[PCell](cast[TAddress](usr)-%TAddress(sizeof(TCell)))
|
||||||
|
|
||||||
proc canbeCycleRoot(c: PCell): bool {.inline.} =
|
proc canbeCycleRoot(c: PCell): bool {.inline.} =
|
||||||
|
if c.typ == nil:
|
||||||
|
echo "ARRGHHHHHHH"
|
||||||
result = ntfAcyclic notin c.typ.flags
|
result = ntfAcyclic notin c.typ.flags
|
||||||
|
|
||||||
proc extGetCellType(c: pointer): PNimType {.compilerproc.} =
|
proc extGetCellType(c: pointer): PNimType {.compilerproc.} =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue