-
Notifications
You must be signed in to change notification settings - Fork 14
/
ReplaceableCapability.rho
48 lines (48 loc) · 1.28 KB
/
ReplaceableCapability.rho
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
new return(`rho:io:stdout`), // return(`rho:rchain:deployId`),
insertArbitrary(`rho:registry:insertArbitrary`), ReplaceableCapability in {
new uriCh, valueCh in {
insertArbitrary!(bundle+{*ReplaceableCapability}, *uriCh) |
for (@uri <- uriCh) {
return!(("URI", uri))
}
} |
contract ReplaceableCapability(capability, ret) = {
new capCh, invoke, replace, revoked in {
capCh!(*capability) |
contract revoked(return) = {
for ( curr <<- capCh ) {
return!(cur == Nil)
}
}} |
contract invoke(arg) = {
for ( curr <<- capCh ) {
curr!(*arg)
}}|
contract invoke(arg1, arg2) = {
for ( curr <<- capCh ) {
curr!(*arg1, *arg2)
}}|
contract invoke(arg1, arg2, arg3) = {
for ( curr <<- capCh ) {
curr!(*arg1, *arg2, *arg3)
}}|
contract replace(newcapability, ret) = {
for ( curr <- capCh ) {
capCh!(*newcapability) |
ret!(*invoke)
}}|
ret!(*invoke,*replace)
}} |
new stdout(`rho:io:stdout`), myChan, ret, kickme in {
ReplaceableCapability!(*myChan,*ret) |
for ( thiscap, thisrep <- ret ) {
thiscap!("hello world.") |
for ( x <- myChan) {
stdout!(["x", *x]) |
thisrep!(*stdout, *kickme) |
for ( k <- kickme) {
stdout!(["k", *k]) |
thiscap!("goodbye world!")
}
}
}}}