@@ -7,7 +7,12 @@ and exportModuleValue =
7
7
| M of exportModuleItem
8
8
9
9
type exportModuleItems = (string , exportModuleItem ) Hashtbl .t
10
- type types = {typeForValue : type_ ; typeForType : type_ ; needsConversion : bool }
10
+
11
+ type types = {
12
+ typeForValue : type_ ;
13
+ typeForType : type_ ;
14
+ needsConversion : bool ;
15
+ }
11
16
12
17
type fieldInfo = {
13
18
fieldForValue : field ;
@@ -18,37 +23,37 @@ type fieldInfo = {
18
23
let rec exportModuleValueToType ~config exportModuleValue =
19
24
match exportModuleValue with
20
25
| S (s , type_ , converter ) ->
21
- {
22
- typeForValue = ident s;
23
- typeForType = type_;
24
- needsConversion =
25
- not (converter |> Converter. converterIsIdentity ~config ~to JS:true );
26
- }
26
+ {
27
+ typeForValue = ident s;
28
+ typeForType = type_;
29
+ needsConversion =
30
+ not (converter |> Converter. converterIsIdentity ~config ~to JS:true );
31
+ }
27
32
| M exportModuleItem ->
28
- let fieldsInfo = exportModuleItem |> exportModuleItemToFields ~config in
29
- let fieldsForValue =
30
- fieldsInfo |> List. map (fun {fieldForValue} -> fieldForValue)
31
- in
32
- let fieldsForType =
33
- fieldsInfo |> List. map (fun {fieldForType} -> fieldForType)
34
- in
35
- let needsConversion =
36
- fieldsInfo
37
- |> List. fold_left
38
- (fun acc {needsConversion} -> acc || needsConversion)
39
- false
40
- in
41
- {
42
- typeForValue = Object (Open , fieldsForValue);
43
- typeForType = Object (Open , fieldsForType);
44
- needsConversion;
45
- }
33
+ let fieldsInfo = exportModuleItem |> exportModuleItemToFields ~config in
34
+ let fieldsForValue =
35
+ fieldsInfo |> List. map (fun { fieldForValue } -> fieldForValue)
36
+ in
37
+ let fieldsForType =
38
+ fieldsInfo |> List. map (fun { fieldForType } -> fieldForType)
39
+ in
40
+ let needsConversion =
41
+ fieldsInfo
42
+ |> List. fold_left
43
+ (fun acc { needsConversion } -> acc || needsConversion)
44
+ false
45
+ in
46
+ {
47
+ typeForValue = Object (Open , fieldsForValue);
48
+ typeForType = Object (Open , fieldsForType);
49
+ needsConversion;
50
+ }
46
51
47
52
and exportModuleItemToFields =
48
53
(fun ~config exportModuleItem ->
49
54
Hashtbl. fold
50
55
(fun fieldName exportModuleValue fields ->
51
- let {typeForValue; typeForType; needsConversion} =
56
+ let { typeForValue; typeForType; needsConversion } =
52
57
exportModuleValue |> exportModuleValueToType ~config
53
58
in
54
59
let fieldForType =
@@ -60,47 +65,48 @@ and exportModuleItemToFields =
60
65
type_ = typeForType;
61
66
}
62
67
in
63
- let fieldForValue = {fieldForType with type_ = typeForValue} in
64
- {fieldForValue; fieldForType; needsConversion} :: fields)
68
+ let fieldForValue = { fieldForType with type_ = typeForValue } in
69
+ { fieldForValue; fieldForType; needsConversion } :: fields)
65
70
exportModuleItem []
66
71
: config:Config. t -> exportModuleItem -> fieldInfo list )
67
72
68
73
let rec extendExportModuleItem x ~converter
69
74
~(exportModuleItem : exportModuleItem ) ~type_ ~valueName =
70
75
match x with
71
76
| [] -> ()
72
- | [fieldName] ->
73
- Hashtbl. replace exportModuleItem fieldName (S (valueName, type_, converter))
77
+ | [ fieldName ] ->
78
+ Hashtbl. replace exportModuleItem fieldName
79
+ (S (valueName, type_, converter))
74
80
| fieldName :: rest ->
75
- let innerExportModuleItem =
76
- match Hashtbl. find exportModuleItem fieldName with
77
- | M innerExportModuleItem -> innerExportModuleItem
78
- | S _ -> assert false
79
- | exception Not_found ->
80
- let innerExportModuleItem = Hashtbl. create 1 in
81
- Hashtbl. replace exportModuleItem fieldName (M innerExportModuleItem);
82
- innerExportModuleItem
83
- in
84
- rest
85
- |> extendExportModuleItem ~converter ~export ModuleItem:innerExportModuleItem
86
- ~value Name ~type_
81
+ let innerExportModuleItem =
82
+ match Hashtbl. find exportModuleItem fieldName with
83
+ | M innerExportModuleItem -> innerExportModuleItem
84
+ | S _ -> assert false
85
+ | exception Not_found ->
86
+ let innerExportModuleItem = Hashtbl. create 1 in
87
+ Hashtbl. replace exportModuleItem fieldName (M innerExportModuleItem);
88
+ innerExportModuleItem
89
+ in
90
+ rest
91
+ |> extendExportModuleItem ~converter
92
+ ~export ModuleItem:innerExportModuleItem ~value Name ~type_
87
93
88
94
let extendExportModuleItems x ~converter
89
95
~(exportModuleItems : exportModuleItems ) ~type_ ~valueName =
90
96
match x with
91
97
| [] -> assert false
92
- | [_valueName] -> ()
98
+ | [ _valueName ] -> ()
93
99
| moduleName :: rest ->
94
- let exportModuleItem =
95
- match Hashtbl. find exportModuleItems moduleName with
96
- | exportModuleItem -> exportModuleItem
97
- | exception Not_found ->
98
- let exportModuleItem = Hashtbl. create 1 in
99
- Hashtbl. replace exportModuleItems moduleName exportModuleItem;
100
- exportModuleItem
101
- in
102
- rest
103
- |> extendExportModuleItem ~converter ~export ModuleItem ~type_ ~value Name
100
+ let exportModuleItem =
101
+ match Hashtbl. find exportModuleItems moduleName with
102
+ | exportModuleItem -> exportModuleItem
103
+ | exception Not_found ->
104
+ let exportModuleItem = Hashtbl. create 1 in
105
+ Hashtbl. replace exportModuleItems moduleName exportModuleItem;
106
+ exportModuleItem
107
+ in
108
+ rest
109
+ |> extendExportModuleItem ~converter ~export ModuleItem ~type_ ~value Name
104
110
105
111
let createModuleItemsEmitter =
106
112
(fun () -> Hashtbl. create 1 : unit -> exportModuleItems)
@@ -114,7 +120,7 @@ let emitAllModuleItems ~config ~emitters ~fileName
114
120
emitters
115
121
|> rev_fold
116
122
(fun moduleName exportModuleItem emitters ->
117
- let {typeForType; needsConversion} =
123
+ let { typeForType; needsConversion } =
118
124
M exportModuleItem |> exportModuleValueToType ~config
119
125
in
120
126
if ! Debug. codeItems then
0 commit comments