Mark a preserves template as used
This commit is contained in:
parent
30a9d55aac
commit
54c28c90ce
|
@ -695,8 +695,7 @@ proc toPreserve*[T](x: T; E = void): Preserve[E] =
|
|||
elif T is SomeInteger:
|
||||
result = Preserve[E](kind: pkSignedInteger, int: x.BiggestInt)
|
||||
elif T is object:
|
||||
trace T, " is object"
|
||||
template fieldToPreserve(key: string; val: typed): Preserve =
|
||||
template fieldToPreserve(key: string; val: typed): Preserve {.used.} =
|
||||
when x.dot(key).hasCustomPragma(preservesSymbol):
|
||||
toSymbol(val, E)
|
||||
elif x.dot(key).hasCustomPragma(preservesLiteral):
|
||||
|
@ -708,7 +707,6 @@ proc toPreserve*[T](x: T; E = void): Preserve[E] =
|
|||
elif T.hasCustomPragma(preservesOr):
|
||||
var hasKind, hasVariant: bool
|
||||
for k, v in x.fieldPairs:
|
||||
trace T, ": iterate to ", k
|
||||
if k == "orKind":
|
||||
assert(not hasKind)
|
||||
hasKind = true
|
||||
|
@ -716,8 +714,6 @@ proc toPreserve*[T](x: T; E = void): Preserve[E] =
|
|||
assert(hasKind and not hasVariant)
|
||||
result = fieldToPreserve(k, v)
|
||||
hasVariant = true
|
||||
if not hasVariant:
|
||||
trace T, ": no value found"
|
||||
elif T.hasCustomPragma(preservesRecord):
|
||||
result = Preserve[E](kind: pkRecord)
|
||||
for k, v in x.fieldPairs:
|
||||
|
@ -733,7 +729,6 @@ proc toPreserve*[T](x: T; E = void): Preserve[E] =
|
|||
else:
|
||||
result.sequence.add(fieldToPreserve(label, field))
|
||||
elif T.hasCustomPragma(preservesDictionary):
|
||||
trace T, ": convert to a dictionary"
|
||||
result = initDictionary[E]()
|
||||
for key, val in x.fieldPairs:
|
||||
result[toSymbol(key, E)] = fieldToPreserve(key, val)
|
||||
|
@ -919,7 +914,6 @@ proc fromPreserve*[T, E](v: var T; pr: Preserve[E]): bool =
|
|||
inc i
|
||||
result = result and (i == pr.len)
|
||||
elif T.hasCustomPragma(preservesDictionary):
|
||||
trace T, " is a preservesDictionary"
|
||||
if pr.isDictionary:
|
||||
result = true
|
||||
var i: int
|
||||
|
|
Loading…
Reference in New Issue