lift the =dup hook (#21903)

* fixes tests again
* remove helper functions
* fixes closures, owned refs
* final cleanup
This commit is contained in:
ringabout
2023-06-02 22:03:32 +08:00
committed by GitHub
parent ead7e20926
commit 1133f20fe2
15 changed files with 151 additions and 93 deletions

View File

@@ -137,7 +137,7 @@ proc new*[T](a: var ref T, finalizer: proc (x: ref T) {.nimcall.}) {.
## **Note**: The `finalizer` refers to the type `T`, not to the object!
## This means that for each object of type `T` the finalizer will be called!
proc `=wasMoved`[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
proc `=wasMoved`*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
## Generic `wasMoved`:idx: implementation that can be overridden.
proc wasMoved*[T](obj: var T) {.inline, noSideEffect.} =
@@ -354,7 +354,7 @@ proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
discard
when defined(nimHasDup):
proc `=dup`*[T](x: ref T): ref T {.inline, magic: "Dup".} =
proc `=dup`*[T](x: T): T {.inline, magic: "Dup".} =
## Generic `dup`:idx: implementation that can be overridden.
discard

View File

@@ -200,10 +200,6 @@ proc nimDecRefIsLast(p: pointer): bool {.compilerRtl, inl.} =
when traceCollector:
cprintf("[DECREF] %p\n", cell)
proc nimDupRef(dest: ptr pointer, src: pointer) {.compilerRtl, inl.} =
dest[] = src
if src != nil: nimIncRef src
proc GC_unref*[T](x: ref T) =
## New runtime only supports this operation for 'ref T'.
var y {.cursor.} = x