@@ -9,223 +9,193 @@ type env = Env.t;
99type ident = Ident . t ;
1010type attributes = Typedtree . attributes ;
1111
12- let default_loc = Location . dummy_loc;
1312let default_env = Env . empty;
1413let default_attributes = [] ;
1514let default_allocation_type = Managed ;
1615
17- let or_default_loc = Option . value(~default= default_loc);
1816let or_default_env = Option . value(~default= default_env);
1917let or_default_attributes = Option . value(~default= default_attributes);
2018let or_default_allocation_type =
2119 Option . value(~default= default_allocation_type);
2220
2321module Imm = {
24- let mk = (~loc=? , ~env=?, d) => {
22+ let mk = (~loc, ~env=?, d) => {
2523 imm_desc: d,
26- imm_loc: or_default_loc( loc) ,
24+ imm_loc: loc,
2725 imm_env: or_default_env(env),
2826 imm_analyses: ref ([] ),
2927 };
30- let id = (~loc=? , ~env=?, id) => mk(~loc? , ~env? , ImmId (id));
31- let const = (~loc=? , ~env=?, const) => mk(~loc? , ~env? , ImmConst (const));
32- let trap = (~loc=? , ~env=?, () ) => mk(~loc? , ~env? , ImmTrap );
28+ let id = (~loc, ~env=?, id) => mk(~loc, ~env? , ImmId (id));
29+ let const = (~loc, ~env=?, const) => mk(~loc, ~env? , ImmConst (const));
30+ let trap = (~loc, ~env=?, () ) => mk(~loc, ~env? , ImmTrap );
3331};
3432
3533module Comp = {
36- let mk = (~loc=? , ~attributes=?, ~allocation_type=?, ~env=?, d) => {
34+ let mk = (~loc, ~attributes=?, ~allocation_type=?, ~env=?, d) => {
3735 comp_desc: d,
38- comp_loc: or_default_loc( loc) ,
36+ comp_loc: loc,
3937 comp_env: or_default_env(env),
4038 comp_attributes: or_default_attributes(attributes),
4139 comp_allocation_type: or_default_allocation_type(allocation_type),
4240 comp_analyses: ref ([] ),
4341 };
44- let imm = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, imm) =>
45- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CImmExpr (imm));
46- let number = (~loc=? , ~attributes=?, ~env=?, i) =>
47- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CNumber (i));
48- let int32 = (~loc=? , ~attributes=?, ~env=?, i) =>
49- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CInt32 (i));
50- let int64 = (~loc=? , ~attributes=?, ~env=?, i) =>
51- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CInt64 (i));
52- let uint32 = (~loc=? , ~attributes=?, ~env=?, i) =>
53- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CUint32 (i));
54- let uint64 = (~loc=? , ~attributes=?, ~env=?, i) =>
55- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CUint64 (i));
56- let float32 = (~loc=? , ~attributes=?, ~env=?, i) =>
57- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CFloat32 (i));
58- let float64 = (~loc=? , ~attributes=?, ~env=?, i) =>
59- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CFloat64 (i));
60- let prim0 = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, p0) =>
61- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CPrim0 (p0));
62- let prim1 = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, p1, a) =>
63- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CPrim1 (p1, a));
64- let prim2 = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, p2, a1, a2) =>
65- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CPrim2 (p2, a1, a2));
66- let primn = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, p, args) =>
67- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CPrimN (p, args));
68- let box_assign = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, a1, a2) =>
69- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CBoxAssign (a1, a2));
70- let local_assign = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, a1, a2) =>
71- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CLocalAssign (a1, a2));
72- let assign = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, a1, a2) =>
73- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CAssign (a1, a2));
74- let tuple = (~loc=? , ~attributes=?, ~env=?, elts) =>
75- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CTuple (elts));
76- let array = (~loc=? , ~attributes=?, ~env=?, elts) =>
77- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CArray (elts));
78- let array_get = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, arr, i) =>
79- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CArrayGet (arr, i));
80- let array_set = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, arr, i, a) =>
81- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CArraySet (arr, i, a));
82- let record = (~loc=? , ~attributes=?, ~env=?, type_hash, ttag, elts) =>
42+ let imm = (~loc, ~attributes=?, ~allocation_type, ~env=?, imm) =>
43+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CImmExpr (imm));
44+ let number = (~loc, ~attributes=?, ~env=?, i) =>
45+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CNumber (i));
46+ let int32 = (~loc, ~attributes=?, ~env=?, i) =>
47+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CInt32 (i));
48+ let int64 = (~loc, ~attributes=?, ~env=?, i) =>
49+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CInt64 (i));
50+ let uint32 = (~loc, ~attributes=?, ~env=?, i) =>
51+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CUint32 (i));
52+ let uint64 = (~loc, ~attributes=?, ~env=?, i) =>
53+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CUint64 (i));
54+ let float32 = (~loc, ~attributes=?, ~env=?, i) =>
55+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CFloat32 (i));
56+ let float64 = (~loc, ~attributes=?, ~env=?, i) =>
57+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CFloat64 (i));
58+ let prim0 = (~loc, ~attributes=?, ~allocation_type, ~env=?, p0) =>
59+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CPrim0 (p0));
60+ let prim1 = (~loc, ~attributes=?, ~allocation_type, ~env=?, p1, a) =>
61+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CPrim1 (p1, a));
62+ let prim2 = (~loc, ~attributes=?, ~allocation_type, ~env=?, p2, a1, a2) =>
63+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CPrim2 (p2, a1, a2));
64+ let primn = (~loc, ~attributes=?, ~allocation_type, ~env=?, p, args) =>
65+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CPrimN (p, args));
66+ let box_assign = (~loc, ~attributes=?, ~allocation_type, ~env=?, a1, a2) =>
67+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CBoxAssign (a1, a2));
68+ let local_assign = (~loc, ~attributes=?, ~allocation_type, ~env=?, a1, a2) =>
69+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CLocalAssign (a1, a2));
70+ let assign = (~loc, ~attributes=?, ~allocation_type, ~env=?, a1, a2) =>
71+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CAssign (a1, a2));
72+ let tuple = (~loc, ~attributes=?, ~env=?, elts) =>
73+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CTuple (elts));
74+ let array = (~loc, ~attributes=?, ~env=?, elts) =>
75+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CArray (elts));
76+ let array_get = (~loc, ~attributes=?, ~allocation_type, ~env=?, arr, i) =>
77+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CArrayGet (arr, i));
78+ let array_set = (~loc, ~attributes=?, ~allocation_type, ~env=?, arr, i, a) =>
79+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CArraySet (arr, i, a));
80+ let record = (~loc, ~attributes=?, ~env=?, type_hash, ttag, elts) =>
8381 mk(
84- ~loc? ,
82+ ~loc,
8583 ~attributes? ,
8684 ~allocation_type= Managed ,
8785 ~env? ,
8886 CRecord (type_hash, ttag, elts),
8987 );
90- let adt = (~loc=? , ~attributes=?, ~env=?, type_hash, ttag, vtag, elts) =>
88+ let adt = (~loc, ~attributes=?, ~env=?, type_hash, ttag, vtag, elts) =>
9189 mk(
92- ~loc? ,
90+ ~loc,
9391 ~attributes? ,
9492 ~allocation_type= Managed ,
9593 ~env? ,
9694 CAdt (type_hash, ttag, vtag, elts),
9795 );
98- let tuple_get = (~loc=?, ~attributes=?, ~allocation_type, ~env=?, idx, tup) =>
99- mk(
100- ~loc? ,
101- ~attributes? ,
102- ~allocation_type,
103- ~env? ,
104- CGetTupleItem (idx, tup),
105- );
96+ let tuple_get = (~loc, ~attributes=?, ~allocation_type, ~env=?, idx, tup) =>
97+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CGetTupleItem (idx, tup));
10698 let tuple_set =
107- (~loc=? , ~attributes=?, ~allocation_type, ~env=?, idx, tup, value) =>
99+ (~loc, ~attributes=?, ~allocation_type, ~env=?, idx, tup, value) =>
108100 mk(
109- ~loc? ,
101+ ~loc,
110102 ~attributes? ,
111103 ~allocation_type,
112104 ~env? ,
113105 CSetTupleItem (idx, tup, value),
114106 );
115- let adt_get = (~loc=?, ~attributes=?, ~allocation_type, ~env=?, idx, value) =>
116- mk(
117- ~loc? ,
118- ~attributes? ,
119- ~allocation_type,
120- ~env? ,
121- CGetAdtItem (idx, value),
122- );
123- let adt_get_tag = (~loc=?, ~attributes=?, ~env=?, value) =>
107+ let adt_get = (~loc, ~attributes=?, ~allocation_type, ~env=?, idx, value) =>
108+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CGetAdtItem (idx, value));
109+ let adt_get_tag = (~loc, ~attributes=?, ~env=?, value) =>
124110 mk(
125- ~loc? ,
111+ ~loc,
126112 ~attributes? ,
127113 ~allocation_type= Unmanaged (WasmI32 ),
128114 ~env? ,
129115 CGetAdtTag (value),
130116 );
131117 let record_get =
132- (~loc=? , ~attributes=?, ~allocation_type, ~env=?, idx, record) =>
118+ (~loc, ~attributes=?, ~allocation_type, ~env=?, idx, record) =>
133119 mk(
134- ~loc? ,
120+ ~loc,
135121 ~attributes? ,
136122 ~allocation_type,
137123 ~env? ,
138124 CGetRecordItem (idx, record),
139125 );
140126 let record_set =
141- (~loc=? , ~attributes=?, ~allocation_type, ~env=?, idx, record, arg) =>
127+ (~loc, ~attributes=?, ~allocation_type, ~env=?, idx, record, arg) =>
142128 mk(
143- ~loc? ,
129+ ~loc,
144130 ~attributes? ,
145131 ~allocation_type,
146132 ~env? ,
147133 CSetRecordItem (idx, record, arg),
148134 );
149- let if_ = (~loc=? , ~attributes=?, ~allocation_type, ~env=?, cond, tru, fals) =>
150- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CIf (cond, tru, fals));
151- let for_ = (~loc=? , ~attributes=?, ~env=?, cond, inc, body) =>
135+ let if_ = (~loc, ~attributes=?, ~allocation_type, ~env=?, cond, tru, fals) =>
136+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CIf (cond, tru, fals));
137+ let for_ = (~loc, ~attributes=?, ~env=?, cond, inc, body) =>
152138 mk(
153- ~loc? ,
139+ ~loc,
154140 ~attributes? ,
155141 ~allocation_type= Unmanaged (WasmI32 ),
156142 ~env? ,
157143 CFor (cond, inc, body),
158144 );
159- let continue = (~loc=? , ~attributes=?, ~env=?, () ) =>
145+ let continue = (~loc, ~attributes=?, ~env=?, () ) =>
160146 mk(
161- ~loc? ,
147+ ~loc,
162148 ~attributes? ,
163149 ~allocation_type= Unmanaged (WasmI32 ),
164150 ~env? ,
165151 CContinue ,
166152 );
167- let break = (~loc=? , ~attributes=?, ~env=?, () ) =>
153+ let break = (~loc, ~attributes=?, ~env=?, () ) =>
168154 mk(
169- ~loc? ,
155+ ~loc,
170156 ~attributes? ,
171157 ~allocation_type= Unmanaged (WasmI32 ),
172158 ~env? ,
173159 CBreak ,
174160 );
175- let return = (~loc=? , ~attributes=?, ~env=?, ret) =>
161+ let return = (~loc, ~attributes=?, ~env=?, ret) =>
176162 mk(
177- ~loc? ,
163+ ~loc,
178164 ~attributes? ,
179165 ~allocation_type= Unmanaged (WasmI32 ),
180166 ~env? ,
181167 CReturn (ret),
182168 );
183169 let switch_ =
184- (
185- ~loc=?,
186- ~attributes=?,
187- ~allocation_type,
188- ~env=?,
189- arg,
190- branches,
191- partial,
192- ) =>
170+ (~loc, ~attributes=?, ~allocation_type, ~env=?, arg, branches, partial) =>
193171 mk(
194- ~loc? ,
172+ ~loc,
195173 ~attributes? ,
196174 ~allocation_type,
197175 ~env? ,
198176 CSwitch (arg, branches, partial),
199177 );
200178 let app =
201- (
202- ~loc=?,
203- ~attributes=?,
204- ~allocation_type,
205- ~env=?,
206- ~tail= false ,
207- func,
208- args,
209- ) =>
210- mk(~loc? , ~attributes? , ~allocation_type, ~env? , CApp (func, args, tail));
211- let lambda = (~loc=?, ~attributes=?, ~env=?, ~name=?, args, body) =>
179+ (~loc, ~attributes=?, ~allocation_type, ~env=?, ~tail= false , func, args) =>
180+ mk(~loc, ~attributes? , ~allocation_type, ~env? , CApp (func, args, tail));
181+ let lambda = (~loc, ~attributes=?, ~env=?, ~name=?, args, body) =>
212182 mk(
213- ~loc? ,
183+ ~loc,
214184 ~attributes? ,
215185 ~allocation_type= Managed ,
216186 ~env? ,
217187 CLambda (name, args, body, Uncomputed ),
218188 );
219- let bytes = (~loc=? , ~attributes=?, ~env=?, b) =>
220- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CBytes (b));
221- let string = (~loc=? , ~attributes=?, ~env=?, s) =>
222- mk(~loc? , ~attributes? , ~allocation_type= Managed , ~env? , CString (s));
189+ let bytes = (~loc, ~attributes=?, ~env=?, b) =>
190+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CBytes (b));
191+ let string = (~loc, ~attributes=?, ~env=?, s) =>
192+ mk(~loc, ~attributes? , ~allocation_type= Managed , ~env? , CString (s));
223193};
224194
225195module AExp = {
226- let mk = (~loc=? , ~env=?, ~alloc_type, d) => {
196+ let mk = (~loc, ~env=?, ~alloc_type, d) => {
227197 anf_desc: d,
228- anf_loc: or_default_loc( loc) ,
198+ anf_loc: loc,
229199 anf_env: or_default_env(env),
230200 anf_analyses: ref ([] ),
231201 anf_allocation_type: alloc_type,
@@ -240,7 +210,7 @@ module AExp = {
240210
241211 let let_ =
242212 (
243- ~loc=? ,
213+ ~loc,
244214 ~env=?,
245215 ~global= Nonglobal ,
246216 ~mut_flag= Immutable ,
@@ -249,15 +219,15 @@ module AExp = {
249219 body,
250220 ) =>
251221 mk(
252- ~loc? ,
222+ ~loc,
253223 ~env? ,
254224 ~alloc_type= alloc_type(body),
255225 AELet (global, rec_flag, mut_flag, binds, body),
256226 );
257- let seq = (~loc=? , ~env=?, hd, tl) =>
258- mk(~loc? , ~env? , ~alloc_type= alloc_type(tl), AESeq (hd, tl));
259- let comp = (~loc=? , ~env=?, e) =>
260- mk(~loc? , ~env? , ~alloc_type= e. comp_allocation_type, AEComp (e));
227+ let seq = (~loc, ~env=?, hd, tl) =>
228+ mk(~loc, ~env? , ~alloc_type= alloc_type(tl), AESeq (hd, tl));
229+ let comp = (~loc, ~env=?, e) =>
230+ mk(~loc, ~env? , ~alloc_type= e. comp_allocation_type, AEComp (e));
261231};
262232
263233module IncludeDeclaration = {
0 commit comments