@@ -74,7 +74,8 @@ let declare_variable ?comment ?ident_info ~kind (v:Ident.t) : t=
74
74
ident_info ;};
75
75
comment}
76
76
77
- let define ?comment ?ident_info ~kind (v :Ident.t ) exp : t =
77
+ let define_variable ?comment ?ident_info
78
+ ~kind (v :Ident.t ) exp : t =
78
79
let property : J.property = kind in
79
80
let ident_info : J.ident_info =
80
81
match ident_info with
@@ -85,6 +86,14 @@ let define ?comment ?ident_info ~kind (v:Ident.t) exp : t=
85
86
ident_info ;};
86
87
comment}
87
88
89
+ let alias_variable ?comment ~exp (v :Ident.t ) : t =
90
+ {statement_desc =
91
+ Variable {
92
+ ident = v; value = Some exp; property = Alias ;
93
+ ident_info = {used_stats = NA } };
94
+ comment}
95
+
96
+
88
97
let int_switch ?comment ?declaration ?default (e : J.expression ) clauses : t =
89
98
match e.expression_desc with
90
99
| Number (Int {i; _} ) ->
@@ -105,7 +114,7 @@ let int_switch ?comment ?declaration ?default (e : J.expression) clauses : t
105
114
[ {statement_desc = Exp {expression_desc = Bin (Eq , {expression_desc = Var (Id id) ; _}, e0); _}; _}]
106
115
when Ident. same did id
107
116
->
108
- define ?comment ~kind id e0
117
+ define_variable ?comment ~kind id e0
109
118
| Some (kind,did), _
110
119
->
111
120
block (declare_variable ?comment ~kind did :: continuation)
@@ -142,7 +151,7 @@ let string_switch ?comment ?declaration ?default (e : J.expression) clauses :
142
151
[ {statement_desc = Exp {expression_desc = Bin (Eq , {expression_desc = Var (Id id); _}, e0);_} ; _}]
143
152
when Ident. same did id
144
153
->
145
- define ?comment ~kind id e0
154
+ define_variable ?comment ~kind id e0
146
155
| Some (kind,did), _
147
156
->
148
157
block @@ declare_variable ?comment ~kind did :: continuation
@@ -190,7 +199,7 @@ let rec if_ ?comment ?declaration ?else_ (e : J.expression) (then_ : J.block)
190
199
begin match declaration with
191
200
| Some (kind ,did ) when Ident. same did id0 ->
192
201
declared := true ;
193
- define ~kind id0 (E. econd e a0 b0) :: acc
202
+ define_variable ~kind id0 (E. econd e a0 b0) :: acc
194
203
(* To hit this branch, we also need [declaration] passed down
195
204
TODO: check how we compile [Lifthenelse]
196
205
*)
@@ -278,12 +287,7 @@ let rec if_ ?comment ?declaration ?else_ (e : J.expression) (then_ : J.block)
278
287
279
288
280
289
281
- let alias_variable ?comment ?exp (v :Ident.t ) : t =
282
- {statement_desc =
283
- Variable {
284
- ident = v; value = exp; property = Alias ;
285
- ident_info = {used_stats = NA } };
286
- comment}
290
+
287
291
288
292
let assign ?comment id e : t =
289
293
{
@@ -354,7 +358,7 @@ let continue_stmt ?comment ?(label="") unit : t =
354
358
comment;
355
359
}
356
360
357
- let debugger : t =
358
- { statement_desc = J. Debugger ;
361
+ let debugger_block : t list =
362
+ [ { statement_desc = J. Debugger ;
359
363
comment = None
360
- }
364
+ }]
0 commit comments