@glutinum/cli 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/Glutinum.Converter/FsharpAST.js +18 -4
- package/dist/Glutinum.Converter/FsharpAST.js.map +1 -1
- package/dist/Glutinum.Converter/GlueAST.js +53 -25
- package/dist/Glutinum.Converter/GlueAST.js.map +1 -1
- package/dist/Glutinum.Converter/Printer.js +9 -1
- package/dist/Glutinum.Converter/Printer.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +2 -2
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/Declaration.js +3 -3
- package/dist/Glutinum.Converter/Reader/Declaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/Documentation.js +65 -22
- package/dist/Glutinum.Converter/Reader/Documentation.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +1 -1
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/NamedTupleMember.js +7 -0
- package/dist/Glutinum.Converter/Reader/NamedTupleMember.js.map +1 -0
- package/dist/Glutinum.Converter/Reader/Node.js +1 -1
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js +1 -1
- package/dist/Glutinum.Converter/Reader/TypeAliasDeclaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeNode.js +24 -12
- package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +6 -2
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +7 -2
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +8 -3
- package/dist/Glutinum.Converter/Reader/VariableStatement.js.map +1 -1
- package/dist/Glutinum.Converter/Transform.js +429 -249
- package/dist/Glutinum.Converter/Transform.js.map +1 -1
- package/dist/Glutinum.Converter/Utils/Naming.js +28 -16
- package/dist/Glutinum.Converter/Utils/Naming.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { printf, toFail, interpolate, toText, trimStart } from "../fable_modules/fable-library-js.4.14.0/String.js";
|
|
2
|
-
import { class_type } from "../fable_modules/fable-library-js.4.14.0/Reflection.js";
|
|
1
|
+
import { printf, toFail, interpolate, toText, join, trimStart } from "../fable_modules/fable-library-js.4.14.0/String.js";
|
|
2
|
+
import { record_type, list_type, class_type } from "../fable_modules/fable-library-js.4.14.0/Reflection.js";
|
|
3
|
+
import { Record } from "../fable_modules/fable-library-js.4.14.0/Types.js";
|
|
4
|
+
import { FSharpTypeParameter_Create_Z6CFD3565, FSharpTypeAlias, FSharpEnum, FSharpEnumCase, FSharpStaticMemberInfo, FSharpAccessor, FSharpMapped, FSharpMember, FSharpMemberInfo, FSharpInterface, FSharpClass, FSharpConstructor, FSharpAccessibility, FSharpExplicitField, FSharpParameter, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpPrimitive, FSharpLiteral, FSharpCommentTypeParam, FSharpCommentParam, FSharpXmlDoc, FSharpAttribute, FSharpType, FSharpModule, FSharpXmlDoc_$reflection, FSharpAttribute_$reflection } from "./FsharpAST.js";
|
|
3
5
|
import { empty as empty_1, singleton as singleton_1, collect, append, delay, toList } from "../fable_modules/fable-library-js.4.14.0/Seq.js";
|
|
4
|
-
import { exists,
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { unwrap, map as map_1, defaultArg } from "../fable_modules/fable-library-js.4.14.0/Option.js";
|
|
8
|
-
import { GlueType, GlueTypeUnion, GlueType__get_Name } from "./GlueAST.js";
|
|
6
|
+
import { exists, filter, choose, collect as collect_1, ofArray, forAll, length, partition, sortBy, map, append as append_1, head as head_1, tail, singleton, empty, isEmpty } from "../fable_modules/fable-library-js.4.14.0/List.js";
|
|
7
|
+
import { sanitizeNameWithResult, removeSurroundingQuotes, mapTypeNameToFableCoreAwareName, sanitizeName } from "./Utils/Naming.js";
|
|
8
|
+
import { unwrap, value as value_4, map as map_1, defaultArg } from "../fable_modules/fable-library-js.4.14.0/Option.js";
|
|
9
9
|
import { int32ToString, safeHash, equals, comparePrimitives } from "../fable_modules/fable-library-js.4.14.0/Util.js";
|
|
10
|
-
import {
|
|
10
|
+
import { GlueType, GlueTypeUnion, GlueConstructor, GlueType__get_Name } from "./GlueAST.js";
|
|
11
|
+
import { warn, error } from "./Log.js";
|
|
11
12
|
import { List_distinct } from "../fable_modules/fable-library-js.4.14.0/Seq2.js";
|
|
12
|
-
import { removeSingleQuote, removeDoubleQuote } from "./Utils/String.js";
|
|
13
13
|
|
|
14
14
|
export class TransformContext {
|
|
15
15
|
constructor(currentScopeName, parent) {
|
|
@@ -32,6 +32,18 @@ export function TransformContext_$ctor_Z535BF207(currentScopeName, parent) {
|
|
|
32
32
|
return new TransformContext(currentScopeName, parent);
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
export class TransformCommentResult extends Record {
|
|
36
|
+
constructor(ObsoleteAttributes, XmlDoc) {
|
|
37
|
+
super();
|
|
38
|
+
this.ObsoleteAttributes = ObsoleteAttributes;
|
|
39
|
+
this.XmlDoc = XmlDoc;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function TransformCommentResult_$reflection() {
|
|
44
|
+
return record_type("Glutinum.Converter.Transform.TransformCommentResult", [], TransformCommentResult, () => [["ObsoleteAttributes", list_type(FSharpAttribute_$reflection())], ["XmlDoc", list_type(FSharpXmlDoc_$reflection())]]);
|
|
45
|
+
}
|
|
46
|
+
|
|
35
47
|
export function TransformContext__get_FullName(__) {
|
|
36
48
|
return __["FullName@"];
|
|
37
49
|
}
|
|
@@ -82,44 +94,112 @@ function sanitizeNameAndPushScope(name, context) {
|
|
|
82
94
|
}
|
|
83
95
|
|
|
84
96
|
function transformComment(comment) {
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
+
const categorize = (acc_mut, comments_mut) => {
|
|
98
|
+
categorize:
|
|
99
|
+
while (true) {
|
|
100
|
+
const acc = acc_mut, comments = comments_mut;
|
|
101
|
+
if (!isEmpty(comments)) {
|
|
102
|
+
const rest = tail(comments);
|
|
103
|
+
const comment_1 = head_1(comments);
|
|
104
|
+
switch (comment_1.tag) {
|
|
105
|
+
case 3: {
|
|
106
|
+
acc_mut = {
|
|
107
|
+
Deprecated: append_1(acc.Deprecated, singleton(comment_1.fields[0])),
|
|
108
|
+
Others: acc.Others,
|
|
109
|
+
Remarks: acc.Remarks,
|
|
110
|
+
Throws: acc.Throws,
|
|
111
|
+
};
|
|
112
|
+
comments_mut = rest;
|
|
113
|
+
continue categorize;
|
|
114
|
+
}
|
|
115
|
+
case 8: {
|
|
116
|
+
acc_mut = {
|
|
117
|
+
Deprecated: acc.Deprecated,
|
|
118
|
+
Others: acc.Others,
|
|
119
|
+
Remarks: acc.Remarks,
|
|
120
|
+
Throws: append_1(acc.Throws, singleton(comment_1.fields[0])),
|
|
121
|
+
};
|
|
122
|
+
comments_mut = rest;
|
|
123
|
+
continue categorize;
|
|
124
|
+
}
|
|
125
|
+
case 4: {
|
|
126
|
+
acc_mut = {
|
|
127
|
+
Deprecated: acc.Deprecated,
|
|
128
|
+
Others: acc.Others,
|
|
129
|
+
Remarks: append_1(acc.Remarks, singleton(comment_1.fields[0])),
|
|
130
|
+
Throws: acc.Throws,
|
|
131
|
+
};
|
|
132
|
+
comments_mut = rest;
|
|
133
|
+
continue categorize;
|
|
134
|
+
}
|
|
135
|
+
default: {
|
|
136
|
+
acc_mut = {
|
|
137
|
+
Deprecated: acc.Deprecated,
|
|
138
|
+
Others: append_1(acc.Others, singleton(comment_1)),
|
|
139
|
+
Remarks: acc.Remarks,
|
|
140
|
+
Throws: acc.Throws,
|
|
141
|
+
};
|
|
142
|
+
comments_mut = rest;
|
|
143
|
+
continue categorize;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
97
146
|
}
|
|
98
147
|
else {
|
|
99
|
-
|
|
100
|
-
}
|
|
101
|
-
}, patternInput[0]),
|
|
102
|
-
Others: map((comment_1) => {
|
|
103
|
-
switch (comment_1.tag) {
|
|
104
|
-
case 0:
|
|
105
|
-
return new FSharpXmlDoc(0, [comment_1.fields[0]]);
|
|
106
|
-
case 1:
|
|
107
|
-
return new FSharpXmlDoc(2, [comment_1.fields[0]]);
|
|
108
|
-
case 2: {
|
|
109
|
-
const param = comment_1.fields[0];
|
|
110
|
-
return new FSharpXmlDoc(1, [new FSharpCommentParam(param.Name, defaultArg(map_1((content_1) => trimStart(trimStart(trimStart(content_1), "-")), param.Content), ""))]);
|
|
111
|
-
}
|
|
112
|
-
case 4:
|
|
113
|
-
return new FSharpXmlDoc(3, [comment_1.fields[0]]);
|
|
114
|
-
case 5:
|
|
115
|
-
return new FSharpXmlDoc(4, [comment_1.fields[0]]);
|
|
116
|
-
case 6:
|
|
117
|
-
return new FSharpXmlDoc(5, [comment_1.fields[0]]);
|
|
118
|
-
default:
|
|
119
|
-
throw new Error("Should not happen");
|
|
148
|
+
return acc;
|
|
120
149
|
}
|
|
121
|
-
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
122
152
|
};
|
|
153
|
+
const categories = categorize({
|
|
154
|
+
Deprecated: empty(),
|
|
155
|
+
Others: empty(),
|
|
156
|
+
Remarks: empty(),
|
|
157
|
+
Throws: empty(),
|
|
158
|
+
}, comment);
|
|
159
|
+
const obsoleteAttributes = map((Item) => (new FSharpAttribute(8, [Item])), categories.Deprecated);
|
|
160
|
+
const remarks = (!isEmpty(categories.Remarks) ? true : !isEmpty(categories.Throws)) ? (new FSharpXmlDoc(3, [join("\n", toList(delay(() => append(categories.Remarks, delay(() => append(!isEmpty(categories.Throws) ? append(!isEmpty(categories.Remarks) ? singleton_1("") : empty_1(), delay(() => append(singleton_1("Throws:"), delay(() => singleton_1("-------"))))) : empty_1(), delay(() => collect((throws) => append(singleton_1(""), delay(() => singleton_1(throws))), categories.Throws))))))))])) : void 0;
|
|
161
|
+
const others = map((comment_2) => {
|
|
162
|
+
switch (comment_2.tag) {
|
|
163
|
+
case 0:
|
|
164
|
+
return new FSharpXmlDoc(0, [comment_2.fields[0]]);
|
|
165
|
+
case 1:
|
|
166
|
+
return new FSharpXmlDoc(2, [comment_2.fields[0]]);
|
|
167
|
+
case 2: {
|
|
168
|
+
const param = comment_2.fields[0];
|
|
169
|
+
return new FSharpXmlDoc(1, [new FSharpCommentParam(param.Name, defaultArg(map_1((content_3) => trimStart(trimStart(trimStart(content_3), "-")), param.Content), ""))]);
|
|
170
|
+
}
|
|
171
|
+
case 5:
|
|
172
|
+
return new FSharpXmlDoc(4, [comment_2.fields[0]]);
|
|
173
|
+
case 6:
|
|
174
|
+
return new FSharpXmlDoc(5, [comment_2.fields[0]]);
|
|
175
|
+
case 7: {
|
|
176
|
+
const typeParam = comment_2.fields[0];
|
|
177
|
+
return new FSharpXmlDoc(6, [new FSharpCommentTypeParam(typeParam.TypeName, defaultArg(typeParam.Content, ""))]);
|
|
178
|
+
}
|
|
179
|
+
default:
|
|
180
|
+
throw new Error("Should not happen");
|
|
181
|
+
}
|
|
182
|
+
}, categories.Others);
|
|
183
|
+
return new TransformCommentResult(obsoleteAttributes, sortBy((xmlDoc) => {
|
|
184
|
+
switch (xmlDoc.tag) {
|
|
185
|
+
case 4:
|
|
186
|
+
return 1;
|
|
187
|
+
case 3:
|
|
188
|
+
return 2;
|
|
189
|
+
case 5:
|
|
190
|
+
return 3;
|
|
191
|
+
case 1:
|
|
192
|
+
return 4;
|
|
193
|
+
case 6:
|
|
194
|
+
return 5;
|
|
195
|
+
case 2:
|
|
196
|
+
return 999;
|
|
197
|
+
default:
|
|
198
|
+
return 0;
|
|
199
|
+
}
|
|
200
|
+
}, toList(delay(() => append(others, delay(() => ((remarks != null) ? singleton_1(value_4(remarks)) : empty_1()))))), {
|
|
201
|
+
Compare: comparePrimitives,
|
|
202
|
+
}));
|
|
123
203
|
}
|
|
124
204
|
|
|
125
205
|
function transformLiteral(glueLiteral) {
|
|
@@ -157,6 +237,8 @@ function transformPrimitive(gluePrimitive) {
|
|
|
157
237
|
return new FSharpPrimitive(6, []);
|
|
158
238
|
case 9:
|
|
159
239
|
return new FSharpPrimitive(6, []);
|
|
240
|
+
case 10:
|
|
241
|
+
return new FSharpPrimitive(6, []);
|
|
160
242
|
default:
|
|
161
243
|
return new FSharpPrimitive(0, []);
|
|
162
244
|
}
|
|
@@ -173,7 +255,7 @@ function transformType(context_mut, glueType_mut) {
|
|
|
173
255
|
switch (glueType.tag) {
|
|
174
256
|
case 3:
|
|
175
257
|
return new FSharpType(7, [transformPrimitive(glueType.fields[0])]);
|
|
176
|
-
case
|
|
258
|
+
case 23:
|
|
177
259
|
return new FSharpType(2, [transformType(context, glueType.fields[0])]);
|
|
178
260
|
case 18:
|
|
179
261
|
return new FSharpType(14, [glueType.fields[0]]);
|
|
@@ -206,7 +288,14 @@ function transformType(context_mut, glueType_mut) {
|
|
|
206
288
|
continue transformType;
|
|
207
289
|
}
|
|
208
290
|
else {
|
|
209
|
-
|
|
291
|
+
const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others);
|
|
292
|
+
if (matchValue == null) {
|
|
293
|
+
return new FSharpType(1, [new FSharpUnion(empty(), `U${length(others)}`, map((caseType) => (new FSharpUnionCase(empty(), mapTypeNameToFableCoreAwareName(GlueType__get_Name(caseType)))), others), isOptional)]);
|
|
294
|
+
}
|
|
295
|
+
else {
|
|
296
|
+
TransformContext__ExposeType_Z1D58A540(context, matchValue);
|
|
297
|
+
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
298
|
+
}
|
|
210
299
|
}
|
|
211
300
|
}
|
|
212
301
|
case 13: {
|
|
@@ -227,23 +316,40 @@ function transformType(context_mut, glueType_mut) {
|
|
|
227
316
|
}
|
|
228
317
|
case 1:
|
|
229
318
|
return new FSharpType(4, [transformInterface(context, glueType.fields[0])]);
|
|
230
|
-
case
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
319
|
+
case 22: {
|
|
320
|
+
const typeLiteralInfo = glueType.fields[0];
|
|
321
|
+
if (forAll((_arg) => {
|
|
322
|
+
switch (_arg.tag) {
|
|
323
|
+
case 4:
|
|
324
|
+
case 1:
|
|
325
|
+
case 2:
|
|
326
|
+
case 0:
|
|
327
|
+
case 5:
|
|
328
|
+
return true;
|
|
329
|
+
default:
|
|
330
|
+
return false;
|
|
238
331
|
}
|
|
239
|
-
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
332
|
+
}, typeLiteralInfo.Members)) {
|
|
333
|
+
const typeLiteralParameters = sortBy((_arg_1) => _arg_1.IsOptional, map((parameter_1) => {
|
|
334
|
+
const matchValue_1 = parameter_1.Type;
|
|
335
|
+
if (matchValue_1.tag === 2) {
|
|
336
|
+
return new FSharpParameter(parameter_1.Attributes, parameter_1.Name, true, matchValue_1.fields[0]);
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
return parameter_1;
|
|
340
|
+
}
|
|
341
|
+
}, TransformMembers_toFSharpParameters(context, typeLiteralInfo.Members)), {
|
|
342
|
+
Compare: comparePrimitives,
|
|
343
|
+
});
|
|
344
|
+
const explicitFields = map((parameter_2) => (new FSharpExplicitField(parameter_2.Name, parameter_2.IsOptional ? (new FSharpType(2, [parameter_2.Type])) : parameter_2.Type)), typeLiteralParameters);
|
|
345
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(16, [new FSharpClass(ofArray([new FSharpAttribute(15, []), new FSharpAttribute(7, [])]), TransformContext__get_CurrentScopeName(context), empty(), new FSharpConstructor(typeLiteralParameters, ofArray([new FSharpAttribute(16, []), new FSharpAttribute(2, [])]), new FSharpAccessibility(0, [])), empty(), explicitFields)]));
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), TransformContext__get_CurrentScopeName(context), "", empty(), TransformMembers_toFSharpMember(context, typeLiteralInfo.Members))]));
|
|
349
|
+
}
|
|
244
350
|
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
245
351
|
}
|
|
246
|
-
case
|
|
352
|
+
case 25: {
|
|
247
353
|
context_mut = context;
|
|
248
354
|
glueType_mut = glueType.fields[0];
|
|
249
355
|
continue transformType;
|
|
@@ -253,15 +359,29 @@ function transformType(context_mut, glueType_mut) {
|
|
|
253
359
|
glueType_mut = glueType.fields[0].Type;
|
|
254
360
|
continue transformType;
|
|
255
361
|
}
|
|
362
|
+
case 9: {
|
|
363
|
+
const matchValue_2 = TypeAliasDeclaration_tryTransformKeyOf(TransformContext__get_CurrentScopeName(context), glueType.fields[0]);
|
|
364
|
+
if (matchValue_2 == null) {
|
|
365
|
+
return new FSharpType(17, []);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
TransformContext__ExposeType_Z1D58A540(context, matchValue_2);
|
|
369
|
+
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
case 20: {
|
|
373
|
+
context_mut = context;
|
|
374
|
+
glueType_mut = glueType.fields[0].Type;
|
|
375
|
+
continue transformType;
|
|
376
|
+
}
|
|
256
377
|
case 11:
|
|
257
378
|
case 10:
|
|
258
379
|
case 8:
|
|
259
380
|
case 4:
|
|
260
381
|
case 5:
|
|
261
|
-
case 9:
|
|
262
382
|
case 0:
|
|
263
383
|
case 14:
|
|
264
|
-
case
|
|
384
|
+
case 21:
|
|
265
385
|
case 6: {
|
|
266
386
|
error(toText(interpolate("Could not transform type: %A%P()", [glueType])));
|
|
267
387
|
return new FSharpType(9, []);
|
|
@@ -281,39 +401,41 @@ function transformExports(context, isTopLevel, exports) {
|
|
|
281
401
|
case 2: {
|
|
282
402
|
const info = _arg.fields[0];
|
|
283
403
|
const patternInput = sanitizeNameAndPushScope(info.Name, context_1);
|
|
284
|
-
|
|
404
|
+
const xmlDocInfo = transformComment(info.Documentation);
|
|
405
|
+
return singleton(new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => append(singleton_1(new FSharpAttribute(3, [info.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => xmlDocInfo.ObsoleteAttributes)))), patternInput[0], info.Name, empty(), empty(), transformType(patternInput[1], info.Type), false, true, void 0, new FSharpAccessibility(0, []), xmlDocInfo.XmlDoc)]));
|
|
285
406
|
}
|
|
286
407
|
case 6: {
|
|
287
408
|
const info_1 = _arg.fields[0];
|
|
288
409
|
const patternInput_1 = sanitizeNameAndPushScope(info_1.Name, context_1);
|
|
289
410
|
const context_3 = patternInput_1[1];
|
|
290
|
-
const
|
|
291
|
-
return singleton(new FSharpMember(0, [(Attributes_1 = toList(delay(() => append(singleton_1(new FSharpAttribute(3, [info_1.Name, "
|
|
411
|
+
const xmlDocInfo_1 = transformComment(info_1.Documentation);
|
|
412
|
+
return singleton(new FSharpMember(0, [(Attributes_1 = toList(delay(() => append(singleton_1(new FSharpAttribute(3, [info_1.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => xmlDocInfo_1.ObsoleteAttributes)))), (Parameters_1 = map((parameter) => transformParameter(context_3, parameter), info_1.Parameters), new FSharpMemberInfo(Attributes_1, patternInput_1[0], info_1.Name, transformTypeParameters(context_3, info_1.TypeParameters), Parameters_1, transformType(context_3, info_1.Type), false, true, void 0, new FSharpAccessibility(0, []), xmlDocInfo_1.XmlDoc)))]));
|
|
292
413
|
}
|
|
293
414
|
case 12: {
|
|
294
415
|
const info_2 = _arg.fields[0];
|
|
295
416
|
const patternInput_2 = sanitizeNameAndPushScope(info_2.Name, context_1);
|
|
296
417
|
const context_4 = patternInput_2[1];
|
|
297
|
-
return map((
|
|
418
|
+
return map((constructorInfo) => {
|
|
298
419
|
let Attributes_2, Parameters_2;
|
|
299
|
-
|
|
300
|
-
|
|
420
|
+
const xmlDocInfo_2 = transformComment(constructorInfo.Documentation);
|
|
421
|
+
return new FSharpMember(0, [(Attributes_2 = toList(delay(() => append(isTopLevel ? append(singleton_1(new FSharpAttribute(3, [info_2.Name, "REPLACE_ME_WITH_MODULE_NAME"])), delay(() => singleton_1(new FSharpAttribute(12, [])))) : singleton_1(new FSharpAttribute(13, [info_2.Name])), delay(() => xmlDocInfo_2.ObsoleteAttributes)))), (Parameters_2 = map((parameter_1) => transformParameter(context_4, parameter_1), constructorInfo.Parameters), new FSharpMemberInfo(Attributes_2, patternInput_2[0], info_2.Name, transformTypeParameters(context_4, info_2.TypeParameters), Parameters_2, new FSharpType(6, [new FSharpMapped(sanitizeName(info_2.Name), empty())]), false, true, void 0, new FSharpAccessibility(0, []), xmlDocInfo_2.XmlDoc)))]);
|
|
422
|
+
}, isEmpty(info_2.Constructors) ? singleton(new GlueConstructor(empty(), empty())) : info_2.Constructors);
|
|
301
423
|
}
|
|
302
424
|
case 11: {
|
|
303
425
|
const moduleDeclaration = _arg.fields[0];
|
|
304
426
|
return choose((typ) => {
|
|
305
427
|
if (typ.tag === 12) {
|
|
306
|
-
return new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(4, ["
|
|
428
|
+
return new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"])), moduleDeclaration.Name + "_", moduleDeclaration.Name, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${moduleDeclaration.Name}.Exports`, empty())]), false, true, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty())]);
|
|
307
429
|
}
|
|
308
430
|
else {
|
|
309
431
|
return void 0;
|
|
310
432
|
}
|
|
311
433
|
}, moduleDeclaration.Types);
|
|
312
434
|
}
|
|
313
|
-
case
|
|
435
|
+
case 25: {
|
|
314
436
|
const glueType = _arg.fields[0];
|
|
315
437
|
const patternInput_3 = sanitizeNameAndPushScope(GlueType__get_Name(glueType), context_1);
|
|
316
|
-
return singleton(new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(5, ["
|
|
438
|
+
return singleton(new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(5, ["REPLACE_ME_WITH_MODULE_NAME"])), patternInput_3[0], GlueType__get_Name(glueType), empty(), empty(), transformType(patternInput_3[1], glueType), false, true, void 0, new FSharpAccessibility(0, []), empty())]));
|
|
317
439
|
}
|
|
318
440
|
default:
|
|
319
441
|
return toFail(printf("Could not generate exportMembers for: %A"))(_arg);
|
|
@@ -356,7 +478,10 @@ function TransformMembers_toFSharpMember(context, members) {
|
|
|
356
478
|
return void 0;
|
|
357
479
|
}
|
|
358
480
|
else {
|
|
359
|
-
|
|
481
|
+
let typ;
|
|
482
|
+
const typ$0027 = transformType(patternInput_2[1], propertyInfo.Type);
|
|
483
|
+
typ = (propertyInfo.IsOptional ? ((typ$0027.tag === 2) ? typ$0027.fields[0] : typ$0027) : typ$0027);
|
|
484
|
+
return new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo.ObsoleteAttributes)), patternInput_2[0], propertyInfo.Name, empty(), empty(), typ, propertyInfo.IsOptional, propertyInfo.IsStatic, transformAccessor(propertyInfo.Accessor), propertyInfo.IsPrivate ? (new FSharpAccessibility(1, [])) : (new FSharpAccessibility(0, [])), xmlDocInfo.XmlDoc)]);
|
|
360
485
|
}
|
|
361
486
|
}
|
|
362
487
|
case 3: {
|
|
@@ -369,7 +494,8 @@ function TransformMembers_toFSharpMember(context, members) {
|
|
|
369
494
|
const methodSignature = _arg.fields[0];
|
|
370
495
|
const patternInput_4 = sanitizeNameAndPushScope(methodSignature.Name, context);
|
|
371
496
|
const context_5 = patternInput_4[1];
|
|
372
|
-
|
|
497
|
+
const xmlDocInfo_1 = transformComment(methodSignature.Documentation);
|
|
498
|
+
return new FSharpMember(0, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo_1.ObsoleteAttributes)), patternInput_4[0], methodSignature.Name, empty(), map((parameter_4) => transformParameter(context_5, parameter_4), methodSignature.Parameters), transformType(context_5, methodSignature.Type), false, false, void 0, new FSharpAccessibility(0, []), xmlDocInfo_1.XmlDoc)]);
|
|
373
499
|
}
|
|
374
500
|
case 5: {
|
|
375
501
|
const constructSignature = _arg.fields[0];
|
|
@@ -469,8 +595,7 @@ function transformEnum(glueEnum) {
|
|
|
469
595
|
throw new Error("Should not happen");
|
|
470
596
|
}
|
|
471
597
|
const caseName = sanitizeName(glueMember_1.Name);
|
|
472
|
-
|
|
473
|
-
return new FSharpUnionCase(toList(delay(() => (differentName ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(caseValue)])) : empty_1()))), sanitizeName(caseName));
|
|
598
|
+
return new FSharpUnionCase(toList(delay(() => ((caseName !== caseValue) ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(caseValue)])) : empty_1()))), caseName);
|
|
474
599
|
}, stringValues), {
|
|
475
600
|
Equals: equals,
|
|
476
601
|
GetHashCode: safeHash,
|
|
@@ -491,9 +616,9 @@ Errored enum: ${glueEnum.Name}
|
|
|
491
616
|
}
|
|
492
617
|
}
|
|
493
618
|
|
|
494
|
-
export function
|
|
619
|
+
export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
|
|
495
620
|
const cases = (glueType.tag === 1) ? choose((m) => {
|
|
496
|
-
let
|
|
621
|
+
let sanitizeResult;
|
|
497
622
|
let matchResult, caseName;
|
|
498
623
|
switch (m.tag) {
|
|
499
624
|
case 2:
|
|
@@ -518,19 +643,33 @@ export function TypeAliasDeclaration_transformKeyOf(aliasName, glueType) {
|
|
|
518
643
|
}
|
|
519
644
|
}
|
|
520
645
|
switch (matchResult) {
|
|
521
|
-
case 0:
|
|
522
|
-
|
|
523
|
-
return (differentName = nameNotEqualsDefaultFableValue(caseName, caseValue), new FSharpUnionCase(toList(delay(() => (differentName ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(caseName)])) : empty_1()))), sanitizeName(caseValue)));
|
|
524
|
-
}
|
|
646
|
+
case 0:
|
|
647
|
+
return (sanitizeResult = sanitizeNameWithResult(caseName), new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(caseName)])) : empty_1()))), sanitizeResult.Name));
|
|
525
648
|
default:
|
|
526
649
|
return void 0;
|
|
527
650
|
}
|
|
528
651
|
}, glueType.fields[0].Members) : empty();
|
|
529
|
-
|
|
652
|
+
if (isEmpty(cases)) {
|
|
653
|
+
return void 0;
|
|
654
|
+
}
|
|
655
|
+
else {
|
|
656
|
+
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), sanitizeName(aliasName), cases, false)]);
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
|
|
660
|
+
export function TypeAliasDeclaration_transformKeyOf(aliasName, glueType) {
|
|
661
|
+
const matchValue = TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType);
|
|
662
|
+
if (matchValue == null) {
|
|
663
|
+
warn(`Could not transform KeyOf: ${aliasName}`);
|
|
664
|
+
return new FSharpType(9, []);
|
|
665
|
+
}
|
|
666
|
+
else {
|
|
667
|
+
return matchValue;
|
|
668
|
+
}
|
|
530
669
|
}
|
|
531
670
|
|
|
532
|
-
export function TypeAliasDeclaration_transformLiteral(typeAliasName, literalInfo) {
|
|
533
|
-
const makeTypeAlias = (primitiveType) => (new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(7, [primitiveType]), empty())]));
|
|
671
|
+
export function TypeAliasDeclaration_transformLiteral(xmlDoc, typeAliasName, literalInfo) {
|
|
672
|
+
const makeTypeAlias = (primitiveType) => (new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(7, [primitiveType]), empty())]));
|
|
534
673
|
switch (literalInfo.tag) {
|
|
535
674
|
case 1:
|
|
536
675
|
return makeTypeAlias(new FSharpPrimitive(1, []));
|
|
@@ -541,7 +680,7 @@ export function TypeAliasDeclaration_transformLiteral(typeAliasName, literalInfo
|
|
|
541
680
|
case 4:
|
|
542
681
|
return makeTypeAlias(new FSharpPrimitive(6, []));
|
|
543
682
|
default:
|
|
544
|
-
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), typeAliasName, singleton(new FSharpUnionCase(empty(), sanitizeName(
|
|
683
|
+
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), typeAliasName, singleton(new FSharpUnionCase(empty(), sanitizeName(literalInfo.fields[0]))), false)]);
|
|
545
684
|
}
|
|
546
685
|
}
|
|
547
686
|
|
|
@@ -549,62 +688,208 @@ function transformTypeParameters(context, typeParameters) {
|
|
|
549
688
|
return map((typeParameter) => FSharpTypeParameter_Create_Z6CFD3565(typeParameter.Name, unwrap(map_1((glueType) => transformType(context, glueType), typeParameter.Constraint)), unwrap(map_1((glueType_1) => transformType(context, glueType_1), typeParameter.Default))), typeParameters);
|
|
550
689
|
}
|
|
551
690
|
|
|
691
|
+
function tryOptimizeUnionType(context, typeName, cases) {
|
|
692
|
+
const flattenCases = (cases_1) => collect_1((_arg) => {
|
|
693
|
+
switch (_arg.tag) {
|
|
694
|
+
case 8:
|
|
695
|
+
return singleton(_arg);
|
|
696
|
+
case 7:
|
|
697
|
+
return flattenCases(_arg.fields[0].fields[0]);
|
|
698
|
+
case 5: {
|
|
699
|
+
const matchValue = _arg.fields[0].Type;
|
|
700
|
+
if (matchValue.tag === 7) {
|
|
701
|
+
return flattenCases(matchValue.fields[0].fields[0]);
|
|
702
|
+
}
|
|
703
|
+
else {
|
|
704
|
+
return empty();
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
default:
|
|
708
|
+
return empty();
|
|
709
|
+
}
|
|
710
|
+
}, cases_1);
|
|
711
|
+
const flattenedCases = flattenCases(cases);
|
|
712
|
+
const isStringOnly = !isEmpty(flattenedCases) && forAll((_arg_1) => {
|
|
713
|
+
let matchResult;
|
|
714
|
+
if (_arg_1.tag === 8) {
|
|
715
|
+
if (_arg_1.fields[0].tag === 0) {
|
|
716
|
+
matchResult = 0;
|
|
717
|
+
}
|
|
718
|
+
else {
|
|
719
|
+
matchResult = 1;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
else {
|
|
723
|
+
matchResult = 1;
|
|
724
|
+
}
|
|
725
|
+
switch (matchResult) {
|
|
726
|
+
case 0:
|
|
727
|
+
return true;
|
|
728
|
+
default:
|
|
729
|
+
return false;
|
|
730
|
+
}
|
|
731
|
+
}, flattenedCases);
|
|
732
|
+
const isNumericOnly = !isEmpty(flattenedCases) && forAll((_arg_2) => {
|
|
733
|
+
let matchResult_1;
|
|
734
|
+
if (_arg_2.tag === 8) {
|
|
735
|
+
if (_arg_2.fields[0].tag === 1) {
|
|
736
|
+
matchResult_1 = 0;
|
|
737
|
+
}
|
|
738
|
+
else {
|
|
739
|
+
matchResult_1 = 1;
|
|
740
|
+
}
|
|
741
|
+
}
|
|
742
|
+
else {
|
|
743
|
+
matchResult_1 = 1;
|
|
744
|
+
}
|
|
745
|
+
switch (matchResult_1) {
|
|
746
|
+
case 0:
|
|
747
|
+
return true;
|
|
748
|
+
default:
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
}, flattenedCases);
|
|
752
|
+
if (isStringOnly) {
|
|
753
|
+
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), typeName, List_distinct(map((value) => {
|
|
754
|
+
let matchResult_2, value_1;
|
|
755
|
+
if (value.tag === 8) {
|
|
756
|
+
if (value.fields[0].tag === 0) {
|
|
757
|
+
matchResult_2 = 0;
|
|
758
|
+
value_1 = value.fields[0].fields[0];
|
|
759
|
+
}
|
|
760
|
+
else {
|
|
761
|
+
matchResult_2 = 1;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
else {
|
|
765
|
+
matchResult_2 = 1;
|
|
766
|
+
}
|
|
767
|
+
switch (matchResult_2) {
|
|
768
|
+
case 0: {
|
|
769
|
+
const sanitizeResult = sanitizeNameWithResult(value_1);
|
|
770
|
+
return new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(10, [removeSurroundingQuotes(value_1)])) : empty_1()))), sanitizeResult.Name);
|
|
771
|
+
}
|
|
772
|
+
default:
|
|
773
|
+
throw new Error("Should not happen");
|
|
774
|
+
}
|
|
775
|
+
}, flattenedCases), {
|
|
776
|
+
Equals: equals,
|
|
777
|
+
GetHashCode: safeHash,
|
|
778
|
+
}), false)]);
|
|
779
|
+
}
|
|
780
|
+
else if (isNumericOnly) {
|
|
781
|
+
return new FSharpType(0, [new FSharpEnum(typeName, List_distinct(map((value_2) => {
|
|
782
|
+
let matchResult_3, value_3;
|
|
783
|
+
if (value_2.tag === 8) {
|
|
784
|
+
if (value_2.fields[0].tag === 1) {
|
|
785
|
+
matchResult_3 = 0;
|
|
786
|
+
value_3 = value_2.fields[0].fields[0];
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
matchResult_3 = 1;
|
|
790
|
+
}
|
|
791
|
+
}
|
|
792
|
+
else {
|
|
793
|
+
matchResult_3 = 1;
|
|
794
|
+
}
|
|
795
|
+
switch (matchResult_3) {
|
|
796
|
+
case 0:
|
|
797
|
+
return new FSharpEnumCase(int32ToString(value_3), new FSharpLiteral(1, [value_3]));
|
|
798
|
+
default:
|
|
799
|
+
throw new Error("Should not happen");
|
|
800
|
+
}
|
|
801
|
+
}, flattenedCases), {
|
|
802
|
+
Equals: equals,
|
|
803
|
+
GetHashCode: safeHash,
|
|
804
|
+
}))]);
|
|
805
|
+
}
|
|
806
|
+
else if (forAll((_arg_3) => {
|
|
807
|
+
if (_arg_3.tag === 22) {
|
|
808
|
+
return true;
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
return false;
|
|
812
|
+
}
|
|
813
|
+
}, cases)) {
|
|
814
|
+
const members = collect_1((_arg_4) => {
|
|
815
|
+
if (_arg_4.tag === 22) {
|
|
816
|
+
return TransformMembers_toFSharpMember(context, _arg_4.fields[0].Members);
|
|
817
|
+
}
|
|
818
|
+
else {
|
|
819
|
+
return empty();
|
|
820
|
+
}
|
|
821
|
+
}, cases);
|
|
822
|
+
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeName, TransformContext__get_CurrentScopeName(context), empty(), members)]);
|
|
823
|
+
}
|
|
824
|
+
else {
|
|
825
|
+
return void 0;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
|
|
552
829
|
function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
553
|
-
let glueType_2;
|
|
554
830
|
const patternInput = sanitizeNameAndPushScope(glueTypeAliasDeclaration.Name, context);
|
|
555
831
|
const typeAliasName = patternInput[0];
|
|
556
832
|
const context_1 = patternInput[1];
|
|
833
|
+
const xmlDoc = transformComment(glueTypeAliasDeclaration.Documentation);
|
|
557
834
|
const matchValue = glueTypeAliasDeclaration.Type;
|
|
558
835
|
switch (matchValue.tag) {
|
|
559
836
|
case 9:
|
|
560
837
|
return TypeAliasDeclaration_transformKeyOf(glueTypeAliasDeclaration.Name, matchValue.fields[0]);
|
|
561
838
|
case 10: {
|
|
562
839
|
const glueType_1 = matchValue.fields[0];
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
840
|
+
let typ_2;
|
|
841
|
+
if (glueType_1.tag === 9) {
|
|
842
|
+
const glueType_2 = glueType_1.fields[0];
|
|
843
|
+
typ_2 = ((glueType_2.tag === 1) ? transformType(context_1, new GlueType(7, [new GlueTypeUnion(List_distinct(collect_1((m) => {
|
|
844
|
+
let typ_1;
|
|
845
|
+
switch (m.tag) {
|
|
846
|
+
case 1: {
|
|
847
|
+
typ_1 = m.fields[0].Type;
|
|
848
|
+
break;
|
|
849
|
+
}
|
|
850
|
+
case 2: {
|
|
851
|
+
typ_1 = m.fields[0].Type;
|
|
852
|
+
break;
|
|
853
|
+
}
|
|
854
|
+
case 5: {
|
|
855
|
+
typ_1 = m.fields[0].Type;
|
|
856
|
+
break;
|
|
857
|
+
}
|
|
858
|
+
case 4: {
|
|
859
|
+
typ_1 = m.fields[0].Type;
|
|
860
|
+
break;
|
|
861
|
+
}
|
|
862
|
+
case 3: {
|
|
863
|
+
typ_1 = m.fields[0].Type;
|
|
864
|
+
break;
|
|
865
|
+
}
|
|
866
|
+
default:
|
|
867
|
+
typ_1 = m.fields[0].Type;
|
|
577
868
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
break;
|
|
869
|
+
if (typ_1.tag === 7) {
|
|
870
|
+
return typ_1.fields[0].fields[0];
|
|
581
871
|
}
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
break;
|
|
872
|
+
else {
|
|
873
|
+
return singleton(typ_1);
|
|
585
874
|
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
}, glueType_2.fields[0].Members), {
|
|
596
|
-
Equals: equals,
|
|
597
|
-
GetHashCode: safeHash,
|
|
598
|
-
}))])) : (new FSharpType(9, [])))) : (new FSharpType(9, [])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
875
|
+
}, glueType_2.fields[0].Members), {
|
|
876
|
+
Equals: equals,
|
|
877
|
+
GetHashCode: safeHash,
|
|
878
|
+
}))])) : (new FSharpType(9, [])));
|
|
879
|
+
}
|
|
880
|
+
else {
|
|
881
|
+
typ_2 = (new FSharpType(9, []));
|
|
882
|
+
}
|
|
883
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, typ_2, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
599
884
|
}
|
|
600
885
|
case 8:
|
|
601
|
-
return TypeAliasDeclaration_transformLiteral(typeAliasName, matchValue.fields[0]);
|
|
886
|
+
return TypeAliasDeclaration_transformLiteral(xmlDoc, typeAliasName, matchValue.fields[0]);
|
|
602
887
|
case 3:
|
|
603
|
-
return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(7, [transformPrimitive(matchValue.fields[0])]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
888
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(7, [transformPrimitive(matchValue.fields[0])]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
604
889
|
case 13: {
|
|
605
890
|
const typeReference = matchValue.fields[0];
|
|
606
891
|
const context_2 = TransformContext__PushScope_Z721C83C5(context_1, typeReference.Name);
|
|
607
|
-
const handleDefaultCase = () => (new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformType(context_2, new GlueType(13, [typeReference])), transformTypeParameters(context_2, glueTypeAliasDeclaration.TypeParameters))]));
|
|
892
|
+
const handleDefaultCase = () => (new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_2, new GlueType(13, [typeReference])), transformTypeParameters(context_2, glueTypeAliasDeclaration.TypeParameters))]));
|
|
608
893
|
const matchValue_2 = typeReference.TypeArguments;
|
|
609
894
|
let matchResult_1, head;
|
|
610
895
|
if (!isEmpty(matchValue_2)) {
|
|
@@ -621,12 +906,12 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
621
906
|
}
|
|
622
907
|
switch (matchResult_1) {
|
|
623
908
|
case 0:
|
|
624
|
-
if (head.tag ===
|
|
909
|
+
if (head.tag === 21) {
|
|
625
910
|
const makeInterfaceTyp = (name) => (new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), name, glueTypeAliasDeclaration.Name, empty(), TransformMembers_toFSharpMember(context_2, head.fields[0])));
|
|
626
911
|
const exposedType = makeInterfaceTyp("ReturnType");
|
|
627
912
|
const typeArgument = makeInterfaceTyp(TransformContext__get_FullName(context_2) + ".ReturnType");
|
|
628
913
|
TransformContext__ExposeType_Z1D58A540(TransformContext__PushScope_Z721C83C5(context_2, typeReference.Name), new FSharpType(4, [exposedType]));
|
|
629
|
-
return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(10, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, singleton(new FSharpType(4, [typeArgument])), new FSharpType(9, []))]), empty())]);
|
|
914
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(10, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, singleton(new FSharpType(4, [typeArgument])), new FSharpType(9, []))]), empty())]);
|
|
630
915
|
}
|
|
631
916
|
else {
|
|
632
917
|
return handleDefaultCase();
|
|
@@ -636,7 +921,7 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
636
921
|
}
|
|
637
922
|
}
|
|
638
923
|
case 15:
|
|
639
|
-
return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformType(context_1, new GlueType(15, [matchValue.fields[0]])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
924
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_1, new GlueType(15, [matchValue.fields[0]])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
640
925
|
case 14: {
|
|
641
926
|
const originalInterface = transformInterface(context_1, matchValue.fields[0]);
|
|
642
927
|
return new FSharpType(4, [new FSharpInterface(originalInterface.Attributes, typeAliasName, originalInterface.OriginalName, originalInterface.TypeParameters, map((m_1) => {
|
|
@@ -661,141 +946,35 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
661
946
|
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), singleton(new FSharpMember(0, [new FSharpMemberInfo(singleton(new FSharpAttribute(1, [])), "Invoke", "Invoke", empty(), map((parameter) => transformParameter(context_1, parameter), functionType.Parameters), transformType(context_1, functionType.Type), false, false, void 0, new FSharpAccessibility(0, []), empty())])))]);
|
|
662
947
|
}
|
|
663
948
|
case 19:
|
|
664
|
-
return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, transformTupleType(context_1, matchValue.fields[0]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
665
|
-
case 20:
|
|
666
|
-
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0]))]);
|
|
949
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformTupleType(context_1, matchValue.fields[0]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
667
950
|
case 21:
|
|
951
|
+
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0]))]);
|
|
952
|
+
case 22:
|
|
668
953
|
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(18, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0].Members))]);
|
|
669
|
-
case
|
|
670
|
-
return new FSharpType(8, [new FSharpTypeAlias(typeAliasName, new FSharpType(17, []), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
954
|
+
case 24:
|
|
955
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(17, []), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
956
|
+
case 17:
|
|
957
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(12, [matchValue.fields[0]]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
671
958
|
case 12:
|
|
672
959
|
case 4:
|
|
673
960
|
case 1:
|
|
674
961
|
case 11:
|
|
675
962
|
case 5:
|
|
676
|
-
case 17:
|
|
677
963
|
case 0:
|
|
678
964
|
case 6:
|
|
679
965
|
case 18:
|
|
680
966
|
case 2:
|
|
681
|
-
case
|
|
682
|
-
case
|
|
967
|
+
case 25:
|
|
968
|
+
case 20:
|
|
969
|
+
case 23:
|
|
683
970
|
return new FSharpType(9, []);
|
|
684
971
|
default: {
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
return singleton(_arg);
|
|
689
|
-
case 7:
|
|
690
|
-
return flattenCases(_arg.fields[0].fields[0]);
|
|
691
|
-
case 5: {
|
|
692
|
-
const matchValue_1 = _arg.fields[0].Type;
|
|
693
|
-
if (matchValue_1.tag === 7) {
|
|
694
|
-
return flattenCases(matchValue_1.fields[0].fields[0]);
|
|
695
|
-
}
|
|
696
|
-
else {
|
|
697
|
-
return empty();
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
default:
|
|
701
|
-
return empty();
|
|
702
|
-
}
|
|
703
|
-
}, cases_1);
|
|
704
|
-
const flattenedCases = flattenCases(matchValue.fields[0].fields[0]);
|
|
705
|
-
const isStringOnly = !isEmpty(flattenedCases) && forAll((_arg_1) => {
|
|
706
|
-
let matchResult_2;
|
|
707
|
-
if (_arg_1.tag === 8) {
|
|
708
|
-
if (_arg_1.fields[0].tag === 0) {
|
|
709
|
-
matchResult_2 = 0;
|
|
710
|
-
}
|
|
711
|
-
else {
|
|
712
|
-
matchResult_2 = 1;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
else {
|
|
716
|
-
matchResult_2 = 1;
|
|
717
|
-
}
|
|
718
|
-
switch (matchResult_2) {
|
|
719
|
-
case 0:
|
|
720
|
-
return true;
|
|
721
|
-
default:
|
|
722
|
-
return false;
|
|
723
|
-
}
|
|
724
|
-
}, flattenedCases);
|
|
725
|
-
const isNumericOnly = !isEmpty(flattenedCases) && forAll((_arg_2) => {
|
|
726
|
-
let matchResult_3;
|
|
727
|
-
if (_arg_2.tag === 8) {
|
|
728
|
-
if (_arg_2.fields[0].tag === 1) {
|
|
729
|
-
matchResult_3 = 0;
|
|
730
|
-
}
|
|
731
|
-
else {
|
|
732
|
-
matchResult_3 = 1;
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
else {
|
|
736
|
-
matchResult_3 = 1;
|
|
737
|
-
}
|
|
738
|
-
switch (matchResult_3) {
|
|
739
|
-
case 0:
|
|
740
|
-
return true;
|
|
741
|
-
default:
|
|
742
|
-
return false;
|
|
743
|
-
}
|
|
744
|
-
}, flattenedCases);
|
|
745
|
-
if (isStringOnly) {
|
|
746
|
-
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(11, []), new FSharpAttribute(9, [0])]), typeAliasName, List_distinct(map((value) => {
|
|
747
|
-
let matchResult_4, value_1;
|
|
748
|
-
if (value.tag === 8) {
|
|
749
|
-
if (value.fields[0].tag === 0) {
|
|
750
|
-
matchResult_4 = 0;
|
|
751
|
-
value_1 = value.fields[0].fields[0];
|
|
752
|
-
}
|
|
753
|
-
else {
|
|
754
|
-
matchResult_4 = 1;
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
else {
|
|
758
|
-
matchResult_4 = 1;
|
|
759
|
-
}
|
|
760
|
-
switch (matchResult_4) {
|
|
761
|
-
case 0:
|
|
762
|
-
return new FSharpUnionCase(empty(), sanitizeName(removeDoubleQuote(removeSingleQuote(value_1))));
|
|
763
|
-
default:
|
|
764
|
-
throw new Error("Should not happen");
|
|
765
|
-
}
|
|
766
|
-
}, flattenedCases), {
|
|
767
|
-
Equals: equals,
|
|
768
|
-
GetHashCode: safeHash,
|
|
769
|
-
}), false)]);
|
|
770
|
-
}
|
|
771
|
-
else if (isNumericOnly) {
|
|
772
|
-
return new FSharpType(0, [new FSharpEnum(typeAliasName, List_distinct(map((value_2) => {
|
|
773
|
-
let matchResult_5, value_3;
|
|
774
|
-
if (value_2.tag === 8) {
|
|
775
|
-
if (value_2.fields[0].tag === 1) {
|
|
776
|
-
matchResult_5 = 0;
|
|
777
|
-
value_3 = value_2.fields[0].fields[0];
|
|
778
|
-
}
|
|
779
|
-
else {
|
|
780
|
-
matchResult_5 = 1;
|
|
781
|
-
}
|
|
782
|
-
}
|
|
783
|
-
else {
|
|
784
|
-
matchResult_5 = 1;
|
|
785
|
-
}
|
|
786
|
-
switch (matchResult_5) {
|
|
787
|
-
case 0:
|
|
788
|
-
return new FSharpEnumCase(int32ToString(value_3), new FSharpLiteral(1, [value_3]));
|
|
789
|
-
default:
|
|
790
|
-
throw new Error("Should not happen");
|
|
791
|
-
}
|
|
792
|
-
}, flattenedCases), {
|
|
793
|
-
Equals: equals,
|
|
794
|
-
GetHashCode: safeHash,
|
|
795
|
-
}))]);
|
|
972
|
+
const matchValue_1 = tryOptimizeUnionType(context_1, typeAliasName, matchValue.fields[0].fields[0]);
|
|
973
|
+
if (matchValue_1 == null) {
|
|
974
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_1, matchValue), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
796
975
|
}
|
|
797
976
|
else {
|
|
798
|
-
return
|
|
977
|
+
return matchValue_1;
|
|
799
978
|
}
|
|
800
979
|
}
|
|
801
980
|
}
|
|
@@ -823,7 +1002,7 @@ function transformToFsharp(context, glueTypes) {
|
|
|
823
1002
|
return transformModuleDeclaration(_arg.fields[0]);
|
|
824
1003
|
case 12:
|
|
825
1004
|
return transformClassDeclaration(context, _arg.fields[0]);
|
|
826
|
-
case
|
|
1005
|
+
case 25: {
|
|
827
1006
|
const exportedType = _arg.fields[0];
|
|
828
1007
|
if (exportedType.tag === 12) {
|
|
829
1008
|
return transformClassDeclaration(context, exportedType.fields[0]);
|
|
@@ -843,13 +1022,14 @@ function transformToFsharp(context, glueTypes) {
|
|
|
843
1022
|
case 8:
|
|
844
1023
|
case 2:
|
|
845
1024
|
case 3:
|
|
846
|
-
case
|
|
1025
|
+
case 24:
|
|
847
1026
|
case 9:
|
|
848
1027
|
case 0:
|
|
849
1028
|
case 19:
|
|
850
|
-
case 20:
|
|
851
1029
|
case 21:
|
|
852
1030
|
case 22:
|
|
1031
|
+
case 23:
|
|
1032
|
+
case 20:
|
|
853
1033
|
case 18:
|
|
854
1034
|
return new FSharpType(9, []);
|
|
855
1035
|
default:
|
|
@@ -864,7 +1044,7 @@ export function transform(isTopLevel, glueAst) {
|
|
|
864
1044
|
case 2:
|
|
865
1045
|
case 6:
|
|
866
1046
|
return true;
|
|
867
|
-
case
|
|
1047
|
+
case 25:
|
|
868
1048
|
if (glueType.fields[0].tag === 2) {
|
|
869
1049
|
return true;
|
|
870
1050
|
}
|
|
@@ -889,7 +1069,7 @@ export function transform(isTopLevel, glueAst) {
|
|
|
889
1069
|
return false;
|
|
890
1070
|
}
|
|
891
1071
|
}, glueType_1.fields[0].Types);
|
|
892
|
-
case
|
|
1072
|
+
case 25:
|
|
893
1073
|
if (glueType_1.fields[0].tag === 12) {
|
|
894
1074
|
return true;
|
|
895
1075
|
}
|