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)
|
let oidPr = toPreserve(oid, Ref)
|
||||||
SturdyRef(oid: oidPr, sig: hmacSha256(key, encode(oidPr), key.len))
|
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 =
|
proc attenuate*(r: SturdyRef; caveats: Attenuation): SturdyRef =
|
||||||
result = SturdyRef(
|
result = SturdyRef(
|
||||||
oid: r.oid,
|
oid: r.oid,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
|
# SPDX-FileCopyrightText: ☭ 2021 Emery Hemingway
|
||||||
# SPDX-License-Identifier: Unlicense
|
# SPDX-License-Identifier: Unlicense
|
||||||
|
|
||||||
import std/[macros, tables]
|
import std/[macros, tables, typetraits]
|
||||||
|
|
||||||
import preserves
|
import preserves
|
||||||
import ./protocols/dataspacePatterns
|
import ./protocols/dataspacePatterns
|
||||||
|
@ -29,13 +29,11 @@ proc `?`*(d: DCompound): Pattern =
|
||||||
proc `?`*(s: string): Pattern =
|
proc `?`*(s: string): Pattern =
|
||||||
?DLit(value: toPreserve(s, Ref))
|
?DLit(value: toPreserve(s, Ref))
|
||||||
|
|
||||||
proc arity(T: typedesc): int =
|
proc drop*(): Pattern = Pattern(orKind: PatternKind.DDiscard)
|
||||||
var t: T # a hack to iterate the fields of a non-existent instance
|
proc grab*(): Pattern = ?DBind(pattern: drop())
|
||||||
for _ in fields(t): inc result
|
|
||||||
|
|
||||||
proc `?_`*(): Pattern = Pattern(orKind: PatternKind.DDiscard)
|
proc `?_`*(): Pattern = drop()
|
||||||
|
proc `?*`*(): Pattern = grab()
|
||||||
proc `?*`*(): Pattern = ?DBind(pattern: `?_`())
|
|
||||||
|
|
||||||
proc `?`*(T: typedesc; bindings: openArray[(int, Pattern)]): Pattern =
|
proc `?`*(T: typedesc; bindings: openArray[(int, Pattern)]): Pattern =
|
||||||
## Pattern constructor operator.
|
## Pattern constructor operator.
|
||||||
|
@ -44,8 +42,10 @@ proc `?`*(T: typedesc; bindings: openArray[(int, Pattern)]): Pattern =
|
||||||
result = ?DCompound(
|
result = ?DCompound(
|
||||||
orKind: DCompoundKind.rec,
|
orKind: DCompoundKind.rec,
|
||||||
rec: DCompoundRec(
|
rec: DCompoundRec(
|
||||||
ctor: CRec(label: label, arity: T.arity),
|
ctor: CRec(label: label, arity: bindings.len),
|
||||||
members: toTable bindings))
|
members: toTable bindings))
|
||||||
|
elif T is ref:
|
||||||
|
`?`(pointerBase(T), bindings)
|
||||||
else:
|
else:
|
||||||
{.error: "no custom pragma on " & $T.}
|
{.error: "no custom pragma on " & $T.}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue