code cleanup: there is no MoveError and sinks are always available
This commit is contained in:
parent
df3d08b58b
commit
0fd5417aff
2 changed files with 16 additions and 32 deletions
|
|
@ -236,14 +236,13 @@ proc reset*[T](obj: var T) {.magic: "Reset", noSideEffect.}
|
||||||
## resets an object `obj` to its initial (binary zero) value. This needs to
|
## resets an object `obj` to its initial (binary zero) value. This needs to
|
||||||
## be called before any possible `object branch transition`:idx:.
|
## be called before any possible `object branch transition`:idx:.
|
||||||
|
|
||||||
when defined(nimNewRuntime):
|
proc wasMoved*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
|
||||||
proc wasMoved*[T](obj: var T) {.magic: "WasMoved", noSideEffect.} =
|
|
||||||
## resets an object `obj` to its initial (binary zero) value to signify
|
## resets an object `obj` to its initial (binary zero) value to signify
|
||||||
## it was "moved" and to signify its destructor should do nothing and
|
## it was "moved" and to signify its destructor should do nothing and
|
||||||
## ideally be optimized away.
|
## ideally be optimized away.
|
||||||
discard
|
discard
|
||||||
|
|
||||||
proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} =
|
proc move*[T](x: var T): T {.magic: "Move", noSideEffect.} =
|
||||||
result = x
|
result = x
|
||||||
wasMoved(x)
|
wasMoved(x)
|
||||||
|
|
||||||
|
|
@ -268,12 +267,8 @@ else:
|
||||||
UncheckedArray*{.unchecked.}[T] = array[0,T]
|
UncheckedArray*{.unchecked.}[T] = array[0,T]
|
||||||
## Array with no bounds checking
|
## Array with no bounds checking
|
||||||
|
|
||||||
when defined(nimHasOpt):
|
type sink*{.magic: "BuiltinType".}[T]
|
||||||
type opt*{.magic: "Opt".}[T]
|
type lent*{.magic: "BuiltinType".}[T]
|
||||||
|
|
||||||
when defined(nimNewRuntime):
|
|
||||||
type sink*{.magic: "BuiltinType".}[T]
|
|
||||||
type lent*{.magic: "BuiltinType".}[T]
|
|
||||||
|
|
||||||
proc high*[T: Ordinal](x: T): T {.magic: "High", noSideEffect.}
|
proc high*[T: Ordinal](x: T): T {.magic: "High", noSideEffect.}
|
||||||
## returns the highest possible value of an ordinal value `x`. As a special
|
## returns the highest possible value of an ordinal value `x`. As a special
|
||||||
|
|
@ -388,7 +383,6 @@ when defined(nimArrIdx):
|
||||||
proc arrPut[I: Ordinal;T,S](a: T; i: I;
|
proc arrPut[I: Ordinal;T,S](a: T; i: I;
|
||||||
x: S) {.noSideEffect, magic: "ArrPut".}
|
x: S) {.noSideEffect, magic: "ArrPut".}
|
||||||
|
|
||||||
when defined(nimNewRuntime):
|
|
||||||
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} =
|
||||||
## generic `destructor`:idx: implementation that can be overriden.
|
## generic `destructor`:idx: implementation that can be overriden.
|
||||||
discard
|
discard
|
||||||
|
|
@ -676,11 +670,6 @@ type
|
||||||
##
|
##
|
||||||
## This is only raised if the ``segfaults.nim`` module was imported!
|
## This is only raised if the ``segfaults.nim`` module was imported!
|
||||||
|
|
||||||
when defined(nimNewRuntime):
|
|
||||||
type
|
|
||||||
MoveError* = object of Defect ## \
|
|
||||||
## Raised on attempts to re-sink an already consumed ``sink`` parameter.
|
|
||||||
|
|
||||||
when defined(js) or defined(nimdoc):
|
when defined(js) or defined(nimdoc):
|
||||||
type
|
type
|
||||||
JsRoot* = ref object of RootObj
|
JsRoot* = ref object of RootObj
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,6 @@ proc chckNil(p: pointer) =
|
||||||
if p == nil:
|
if p == nil:
|
||||||
sysFatal(NilAccessError, "attempt to write to a nil address")
|
sysFatal(NilAccessError, "attempt to write to a nil address")
|
||||||
|
|
||||||
when defined(nimNewRuntime):
|
|
||||||
proc chckMove(b: bool) {.compilerproc.} =
|
|
||||||
if not b:
|
|
||||||
sysFatal(MoveError, "attempt to access an object that was moved")
|
|
||||||
|
|
||||||
proc chckNilDisp(p: pointer) {.compilerproc.} =
|
proc chckNilDisp(p: pointer) {.compilerproc.} =
|
||||||
if p == nil:
|
if p == nil:
|
||||||
sysFatal(NilAccessError, "cannot dispatch; dispatcher is nil")
|
sysFatal(NilAccessError, "cannot dispatch; dispatcher is nil")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue