@@ -11,14 +11,15 @@ use std::io;
11
11
use std:: io:: Write ;
12
12
13
13
pub struct Parameter {
14
+ // Don't box here, it's just to reference those fields
14
15
declare_local : DeclareLocal ,
15
16
}
16
17
17
18
impl Parameter {
18
- pub fn new ( name : Name , typ : Type ) -> Self {
19
+ pub fn new ( name : Name , typ : Type ) -> Box < Self > {
19
20
// todo: should this store declare local AND name/type?
20
- let declare_local = DeclareLocal :: new ( name. clone ( ) , typ. clone ( ) ) ;
21
- Parameter { declare_local }
21
+ let declare_local = DeclareLocal :: new_unboxed ( name. clone ( ) , typ. clone ( ) ) ;
22
+ Box :: new ( Parameter { declare_local } )
22
23
}
23
24
24
25
pub fn name ( & self ) -> & Name {
@@ -49,8 +50,8 @@ pub struct Output {
49
50
}
50
51
51
52
impl Output {
52
- pub fn new ( typ : Type ) -> Self {
53
- Output { typ }
53
+ pub fn new ( typ : Type ) -> Box < Self > {
54
+ Box :: new ( Output { typ } )
54
55
}
55
56
}
56
57
@@ -66,12 +67,12 @@ impl Wasm for Output {
66
67
67
68
pub struct FunctionSignature {
68
69
name : Name ,
69
- parameters : Vec < Parameter > ,
70
- results : Vec < Output > ,
70
+ parameters : Vec < Box < Parameter > > ,
71
+ results : Vec < Box < Output > > ,
71
72
}
72
73
73
74
impl FunctionSignature {
74
- pub fn new ( name : Name , parameters : Vec < Parameter > , results : Vec < Output > ) -> Self {
75
+ pub fn new ( name : Name , parameters : Vec < Box < Parameter > > , results : Vec < Box < Output > > ) -> Self {
75
76
assert ! ( results. len( ) <= 1 ) ; //
76
77
FunctionSignature {
77
78
name,
@@ -114,18 +115,18 @@ impl Function {
114
115
// This uses group, so it has a label, but this isn't final... It might be useless.
115
116
pub fn new (
116
117
name : Name ,
117
- parameters : Vec < Parameter > ,
118
- results : Vec < Output > ,
118
+ parameters : Vec < Box < Parameter > > ,
119
+ results : Vec < Box < Output > > ,
119
120
statements_gen : & Fn ( Label ) -> Vec < Box < Statement > > ,
120
- ) -> Self {
121
- Function {
121
+ ) -> Box < Self > {
122
+ Box :: new ( Function {
122
123
signature : FunctionSignature {
123
124
name : name. clone ( ) ,
124
125
parameters,
125
126
results,
126
127
} ,
127
128
body : Group :: new ( Label :: internal ( name) , statements_gen) ,
128
- }
129
+ } )
129
130
}
130
131
}
131
132
0 commit comments