Skip to content

Commit 6ec4d78

Browse files
committed
emit respects casing option
1 parent aacf9dd commit 6ec4d78

6 files changed

Lines changed: 41 additions & 13 deletions

File tree

src/mir/client/iter.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl Client {
4242
b.stmt(format!("return {next}, {captured}, 1"));
4343
});
4444

45-
self.export(b, "iter", &iter);
45+
self.export(b, &self.name("iter"), &iter);
4646
}
4747

4848
fn event_recv_iter_1data(&self, b: &mut Builder, event: &Event) {
@@ -54,7 +54,7 @@ impl Client {
5454
b.stmt(format!("return {captured}"));
5555
});
5656

57-
self.export(b, "iter", &iter);
57+
self.export(b, &self.name("iter"), &iter);
5858
}
5959

6060
fn event_recv_iter_0data(&self, b: &mut Builder, event: &Event) {
@@ -77,7 +77,7 @@ impl Client {
7777
b.stmt(format!("return {next}, {captured}, 0"));
7878
});
7979

80-
self.export(b, "iter", &iter);
80+
self.export(b, &self.name("iter"), &iter);
8181
}
8282

8383
fn event_recv_queue(&self, b: &mut Builder, event: &Event) -> InitVar {

src/mir/client/mod.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod send;
1616
#[derive(Clone)]
1717
pub struct Client {
1818
pub location: String,
19+
pub options: Rc<Options>,
1920

2021
pub ser: Ser,
2122
pub des: Des,
@@ -24,6 +25,7 @@ pub struct Client {
2425
impl Default for Client {
2526
fn default() -> Self {
2627
let location = "result".to_string();
28+
let options = Rc::new(Options::default());
2729

2830
let ser = Ser {
2931
options: Rc::new(Options::default()),
@@ -36,7 +38,12 @@ impl Default for Client {
3638
check: false,
3739
};
3840

39-
Client { location, ser, des }
41+
Client {
42+
location,
43+
options,
44+
ser,
45+
des,
46+
}
4047
}
4148
}
4249

@@ -63,20 +70,27 @@ impl Client {
6370
}
6471

6572
fn child(&self, options: &Rc<Options>, name: &str) -> Self {
73+
let options = Rc::clone(options);
74+
6675
let mut ser = self.ser.clone();
67-
ser.options = Rc::clone(options);
76+
ser.options = Rc::clone(&options);
6877

6978
let mut des = self.des.clone();
70-
des.options = Rc::clone(options);
79+
des.options = Rc::clone(&options);
7180

7281
Client {
7382
location: self.location.clone() + "." + name,
83+
options,
7484

7585
ser,
7686
des,
7787
}
7888
}
7989

90+
fn name(&self, words: &'static str) -> String {
91+
self.options.casing().fmt(words)
92+
}
93+
8094
fn export(&self, b: &mut Builder, name: &str, expr: impl Into<Expr>) {
8195
let expr = expr.into();
8296
let location = &self.location;

src/mir/client/send.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Client {
3636
b.stmt(format!("{remote}:FireServer(out)"));
3737
});
3838

39-
self.export(b, "send", &send);
39+
self.export(b, &self.name("send"), &send);
4040
}
4141

4242
pub fn event_send_0data(&self, b: &mut Builder, event: &Event) {
@@ -46,6 +46,6 @@ impl Client {
4646
b.stmt(format!("{remote}:FireServer()"));
4747
});
4848

49-
self.export(b, "send", &send);
49+
self.export(b, &self.name("send"), &send);
5050
}
5151
}

src/mir/server/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ impl Server {
4141
b.stmt(format!("return {next}, {captured}, 1"));
4242
});
4343

44-
self.export(b, "iter", &iter);
44+
self.export(b, &self.name("iter"), &iter);
4545
}
4646

4747
fn event_recv_iter_0data(&self, b: &mut Builder, event: &Event) {
@@ -53,7 +53,7 @@ impl Server {
5353
b.stmt(format!("return {captured}"));
5454
});
5555

56-
self.export(b, "iter", &iter);
56+
self.export(b, &self.name("iter"), &iter);
5757
}
5858

5959
fn event_recv_queue_ndata(&self, b: &mut Builder, event: &Event) -> InitVar {

src/mir/server/mod.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mod send;
1616
#[derive(Clone)]
1717
pub struct Server {
1818
pub location: String,
19+
pub options: Rc<Options>,
1920

2021
pub ser: Ser,
2122
pub des: Des,
@@ -24,6 +25,7 @@ pub struct Server {
2425
impl Default for Server {
2526
fn default() -> Self {
2627
let location = "result".to_string();
28+
let options = Rc::new(Options::default());
2729

2830
let ser = Ser {
2931
options: Rc::new(Options::default()),
@@ -36,7 +38,12 @@ impl Default for Server {
3638
check: true,
3739
};
3840

39-
Server { location, ser, des }
41+
Server {
42+
location,
43+
options,
44+
ser,
45+
des,
46+
}
4047
}
4148
}
4249

@@ -63,6 +70,8 @@ impl Server {
6370
}
6471

6572
fn child(&self, options: &Rc<Options>, name: &str) -> Self {
73+
let options = Rc::clone(options);
74+
6675
let mut ser = self.ser.clone();
6776
ser.options = Rc::clone(&options);
6877

@@ -71,11 +80,16 @@ impl Server {
7180

7281
Server {
7382
location: self.location.clone() + "." + name,
83+
options,
7484
ser,
7585
des,
7686
}
7787
}
7888

89+
fn name(&self, words: &'static str) -> String {
90+
self.options.casing().fmt(words)
91+
}
92+
7993
fn export(&self, b: &mut Builder, name: &str, expr: impl Into<Expr>) {
8094
let expr = expr.into();
8195
let location = &self.location;

src/mir/server/send.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl Server {
3737
b.stmt(format!("{remote}:FireClient({player}, out)"));
3838
});
3939

40-
self.export(b, "send", &send);
40+
self.export(b, &self.name("send"), &send);
4141
}
4242

4343
fn event_send_0data(&self, b: &mut Builder, event: &Event) {
@@ -47,6 +47,6 @@ impl Server {
4747
b.stmt(format!("{remote}:FireClient({player})"));
4848
});
4949

50-
self.export(b, "send", &send);
50+
self.export(b, &self.name("send"), &send);
5151
}
5252
}

0 commit comments

Comments
 (0)