New constructors for record and sequence
This commit is contained in:
parent
cd5dd7dd03
commit
75c176ddb6
|
@ -228,6 +228,11 @@ proc symbol*(s: string; E = void): Preserve {.inline.} =
|
|||
## Create a Preserves symbol value.
|
||||
Preserve(kind: pkSymbol, symbol: s)
|
||||
|
||||
proc initRecord*(label: Preserve; arity = 0): Preserve =
|
||||
## Create a Preserves record value.
|
||||
result = Preserve(kind: pkRecord, record: newSeq[Preserve](arity.succ))
|
||||
result.record[arity] = label
|
||||
|
||||
proc initRecord*(label: Preserve; args: varargs[Preserve]): Preserve =
|
||||
## Create a Preserves record value.
|
||||
result = Preserve(kind: pkRecord,
|
||||
|
@ -242,6 +247,10 @@ proc initRecord*(label: string; args: varargs[Preserve, toPreserve]): Preserve =
|
|||
assert($initRecord("foo", 1, 2.0) == "<foo 1 2.0f>")
|
||||
initRecord(symbol(label), args)
|
||||
|
||||
proc initSequence*(len = 0): Preserve =
|
||||
## Create a Preserves sequence value.
|
||||
Preserve(kind: pkSequence, record: newSeq[Preserve](len))
|
||||
|
||||
proc initSet*(): Preserve = Preserve(kind: pkSet)
|
||||
## Create a Preserves set value.
|
||||
|
||||
|
|
Loading…
Reference in New Issue