@glutinum/cli 0.8.0 → 0.10.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/dist/Glutinum.Converter/FsharpAST.js +21 -8
- package/dist/Glutinum.Converter/FsharpAST.js.map +1 -1
- package/dist/Glutinum.Converter/Generate.js +23 -8
- package/dist/Glutinum.Converter/Generate.js.map +1 -1
- package/dist/Glutinum.Converter/GlueAST.js +51 -16
- package/dist/Glutinum.Converter/GlueAST.js.map +1 -1
- package/dist/Glutinum.Converter/Merge.js +86 -0
- package/dist/Glutinum.Converter/Merge.js.map +1 -0
- package/dist/Glutinum.Converter/Printer.js +61 -25
- package/dist/Glutinum.Converter/Printer.js.map +1 -1
- package/dist/Glutinum.Converter/Read.js +5 -2
- package/dist/Glutinum.Converter/Read.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +1 -1
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +1 -1
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +2 -2
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/NamedTupleMember.js +1 -1
- package/dist/Glutinum.Converter/Reader/Node.js +1 -1
- package/dist/Glutinum.Converter/Reader/TypeNode.js +166 -123
- package/dist/Glutinum.Converter/Reader/TypeNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -1
- package/dist/Glutinum.Converter/Reader/TypeParameters.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +8 -1
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +8 -5
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js.map +1 -1
- package/dist/Glutinum.Converter/Reader/Utils.js +41 -6
- package/dist/Glutinum.Converter/Reader/Utils.js.map +1 -1
- package/dist/Glutinum.Converter/Transform.js +374 -120
- package/dist/Glutinum.Converter/Transform.js.map +1 -1
- package/dist/Glutinum.Converter/Utils/Naming.js +0 -19
- package/dist/Glutinum.Converter/Utils/Naming.js.map +1 -1
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
|
@@ -1,26 +1,46 @@
|
|
|
1
|
+
import { bool_type, array_type, string_type, record_type, list_type, class_type } from "../fable_modules/fable-library-js.4.14.0/Reflection.js";
|
|
1
2
|
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
3
|
import { Record } from "../fable_modules/fable-library-js.4.14.0/Types.js";
|
|
4
|
-
import { FSharpTypeParameter_Create_Z6CFD3565, FSharpTypeAlias, FSharpEnum, FSharpEnumCase, FSharpStaticMemberInfo, FSharpAccessor,
|
|
4
|
+
import { FSharpTypeParameter_Create_Z6CFD3565, FSharpTypeAlias, FSharpEnum, FSharpEnumCase, FSharpUnionCaseNamed, FSharpStaticMemberInfo, FSharpAccessor, FSharpMember, FSharpMemberInfo, FSharpMemberInfoBody, FSharpMapped, FSharpInterface, FSharpClass, FSharpConstructor, FSharpAccessibility, FSharpExplicitField, FSharpParameter, FSharpFunctionType, FSharpTypeReference, FSharpUnion, FSharpUnionCase, FSharpPrimitive, FSharpLiteral, FSharpCommentTypeParam, FSharpCommentParam, FSharpXmlDoc, FSharpAttribute, FSharpType, FSharpModule, FSharpType_$reflection, FSharpXmlDoc_$reflection, FSharpAttribute_$reflection } from "./FsharpAST.js";
|
|
5
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";
|
|
6
|
-
import { exists,
|
|
7
|
-
import { sanitizeNameWithResult, removeSurroundingQuotes,
|
|
8
|
-
import { unwrap, value as value_4, map as map_1, defaultArg } from "../fable_modules/fable-library-js.4.14.0/Option.js";
|
|
6
|
+
import { exists, item, concat, tryFind, choose, collect as collect_1, ofArray, forAll, filter, mapIndexed, 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, sanitizeName } from "./Utils/Naming.js";
|
|
8
|
+
import { bind, 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 { GlueType, GlueTypeUnion, GlueMember, GlueProperty, GlueAccessor,
|
|
11
|
-
import { warn, error } from "./Log.js";
|
|
10
|
+
import { GlueType, GlueTypeUnion, GlueMember, GlueProperty, GlueAccessor, GlueType__get_Name, GlueConstructor } from "./GlueAST.js";
|
|
12
11
|
import { List_distinct } from "../fable_modules/fable-library-js.4.14.0/Seq2.js";
|
|
12
|
+
import { apply as apply_1 } from "./Merge.js";
|
|
13
|
+
|
|
14
|
+
export class Reporter {
|
|
15
|
+
constructor() {
|
|
16
|
+
this["Warnings@"] = [];
|
|
17
|
+
this["Errors@"] = [];
|
|
18
|
+
this["HasRegEpx@"] = false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function Reporter_$reflection() {
|
|
23
|
+
return class_type("Glutinum.Converter.Transform.Reporter", void 0, Reporter);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function Reporter_$ctor() {
|
|
27
|
+
return new Reporter();
|
|
28
|
+
}
|
|
13
29
|
|
|
14
30
|
export class TransformContext {
|
|
15
|
-
constructor(currentScopeName, parent) {
|
|
31
|
+
constructor(reporter, currentScopeName, typeMemory, parent) {
|
|
16
32
|
let matchValue;
|
|
33
|
+
this.reporter = reporter;
|
|
17
34
|
this.currentScopeName = currentScopeName;
|
|
35
|
+
this.typeMemory = typeMemory;
|
|
18
36
|
this.parent = parent;
|
|
19
37
|
this.types = [];
|
|
20
38
|
this.modules = [];
|
|
21
39
|
this["FullName@"] = ((matchValue = this.parent, (matchValue != null) ? trimStart((TransformContext__get_FullName(matchValue) + ".") + this.currentScopeName, ".") : ""));
|
|
22
40
|
this["CurrentScopeName@"] = this.currentScopeName;
|
|
41
|
+
this["TypeMemory@"] = this.typeMemory;
|
|
23
42
|
this["_types@"] = this.types;
|
|
43
|
+
this["_Reporter@"] = this.reporter;
|
|
24
44
|
}
|
|
25
45
|
}
|
|
26
46
|
|
|
@@ -28,8 +48,8 @@ export function TransformContext_$reflection() {
|
|
|
28
48
|
return class_type("Glutinum.Converter.Transform.TransformContext", void 0, TransformContext);
|
|
29
49
|
}
|
|
30
50
|
|
|
31
|
-
export function TransformContext_$
|
|
32
|
-
return new TransformContext(currentScopeName, parent);
|
|
51
|
+
export function TransformContext_$ctor_Z4CBC0890(reporter, currentScopeName, typeMemory, parent) {
|
|
52
|
+
return new TransformContext(reporter, currentScopeName, typeMemory, parent);
|
|
33
53
|
}
|
|
34
54
|
|
|
35
55
|
export class TransformCommentResult extends Record {
|
|
@@ -44,6 +64,36 @@ export function TransformCommentResult_$reflection() {
|
|
|
44
64
|
return record_type("Glutinum.Converter.Transform.TransformCommentResult", [], TransformCommentResult, () => [["ObsoleteAttributes", list_type(FSharpAttribute_$reflection())], ["XmlDoc", list_type(FSharpXmlDoc_$reflection())]]);
|
|
45
65
|
}
|
|
46
66
|
|
|
67
|
+
export class TransformResult extends Record {
|
|
68
|
+
constructor(FSharpAST, Warnings, Errors, IncludeRegExpAlias) {
|
|
69
|
+
super();
|
|
70
|
+
this.FSharpAST = FSharpAST;
|
|
71
|
+
this.Warnings = Warnings;
|
|
72
|
+
this.Errors = Errors;
|
|
73
|
+
this.IncludeRegExpAlias = IncludeRegExpAlias;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function TransformResult_$reflection() {
|
|
78
|
+
return record_type("Glutinum.Converter.Transform.TransformResult", [], TransformResult, () => [["FSharpAST", list_type(FSharpType_$reflection())], ["Warnings", array_type(string_type)], ["Errors", array_type(string_type)], ["IncludeRegExpAlias", bool_type]]);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function Reporter__get_Warnings(__) {
|
|
82
|
+
return __["Warnings@"];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function Reporter__get_Errors(__) {
|
|
86
|
+
return __["Errors@"];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function Reporter__get_HasRegEpx(__) {
|
|
90
|
+
return __["HasRegEpx@"];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export function Reporter__set_HasRegEpx_Z1FBCCD16(__, v) {
|
|
94
|
+
__["HasRegEpx@"] = v;
|
|
95
|
+
}
|
|
96
|
+
|
|
47
97
|
export function TransformContext__get_FullName(__) {
|
|
48
98
|
return __["FullName@"];
|
|
49
99
|
}
|
|
@@ -52,10 +102,22 @@ export function TransformContext__get_CurrentScopeName(__) {
|
|
|
52
102
|
return __["CurrentScopeName@"];
|
|
53
103
|
}
|
|
54
104
|
|
|
105
|
+
export function TransformContext__get_TypeMemory(__) {
|
|
106
|
+
return __["TypeMemory@"];
|
|
107
|
+
}
|
|
108
|
+
|
|
55
109
|
export function TransformContext__get__types(__) {
|
|
56
110
|
return __["_types@"];
|
|
57
111
|
}
|
|
58
112
|
|
|
113
|
+
export function TransformContext__get__Reporter(__) {
|
|
114
|
+
return __["_Reporter@"];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function TransformContext__ExposeRegExp(_) {
|
|
118
|
+
Reporter__set_HasRegEpx_Z1FBCCD16(_.reporter, true);
|
|
119
|
+
}
|
|
120
|
+
|
|
59
121
|
export function TransformContext__ExposeType_Z1D58A540(_, typ) {
|
|
60
122
|
const matchValue = _.parent;
|
|
61
123
|
if (matchValue != null) {
|
|
@@ -68,7 +130,7 @@ export function TransformContext__ExposeType_Z1D58A540(_, typ) {
|
|
|
68
130
|
}
|
|
69
131
|
|
|
70
132
|
export function TransformContext__PushScope_Z721C83C5(this$, scopeName) {
|
|
71
|
-
const childContext = TransformContext_$
|
|
133
|
+
const childContext = TransformContext_$ctor_Z4CBC0890(this$.reporter, scopeName, this$.typeMemory, this$);
|
|
72
134
|
void (this$.modules.push(childContext));
|
|
73
135
|
return childContext;
|
|
74
136
|
}
|
|
@@ -88,6 +150,58 @@ export function TransformContext__ToList(_) {
|
|
|
88
150
|
}
|
|
89
151
|
}
|
|
90
152
|
|
|
153
|
+
export function TransformContext__AddWarning_Z721C83C5(_, warning) {
|
|
154
|
+
void (Reporter__get_Warnings(_.reporter).push(warning));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function TransformContext__AddError_Z721C83C5(_, error) {
|
|
158
|
+
void (Reporter__get_Errors(_.reporter).push(error));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function mapTypeNameToFableCoreAwareName(context, typeReference) {
|
|
162
|
+
if (typeReference.IsStandardLibrary) {
|
|
163
|
+
const matchValue = typeReference.Name;
|
|
164
|
+
switch (matchValue) {
|
|
165
|
+
case "Date":
|
|
166
|
+
return "JS.Date";
|
|
167
|
+
case "Promise":
|
|
168
|
+
return "JS.Promise";
|
|
169
|
+
case "Uint8Array":
|
|
170
|
+
return "JS.Uint8Array";
|
|
171
|
+
case "ReadonlyArray":
|
|
172
|
+
return "ResizeArray";
|
|
173
|
+
case "Array":
|
|
174
|
+
return "ResizeArray";
|
|
175
|
+
case "Boolean":
|
|
176
|
+
return "bool";
|
|
177
|
+
case "RegExp": {
|
|
178
|
+
TransformContext__ExposeRegExp(context);
|
|
179
|
+
return "RegExp";
|
|
180
|
+
}
|
|
181
|
+
default:
|
|
182
|
+
return matchValue;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return typeReference.Name;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function unwrapOptionIfAlreadyOptional(context, typ, isOptional) {
|
|
191
|
+
const typ$0027 = transformType(context, typ);
|
|
192
|
+
if (isOptional) {
|
|
193
|
+
if (typ$0027.tag === 2) {
|
|
194
|
+
return typ$0027.fields[0];
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
return typ$0027;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return typ$0027;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
91
205
|
function sanitizeNameAndPushScope(name, context) {
|
|
92
206
|
const name_1 = sanitizeName(name);
|
|
93
207
|
return [name_1, TransformContext__PushScope_Z721C83C5(context, name_1)];
|
|
@@ -256,11 +370,13 @@ function transformType(context_mut, glueType_mut) {
|
|
|
256
370
|
switch (glueType.tag) {
|
|
257
371
|
case 3:
|
|
258
372
|
return new FSharpType(7, [transformPrimitive(glueType.fields[0])]);
|
|
259
|
-
case
|
|
373
|
+
case 25:
|
|
374
|
+
return new FSharpType(7, [new FSharpPrimitive(0, [])]);
|
|
375
|
+
case 22:
|
|
260
376
|
return new FSharpType(2, [transformType(context, glueType.fields[0])]);
|
|
261
|
-
case
|
|
377
|
+
case 17:
|
|
262
378
|
return new FSharpType(14, [glueType.fields[0]]);
|
|
263
|
-
case
|
|
379
|
+
case 18:
|
|
264
380
|
return transformTupleType(context, glueType.fields[0]);
|
|
265
381
|
case 7: {
|
|
266
382
|
const patternInput = partition((glueType_2) => {
|
|
@@ -291,7 +407,8 @@ function transformType(context_mut, glueType_mut) {
|
|
|
291
407
|
else {
|
|
292
408
|
const matchValue = tryOptimizeUnionType(context, TransformContext__get_CurrentScopeName(context), others);
|
|
293
409
|
if (matchValue == null) {
|
|
294
|
-
|
|
410
|
+
const patternInput_1 = sanitizeNameAndPushScope(`U${length(others)}`, context);
|
|
411
|
+
return new FSharpType(1, [new FSharpUnion(empty(), patternInput_1[0], mapIndexed((index, caseType) => (new FSharpUnionCase(1, [transformType(TransformContext__PushScope_Z721C83C5(patternInput_1[1], `Case${index + 1}`), caseType)])), others), isOptional)]);
|
|
295
412
|
}
|
|
296
413
|
else {
|
|
297
414
|
TransformContext__ExposeType_Z1D58A540(context, matchValue);
|
|
@@ -301,23 +418,23 @@ function transformType(context_mut, glueType_mut) {
|
|
|
301
418
|
}
|
|
302
419
|
case 13: {
|
|
303
420
|
const typeReference = glueType.fields[0];
|
|
304
|
-
return new FSharpType(10, [new FSharpTypeReference(mapTypeNameToFableCoreAwareName(typeReference
|
|
421
|
+
return new FSharpType(10, [new FSharpTypeReference(mapTypeNameToFableCoreAwareName(context, typeReference), typeReference.FullName, map((glueType_3) => transformType(context, glueType_3), typeReference.TypeArguments), new FSharpType(7, [new FSharpPrimitive(0, [])]))]);
|
|
305
422
|
}
|
|
306
|
-
case
|
|
423
|
+
case 14:
|
|
307
424
|
return new FSharpType(13, [transformType(context, glueType.fields[0])]);
|
|
308
425
|
case 12: {
|
|
309
426
|
const classDeclaration = glueType.fields[0];
|
|
310
427
|
return new FSharpType(10, [new FSharpTypeReference(classDeclaration.Name, classDeclaration.Name, empty(), new FSharpType(9, []))]);
|
|
311
428
|
}
|
|
312
|
-
case
|
|
429
|
+
case 16:
|
|
313
430
|
return new FSharpType(12, [glueType.fields[0]]);
|
|
314
|
-
case
|
|
431
|
+
case 15: {
|
|
315
432
|
const functionTypeInfo = glueType.fields[0];
|
|
316
|
-
return new FSharpType(15, [new FSharpFunctionType(map((
|
|
433
|
+
return new FSharpType(15, [new FSharpFunctionType(map((parameter_1) => transformParameter(context, parameter_1), filter((parameter) => (parameter.Name !== "this"), functionTypeInfo.Parameters)), transformType(context, functionTypeInfo.Type))]);
|
|
317
434
|
}
|
|
318
435
|
case 1:
|
|
319
436
|
return new FSharpType(4, [transformInterface(context, glueType.fields[0])]);
|
|
320
|
-
case
|
|
437
|
+
case 21: {
|
|
321
438
|
const typeLiteralInfo = glueType.fields[0];
|
|
322
439
|
if (forAll((_arg) => {
|
|
323
440
|
switch (_arg.tag) {
|
|
@@ -333,18 +450,18 @@ function transformType(context_mut, glueType_mut) {
|
|
|
333
450
|
return false;
|
|
334
451
|
}
|
|
335
452
|
}, typeLiteralInfo.Members)) {
|
|
336
|
-
const typeLiteralParameters = sortBy((_arg_1) => _arg_1.IsOptional, map((
|
|
337
|
-
const matchValue_1 =
|
|
453
|
+
const typeLiteralParameters = sortBy((_arg_1) => _arg_1.IsOptional, map((parameter_2) => {
|
|
454
|
+
const matchValue_1 = parameter_2.Type;
|
|
338
455
|
if (matchValue_1.tag === 2) {
|
|
339
|
-
return new FSharpParameter(
|
|
456
|
+
return new FSharpParameter(parameter_2.Attributes, parameter_2.Name, true, matchValue_1.fields[0]);
|
|
340
457
|
}
|
|
341
458
|
else {
|
|
342
|
-
return
|
|
459
|
+
return parameter_2;
|
|
343
460
|
}
|
|
344
461
|
}, TransformMembers_toFSharpParameters(context, typeLiteralInfo.Members)), {
|
|
345
462
|
Compare: comparePrimitives,
|
|
346
463
|
});
|
|
347
|
-
const explicitFields = map((
|
|
464
|
+
const explicitFields = map((parameter_3) => (new FSharpExplicitField(parameter_3.Name, parameter_3.IsOptional ? (new FSharpType(2, [parameter_3.Type])) : parameter_3.Type)), typeLiteralParameters);
|
|
348
465
|
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(16, [new FSharpClass(ofArray([new FSharpAttribute(17, []), new FSharpAttribute(8, [])]), TransformContext__get_CurrentScopeName(context), empty(), new FSharpConstructor(typeLiteralParameters, ofArray([new FSharpAttribute(18, []), new FSharpAttribute(2, [])]), new FSharpAccessibility(0, [])), empty(), explicitFields)]));
|
|
349
466
|
}
|
|
350
467
|
else {
|
|
@@ -352,7 +469,7 @@ function transformType(context_mut, glueType_mut) {
|
|
|
352
469
|
}
|
|
353
470
|
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
354
471
|
}
|
|
355
|
-
case
|
|
472
|
+
case 24: {
|
|
356
473
|
context_mut = context;
|
|
357
474
|
glueType_mut = glueType.fields[0];
|
|
358
475
|
continue transformType;
|
|
@@ -372,25 +489,59 @@ function transformType(context_mut, glueType_mut) {
|
|
|
372
489
|
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
373
490
|
}
|
|
374
491
|
}
|
|
375
|
-
case
|
|
492
|
+
case 19: {
|
|
376
493
|
context_mut = context;
|
|
377
494
|
glueType_mut = glueType.fields[0].Type;
|
|
378
495
|
continue transformType;
|
|
379
496
|
}
|
|
380
|
-
case 14: {
|
|
381
|
-
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(4, [(originalInterface = transformInterface(context, glueType.fields[0]), Interface_makePartial(TransformContext__get_CurrentScopeName(context), originalInterface))]));
|
|
382
|
-
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
383
|
-
}
|
|
384
497
|
case 0:
|
|
385
498
|
return new FSharpType(17, []);
|
|
499
|
+
case 8: {
|
|
500
|
+
const glueLiteral = glueType.fields[0];
|
|
501
|
+
switch (glueLiteral.tag) {
|
|
502
|
+
case 1:
|
|
503
|
+
return new FSharpType(7, [new FSharpPrimitive(1, [])]);
|
|
504
|
+
case 2:
|
|
505
|
+
return new FSharpType(7, [new FSharpPrimitive(2, [])]);
|
|
506
|
+
case 3:
|
|
507
|
+
return new FSharpType(7, [new FSharpPrimitive(3, [])]);
|
|
508
|
+
case 4:
|
|
509
|
+
return new FSharpType(7, [new FSharpPrimitive(6, [])]);
|
|
510
|
+
default:
|
|
511
|
+
return new FSharpType(7, [new FSharpPrimitive(0, [])]);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
case 6: {
|
|
515
|
+
const functionDeclaration = glueType.fields[0];
|
|
516
|
+
return new FSharpType(15, [new FSharpFunctionType(map((parameter_4) => transformParameter(context, parameter_4), functionDeclaration.Parameters), transformType(context, functionDeclaration.Type))]);
|
|
517
|
+
}
|
|
518
|
+
case 20: {
|
|
519
|
+
const members_1 = glueType.fields[0];
|
|
520
|
+
if (isEmpty(members_1)) {
|
|
521
|
+
return new FSharpType(17, []);
|
|
522
|
+
}
|
|
523
|
+
else {
|
|
524
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), TransformContext__get_CurrentScopeName(context), TransformContext__get_CurrentScopeName(context), empty(), TransformMembers_toFSharpMember(context, members_1), empty())]));
|
|
525
|
+
return new FSharpType(6, [new FSharpMapped(TransformContext__get_FullName(context), empty())]);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
case 26: {
|
|
529
|
+
const utilityType = glueType.fields[0];
|
|
530
|
+
if (utilityType.tag === 1) {
|
|
531
|
+
TransformContext__ExposeType_Z1D58A540(context, transformRecord(context, TransformContext__get_CurrentScopeName(context), empty(), utilityType.fields[0]));
|
|
532
|
+
return new FSharpType(6, [new FSharpMapped(TransformContext__get_FullName(context), empty())]);
|
|
533
|
+
}
|
|
534
|
+
else {
|
|
535
|
+
TransformContext__ExposeType_Z1D58A540(context, new FSharpType(4, [(originalInterface = transformInterface(context, utilityType.fields[0]), Interface_makePartial(TransformContext__get_CurrentScopeName(context), originalInterface))]));
|
|
536
|
+
return new FSharpType(10, [new FSharpTypeReference(TransformContext__get_FullName(context), TransformContext__get_FullName(context), empty(), new FSharpType(9, []))]);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
case 5:
|
|
540
|
+
return new FSharpType(6, [new FSharpMapped(glueType.fields[0].Name, empty())]);
|
|
386
541
|
case 11:
|
|
387
542
|
case 10:
|
|
388
|
-
case
|
|
389
|
-
|
|
390
|
-
case 5:
|
|
391
|
-
case 21:
|
|
392
|
-
case 6: {
|
|
393
|
-
error(toText(interpolate("Could not transform type: %A%P()", [glueType])));
|
|
543
|
+
case 4: {
|
|
544
|
+
TransformContext__AddError_Z721C83C5(context, toText(interpolate("Could not transform type: %A%P()", [glueType])));
|
|
394
545
|
return new FSharpType(9, []);
|
|
395
546
|
}
|
|
396
547
|
default:
|
|
@@ -404,57 +555,82 @@ function transformExports(context, isTopLevel, exports) {
|
|
|
404
555
|
const context_1 = TransformContext__PushScope_Z721C83C5(context, "Exports");
|
|
405
556
|
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(7, []), new FSharpAttribute(6, [])]), "Exports", "Exports", empty(), collect_1((_arg) => {
|
|
406
557
|
let Attributes_1, Parameters_1;
|
|
558
|
+
let matchResult, info, info_1, info_2, moduleDeclaration, glueType, glueType_1;
|
|
407
559
|
switch (_arg.tag) {
|
|
408
560
|
case 2: {
|
|
409
|
-
|
|
561
|
+
matchResult = 0;
|
|
562
|
+
info = _arg.fields[0];
|
|
563
|
+
break;
|
|
564
|
+
}
|
|
565
|
+
case 6: {
|
|
566
|
+
matchResult = 1;
|
|
567
|
+
info_1 = _arg.fields[0];
|
|
568
|
+
break;
|
|
569
|
+
}
|
|
570
|
+
case 12: {
|
|
571
|
+
matchResult = 2;
|
|
572
|
+
info_2 = _arg.fields[0];
|
|
573
|
+
break;
|
|
574
|
+
}
|
|
575
|
+
case 24: {
|
|
576
|
+
if (_arg.fields[0].tag === 12) {
|
|
577
|
+
matchResult = 2;
|
|
578
|
+
info_2 = _arg.fields[0].fields[0];
|
|
579
|
+
}
|
|
580
|
+
else {
|
|
581
|
+
matchResult = 4;
|
|
582
|
+
glueType = _arg.fields[0];
|
|
583
|
+
}
|
|
584
|
+
break;
|
|
585
|
+
}
|
|
586
|
+
case 11: {
|
|
587
|
+
matchResult = 3;
|
|
588
|
+
moduleDeclaration = _arg.fields[0];
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
default: {
|
|
592
|
+
matchResult = 5;
|
|
593
|
+
glueType_1 = _arg;
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
switch (matchResult) {
|
|
597
|
+
case 0: {
|
|
410
598
|
const patternInput = sanitizeNameAndPushScope(info.Name, context_1);
|
|
411
599
|
const xmlDocInfo = transformComment(info.Documentation);
|
|
412
600
|
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, new FSharpMemberInfoBody(0, []))]));
|
|
413
601
|
}
|
|
414
|
-
case
|
|
415
|
-
const info_1 = _arg.fields[0];
|
|
602
|
+
case 1: {
|
|
416
603
|
const patternInput_1 = sanitizeNameAndPushScope(info_1.Name, context_1);
|
|
417
604
|
const context_3 = patternInput_1[1];
|
|
418
605
|
const xmlDocInfo_1 = transformComment(info_1.Documentation);
|
|
419
606
|
return singleton(new FSharpMember(0, [(Attributes_1 = toList(delay(() => append(isTopLevel ? singleton_1(new FSharpAttribute(3, [info_1.Name, "REPLACE_ME_WITH_MODULE_NAME"])) : singleton_1(new FSharpAttribute(15, [info_1.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, isTopLevel, void 0, new FSharpAccessibility(0, []), xmlDocInfo_1.XmlDoc, new FSharpMemberInfoBody(0, []))))]));
|
|
420
607
|
}
|
|
421
|
-
case
|
|
422
|
-
const info_2 = _arg.fields[0];
|
|
608
|
+
case 2: {
|
|
423
609
|
const patternInput_2 = sanitizeNameAndPushScope(info_2.Name, context_1);
|
|
424
610
|
const context_4 = patternInput_2[1];
|
|
425
611
|
return map((constructorInfo) => {
|
|
426
612
|
let Attributes_2, Parameters_2;
|
|
427
613
|
const xmlDocInfo_2 = transformComment(constructorInfo.Documentation);
|
|
428
|
-
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(13, [])))) : singleton_1(new FSharpAttribute(14, [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),
|
|
614
|
+
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(13, [])))) : singleton_1(new FSharpAttribute(14, [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), transformTypeParameters(context_4, info_2.TypeParameters))]), false, isTopLevel, void 0, new FSharpAccessibility(0, []), xmlDocInfo_2.XmlDoc, new FSharpMemberInfoBody(0, []))))]);
|
|
429
615
|
}, isEmpty(info_2.Constructors) ? singleton(new GlueConstructor(empty(), empty())) : info_2.Constructors);
|
|
430
616
|
}
|
|
431
|
-
case
|
|
432
|
-
const
|
|
433
|
-
return
|
|
434
|
-
switch (typ.tag) {
|
|
435
|
-
case 12:
|
|
436
|
-
return new FSharpMember(1, [new FSharpMemberInfo(ofArray([new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"]), new FSharpAttribute(0, [`Emit("$0.${moduleDeclaration.Name}")`])]), moduleDeclaration.Name + "_", moduleDeclaration.Name, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${moduleDeclaration.Name}.Exports`, empty(), empty())]), false, true, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
|
|
437
|
-
case 6:
|
|
438
|
-
return new FSharpMember(1, [new FSharpMemberInfo(ofArray([new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"]), new FSharpAttribute(0, [`Emit("$0.${moduleDeclaration.Name}")`])]), moduleDeclaration.Name + "_", `${moduleDeclaration.Name}.Exports`, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${moduleDeclaration.Name}.Exports`, empty(), empty())]), false, isTopLevel, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]);
|
|
439
|
-
default:
|
|
440
|
-
return void 0;
|
|
441
|
-
}
|
|
442
|
-
}, moduleDeclaration.Types);
|
|
617
|
+
case 3: {
|
|
618
|
+
const sanitizedName = sanitizeName(moduleDeclaration.Name);
|
|
619
|
+
return singleton(new FSharpMember(1, [new FSharpMemberInfo(ofArray([new FSharpAttribute(4, ["REPLACE_ME_WITH_MODULE_NAME"]), new FSharpAttribute(0, [`Emit("$0.${removeSurroundingQuotes(moduleDeclaration.Name)}")`])]), sanitizedName + "_", `${moduleDeclaration.Name}.Exports`, empty(), empty(), new FSharpType(6, [new FSharpMapped(`${sanitizedName}.Exports`, empty())]), false, isTopLevel, new FSharpAccessor(0, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))]));
|
|
443
620
|
}
|
|
444
|
-
case
|
|
445
|
-
const glueType = _arg.fields[0];
|
|
621
|
+
case 4: {
|
|
446
622
|
const patternInput_3 = sanitizeNameAndPushScope(GlueType__get_Name(glueType), context_1);
|
|
447
623
|
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(), new FSharpMemberInfoBody(0, []))]));
|
|
448
624
|
}
|
|
449
625
|
default:
|
|
450
|
-
return toFail(printf("Could not generate exportMembers for: %A"))(
|
|
626
|
+
return toFail(printf("Could not generate exportMembers for: %A"))(glueType_1);
|
|
451
627
|
}
|
|
452
628
|
}, exports), empty())]);
|
|
453
629
|
}
|
|
454
630
|
|
|
455
631
|
function transformParameter(context, parameter) {
|
|
456
632
|
let typ;
|
|
457
|
-
const computedType =
|
|
633
|
+
const computedType = unwrapOptionIfAlreadyOptional(TransformContext__PushScope_Z721C83C5(context, parameter.Name), parameter.Type, parameter.IsOptional);
|
|
458
634
|
typ = (parameter.IsSpread ? ((computedType.tag === 13) ? computedType.fields[0] : computedType) : computedType);
|
|
459
635
|
return new FSharpParameter(toList(delay(() => (parameter.IsSpread ? singleton_1(new FSharpAttribute(19, [])) : empty_1()))), sanitizeName(parameter.Name), parameter.IsOptional, typ);
|
|
460
636
|
}
|
|
@@ -487,10 +663,7 @@ function TransformMembers_toFSharpMember(context, members) {
|
|
|
487
663
|
return void 0;
|
|
488
664
|
}
|
|
489
665
|
else {
|
|
490
|
-
|
|
491
|
-
const typ$0027 = transformType(patternInput_2[1], propertyInfo.Type);
|
|
492
|
-
typ = (propertyInfo.IsOptional ? ((typ$0027.tag === 2) ? typ$0027.fields[0] : typ$0027) : typ$0027);
|
|
493
|
-
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, new FSharpMemberInfoBody(1, []))]);
|
|
666
|
+
return new FSharpMember(1, [new FSharpMemberInfo(toList(delay(() => xmlDocInfo.ObsoleteAttributes)), patternInput_2[0], propertyInfo.Name, empty(), empty(), unwrapOptionIfAlreadyOptional(patternInput_2[1], propertyInfo.Type, propertyInfo.IsOptional), propertyInfo.IsOptional, propertyInfo.IsStatic, transformAccessor(propertyInfo.Accessor), propertyInfo.IsPrivate ? (new FSharpAccessibility(1, [])) : (new FSharpAccessibility(0, [])), xmlDocInfo.XmlDoc, new FSharpMemberInfoBody(1, []))]);
|
|
494
667
|
}
|
|
495
668
|
}
|
|
496
669
|
case 2: {
|
|
@@ -635,26 +808,72 @@ function TransformMembers_toFSharpParameters(context, members) {
|
|
|
635
808
|
function transformInterface(context, info) {
|
|
636
809
|
const patternInput = sanitizeNameAndPushScope(info.Name, context);
|
|
637
810
|
const context_1 = patternInput[1];
|
|
638
|
-
const
|
|
639
|
-
|
|
811
|
+
const membersComingFromPartial = concat(map((fullName) => concat(choose((glueType) => {
|
|
812
|
+
if (glueType.tag === 1) {
|
|
813
|
+
const glueInterface = glueType.fields[0];
|
|
814
|
+
if (glueInterface.FullName === fullName) {
|
|
815
|
+
return Interface_makePartial("FakeName", transformInterface(context_1, glueInterface)).Members;
|
|
816
|
+
}
|
|
817
|
+
else {
|
|
818
|
+
return void 0;
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
else {
|
|
822
|
+
return void 0;
|
|
823
|
+
}
|
|
824
|
+
}, TransformContext__get_TypeMemory(context_1))), choose((heritageClause) => {
|
|
825
|
+
if (heritageClause.tag === 13) {
|
|
826
|
+
const typeReference = heritageClause.fields[0];
|
|
827
|
+
if (typeReference.IsStandardLibrary && (typeReference.Name === "Partial")) {
|
|
828
|
+
if (length(typeReference.TypeArguments) === 1) {
|
|
829
|
+
const matchValue = item(0, typeReference.TypeArguments);
|
|
830
|
+
if (matchValue.tag === 13) {
|
|
831
|
+
return matchValue.fields[0].FullName;
|
|
832
|
+
}
|
|
833
|
+
else {
|
|
834
|
+
return void 0;
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
else {
|
|
838
|
+
return void 0;
|
|
839
|
+
}
|
|
840
|
+
}
|
|
841
|
+
else {
|
|
842
|
+
return void 0;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
else {
|
|
846
|
+
return void 0;
|
|
847
|
+
}
|
|
848
|
+
}, info.HeritageClauses)));
|
|
849
|
+
const standardMembers = TransformMembers_toFSharpMember(context_1, info.Members);
|
|
850
|
+
const inheritance = filter((heritageClause_1) => {
|
|
851
|
+
if (heritageClause_1.tag === 13) {
|
|
852
|
+
const typeReference_2 = heritageClause_1.fields[0];
|
|
853
|
+
return !(typeReference_2.IsStandardLibrary && (typeReference_2.Name === "Partial"));
|
|
854
|
+
}
|
|
855
|
+
else {
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
}, info.HeritageClauses);
|
|
859
|
+
const Members = append_1(standardMembers, membersComingFromPartial);
|
|
860
|
+
return new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), patternInput[0], info.Name, transformTypeParameters(context_1, info.TypeParameters), Members, map((glueType_1) => transformType(context_1, glueType_1), inheritance));
|
|
640
861
|
}
|
|
641
862
|
|
|
642
863
|
export function Interface_makePartial(name, originalInterface) {
|
|
643
864
|
return new FSharpInterface(originalInterface.Attributes, name, originalInterface.OriginalName, originalInterface.TypeParameters, map((m) => {
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
return
|
|
648
|
-
}
|
|
649
|
-
case 2: {
|
|
650
|
-
const staticMember = m.fields[0];
|
|
651
|
-
return new FSharpMember(2, [new FSharpStaticMemberInfo(staticMember.Attributes, staticMember.Name, staticMember.OriginalName, staticMember.TypeParameters, staticMember.Parameters, staticMember.Type, true, staticMember.Accessor, staticMember.Accessibility)]);
|
|
865
|
+
if (m.tag === 1) {
|
|
866
|
+
const property = m.fields[0];
|
|
867
|
+
if (property.Type.tag === 2) {
|
|
868
|
+
return m;
|
|
652
869
|
}
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
return new FSharpMember(0, [new FSharpMemberInfo(method.Attributes, method.Name, method.OriginalName, method.TypeParameters, method.Parameters, method.Type, true, method.IsStatic, method.Accessor, method.Accessibility, method.XmlDoc, method.Body)]);
|
|
870
|
+
else {
|
|
871
|
+
return new FSharpMember(1, [new FSharpMemberInfo(property.Attributes, property.Name, property.OriginalName, property.TypeParameters, property.Parameters, property.Type, true, property.IsStatic, property.Accessor, property.Accessibility, property.XmlDoc, property.Body)]);
|
|
656
872
|
}
|
|
657
873
|
}
|
|
874
|
+
else {
|
|
875
|
+
return m;
|
|
876
|
+
}
|
|
658
877
|
}, originalInterface.Members), originalInterface.Inheritance);
|
|
659
878
|
}
|
|
660
879
|
|
|
@@ -693,7 +912,7 @@ function transformEnum(glueEnum) {
|
|
|
693
912
|
throw new Error("Should not happen");
|
|
694
913
|
}
|
|
695
914
|
const caseName = sanitizeName(glueMember_1.Name);
|
|
696
|
-
return new FSharpUnionCase(toList(delay(() => ((caseName !== caseValue) ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(caseValue)])) : empty_1()))), caseName);
|
|
915
|
+
return new FSharpUnionCase(0, [new FSharpUnionCaseNamed(toList(delay(() => ((caseName !== caseValue) ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(caseValue)])) : empty_1()))), caseName)]);
|
|
697
916
|
}, stringValues), {
|
|
698
917
|
Equals: equals,
|
|
699
918
|
GetHashCode: safeHash,
|
|
@@ -716,7 +935,6 @@ Errored enum: ${glueEnum.Name}
|
|
|
716
935
|
|
|
717
936
|
export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
|
|
718
937
|
const cases = (glueType.tag === 1) ? choose((m) => {
|
|
719
|
-
let sanitizeResult;
|
|
720
938
|
let matchResult, caseName;
|
|
721
939
|
switch (m.tag) {
|
|
722
940
|
case 4:
|
|
@@ -751,8 +969,10 @@ export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
|
|
|
751
969
|
}
|
|
752
970
|
}
|
|
753
971
|
switch (matchResult) {
|
|
754
|
-
case 0:
|
|
755
|
-
|
|
972
|
+
case 0: {
|
|
973
|
+
const sanitizeResult = sanitizeNameWithResult(caseName);
|
|
974
|
+
return new FSharpUnionCase(0, [new FSharpUnionCaseNamed(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(caseName)])) : empty_1()))), sanitizeResult.Name)]);
|
|
975
|
+
}
|
|
756
976
|
default:
|
|
757
977
|
return void 0;
|
|
758
978
|
}
|
|
@@ -765,10 +985,10 @@ export function TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType) {
|
|
|
765
985
|
}
|
|
766
986
|
}
|
|
767
987
|
|
|
768
|
-
export function TypeAliasDeclaration_transformKeyOf(aliasName, glueType) {
|
|
988
|
+
export function TypeAliasDeclaration_transformKeyOf(context, aliasName, glueType) {
|
|
769
989
|
const matchValue = TypeAliasDeclaration_tryTransformKeyOf(aliasName, glueType);
|
|
770
990
|
if (matchValue == null) {
|
|
771
|
-
|
|
991
|
+
TransformContext__AddWarning_Z721C83C5(context, `Could not transform KeyOf: ${aliasName}`);
|
|
772
992
|
return new FSharpType(9, []);
|
|
773
993
|
}
|
|
774
994
|
else {
|
|
@@ -788,12 +1008,30 @@ export function TypeAliasDeclaration_transformLiteral(xmlDoc, typeAliasName, lit
|
|
|
788
1008
|
case 4:
|
|
789
1009
|
return makeTypeAlias(new FSharpPrimitive(6, []));
|
|
790
1010
|
default:
|
|
791
|
-
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(12, []), new FSharpAttribute(10, [0])]), typeAliasName, singleton(new FSharpUnionCase(empty(), sanitizeName(literalInfo.fields[0]))), false)]);
|
|
1011
|
+
return new FSharpType(1, [new FSharpUnion(ofArray([new FSharpAttribute(12, []), new FSharpAttribute(10, [0])]), typeAliasName, singleton(new FSharpUnionCase(0, [new FSharpUnionCaseNamed(empty(), sanitizeName(literalInfo.fields[0]))])), false)]);
|
|
792
1012
|
}
|
|
793
1013
|
}
|
|
794
1014
|
|
|
1015
|
+
function transformRecord(context, name, typeParameters, recordInfo) {
|
|
1016
|
+
const patternInput = sanitizeNameAndPushScope(name, context);
|
|
1017
|
+
const name_1 = patternInput[0];
|
|
1018
|
+
const context_1 = patternInput[1];
|
|
1019
|
+
let parameters;
|
|
1020
|
+
const patternInput_1 = sanitizeNameAndPushScope("key", context_1);
|
|
1021
|
+
parameters = singleton(new FSharpParameter(empty(), patternInput_1[0], false, transformType(patternInput_1[1], recordInfo.KeyType)));
|
|
1022
|
+
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), name_1, name_1, transformTypeParameters(context_1, typeParameters), singleton(new FSharpMember(1, [new FSharpMemberInfo(singleton(new FSharpAttribute(16, [])), "Item", "Item", empty(), parameters, transformType(context_1, recordInfo.ValueType), false, false, new FSharpAccessor(2, []), new FSharpAccessibility(0, []), empty(), new FSharpMemberInfoBody(0, []))])), empty())]);
|
|
1023
|
+
}
|
|
1024
|
+
|
|
795
1025
|
function transformTypeParameters(context, typeParameters) {
|
|
796
|
-
return map((typeParameter) => FSharpTypeParameter_Create_Z6CFD3565(typeParameter.Name, unwrap(
|
|
1026
|
+
return map((typeParameter) => FSharpTypeParameter_Create_Z6CFD3565(typeParameter.Name, unwrap(bind((glueType) => {
|
|
1027
|
+
const matchValue = transformType(context, glueType);
|
|
1028
|
+
if (matchValue.tag === 15) {
|
|
1029
|
+
return void 0;
|
|
1030
|
+
}
|
|
1031
|
+
else {
|
|
1032
|
+
return matchValue;
|
|
1033
|
+
}
|
|
1034
|
+
}, typeParameter.Constraint)), unwrap(map_1((glueType_1) => transformType(context, glueType_1), typeParameter.Default))), typeParameters);
|
|
797
1035
|
}
|
|
798
1036
|
|
|
799
1037
|
function tryOptimizeUnionType(context, typeName, cases) {
|
|
@@ -875,7 +1113,7 @@ function tryOptimizeUnionType(context, typeName, cases) {
|
|
|
875
1113
|
switch (matchResult_2) {
|
|
876
1114
|
case 0: {
|
|
877
1115
|
const sanitizeResult = sanitizeNameWithResult(value_1);
|
|
878
|
-
return new FSharpUnionCase(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(value_1)])) : empty_1()))), sanitizeResult.Name);
|
|
1116
|
+
return new FSharpUnionCase(0, [new FSharpUnionCaseNamed(toList(delay(() => (sanitizeResult.IsDifferent ? singleton_1(new FSharpAttribute(11, [removeSurroundingQuotes(value_1)])) : empty_1()))), sanitizeResult.Name)]);
|
|
879
1117
|
}
|
|
880
1118
|
default:
|
|
881
1119
|
throw new Error("Should not happen");
|
|
@@ -912,7 +1150,7 @@ function tryOptimizeUnionType(context, typeName, cases) {
|
|
|
912
1150
|
}))]);
|
|
913
1151
|
}
|
|
914
1152
|
else if (forAll((_arg_3) => {
|
|
915
|
-
if (_arg_3.tag ===
|
|
1153
|
+
if (_arg_3.tag === 21) {
|
|
916
1154
|
return true;
|
|
917
1155
|
}
|
|
918
1156
|
else {
|
|
@@ -920,7 +1158,7 @@ function tryOptimizeUnionType(context, typeName, cases) {
|
|
|
920
1158
|
}
|
|
921
1159
|
}, cases)) {
|
|
922
1160
|
const members = collect_1((_arg_4) => {
|
|
923
|
-
if (_arg_4.tag ===
|
|
1161
|
+
if (_arg_4.tag === 21) {
|
|
924
1162
|
return TransformMembers_toFSharpMember(context, _arg_4.fields[0].Members);
|
|
925
1163
|
}
|
|
926
1164
|
else {
|
|
@@ -942,7 +1180,7 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
942
1180
|
const matchValue = glueTypeAliasDeclaration.Type;
|
|
943
1181
|
switch (matchValue.tag) {
|
|
944
1182
|
case 9:
|
|
945
|
-
return TypeAliasDeclaration_transformKeyOf(glueTypeAliasDeclaration.Name, matchValue.fields[0]);
|
|
1183
|
+
return TypeAliasDeclaration_transformKeyOf(context_1, glueTypeAliasDeclaration.Name, matchValue.fields[0]);
|
|
946
1184
|
case 10: {
|
|
947
1185
|
const glueType_1 = matchValue.fields[0];
|
|
948
1186
|
let typ_2;
|
|
@@ -1002,9 +1240,12 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
1002
1240
|
return TypeAliasDeclaration_transformLiteral(xmlDoc, typeAliasName, matchValue.fields[0]);
|
|
1003
1241
|
case 3:
|
|
1004
1242
|
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))]);
|
|
1243
|
+
case 25:
|
|
1244
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(7, [new FSharpPrimitive(0, [])]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
1005
1245
|
case 13: {
|
|
1006
1246
|
const typeReference = matchValue.fields[0];
|
|
1007
|
-
const
|
|
1247
|
+
const mappedName = mapTypeNameToFableCoreAwareName(context_1, typeReference);
|
|
1248
|
+
const context_2 = TransformContext__PushScope_Z721C83C5(context_1, mappedName);
|
|
1008
1249
|
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))]));
|
|
1009
1250
|
const matchValue_2 = typeReference.TypeArguments;
|
|
1010
1251
|
let matchResult_1, head;
|
|
@@ -1022,12 +1263,12 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
1022
1263
|
}
|
|
1023
1264
|
switch (matchResult_1) {
|
|
1024
1265
|
case 0:
|
|
1025
|
-
if (head.tag ===
|
|
1266
|
+
if (head.tag === 20) {
|
|
1026
1267
|
const makeInterfaceTyp = (name) => (new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), name, glueTypeAliasDeclaration.Name, empty(), TransformMembers_toFSharpMember(context_2, head.fields[0]), empty()));
|
|
1027
1268
|
const exposedType = makeInterfaceTyp("ReturnType");
|
|
1028
1269
|
const typeArgument = makeInterfaceTyp(TransformContext__get_FullName(context_2) + ".ReturnType");
|
|
1029
1270
|
TransformContext__ExposeType_Z1D58A540(TransformContext__PushScope_Z721C83C5(context_2, typeReference.Name), new FSharpType(4, [exposedType]));
|
|
1030
|
-
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(10, [new FSharpTypeReference(
|
|
1271
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(10, [new FSharpTypeReference(mappedName, typeReference.FullName, singleton(new FSharpType(4, [typeArgument])), new FSharpType(9, []))]), empty())]);
|
|
1031
1272
|
}
|
|
1032
1273
|
else {
|
|
1033
1274
|
return handleDefaultCase();
|
|
@@ -1036,23 +1277,30 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
1036
1277
|
return handleDefaultCase();
|
|
1037
1278
|
}
|
|
1038
1279
|
}
|
|
1039
|
-
case 15:
|
|
1040
|
-
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))]);
|
|
1041
1280
|
case 14:
|
|
1042
|
-
return new FSharpType(
|
|
1043
|
-
case
|
|
1281
|
+
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformType(context_1, new GlueType(14, [matchValue.fields[0]])), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
1282
|
+
case 26: {
|
|
1283
|
+
const utilityType = matchValue.fields[0];
|
|
1284
|
+
if (utilityType.tag === 1) {
|
|
1285
|
+
return transformRecord(context_1, typeAliasName, glueTypeAliasDeclaration.TypeParameters, utilityType.fields[0]);
|
|
1286
|
+
}
|
|
1287
|
+
else {
|
|
1288
|
+
return new FSharpType(4, [Interface_makePartial(typeAliasName, transformInterface(context_1, utilityType.fields[0]))]);
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
case 15: {
|
|
1044
1292
|
const functionType = matchValue.fields[0];
|
|
1045
1293
|
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), 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(), new FSharpMemberInfoBody(0, []))])), empty())]);
|
|
1046
1294
|
}
|
|
1047
|
-
case
|
|
1295
|
+
case 18:
|
|
1048
1296
|
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, transformTupleType(context_1, matchValue.fields[0]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
1049
|
-
case
|
|
1297
|
+
case 20:
|
|
1050
1298
|
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0]), empty())]);
|
|
1051
|
-
case
|
|
1299
|
+
case 21:
|
|
1052
1300
|
return new FSharpType(4, [new FSharpInterface(ofArray([new FSharpAttribute(8, []), new FSharpAttribute(20, [])]), typeAliasName, glueTypeAliasDeclaration.Name, transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters), TransformMembers_toFSharpMember(context_1, matchValue.fields[0].Members), empty())]);
|
|
1053
|
-
case
|
|
1301
|
+
case 23:
|
|
1054
1302
|
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(17, []), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
1055
|
-
case
|
|
1303
|
+
case 16:
|
|
1056
1304
|
return new FSharpType(8, [new FSharpTypeAlias(toList(delay(() => xmlDoc.ObsoleteAttributes)), typeAliasName, xmlDoc.XmlDoc, new FSharpType(12, [matchValue.fields[0]]), transformTypeParameters(context_1, glueTypeAliasDeclaration.TypeParameters))]);
|
|
1057
1305
|
case 12:
|
|
1058
1306
|
case 4:
|
|
@@ -1061,11 +1309,11 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
1061
1309
|
case 5:
|
|
1062
1310
|
case 0:
|
|
1063
1311
|
case 6:
|
|
1064
|
-
case
|
|
1312
|
+
case 17:
|
|
1065
1313
|
case 2:
|
|
1066
|
-
case
|
|
1067
|
-
case
|
|
1068
|
-
case
|
|
1314
|
+
case 24:
|
|
1315
|
+
case 19:
|
|
1316
|
+
case 22:
|
|
1069
1317
|
return new FSharpType(9, []);
|
|
1070
1318
|
default: {
|
|
1071
1319
|
const matchValue_1 = tryOptimizeUnionType(context_1, typeAliasName, matchValue.fields[0].fields[0]);
|
|
@@ -1079,8 +1327,8 @@ function transformTypeAliasDeclaration(context, glueTypeAliasDeclaration) {
|
|
|
1079
1327
|
}
|
|
1080
1328
|
}
|
|
1081
1329
|
|
|
1082
|
-
function transformModuleDeclaration(moduleDeclaration) {
|
|
1083
|
-
return new FSharpType(3, [new FSharpModule(sanitizeName(moduleDeclaration.Name), moduleDeclaration.IsRecursive, transform(false, moduleDeclaration.Types))]);
|
|
1330
|
+
function transformModuleDeclaration(typeMemory, reporter, moduleDeclaration) {
|
|
1331
|
+
return new FSharpType(3, [new FSharpModule(sanitizeName(moduleDeclaration.Name), moduleDeclaration.IsRecursive, transform(typeMemory, reporter, false, moduleDeclaration.Types))]);
|
|
1084
1332
|
}
|
|
1085
1333
|
|
|
1086
1334
|
function transformClassDeclaration(context, classDeclaration) {
|
|
@@ -1098,10 +1346,10 @@ function transformToFsharp(context, glueTypes) {
|
|
|
1098
1346
|
case 5:
|
|
1099
1347
|
return transformTypeAliasDeclaration(context, _arg.fields[0]);
|
|
1100
1348
|
case 11:
|
|
1101
|
-
return transformModuleDeclaration(_arg.fields[0]);
|
|
1349
|
+
return transformModuleDeclaration(TransformContext__get_TypeMemory(context), TransformContext__get__Reporter(context), _arg.fields[0]);
|
|
1102
1350
|
case 12:
|
|
1103
1351
|
return transformClassDeclaration(context, _arg.fields[0]);
|
|
1104
|
-
case
|
|
1352
|
+
case 24: {
|
|
1105
1353
|
const exportedType = _arg.fields[0];
|
|
1106
1354
|
if (exportedType.tag === 12) {
|
|
1107
1355
|
return transformClassDeclaration(context, exportedType.fields[0]);
|
|
@@ -1110,10 +1358,9 @@ function transformToFsharp(context, glueTypes) {
|
|
|
1110
1358
|
return new FSharpType(9, []);
|
|
1111
1359
|
}
|
|
1112
1360
|
}
|
|
1361
|
+
case 15:
|
|
1113
1362
|
case 16:
|
|
1114
|
-
case 17:
|
|
1115
1363
|
case 14:
|
|
1116
|
-
case 15:
|
|
1117
1364
|
case 13:
|
|
1118
1365
|
case 6:
|
|
1119
1366
|
case 10:
|
|
@@ -1121,15 +1368,17 @@ function transformToFsharp(context, glueTypes) {
|
|
|
1121
1368
|
case 8:
|
|
1122
1369
|
case 2:
|
|
1123
1370
|
case 3:
|
|
1124
|
-
case
|
|
1371
|
+
case 23:
|
|
1125
1372
|
case 9:
|
|
1126
1373
|
case 0:
|
|
1127
|
-
case
|
|
1374
|
+
case 18:
|
|
1375
|
+
case 20:
|
|
1128
1376
|
case 21:
|
|
1129
1377
|
case 22:
|
|
1130
|
-
case
|
|
1131
|
-
case
|
|
1132
|
-
case
|
|
1378
|
+
case 19:
|
|
1379
|
+
case 25:
|
|
1380
|
+
case 26:
|
|
1381
|
+
case 17:
|
|
1133
1382
|
return new FSharpType(9, []);
|
|
1134
1383
|
default:
|
|
1135
1384
|
return new FSharpType(4, [transformInterface(context, _arg.fields[0])]);
|
|
@@ -1137,13 +1386,13 @@ function transformToFsharp(context, glueTypes) {
|
|
|
1137
1386
|
}, glueTypes);
|
|
1138
1387
|
}
|
|
1139
1388
|
|
|
1140
|
-
|
|
1389
|
+
function transform(typeMemory, reporter, isTopLevel, glueAst) {
|
|
1141
1390
|
const patternInput = partition((glueType) => {
|
|
1142
1391
|
switch (glueType.tag) {
|
|
1143
1392
|
case 2:
|
|
1144
1393
|
case 6:
|
|
1145
1394
|
return true;
|
|
1146
|
-
case
|
|
1395
|
+
case 24:
|
|
1147
1396
|
if (glueType.fields[0].tag === 2) {
|
|
1148
1397
|
return true;
|
|
1149
1398
|
}
|
|
@@ -1169,7 +1418,7 @@ export function transform(isTopLevel, glueAst) {
|
|
|
1169
1418
|
return false;
|
|
1170
1419
|
}
|
|
1171
1420
|
}, glueType_1.fields[0].Types);
|
|
1172
|
-
case
|
|
1421
|
+
case 24:
|
|
1173
1422
|
if (glueType_1.fields[0].tag === 12) {
|
|
1174
1423
|
return true;
|
|
1175
1424
|
}
|
|
@@ -1180,9 +1429,14 @@ export function transform(isTopLevel, glueAst) {
|
|
|
1180
1429
|
return false;
|
|
1181
1430
|
}
|
|
1182
1431
|
}, rest));
|
|
1183
|
-
const rootTransformContext = TransformContext_$
|
|
1432
|
+
const rootTransformContext = TransformContext_$ctor_Z4CBC0890(reporter, "", typeMemory);
|
|
1184
1433
|
const rest_1 = transformToFsharp(rootTransformContext, rest);
|
|
1185
1434
|
return toList(delay(() => append(!isEmpty(exports_1) ? singleton_1(transformExports(rootTransformContext, isTopLevel, exports_1)) : empty_1(), delay(() => append(rest_1, delay(() => TransformContext__ToList(rootTransformContext)))))));
|
|
1186
1435
|
}
|
|
1187
1436
|
|
|
1437
|
+
export function apply(typeMemory, glueAst) {
|
|
1438
|
+
const reporter = Reporter_$ctor();
|
|
1439
|
+
return new TransformResult(apply_1(transform(typeMemory, reporter, true, glueAst)), Reporter__get_Warnings(reporter), Reporter__get_Errors(reporter), Reporter__get_HasRegEpx(reporter));
|
|
1440
|
+
}
|
|
1441
|
+
|
|
1188
1442
|
//# sourceMappingURL=Transform.js.map
|