Skip to content

Commit 9194f5b

Browse files
committed
---
yaml --- r: 23039 b: refs/heads/master c: 672bfa5 h: refs/heads/master i: 23037: 6215ec9 23035: 5212a62 23031: d96ba14 23023: 5fabe1a 23007: 16ffff0 22975: 1a5496a 22911: e663af9 22783: 26c4b42 22527: 8f84e2e v: v3
1 parent 12dba35 commit 9194f5b

File tree

2 files changed

+113
-1
lines changed

2 files changed

+113
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 8d1922d4c80335d7c850e5856ae0ec549b8a0481
2+
refs/heads/master: 672bfa5773913ce99524703e943729e3e50953b8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
// xfail-test
2+
3+
// Protocols
4+
proto! foo {
5+
foo:recv {
6+
do_foo -> foo
7+
}
8+
}
9+
10+
proto! bar {
11+
bar:recv {
12+
do_bar(int) -> barbar,
13+
do_baz(bool) -> bazbar,
14+
}
15+
16+
barbar:send {
17+
rebarbar -> bar,
18+
}
19+
20+
bazbar:send {
21+
rebazbar -> bar
22+
}
23+
}
24+
25+
26+
// select!
27+
macro_rules! select_if {
28+
{
29+
$index:expr,
30+
$count:expr,
31+
$port:path => [
32+
$($message:path$(($($x: ident),+))dont_type_this*
33+
-> $next:ident $e:expr),+
34+
],
35+
$( $ports:path => [
36+
$($messages:path$(($($xs: ident),+))dont_type_this*
37+
-> $nexts:ident $es:expr),+
38+
], )*
39+
} => {
40+
log_syntax!{select_if1};
41+
if $index == $count {
42+
alt move pipes::try_recv($port) {
43+
$(some($message($($($x,)+)* next)) => {
44+
// FIXME (#2329) we really want move out of enum here.
45+
let $next = unsafe { let x <- *ptr::addr_of(next); x };
46+
$e
47+
})+
48+
_ => fail
49+
}
50+
} else {
51+
select_if!{
52+
$index,
53+
$count + 1,
54+
$( $ports => [
55+
$($messages$(($($xs),+))dont_type_this*
56+
-> $nexts $es),+
57+
], )*
58+
}
59+
}
60+
};
61+
62+
{
63+
$index:expr,
64+
$count:expr,
65+
} => {
66+
log_syntax!{select_if2};
67+
fail
68+
}
69+
}
70+
71+
macro_rules! select {
72+
{
73+
$( $port:path => {
74+
$($message:path$(($($x: ident),+))dont_type_this*
75+
-> $next:ident $e:expr),+
76+
} )+
77+
} => {
78+
let index = pipes::selecti([$(($port).header()),+]/_);
79+
log_syntax!{select};
80+
log_syntax!{
81+
select_if!{index, 0, $( $port => [
82+
$($message$(($($x),+))dont_type_this* -> $next $e),+
83+
], )+}
84+
};
85+
select_if!{index, 0, $( $port => [
86+
$($message$(($($x),+))dont_type_this* -> $next $e),+
87+
], )+}
88+
}
89+
}
90+
91+
// Code
92+
fn test(+foo: foo::client::foo, +bar: bar::client::bar) {
93+
select! {
94+
foo => {
95+
foo::do_foo -> _next {
96+
}
97+
}
98+
99+
bar => {
100+
bar::do_bar(x) -> _next {
101+
//debug!("%?", x)
102+
},
103+
104+
do_baz(b) -> _next {
105+
//if b { debug!("true") } else { debug!("false") }
106+
}
107+
}
108+
}
109+
}
110+
111+
fn main() {
112+
}

0 commit comments

Comments
 (0)