package pfff

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Source file map_ast.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
(* Yoann Padioleau
 *
 * Copyright (C) 2019 r2c
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1 as published by the Free Software Foundation, with the
 * special exception on linking described in file license.txt.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the file
 * license.txt for more details.
 *)
open Ocaml

open Ast_generic

(*****************************************************************************)
(* Prelude *)
(*****************************************************************************)

(* hooks *)

type visitor_in = {
(*
  kexpr: (expr  -> expr) * visitor_out -> expr  -> expr;
  kstmt: (stmt -> stmt) * visitor_out -> stmt -> stmt;
*)
  kinfo: (tok -> tok) * visitor_out -> tok -> tok;
}

and visitor_out = {
  vitem: item -> item;
  vprogram: program -> program;
  vexpr: expr -> expr;
  vany: any -> any;
}

let default_visitor =
  { 
(*
    kexpr   = (fun (k,_) x -> k x);
    kstmt = (fun (k,_) x -> k x);
*)
    kinfo = (fun (k,_) x -> k x);
  }

let (mk_visitor: visitor_in -> visitor_out) = fun vin ->
(* start of auto generation *)

(* generated by ocamltarzan with: camlp4o -o /tmp/yyy.ml -I pa/ pa_type_conv.cmo pa_map.cmo  pr_o.cmo /tmp/xxx.ml  *)

let rec map_tok v = 
  (* old: Parse_info.map_info v *)
  let k x =
    match x with
    { Parse_info.token = v_pinfo;
      transfo = v_transfo;
    } ->
    let v_pinfo =
      (* todo? map_pinfo v_pinfo *)
    v_pinfo
    in
    (* not recurse in transfo ? *)
    { Parse_info.token = v_pinfo;   (* generete a fresh field *)
      transfo = v_transfo;
    }
  in
  vin.kinfo (k, all_functions) v

and map_wrap:'a. ('a -> 'a) -> 'a wrap -> 'a wrap = fun _of_a (v1, v2) ->
  let v1 = _of_a v1 and v2 = map_tok v2 in (v1, v2)
  
and map_ident v = map_wrap map_of_string v
  
and map_dotted_name v = map_of_list map_ident v
  
and map_qualified_name v = map_dotted_name v
  
and map_module_name =
  function
  | FileName v1 -> let v1 = map_wrap map_of_string v1 in FileName ((v1))
  | DottedName v1 -> let v1 = map_dotted_name v1 in DottedName ((v1))
  
and map_resolved_name =
  function
  | Local -> Local
  | Param -> Param
  | Global v1 -> let v1 = map_qualified_name v1 in Global ((v1))
  | NotResolved -> NotResolved
  | Macro -> Macro
  | EnumConstant -> EnumConstant
  | ImportedModule v1 -> let v1 = map_qualified_name v1 in ImportedModule((v1))

and map_name (v1, v2) =
  let v1 = map_ident v1 and v2 = map_id_info v2 in (v1, v2)

and map_xml v1 = map_of_list map_any v1  
and map_expr =
  function
  | L v1 -> let v1 = map_literal v1 in L ((v1))
  | Container ((v1, v2)) ->
      let v1 = map_container_operator v1
      and v2 = map_of_list map_expr v2
      in Container ((v1, v2))
  | Tuple v1 -> let v1 = map_of_list map_expr v1 in Tuple ((v1))
  | Record v1 -> let v1 = map_of_list map_field v1 in Record ((v1))
  | Constructor ((v1, v2)) ->
      let v1 = map_name v1
      and v2 = map_of_list map_expr v2
      in Constructor ((v1, v2))
  | Lambda ((v1)) ->
      let v1 = map_function_definition v1 in Lambda ((v1))
  | AnonClass ((v1)) ->
      let v1 = map_class_definition v1 in AnonClass ((v1))
  | Nop -> Nop
  | Xml v1 -> let v1 = map_xml v1 in Xml v1
  | Name ((v1)) ->
      let v1 = map_name v1 in Name ((v1))
  | IdSpecial v1 -> let v1 = map_wrap map_special v1 in IdSpecial ((v1))
  | Call ((v1, v2)) ->
      let v1 = map_expr v1 and v2 = map_arguments v2 in Call ((v1, v2))
  | Assign ((v1, v2)) ->
      let v1 = map_expr v1 and v2 = map_expr v2 in Assign ((v1, v2))
  | AssignOp ((v1, v2, v3)) ->
      let v1 = map_expr v1
      and v2 = map_wrap map_arithmetic_operator v2
      and v3 = map_expr v3
      in AssignOp ((v1, v2, v3))
  | LetPattern ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_expr v2 in LetPattern ((v1, v2))
  | ObjAccess ((v1, v2)) ->
      let v1 = map_expr v1 and v2 = map_ident v2 in ObjAccess ((v1, v2))
  | ArrayAccess ((v1, v2)) ->
      let v1 = map_expr v1 and v2 = map_expr v2 in ArrayAccess ((v1, v2))
  | Conditional ((v1, v2, v3)) ->
      let v1 = map_expr v1
      and v2 = map_expr v2
      and v3 = map_expr v3
      in Conditional ((v1, v2, v3))
  | MatchPattern ((v1, v2)) ->
      let v1 = map_expr v1
      and v2 = map_of_list map_action v2
      in MatchPattern ((v1, v2))
  | Yield v1 -> let v1 = map_expr v1 in Yield ((v1))
  | Await v1 -> let v1 = map_expr v1 in Await ((v1))
  | Cast ((v1, v2)) ->
      let v1 = map_type_ v1 and v2 = map_expr v2 in Cast ((v1, v2))
  | Seq v1 -> let v1 = map_of_list map_expr v1 in Seq ((v1))
  | Ref v1 -> let v1 = map_expr v1 in Ref ((v1))
  | DeRef v1 -> let v1 = map_expr v1 in DeRef ((v1))
  | Ellipses v1 -> let v1 = map_tok v1 in Ellipses ((v1))
  | OtherExpr ((v1, v2)) ->
      let v1 = map_other_expr_operator v1
      and v2 = map_of_list map_any v2
      in OtherExpr ((v1, v2))

and map_literal =
  function
  | Unit v1 -> let v1 = map_tok v1 in Unit ((v1))
  | Bool v1 -> let v1 = map_wrap map_of_bool v1 in Bool ((v1))
  | Int v1 -> let v1 = map_wrap map_of_string v1 in Int ((v1))
  | Float v1 -> let v1 = map_wrap map_of_string v1 in Float ((v1))
  | Char v1 -> let v1 = map_wrap map_of_string v1 in Char ((v1))
  | String v1 -> let v1 = map_wrap map_of_string v1 in String ((v1))
  | Regexp v1 -> let v1 = map_wrap map_of_string v1 in Regexp ((v1))
  | Null v1 -> let v1 = map_tok v1 in Null ((v1))
  | Undefined v1 -> let v1 = map_tok v1 in Undefined ((v1))

and map_container_operator =
  function | Array -> Array | List -> List | Set -> Set | Dict -> Dict

and
  map_id_info {
                id_qualifier = v_id_qualifier;
                id_typeargs = v_id_typeargs;
                id_resolved = v_id_resolved;
                id_type = v_id_type
              } =
  let v_id_type = map_of_ref (map_of_option map_type_) v_id_type in
  let v_id_resolved = map_of_ref map_resolved_name v_id_resolved in
  let v_id_typeargs = map_of_option map_type_arguments v_id_typeargs in
  let v_id_qualifier = map_of_option map_dotted_name v_id_qualifier
  in 
  { id_qualifier = v_id_qualifier; id_typeargs = v_id_typeargs;
    id_resolved = v_id_resolved; id_type = v_id_type }


and map_special =
  function
  | This -> This
  | Super -> Super
  | Self -> Self
  | Parent -> Parent
  | Eval -> Eval
  | Typeof -> Typeof
  | Instanceof -> Instanceof
  | Sizeof -> Sizeof
  | New -> New
  | Concat -> Concat
  | Spread -> Spread
  | ArithOp v1 -> let v1 = map_arithmetic_operator v1 in ArithOp ((v1))
  | IncrDecr ((v1, v2)) ->
      let v1 = map_of_incdec v1 and v2 = map_of_prepost v2 in IncrDecr ((v1, v2))

and map_of_incdec x = x
and map_of_prepost x = x
and map_arithmetic_operator x = x

and map_arguments v = map_of_list map_argument v

and map_argument =
  function
  | Arg v1 -> let v1 = map_expr v1 in Arg ((v1))
  | ArgType v1 -> let v1 = map_type_ v1 in ArgType ((v1))
  | ArgKwd ((v1, v2)) ->
      let v1 = map_ident v1 and v2 = map_expr v2 in ArgKwd ((v1, v2))
  | ArgOther ((v1, v2)) ->
      let v1 = map_other_argument_operator v1
      and v2 = map_of_list map_any v2
      in ArgOther ((v1, v2))

and map_other_argument_operator x = x

and map_action (v1, v2) =
  let v1 = map_pattern v1 and v2 = map_expr v2 in (v1, v2)

and map_other_expr_operator x = x

and map_type_ =
  function
  | TyBuiltin v1 -> let v1 = map_wrap map_of_string v1 in TyBuiltin ((v1))
  | TyFun ((v1, v2)) ->
      let v1 = map_of_list map_type_ v1
      and v2 = map_type_ v2
      in TyFun ((v1, v2))
  | TyApply ((v1, v2)) ->
      let v1 = map_name v1
      and v2 = map_type_arguments v2
      in TyApply ((v1, v2))
  | TyVar v1 -> let v1 = map_ident v1 in TyVar ((v1))
  | TyArray ((v1, v2)) ->
      let v1 = map_of_option map_expr v1
      and v2 = map_type_ v2
      in TyArray ((v1, v2))
  | TyPointer v1 -> let v1 = map_type_ v1 in TyPointer ((v1))
  | TyTuple v1 -> let v1 = map_of_list map_type_ v1 in TyTuple ((v1))
  | TyQuestion v1 -> let v1 = map_type_ v1 in TyQuestion ((v1))
  | OtherType ((v1, v2)) ->
      let v1 = map_other_type_operator v1
      and v2 = map_of_list map_any v2
      in OtherType ((v1, v2))

and map_type_arguments v = map_of_list map_type_argument v

and map_type_argument =
  function
  | TypeArg v1 -> let v1 = map_type_ v1 in TypeArg ((v1))
  | OtherTypeArg ((v1, v2)) ->
      let v1 = map_other_type_argument_operator v1
      and v2 = map_of_list map_any v2
      in OtherTypeArg ((v1, v2))

and map_other_type_argument_operator =
  function | OTA_Question -> OTA_Question

and map_other_type_operator =
  function
  | OT_Expr -> OT_Expr
  | OT_Arg -> OT_Arg
  | OT_StructName -> OT_StructName
  | OT_UnionName -> OT_UnionName
  | OT_EnumName -> OT_EnumName
  | OT_Shape -> OT_Shape
  | OT_Variadic -> OT_Variadic

and map_attribute =
  function
    | Recursive -> Recursive
    | MutuallyRecursive -> MutuallyRecursive
  | Static -> Static
  | Volatile -> Volatile
  | Extern -> Extern
  | Public -> Public
  | Private -> Private
  | Protected -> Protected
  | Abstract -> Abstract
  | Final -> Final
  | Var -> Var
  | Let -> Let
  | Const -> Const
  | Mutable -> Mutable
  | Generator -> Generator
  | Async -> Async
  | Ctor -> Ctor
  | Dtor -> Dtor
  | Getter -> Getter
  | Setter -> Setter
  | Variadic -> Variadic
  | NamedAttr ((v1, v2)) ->
      let v1 = map_ident v1
      and v2 = map_of_list map_any v2
      in NamedAttr ((v1, v2))
  | OtherAttribute ((v1, v2)) ->
      let v1 = map_other_attribute_operator v1
      and v2 = map_of_list map_any v2
      in OtherAttribute ((v1, v2))

and map_other_attribute_operator x  = x

and map_stmt =
  function
  | ExprStmt v1 -> let v1 = map_expr v1 in ExprStmt ((v1))
  | DefStmt v1 -> let v1 = map_definition v1 in DefStmt ((v1))
  | DirectiveStmt v1 -> let v1 = map_directive v1 in DirectiveStmt ((v1))
  | Block v1 -> let v1 = map_of_list map_stmt v1 in Block ((v1))
  | If ((v1, v2, v3)) ->
      let v1 = map_expr v1
      and v2 = map_stmt v2
      and v3 = map_stmt v3
      in If ((v1, v2, v3))
  | While ((v1, v2)) ->
      let v1 = map_expr v1 and v2 = map_stmt v2 in While ((v1, v2))
  | DoWhile ((v1, v2)) ->
      let v1 = map_stmt v1 and v2 = map_expr v2 in DoWhile ((v1, v2))
  | For ((v1, v2)) ->
      let v1 = map_for_header v1 and v2 = map_stmt v2 in For ((v1, v2))
  | Switch ((v1, v2)) ->
      let v1 = map_expr v1
      and v2 = map_of_list map_case_and_body v2
      in Switch ((v1, v2))
  | Return v1 -> let v1 = map_expr v1 in Return ((v1))
  | Continue v1 -> let v1 = map_of_option map_expr v1 in Continue ((v1))
  | Break v1 -> let v1 = map_of_option map_expr v1 in Break ((v1))
  | Label ((v1, v2)) ->
      let v1 = map_label v1 and v2 = map_stmt v2 in Label ((v1, v2))
  | Goto v1 -> let v1 = map_label v1 in Goto ((v1))
  | Throw v1 -> let v1 = map_expr v1 in Throw ((v1))
  | Try ((v1, v2, v3)) ->
      let v1 = map_stmt v1
      and v2 = map_of_list map_catch v2
      and v3 = map_of_option map_finally v3
      in Try ((v1, v2, v3))
  | Assert ((v1, v2)) ->
      let v1 = map_expr v1
      and v2 = map_of_option map_expr v2
      in Assert ((v1, v2))
  | OtherStmt ((v1, v2)) ->
      let v1 = map_other_stmt_operator v1
      and v2 = map_of_list map_any v2
      in OtherStmt ((v1, v2))

and map_case_and_body (v1, v2) =
  let v1 = map_of_list map_case v1 and v2 = map_stmt v2 in (v1, v2)

and map_case =
  function
  | Case v1 -> let v1 = map_expr v1 in Case ((v1))
  | Default -> Default

and map_catch (v1, v2) =
  let v1 = map_pattern v1 and v2 = map_stmt v2 in (v1, v2)

and map_finally v = map_stmt v

and map_label v = map_ident v

and map_for_header =
  function
  | ForClassic ((v1, v2, v3)) ->
      let v1 = map_of_list map_for_var_or_expr v1
      and v2 = map_expr v2
      and v3 = map_expr v3
      in ForClassic ((v1, v2, v3))
  | ForEach ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_expr v2 in ForEach ((v1, v2))

and map_for_var_or_expr =
  function
  | ForInitVar ((v1, v2)) ->
      let v1 = map_entity v1
      and v2 = map_variable_definition v2
      in ForInitVar ((v1, v2))
  | ForInitExpr v1 -> let v1 = map_expr v1 in ForInitExpr ((v1))

and map_other_stmt_operator x = x

and map_pattern =
  function
  | PatRecord v1 ->
      let v1 =
        map_of_list
          (fun (v1, v2) ->
             let v1 = map_name v1 and v2 = map_pattern v2 in (v1, v2))
          v1
      in PatRecord ((v1))
  | PatVar v1 -> let v1 = map_ident v1 in PatVar ((v1))
  | PatLiteral v1 -> let v1 = map_literal v1 in PatLiteral ((v1))
  | PatConstructor ((v1, v2)) ->
      let v1 = map_name v1
      and v2 = map_of_list map_pattern v2
      in PatConstructor ((v1, v2))
  | PatTuple v1 -> let v1 = map_of_list map_pattern v1 in PatTuple ((v1))
  | PatList v1 -> let v1 = map_of_list map_pattern v1 in PatList ((v1))
  | PatKeyVal ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_pattern v2 in PatKeyVal ((v1, v2))
  | PatUnderscore v1 -> let v1 = map_tok v1 in PatUnderscore ((v1))
  | PatDisj ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_pattern v2 in PatDisj ((v1, v2))
  | PatTyped ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_type_ v2 in PatTyped ((v1, v2))
  | PatAs ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_ident v2 in PatAs ((v1, v2))
  | PatWhen ((v1, v2)) ->
      let v1 = map_pattern v1 and v2 = map_expr v2 in PatWhen ((v1, v2))
  | OtherPat ((v1, v2)) ->
      let v1 = map_other_pattern_operator v1
      and v2 = map_of_list map_any v2
      in OtherPat ((v1, v2))

and map_other_pattern_operator x = x

and map_definition (v1, v2) =

  let v1 = map_entity v1 and v2 = map_definition_kind v2 in (v1, v2)

and
  map_entity {
               name = v_name;
               attrs = v_attrs;
               type_ = v_type_;
               tparams = v_tparams
             } =
  let v_tparams = map_of_list map_type_parameter v_tparams in
  let v_type_ = map_of_option map_type_ v_type_ in
  let v_attrs = map_of_list map_attribute v_attrs in
  let v_name = map_ident v_name 
  in { 
               name = v_name;
               attrs = v_attrs;
               type_ = v_type_;
               tparams = v_tparams
  }
and map_definition_kind =
  function
  | FuncDef v1 -> let v1 = map_function_definition v1 in FuncDef ((v1))
  | VarDef v1 -> let v1 = map_variable_definition v1 in VarDef ((v1))
  | ClassDef v1 -> let v1 = map_class_definition v1 in ClassDef ((v1))
  | TypeDef v1 -> let v1 = map_type_definition v1 in TypeDef ((v1))
  | ModuleDef v1 -> let v1 = map_module_definition v1 in ModuleDef ((v1))
  | MacroDef v1 -> let v1 = map_macro_definition v1 in MacroDef ((v1))
  | Signature v1 -> let v1 = map_type_ v1 in Signature ((v1))

and map_module_definition { mbody = v_mbody } =
  let v_mbody = map_module_definition_kind v_mbody in 
  { mbody = v_mbody; }
and map_module_definition_kind =
  function
  | ModuleAlias v1 -> let v1 = map_name v1 in ModuleAlias ((v1))
  | ModuleStruct ((v1, v2)) ->
      let v1 = map_of_option map_dotted_name v1
      and v2 = map_of_list map_item v2
      in ModuleStruct ((v1, v2))
  | OtherModule ((v1, v2)) ->
      let v1 = map_other_module_operator v1
      and v2 = map_of_list map_any v2
      in OtherModule ((v1, v2))
and map_other_module_operator = function | OMO_Functor -> OMO_Functor
and
  map_macro_definition { macroparams = v_macroparams; macrobody = v_macrobody
                       } =
  let v_macrobody = map_of_list map_any v_macrobody in
  let v_macroparams = map_of_list map_ident v_macroparams in 
  { macroparams = v_macroparams; macrobody = v_macrobody }

and map_type_parameter (v1, v2) =
  let v1 = map_ident v1 and v2 = map_type_parameter_constraints v2 in (v1, v2)

and map_type_parameter_constraints v =
  map_of_list map_type_parameter_constraint v

and map_type_parameter_constraint =
  function | Extends v1 -> let v1 = map_type_ v1 in Extends ((v1))

and
  map_function_definition {
                            fparams = v_fparams;
                            frettype = v_frettype;
                            fbody = v_fbody
                          } =
  let v_fbody = map_stmt v_fbody in
  let v_frettype = map_of_option map_type_ v_frettype in
  let v_fparams = map_parameters v_fparams in 
  { 
                            fparams = v_fparams;
                            frettype = v_frettype;
                            fbody = v_fbody
  }

and map_parameters v = map_of_list map_parameter v

and map_parameter =
  function
  | ParamClassic v1 ->
      let v1 = map_parameter_classic v1 in ParamClassic ((v1))
  | ParamPattern v1 -> let v1 = map_pattern v1 in ParamPattern ((v1))
  | OtherParam ((v1, v2)) ->
      let v1 = map_other_parameter_operator v1
      and v2 = map_of_list map_any v2
      in OtherParam ((v1, v2))

and
  map_parameter_classic {
                          pname = v_pname;
                          pdefault = v_pdefault;
                          ptype = v_ptype;
                          pattrs = v_pattrs
                        } =
  let v_pattrs = map_of_list map_attribute v_pattrs in
  let v_ptype = map_of_option map_type_ v_ptype in
  let v_pdefault = map_of_option map_expr v_pdefault in
  let v_pname = map_ident v_pname in 
  { 
                          pname = v_pname;
                          pdefault = v_pdefault;
                          ptype = v_ptype;
                          pattrs = v_pattrs
                        }

and map_other_parameter_operator x = x

and map_variable_definition { vinit = v_vinit; vtype = v_vtype } =
  let v_vtype = map_of_option map_type_ v_vtype in
  let v_vinit = map_of_option map_expr v_vinit in 
  { vinit = v_vinit; vtype = v_vtype }

and map_field =
  function
  | FieldVar ((v1, v2)) ->
      let v1 = map_entity v1
      and v2 = map_variable_definition v2
      in FieldVar ((v1, v2))
  | FieldMethod ((v1, v2)) ->
      let v1 = map_entity v1
      and v2 = map_function_definition v2
      in FieldMethod ((v1, v2))
  | FieldDynamic ((v1, v2, v3)) ->
      let v1 = map_expr v1
      and v2 = map_of_list map_attribute v2
      and v3 = map_expr v3
      in FieldDynamic ((v1, v2, v3))
  | FieldSpread v1 -> let v1 = map_expr v1 in FieldSpread ((v1))
  | FieldStmt v1 -> let v1 = map_stmt v1 in FieldStmt ((v1))

and map_type_definition { tbody = v_tbody } =
  let v_tbody = map_type_definition_kind v_tbody in { 
    tbody = v_tbody
  }
and map_type_definition_kind =
  function
  | OrType v1 ->
      let v1 = map_of_list map_or_type_element v1 in OrType ((v1))
  | AndType v1 -> let v1 = map_of_list map_field v1 in AndType ((v1))
  | AliasType v1 -> let v1 = map_type_ v1 in AliasType ((v1))
   | Exception ((v1, v2)) ->
      let v1 = map_ident v1
      and v2 = map_of_list map_type_ v2
      in Exception ((v1, v2))
 | OtherTypeKind ((v1, v2)) ->
      let v1 = map_other_type_kind_operator v1
      and v2 = map_of_list map_any v2
      in OtherTypeKind ((v1, v2))

and map_other_type_kind_operator x = x

and map_or_type_element =
  function
  | OrConstructor ((v1, v2)) ->
      let v1 = map_ident v1
      and v2 = map_of_list map_type_ v2
      in OrConstructor ((v1, v2))
  | OrEnum ((v1, v2)) ->
      let v1 = map_ident v1 and v2 = map_expr v2 in OrEnum ((v1, v2))
  | OrUnion ((v1, v2)) ->
      let v1 = map_ident v1 and v2 = map_type_ v2 in OrUnion ((v1, v2))
  | OtherOr ((v1, v2)) ->
      let v1 = map_other_or_type_element_operator v1
      and v2 = map_of_list map_any v2
      in OtherOr ((v1, v2))
and map_other_or_type_element_operator x = x

and
  map_class_definition {
                         ckind = v_ckind;
                         cextends = v_cextends;
                         cimplements = v_cimplements;
                         cbody = v_cbody
                       } =
  let v_cbody = map_of_list map_field v_cbody in
  let v_cimplements = map_of_list map_type_ v_cimplements in
  let v_cextends = map_of_list map_type_ v_cextends in
  let v_ckind = map_class_kind v_ckind in 
  { 
                         ckind = v_ckind;
                         cextends = v_cextends;
                         cimplements = v_cimplements;
                         cbody = v_cbody
                       }

and map_class_kind =
  function | Class -> Class | Interface -> Interface | Trait -> Trait

and map_directive =
  function
  | Import ((v1, v2)) ->
      let v1 = map_module_name v1
      and v2 = map_of_list map_alias v2
      in Import ((v1, v2))
  | ImportAll ((v1, v2)) ->
      let v1 = map_module_name v1
      and v2 = map_of_option map_ident v2
      in ImportAll ((v1, v2))
  | OtherDirective ((v1, v2)) ->
      let v1 = map_other_directive_operator v1
      and v2 = map_of_list map_any v2
      in OtherDirective ((v1, v2))

and map_alias (v1, v2) =
  let v1 = map_ident v1 and v2 = map_of_option map_ident v2 in (v1, v2)

and map_other_directive_operator x = x

and map_item =
  function
  | IStmt v1 -> let v1 = map_stmt v1 in IStmt ((v1))
  | IDef v1 -> let v1 = map_definition v1 in IDef ((v1))
  | IDir v1 -> let v1 = map_directive v1 in IDir ((v1))

and map_program v = map_of_list map_item v

and map_any =
  function
  | Id v1 -> let v1 = map_ident v1 in Id ((v1))
  | N v1 -> let v1 = map_name v1 in N ((v1))
  | En v1 -> let v1 = map_entity v1 in En ((v1))
  | E v1 -> let v1 = map_expr v1 in E ((v1))
  | S v1 -> let v1 = map_stmt v1 in S ((v1))
  | T v1 -> let v1 = map_type_ v1 in T ((v1))
  | P v1 -> let v1 = map_pattern v1 in P ((v1))
  | Def v1 -> let v1 = map_definition v1 in Def ((v1))
  | Dir v1 -> let v1 = map_directive v1 in Dir ((v1))
  | Di v1 -> let v1 = map_dotted_name v1 in Di ((v1))
  | I v1 -> let v1 = map_item v1 in I ((v1))
  | Pa v1 -> let v1 = map_parameter v1 in Pa ((v1))
  | Ar v1 -> let v1 = map_argument v1 in Ar ((v1))
  | At v1 -> let v1 = map_attribute v1 in At ((v1))
  | Dk v1 -> let v1 = map_definition_kind v1 in Dk ((v1))
  | Pr v1 -> let v1 = map_program v1 in Pr ((v1))

 and all_functions =
    {
      vitem = map_item;
      vprogram = map_program;
      vexpr = map_expr;
      vany = map_any;
    }
  in
  all_functions
  
OCaml

Innovation. Community. Security.