-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdirectory.rho
67 lines (67 loc) · 1.81 KB
/
directory.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
new directory in {
contract directory(capabilities) = {
new mapCh, read, write, grant in {
mapCh!({}) |
capabilities!({"read": bundle+{*read},
"write": bundle+{*write},
"grant": bundle+{*grant}}) |
contract grant(@key, ret) = {
new writekey in {
contract writekey(@value, result) = {
write!(key, value, *result)
} |
ret!(*writekey)
}
} |
contract read(return) = {
for ( map <- mapCh ) {
mapCh!(*map) |
return!(*map)
}
} |
contract read(@key, return) = {
for ( map <- mapCh ) {
mapCh!(*map) |
return!(*map.get(key))
}
} |
contract write(@key,@value, ret) = {
for ( map <- mapCh ) {
if ( value == Nil ) {
mapCh!(*map.delete(key)) |
ret!([key,"deleted"])
} else {
mapCh!(*map.set(key,value)) |
ret!([key,value,"added"])
}
}
}
}
} |
new $stdout, $lookup, $insertArbitrary, uriCh, read, write, ret, ack in {
insertArbitrary!(bundle+{*directory},*uriCh) |
for (uri <- uriCh ) {
stdout!(["#define $Directory",*uri])
} |
directory!(*ret) |
for ( @{"read": read, "write": write, "grant": grant, ..._ } <- ret ) {
stdout!("got capabilities.") |
@write!("hello","world", *ack) |
@write!("this","that", *ack) |
@grant!("hello", *ret) |
for( hello <- ret; _ <- ack; _ <- ack ) {
stdout!("got grant.") |
@read!(*ret) |
for ( amap <- ret ) {
stdout!(*amap) |
@write!("this",Nil, *ack) | /* delete a key */
hello!("galaxy", *ret) |
for ( _ <- ack; _ <- ret ) {
@read!("hello",*stdout) |
@read!(*stdout)
}
}
}
}
}
}