parent
fc5dd11b3d
commit
4fb7f076d8
1 changed files with 2 additions and 6 deletions
|
|
@ -47,7 +47,7 @@ proc repr*[Enum: enum](x: Enum): string {.magic: "EnumToStr", noSideEffect.}
|
||||||
|
|
||||||
proc repr*(p: pointer): string =
|
proc repr*(p: pointer): string =
|
||||||
## repr of pointer as its hexadecimal value
|
## repr of pointer as its hexadecimal value
|
||||||
if p == nil:
|
if p == nil:
|
||||||
result = "nil"
|
result = "nil"
|
||||||
else:
|
else:
|
||||||
when nimvm:
|
when nimvm:
|
||||||
|
|
@ -66,7 +66,7 @@ template repr*(x: distinct): string =
|
||||||
|
|
||||||
template repr*(t: typedesc): string = $t
|
template repr*(t: typedesc): string = $t
|
||||||
|
|
||||||
proc reprObject[T: tuple|object](res: var string, x: T) =
|
proc reprObject[T: tuple|object](res: var string, x: T) =
|
||||||
res.add '('
|
res.add '('
|
||||||
var firstElement = true
|
var firstElement = true
|
||||||
const isNamed = T is object or isNamedTuple(T)
|
const isNamed = T is object or isNamedTuple(T)
|
||||||
|
|
@ -98,10 +98,6 @@ proc repr*[T: tuple|object](x: T): string =
|
||||||
when T is object:
|
when T is object:
|
||||||
result = $typeof(x)
|
result = $typeof(x)
|
||||||
reprObject(result, x)
|
reprObject(result, x)
|
||||||
|
|
||||||
proc repr*[T](x: ptr T): string =
|
|
||||||
result.add repr(pointer(x)) & " "
|
|
||||||
result.add repr(x[])
|
|
||||||
|
|
||||||
proc repr*[T](x: ref T | ptr T): string =
|
proc repr*[T](x: ref T | ptr T): string =
|
||||||
if isNil(x): return "nil"
|
if isNil(x): return "nil"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue