Compare commits
3 Commits
9c2f58ad39
...
f710419ead
Author | SHA1 | Date |
---|---|---|
|
f710419ead | |
|
ae04bc1019 | |
|
a8030cce4d |
|
@ -1 +1 @@
|
|||
Subproject commit 9f29722a0dc29c6da84cf11a53dc098ab8da4ea8
|
||||
Subproject commit a466930e6e4663b06f173fe692ce46b59138231f
|
|
@ -15,6 +15,11 @@ proc mint*[T](key: openarray[byte]; oid: T): SturdyRef =
|
|||
let oidPr = toPreserve(oid, Ref)
|
||||
SturdyRef(oid: oidPr, sig: hmacSha256(key, encode(oidPr), key.len))
|
||||
|
||||
proc mint*(): SturdyRef {.deprecated.} =
|
||||
## Mint a test capability for the use with the Syndicate server.
|
||||
var key: array[16, byte]
|
||||
mint(key, "syndicate")
|
||||
|
||||
proc attenuate*(r: SturdyRef; caveats: Attenuation): SturdyRef =
|
||||
result = SturdyRef(
|
||||
oid: r.oid,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
|
||||
# SPDX-License-Identifier: Unlicense
|
||||
|
||||
import std/[macros, tables]
|
||||
import std/[macros, tables, typetraits]
|
||||
|
||||
import preserves
|
||||
import ./protocols/dataspacePatterns
|
||||
|
@ -29,13 +29,11 @@ proc `?`*(d: DCompound): Pattern =
|
|||
proc `?`*(s: string): Pattern =
|
||||
?DLit(value: toPreserve(s, Ref))
|
||||
|
||||
proc arity(T: typedesc): int =
|
||||
var t: T # a hack to iterate the fields of a non-existent instance
|
||||
for _ in fields(t): inc result
|
||||
proc drop*(): Pattern = Pattern(orKind: PatternKind.DDiscard)
|
||||
proc grab*(): Pattern = ?DBind(pattern: drop())
|
||||
|
||||
proc `?_`*(): Pattern = Pattern(orKind: PatternKind.DDiscard)
|
||||
|
||||
proc `?*`*(): Pattern = ?DBind(pattern: `?_`())
|
||||
proc `?_`*(): Pattern = drop()
|
||||
proc `?*`*(): Pattern = grab()
|
||||
|
||||
proc `?`*(T: typedesc; bindings: openArray[(int, Pattern)]): Pattern =
|
||||
## Pattern constructor operator.
|
||||
|
@ -44,8 +42,10 @@ proc `?`*(T: typedesc; bindings: openArray[(int, Pattern)]): Pattern =
|
|||
result = ?DCompound(
|
||||
orKind: DCompoundKind.rec,
|
||||
rec: DCompoundRec(
|
||||
ctor: CRec(label: label, arity: T.arity),
|
||||
ctor: CRec(label: label, arity: bindings.len),
|
||||
members: toTable bindings))
|
||||
elif T is ref:
|
||||
`?`(pointerBase(T), bindings)
|
||||
else:
|
||||
{.error: "no custom pragma on " & $T.}
|
||||
|
||||
|
|
Loading…
Reference in New Issue