-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathEcho.rho
66 lines (64 loc) · 1.79 KB
/
Echo.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
new
Echo
,stdout(`rho:io:stdout`)
in
{ stdout!("Echo class creation")
| contract Echo(message, caps) = {
new
raw
,more
in
{ caps!(bundle+{*raw}, bundle+{*more})
| contract raw(return) =
{ stdout!("raw method: " ++ *message)
| return!(*message)
}
| contract more(return) =
{ stdout!("more method: more " ++ *message)
| return!("more " ++ *message)
}
}
}
|
new
caps
,ret_raw
,ret_more
,lookup_ret_raw
,lookup_ret_more
,lookupCaps
,insertArbitrary(`rho:registry:insertArbitrary`)
,uriCh
,lookup(`rho:registry:lookup`)
,lookupCh
in
{ // print out the unforgeable for the class
stdout!({"Echo unforgeable": bundle+{*Echo}})
// create uri for the class and print it
| insertArbitrary!(bundle+{*Echo}, *uriCh)
| for (URI_Echo <- uriCh)
{ stdout!(["#define $Echo", *URI_Echo])
// lookup the uri for the class and test it
| lookup!(*URI_Echo, *lookupCh)
| for (lookup_Echo <- lookupCh)
{ stdout!({"lookup unforgeable": *lookup_Echo})
| lookup_Echo!("lookup", *lookupCaps)
| for (lookup_rawCap, lookup_moreCap <- lookupCaps)
{ lookup_rawCap!(*lookup_ret_raw)
| stdout!({"lookup raw cap": *lookup_rawCap, "lookup raw return": *lookup_ret_raw})
| lookup_moreCap!(*lookup_ret_more)
| stdout!({"lookup more cap": *lookup_moreCap, "lookup more return": *lookup_ret_more})
}
}
}
// create an instance and print the capabilities
// If possible excercise the capabilities
| Echo!("test", *caps)
| for (rawCap, moreCap <- caps)
{ rawCap!(*ret_raw)
| stdout!({"test raw cap": *rawCap, "test raw return": *ret_raw})
| moreCap!(*ret_more)
| stdout!({"test more cap": *moreCap, "test more return": *ret_more})
}
}
}