@glutinum/cli 1.0.0-beta.2 → 1.0.0-beta.3
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 +16 -0
- package/dist/Glutinum.Converter/Abbreviations.js +9 -32
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +116 -65
- package/dist/Glutinum.Converter/Generate.js +34 -21
- package/dist/Glutinum.Converter/GlueAST.js +79 -41
- package/dist/Glutinum.Converter/Hosting.js +132 -157
- package/dist/Glutinum.Converter/Merge.js +369 -337
- package/dist/Glutinum.Converter/Packages.js +391 -92
- package/dist/Glutinum.Converter/Printer.js +396 -423
- package/dist/Glutinum.Converter/Read.js +387 -88
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +4 -4
- package/dist/Glutinum.Converter/Reader/Declaration.js +6 -12
- package/dist/Glutinum.Converter/Reader/Documentation.js +23 -35
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +103 -36
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +21 -36
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +26 -13
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +14 -20
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +45 -2
- package/dist/Glutinum.Converter/Reader/Node.js +8 -11
- package/dist/Glutinum.Converter/Reader/Parameters.js +34 -26
- package/dist/Glutinum.Converter/Reader/TypeNode.js +1988 -1342
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +32 -44
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +14 -37
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +23 -5
- package/dist/Glutinum.Converter/Reader/Types.js +290 -15
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +14 -28
- package/dist/Glutinum.Converter/Reader/Utils.js +325 -25
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +2 -3
- package/dist/Glutinum.Converter/Transform.js +3568 -8456
- package/dist/Glutinum.Converter/Transformer/AnyFunctionOverloads.js +116 -0
- package/dist/Glutinum.Converter/Transformer/CallableProperties.js +454 -0
- package/dist/Glutinum.Converter/Transformer/Comment.js +136 -0
- package/dist/Glutinum.Converter/Transformer/Conditionals.js +1149 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +666 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +406 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +596 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +353 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/String.js +14 -3
- package/dist/Program.js +18 -10
- package/package.json +1 -1
|
@@ -1,22 +1,43 @@
|
|
|
1
1
|
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { FSharpRef, Record } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
3
|
+
import { record_type, tuple_type, list_type, class_type, string_type } from "../fable_modules/fable-library-js.5.17.2/Reflection.js";
|
|
4
|
+
import { FSharpClass, FSharpModule, FSharpInterface, FSharpStaticMemberInfo, FSharpMember, FSharpMemberInfo, FSharpTypeModule_children, FSharpFunctionType, FSharpParameter, FSharpTypeModule_mapChildren, FSharpTypeReference, FSharpType, FSharpType_$reflection } from "./FsharpAST.js";
|
|
5
|
+
import { ofList, FSharpMap__TryFind, tryFind, ofSeq, empty } from "../fable_modules/fable-library-js.5.17.2/Map.js";
|
|
6
|
+
import { Exception, safeHash, equals, compareArrays, arrayHash, equalArrays, defaultOf, int32ToString, disposeSafe, getEnumerator, comparePrimitives } from "../fable_modules/fable-library-js.5.17.2/Util.js";
|
|
7
|
+
import { mapIndexed, tryFindIndex, ofSeq as ofSeq_2, maxBy, skip, take, forAll2, ofArray, indexed, sortBy, exists, forAll, filter, collect, head, tail, zip, empty as empty_1, length, map, choose, singleton, append, isEmpty as isEmpty_1 } from "../fable_modules/fable-library-js.5.17.2/List.js";
|
|
4
8
|
import { concat, join } from "../fable_modules/fable-library-js.5.17.2/String.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { addToDict, addToSet, tryGetValue
|
|
8
|
-
import { value } from "../fable_modules/fable-library-js.5.17.2/Option.js";
|
|
9
|
-
import { FSharpSet__get_IsEmpty, ofSeq, empty, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
10
|
-
import { FSharpRef } from "../fable_modules/fable-library-js.5.17.2/Types.js";
|
|
9
|
+
import { map as map_1 } from "../fable_modules/fable-library-js.5.17.2/Seq.js";
|
|
10
|
+
import { FSharpSet__get_IsEmpty, ofSeq as ofSeq_1, empty as empty_2, FSharpSet__Contains } from "../fable_modules/fable-library-js.5.17.2/Set.js";
|
|
11
|
+
import { addToDict, getItemFromDict, addToSet, tryGetValue } from "../fable_modules/fable-library-js.5.17.2/MapUtil.js";
|
|
11
12
|
import { List_distinctBy, List_distinct, List_groupBy } from "../fable_modules/fable-library-js.5.17.2/Seq2.js";
|
|
12
13
|
import { FSharpChoice$3 } from "../fable_modules/fable-library-js.5.17.2/Choice.js";
|
|
13
14
|
import { contains, setItem, item } from "../fable_modules/fable-library-js.5.17.2/Array.js";
|
|
15
|
+
import { HashSet } from "../fable_modules/fable-library-js.5.17.2/MutableSet.js";
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The type aliases of the output, two references are the same type when they alias the same one
|
|
19
|
+
*/
|
|
20
|
+
export class Aliases extends Record {
|
|
21
|
+
constructor(Targets, Generic) {
|
|
22
|
+
super();
|
|
23
|
+
this.Targets = Targets;
|
|
24
|
+
this.Generic = Generic;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function Aliases_$reflection() {
|
|
29
|
+
return record_type("Glutinum.Converter.Merge.Aliases", [], Aliases, () => [["Targets", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, FSharpType_$reflection()])], ["Generic", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, tuple_type(list_type(string_type), FSharpType_$reflection())])]]);
|
|
30
|
+
}
|
|
16
31
|
|
|
17
|
-
|
|
32
|
+
export function Aliases_get_Empty() {
|
|
33
|
+
return new Aliases(empty({
|
|
34
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
35
|
+
}), empty({
|
|
36
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
18
39
|
|
|
19
|
-
function collectAliases(path, types) {
|
|
40
|
+
function collectAliases(aliasTargets, genericAliasTargets, path, types) {
|
|
20
41
|
const enumerator = getEnumerator(types);
|
|
21
42
|
try {
|
|
22
43
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
@@ -62,7 +83,7 @@ function collectAliases(path, types) {
|
|
|
62
83
|
break;
|
|
63
84
|
}
|
|
64
85
|
case 4: {
|
|
65
|
-
collectAliases(append(path, singleton(typ.fields[0].Name)), typ.fields[0].Types);
|
|
86
|
+
collectAliases(aliasTargets, genericAliasTargets, append(path, singleton(typ.fields[0].Name)), typ.fields[0].Types);
|
|
66
87
|
break;
|
|
67
88
|
}
|
|
68
89
|
default:
|
|
@@ -75,57 +96,47 @@ function collectAliases(path, types) {
|
|
|
75
96
|
}
|
|
76
97
|
}
|
|
77
98
|
|
|
99
|
+
/**
|
|
100
|
+
* The aliases the types declare
|
|
101
|
+
*/
|
|
102
|
+
export function aliasesOf(types) {
|
|
103
|
+
const aliasTargets = new Map([]);
|
|
104
|
+
const genericAliasTargets = new Map([]);
|
|
105
|
+
collectAliases(aliasTargets, genericAliasTargets, empty_1(), types);
|
|
106
|
+
return new Aliases(ofSeq(map_1((_arg) => {
|
|
107
|
+
const activePatternResult = _arg;
|
|
108
|
+
return [activePatternResult[0], activePatternResult[1]];
|
|
109
|
+
}, aliasTargets), {
|
|
110
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
111
|
+
}), ofSeq(map_1((_arg_1) => {
|
|
112
|
+
const activePatternResult_1 = _arg_1;
|
|
113
|
+
return [activePatternResult_1[0], activePatternResult_1[1]];
|
|
114
|
+
}, genericAliasTargets), {
|
|
115
|
+
Compare: (x_1, y_1) => (comparePrimitives(x_1, y_1) | 0),
|
|
116
|
+
}));
|
|
117
|
+
}
|
|
118
|
+
|
|
78
119
|
function substitute(substitutions, typ) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
const matchValue = tryFind(typ.fields[0], substitutions);
|
|
83
|
-
if (matchValue == null) {
|
|
84
|
-
return typ;
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
return matchValue;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
case 11: {
|
|
91
|
-
const typeReference = typ.fields[0];
|
|
92
|
-
return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference(typeReference.Name, typeReference.FullName, typeReference.ModulePath, map(substitute_1, typeReference.TypeArguments), typeReference.Type)]);
|
|
93
|
-
}
|
|
94
|
-
case 3:
|
|
95
|
-
return new FSharpType(/* Option */ 3, [substitute_1(typ.fields[0])]);
|
|
96
|
-
case 14:
|
|
97
|
-
return new FSharpType(/* ResizeArray */ 14, [substitute_1(typ.fields[0])]);
|
|
98
|
-
case 19:
|
|
99
|
-
return new FSharpType(/* JSApi */ 19, [new FSharpJSApi(substitute_1(typ.fields[0].fields[0]))]);
|
|
100
|
-
case 12:
|
|
101
|
-
return new FSharpType(/* Tuple */ 12, [map(substitute_1, typ.fields[0])]);
|
|
102
|
-
case 16: {
|
|
103
|
-
const functionType = typ.fields[0];
|
|
104
|
-
return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, substitute_1(parameter.Type), parameter.OriginalGlueMember)), functionType.Parameters), substitute_1(functionType.ReturnType))]);
|
|
105
|
-
}
|
|
106
|
-
case 1: {
|
|
107
|
-
const unionInfo = typ.fields[0];
|
|
108
|
-
return new FSharpType(/* Union */ 1, [new FSharpUnion(unionInfo.Attributes, unionInfo.Name, map((_arg) => {
|
|
109
|
-
switch (_arg.tag) {
|
|
110
|
-
case 1:
|
|
111
|
-
return new FSharpUnionCase(/* Typed */ 1, [substitute_1(_arg.fields[0])]);
|
|
112
|
-
case 2:
|
|
113
|
-
return new FSharpUnionCase(/* Field */ 2, [_arg.fields[0], substitute_1(_arg.fields[1])]);
|
|
114
|
-
default:
|
|
115
|
-
return _arg;
|
|
116
|
-
}
|
|
117
|
-
}, unionInfo.Cases), unionInfo.IsOptional, unionInfo.TypeParameters, unionInfo.Constants)]);
|
|
118
|
-
}
|
|
119
|
-
default:
|
|
120
|
+
if (typ.tag === 13) {
|
|
121
|
+
const matchValue = tryFind(typ.fields[0], substitutions);
|
|
122
|
+
if (matchValue == null) {
|
|
120
123
|
return typ;
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return matchValue;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return FSharpTypeModule_mapChildren((typ_3) => substitute(substitutions, typ_3), typ);
|
|
121
131
|
}
|
|
122
132
|
}
|
|
123
133
|
|
|
124
|
-
function tryGenericAliasTarget(typeReference) {
|
|
134
|
+
function tryGenericAliasTarget(aliases, typeReference) {
|
|
125
135
|
let tupledArg;
|
|
126
136
|
const arity = "`" + int32ToString(length(typeReference.TypeArguments));
|
|
127
|
-
|
|
128
|
-
const
|
|
137
|
+
let option_1;
|
|
138
|
+
const matchValue = FSharpMap__TryFind(aliases.Generic, join(".", append(typeReference.ModulePath, singleton(typeReference.Name))) + arity);
|
|
139
|
+
option_1 = ((matchValue == null) ? (isEmpty_1(typeReference.ModulePath) ? FSharpMap__TryFind(aliases.Generic, typeReference.Name + arity) : undefined) : matchValue);
|
|
129
140
|
if (option_1 != null) {
|
|
130
141
|
return (tupledArg = option_1, substitute(ofList(zip(tupledArg[0], typeReference.TypeArguments), {
|
|
131
142
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
@@ -136,298 +147,183 @@ function tryGenericAliasTarget(typeReference) {
|
|
|
136
147
|
}
|
|
137
148
|
}
|
|
138
149
|
|
|
139
|
-
function
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
matchResult = 0;
|
|
149
|
-
typeReference_2 = typ.fields[0];
|
|
150
|
-
}
|
|
151
|
-
else if ((typeReference_1 = typ.fields[0], ((depth < 8) && !isEmpty_1(typeReference_1.TypeArguments)) && (tryGenericAliasTarget(typeReference_1) != null))) {
|
|
152
|
-
matchResult = 1;
|
|
153
|
-
typeReference_3 = typ.fields[0];
|
|
154
|
-
}
|
|
155
|
-
else if (typ.fields[0].Name === "ResizeArray") {
|
|
156
|
-
if (!isEmpty_1(typ.fields[0].TypeArguments)) {
|
|
157
|
-
if (isEmpty_1(tail(typ.fields[0].TypeArguments))) {
|
|
158
|
-
matchResult = 2;
|
|
159
|
-
typeArgument = head(typ.fields[0].TypeArguments);
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
matchResult = 3;
|
|
163
|
-
typeReference_4 = typ.fields[0];
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
else {
|
|
167
|
-
matchResult = 3;
|
|
168
|
-
typeReference_4 = typ.fields[0];
|
|
169
|
-
}
|
|
150
|
+
function tryAliasTarget(aliases, typeReference) {
|
|
151
|
+
if (!isEmpty_1(typeReference.TypeArguments)) {
|
|
152
|
+
return tryGenericAliasTarget(aliases, typeReference);
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const matchValue = FSharpMap__TryFind(aliases.Targets, join(".", append(typeReference.ModulePath, singleton(typeReference.Name))));
|
|
156
|
+
if (matchValue == null) {
|
|
157
|
+
if (isEmpty_1(typeReference.ModulePath)) {
|
|
158
|
+
return FSharpMap__TryFind(aliases.Targets, typeReference.Name);
|
|
170
159
|
}
|
|
171
160
|
else {
|
|
172
|
-
|
|
173
|
-
typeReference_4 = typ.fields[0];
|
|
161
|
+
return undefined;
|
|
174
162
|
}
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
case 3: {
|
|
178
|
-
matchResult = 4;
|
|
179
|
-
typ_2 = typ.fields[0];
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
case 14: {
|
|
183
|
-
matchResult = 5;
|
|
184
|
-
typ_3 = typ.fields[0];
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
case 19: {
|
|
188
|
-
matchResult = 6;
|
|
189
|
-
typ_4 = typ.fields[0].fields[0];
|
|
190
|
-
break;
|
|
191
|
-
}
|
|
192
|
-
case 1: {
|
|
193
|
-
matchResult = 7;
|
|
194
|
-
unionInfo = typ.fields[0];
|
|
195
|
-
break;
|
|
196
|
-
}
|
|
197
|
-
case 12: {
|
|
198
|
-
matchResult = 8;
|
|
199
|
-
types = typ.fields[0];
|
|
200
|
-
break;
|
|
201
163
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
functionType = typ.fields[0];
|
|
205
|
-
break;
|
|
164
|
+
else {
|
|
165
|
+
return matchValue;
|
|
206
166
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function $007CAliasTarget$007C_$007C(aliases, typ) {
|
|
171
|
+
if (typ.tag === 11) {
|
|
172
|
+
return tryAliasTarget(aliases, typ.fields[0]);
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
return undefined;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function signatureTypeAt(aliases, depth, typ) {
|
|
180
|
+
let signatureType_1;
|
|
181
|
+
const depth_1 = (depth + 1) | 0;
|
|
182
|
+
signatureType_1 = ((typ_1) => signatureTypeAt(aliases, depth_1, typ_1));
|
|
183
|
+
let matchResult, target_1;
|
|
184
|
+
const activePatternResult = $007CAliasTarget$007C_$007C(aliases, typ);
|
|
185
|
+
if (activePatternResult != null) {
|
|
186
|
+
if (depth < 8) {
|
|
187
|
+
matchResult = 0;
|
|
188
|
+
target_1 = activePatternResult;
|
|
216
189
|
}
|
|
217
|
-
|
|
218
|
-
matchResult =
|
|
219
|
-
typ_7 = typ;
|
|
190
|
+
else {
|
|
191
|
+
matchResult = 1;
|
|
220
192
|
}
|
|
221
193
|
}
|
|
194
|
+
else {
|
|
195
|
+
matchResult = 1;
|
|
196
|
+
}
|
|
222
197
|
switch (matchResult) {
|
|
223
|
-
case 0:
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
198
|
+
case 0:
|
|
199
|
+
return signatureType_1(target_1);
|
|
200
|
+
default: {
|
|
201
|
+
let matchResult_1, typeArgument, typeReference, functionType, typ_2;
|
|
202
|
+
switch (typ.tag) {
|
|
203
|
+
case 11: {
|
|
204
|
+
if (typ.fields[0].Name === "ResizeArray") {
|
|
205
|
+
if (!isEmpty_1(typ.fields[0].TypeArguments)) {
|
|
206
|
+
if (isEmpty_1(tail(typ.fields[0].TypeArguments))) {
|
|
207
|
+
matchResult_1 = 0;
|
|
208
|
+
typeArgument = head(typ.fields[0].TypeArguments);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
matchResult_1 = 1;
|
|
212
|
+
typeReference = typ.fields[0];
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
matchResult_1 = 1;
|
|
217
|
+
typeReference = typ.fields[0];
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
matchResult_1 = 1;
|
|
222
|
+
typeReference = typ.fields[0];
|
|
223
|
+
}
|
|
224
|
+
break;
|
|
248
225
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
226
|
+
case 16: {
|
|
227
|
+
matchResult_1 = 2;
|
|
228
|
+
functionType = typ.fields[0];
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
case 8: {
|
|
232
|
+
if (typ.fields[0].tag === 6) {
|
|
233
|
+
matchResult_1 = 3;
|
|
234
|
+
}
|
|
235
|
+
else {
|
|
236
|
+
matchResult_1 = 4;
|
|
237
|
+
typ_2 = typ;
|
|
238
|
+
}
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
default: {
|
|
242
|
+
matchResult_1 = 4;
|
|
243
|
+
typ_2 = typ;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
switch (matchResult_1) {
|
|
247
|
+
case 0:
|
|
248
|
+
return new FSharpType(/* ResizeArray */ 14, [signatureType_1(typeArgument)]);
|
|
249
|
+
case 1:
|
|
250
|
+
return new FSharpType(/* TypeReference */ 11, [new FSharpTypeReference((typeReference.Name === "JS.Uint8ClampedArray") ? "JS.Uint8Array" : typeReference.Name, "", typeReference.ModulePath, map(signatureType_1, typeReference.TypeArguments), FSharpType.Discard)]);
|
|
251
|
+
case 2:
|
|
252
|
+
return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, signatureType_1(parameter.Type), undefined)), functionType.Parameters), signatureType_1(functionType.ReturnType))]);
|
|
253
|
+
case 3:
|
|
254
|
+
return FSharpType.Object$;
|
|
255
|
+
default:
|
|
256
|
+
return FSharpTypeModule_mapChildren(signatureType_1, typ_2);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
258
259
|
}
|
|
259
260
|
}
|
|
260
261
|
|
|
261
|
-
export function signatureType(typ) {
|
|
262
|
-
return signatureTypeAt(0, typ);
|
|
262
|
+
export function signatureType(aliases, typ) {
|
|
263
|
+
return signatureTypeAt(aliases, 0, typ);
|
|
263
264
|
}
|
|
264
265
|
|
|
265
266
|
function canonicalTypeParameters(erased, names, typ) {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
267
|
+
if (typ.tag === 13) {
|
|
268
|
+
if (FSharpSet__Contains(erased, typ.fields[0])) {
|
|
269
|
+
return FSharpType.Object$;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
let matchValue;
|
|
273
|
+
let outArg = defaultOf();
|
|
274
|
+
matchValue = [tryGetValue(names, typ.fields[0], new FSharpRef(() => outArg, (v) => {
|
|
275
|
+
outArg = v;
|
|
276
|
+
})), outArg];
|
|
277
|
+
if (matchValue[0]) {
|
|
278
|
+
return new FSharpType(/* TypeParameter */ 13, [matchValue[1]]);
|
|
271
279
|
}
|
|
272
280
|
else {
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
outArg = v;
|
|
277
|
-
})), outArg];
|
|
278
|
-
if (matchValue[0]) {
|
|
279
|
-
return new FSharpType(/* TypeParameter */ 13, [matchValue[1]]);
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
const canonicalName_1 = `T${names.size}`;
|
|
283
|
-
names.set(typ.fields[0], canonicalName_1);
|
|
284
|
-
return new FSharpType(/* TypeParameter */ 13, [canonicalName_1]);
|
|
285
|
-
}
|
|
281
|
+
const canonicalName_1 = `T${names.size}`;
|
|
282
|
+
names.set(typ.fields[0], canonicalName_1);
|
|
283
|
+
return new FSharpType(/* TypeParameter */ 13, [canonicalName_1]);
|
|
286
284
|
}
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
case 14:
|
|
292
|
-
return new FSharpType(/* ResizeArray */ 14, [canonical(typ.fields[0])]);
|
|
293
|
-
case 19:
|
|
294
|
-
return new FSharpType(/* JSApi */ 19, [new FSharpJSApi(canonical(typ.fields[0].fields[0]))]);
|
|
295
|
-
case 1:
|
|
296
|
-
return new FSharpType(/* Union */ 1, [new FSharpUnion(typ.fields[0].Attributes, typ.fields[0].Name, map((_arg) => {
|
|
297
|
-
switch (_arg.tag) {
|
|
298
|
-
case 1:
|
|
299
|
-
return new FSharpUnionCase(/* Typed */ 1, [canonical(_arg.fields[0])]);
|
|
300
|
-
case 2:
|
|
301
|
-
return new FSharpUnionCase(/* Field */ 2, [_arg.fields[0], canonical(_arg.fields[1])]);
|
|
302
|
-
default:
|
|
303
|
-
return _arg;
|
|
304
|
-
}
|
|
305
|
-
}, typ.fields[0].Cases), typ.fields[0].IsOptional, typ.fields[0].TypeParameters, typ.fields[0].Constants)]);
|
|
306
|
-
case 12:
|
|
307
|
-
return new FSharpType(/* Tuple */ 12, [map(canonical, typ.fields[0])]);
|
|
308
|
-
case 16:
|
|
309
|
-
return new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((parameter) => (new FSharpParameter(parameter.Attributes, parameter.Name, parameter.IsOptional, canonical(parameter.Type), parameter.OriginalGlueMember)), typ.fields[0].Parameters), canonical(typ.fields[0].ReturnType))]);
|
|
310
|
-
default:
|
|
311
|
-
return typ;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else {
|
|
288
|
+
return FSharpTypeModule_mapChildren((typ_1) => canonicalTypeParameters(erased, names, typ_1), typ);
|
|
312
289
|
}
|
|
313
290
|
}
|
|
314
291
|
|
|
315
|
-
export function parametersSignatureWith(erased, parameters) {
|
|
292
|
+
export function parametersSignatureWith(aliases, erased, parameters) {
|
|
316
293
|
const names = new Map([]);
|
|
317
|
-
return map((parameter) => [canonicalTypeParameters(erased, names, signatureType(parameter.Type)), parameter.IsOptional], parameters);
|
|
294
|
+
return map((parameter) => [canonicalTypeParameters(erased, names, signatureType(aliases, parameter.Type)), parameter.IsOptional], parameters);
|
|
318
295
|
}
|
|
319
296
|
|
|
320
|
-
export function parametersSignature(parameters) {
|
|
321
|
-
return parametersSignatureWith(
|
|
297
|
+
export function parametersSignature(aliases, parameters) {
|
|
298
|
+
return parametersSignatureWith(aliases, empty_2({
|
|
322
299
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
323
300
|
}), parameters);
|
|
324
301
|
}
|
|
325
302
|
|
|
326
303
|
function distinguishableTypeParameters(typeParameters, parameters) {
|
|
327
|
-
const namesOf = (
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
case 13: {
|
|
334
|
-
matchResult = 0;
|
|
335
|
-
break;
|
|
336
|
-
}
|
|
337
|
-
case 11: {
|
|
338
|
-
matchResult = 1;
|
|
339
|
-
break;
|
|
340
|
-
}
|
|
341
|
-
case 3: {
|
|
342
|
-
matchResult = 2;
|
|
343
|
-
typ_1 = typ.fields[0];
|
|
344
|
-
break;
|
|
345
|
-
}
|
|
346
|
-
case 14: {
|
|
347
|
-
matchResult = 2;
|
|
348
|
-
typ_1 = typ.fields[0];
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
case 19: {
|
|
352
|
-
matchResult = 2;
|
|
353
|
-
typ_1 = typ.fields[0].fields[0];
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
case 1: {
|
|
357
|
-
matchResult = 3;
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
case 12: {
|
|
361
|
-
matchResult = 4;
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
case 16: {
|
|
365
|
-
matchResult = 5;
|
|
366
|
-
break;
|
|
367
|
-
}
|
|
368
|
-
default:
|
|
369
|
-
matchResult = 6;
|
|
370
|
-
}
|
|
371
|
-
switch (matchResult) {
|
|
372
|
-
case 0:
|
|
373
|
-
return singleton(typ.fields[0]);
|
|
374
|
-
case 1:
|
|
375
|
-
return collect(namesOf, typ.fields[0].TypeArguments);
|
|
376
|
-
case 2: {
|
|
377
|
-
typ_mut = typ_1;
|
|
378
|
-
continue namesOf;
|
|
379
|
-
}
|
|
380
|
-
case 3:
|
|
381
|
-
return collect((_arg) => {
|
|
382
|
-
let matchResult_1, typ_2;
|
|
383
|
-
switch (_arg.tag) {
|
|
384
|
-
case 1: {
|
|
385
|
-
matchResult_1 = 0;
|
|
386
|
-
typ_2 = _arg.fields[0];
|
|
387
|
-
break;
|
|
388
|
-
}
|
|
389
|
-
case 2: {
|
|
390
|
-
matchResult_1 = 0;
|
|
391
|
-
typ_2 = _arg.fields[1];
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
default:
|
|
395
|
-
matchResult_1 = 1;
|
|
396
|
-
}
|
|
397
|
-
switch (matchResult_1) {
|
|
398
|
-
case 0:
|
|
399
|
-
return namesOf(typ_2);
|
|
400
|
-
default:
|
|
401
|
-
return empty_1();
|
|
402
|
-
}
|
|
403
|
-
}, typ.fields[0].Cases);
|
|
404
|
-
case 4:
|
|
405
|
-
return collect(namesOf, typ.fields[0]);
|
|
406
|
-
case 5: {
|
|
407
|
-
const functionType = typ.fields[0];
|
|
408
|
-
return append(namesOf(functionType.ReturnType), collect((parameter) => namesOf(parameter.Type), functionType.Parameters));
|
|
409
|
-
}
|
|
410
|
-
default:
|
|
411
|
-
return empty_1();
|
|
412
|
-
}
|
|
413
|
-
break;
|
|
304
|
+
const namesOf = (typ) => {
|
|
305
|
+
if (typ.tag === 13) {
|
|
306
|
+
return singleton(typ.fields[0]);
|
|
307
|
+
}
|
|
308
|
+
else {
|
|
309
|
+
return collect(namesOf, FSharpTypeModule_children(typ));
|
|
414
310
|
}
|
|
415
311
|
};
|
|
416
|
-
const mentioned =
|
|
312
|
+
const mentioned = ofSeq_1(collect((parameter) => namesOf(parameter.Type), parameters), {
|
|
417
313
|
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
418
314
|
});
|
|
419
|
-
return length(filter((
|
|
420
|
-
if (
|
|
315
|
+
return length(filter((_arg) => {
|
|
316
|
+
if (_arg.tag === 0) {
|
|
421
317
|
return true;
|
|
422
318
|
}
|
|
423
319
|
else {
|
|
424
|
-
return !FSharpSet__Contains(mentioned,
|
|
320
|
+
return !FSharpSet__Contains(mentioned, _arg.fields[0].Name);
|
|
425
321
|
}
|
|
426
322
|
}, typeParameters)) | 0;
|
|
427
323
|
}
|
|
428
324
|
|
|
429
325
|
function ownTypeParameterNames(typeParameters) {
|
|
430
|
-
return
|
|
326
|
+
return ofSeq_1(choose((_arg) => {
|
|
431
327
|
if (_arg.tag === 0) {
|
|
432
328
|
return undefined;
|
|
433
329
|
}
|
|
@@ -448,9 +344,9 @@ function withoutOption(typ) {
|
|
|
448
344
|
}
|
|
449
345
|
}
|
|
450
346
|
|
|
451
|
-
function signatureKey(typeParameters, parameters) {
|
|
347
|
+
function signatureKey(aliases, typeParameters, parameters) {
|
|
452
348
|
const erased = ownTypeParameterNames(typeParameters);
|
|
453
|
-
return [distinguishableTypeParameters(typeParameters, parameters), map((arg) => withoutOption(arg[0]), parametersSignatureWith(erased, parameters))];
|
|
349
|
+
return [distinguishableTypeParameters(typeParameters, parameters), map((arg) => withoutOption(arg[0]), parametersSignatureWith(aliases, erased, parameters))];
|
|
454
350
|
}
|
|
455
351
|
|
|
456
352
|
function withParameterlessOverloads(members) {
|
|
@@ -462,7 +358,7 @@ function withParameterlessOverloads(members) {
|
|
|
462
358
|
return false;
|
|
463
359
|
}
|
|
464
360
|
};
|
|
465
|
-
const ambiguous =
|
|
361
|
+
const ambiguous = ofSeq_1(map((tuple) => tuple[0], filter((tupledArg_1) => {
|
|
466
362
|
const group = tupledArg_1[1];
|
|
467
363
|
if (length(filter((tupledArg_2) => tupledArg_2[2], group)) >= 2) {
|
|
468
364
|
return !exists((tupledArg_3) => tupledArg_3[3], group);
|
|
@@ -493,7 +389,7 @@ function withParameterlessOverloads(members) {
|
|
|
493
389
|
return members;
|
|
494
390
|
}
|
|
495
391
|
else {
|
|
496
|
-
const preferred =
|
|
392
|
+
const preferred = ofSeq_1(map((tupledArg_5) => (head(sortBy((tupledArg_6) => [!tupledArg_6[0], tupledArg_6[1]], map((tuple_2) => tuple_2[1], tupledArg_5[1]), {
|
|
497
393
|
Compare: (x_3, y_3) => (compareArrays(x_3, y_3) | 0),
|
|
498
394
|
}))[1] | 0), List_groupBy((tuple_1) => tuple_1[0], choose((tupledArg_4) => {
|
|
499
395
|
let info_2, info_3;
|
|
@@ -578,18 +474,18 @@ function withParameterlessOverloads(members) {
|
|
|
578
474
|
}
|
|
579
475
|
}
|
|
580
476
|
|
|
581
|
-
function withoutSubsumedOverloads(members) {
|
|
477
|
+
function withoutSubsumedOverloads(aliases, members) {
|
|
582
478
|
const signatureOf = (fsharpMember) => {
|
|
583
479
|
switch (fsharpMember.tag) {
|
|
584
480
|
case 2: {
|
|
585
481
|
const info_1 = fsharpMember.fields[0];
|
|
586
|
-
return [[info_1.Name, false, true], info_1.TypeParameters, parametersSignature(info_1.Parameters), info_1.Type];
|
|
482
|
+
return [[info_1.Name, false, true], info_1.TypeParameters, parametersSignature(aliases, info_1.Parameters), info_1.Type];
|
|
587
483
|
}
|
|
588
484
|
case 1:
|
|
589
485
|
return undefined;
|
|
590
486
|
default: {
|
|
591
487
|
const info = fsharpMember.fields[0];
|
|
592
|
-
return [[info.Name, true, info.IsStatic], info.TypeParameters, parametersSignature(info.Parameters), info.Type];
|
|
488
|
+
return [[info.Name, true, info.IsStatic], info.TypeParameters, parametersSignature(aliases, info.Parameters), info.Type];
|
|
593
489
|
}
|
|
594
490
|
}
|
|
595
491
|
};
|
|
@@ -650,9 +546,9 @@ function withoutSubsumedOverloads(members) {
|
|
|
650
546
|
}, members);
|
|
651
547
|
}
|
|
652
548
|
|
|
653
|
-
export function distinctBySignature(members) {
|
|
654
|
-
const members_2 = withParameterlessOverloads(withoutSubsumedOverloads(members));
|
|
655
|
-
const methodNames =
|
|
549
|
+
export function distinctBySignature(aliases, members) {
|
|
550
|
+
const members_2 = withParameterlessOverloads(withoutSubsumedOverloads(aliases, members));
|
|
551
|
+
const methodNames = ofSeq_1(choose((_arg) => {
|
|
656
552
|
if (_arg.tag === 0) {
|
|
657
553
|
return _arg.fields[0].Name;
|
|
658
554
|
}
|
|
@@ -691,16 +587,16 @@ export function distinctBySignature(members) {
|
|
|
691
587
|
switch (_arg_2.tag) {
|
|
692
588
|
case 1: {
|
|
693
589
|
const info_3 = _arg_2.fields[0];
|
|
694
|
-
return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_3.Name, map((tuple) => tuple[0], parametersSignature(info_3.Parameters))]]);
|
|
590
|
+
return new FSharpChoice$3(/* Choice2Of3 */ 1, [[info_3.Name, map((tuple) => tuple[0], parametersSignature(aliases, info_3.Parameters))]]);
|
|
695
591
|
}
|
|
696
592
|
case 2: {
|
|
697
593
|
const info_4 = _arg_2.fields[0];
|
|
698
|
-
const patternInput_1 = signatureKey(info_4.TypeParameters, info_4.Parameters);
|
|
594
|
+
const patternInput_1 = signatureKey(aliases, info_4.TypeParameters, info_4.Parameters);
|
|
699
595
|
return new FSharpChoice$3(/* Choice3Of3 */ 2, [[info_4.Name, patternInput_1[0], patternInput_1[1]]]);
|
|
700
596
|
}
|
|
701
597
|
default: {
|
|
702
598
|
const info_2 = _arg_2.fields[0];
|
|
703
|
-
const patternInput = signatureKey(info_2.TypeParameters, info_2.Parameters);
|
|
599
|
+
const patternInput = signatureKey(aliases, info_2.TypeParameters, info_2.Parameters);
|
|
704
600
|
return new FSharpChoice$3(/* Choice1Of3 */ 0, [[info_2.Name, patternInput[0], patternInput[1]]]);
|
|
705
601
|
}
|
|
706
602
|
}
|
|
@@ -717,9 +613,9 @@ export function distinctBySignature(members) {
|
|
|
717
613
|
}));
|
|
718
614
|
}
|
|
719
615
|
|
|
720
|
-
function mergeTypes(types) {
|
|
616
|
+
function mergeTypes(aliases, types) {
|
|
721
617
|
const indexes = new Map([]);
|
|
722
|
-
const
|
|
618
|
+
const seenAliases = new Set([]);
|
|
723
619
|
const result = [];
|
|
724
620
|
const enumerator = getEnumerator(types);
|
|
725
621
|
try {
|
|
@@ -729,7 +625,7 @@ function mergeTypes(types) {
|
|
|
729
625
|
switch (typ.tag) {
|
|
730
626
|
case 9: {
|
|
731
627
|
const aliasInfo = typ.fields[0];
|
|
732
|
-
if (addToSet(`${aliasInfo.Name}/${length(aliasInfo.TypeParameters)}`,
|
|
628
|
+
if (addToSet(`${aliasInfo.Name}/${length(aliasInfo.TypeParameters)}`, seenAliases)) {
|
|
733
629
|
void (result.push(typ));
|
|
734
630
|
}
|
|
735
631
|
break;
|
|
@@ -741,7 +637,7 @@ function mergeTypes(types) {
|
|
|
741
637
|
const existing = item(index, result);
|
|
742
638
|
if (existing.tag === 5) {
|
|
743
639
|
const existingInterfaceInfo = existing.fields[0];
|
|
744
|
-
setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
|
|
640
|
+
setItem(result, index, new FSharpType(/* Interface */ 5, [(Members = distinctBySignature(aliases, append(existingInterfaceInfo.Members, interfaceInfo.Members)), (Inheritance = List_distinct(append(existingInterfaceInfo.Inheritance, interfaceInfo.Inheritance), {
|
|
745
641
|
Equals: equals,
|
|
746
642
|
GetHashCode: (x) => (safeHash(x) | 0),
|
|
747
643
|
}), new FSharpInterface(existingInterfaceInfo.Attributes, existingInterfaceInfo.Name, existingInterfaceInfo.XmlDoc, existingInterfaceInfo.OriginalName, (length(interfaceInfo.TypeParameters) > length(existingInterfaceInfo.TypeParameters)) ? interfaceInfo.TypeParameters : existingInterfaceInfo.TypeParameters, Members, Inheritance)))]));
|
|
@@ -767,7 +663,7 @@ function mergeTypes(types) {
|
|
|
767
663
|
break;
|
|
768
664
|
}
|
|
769
665
|
case 17: {
|
|
770
|
-
if (addToSet(concat("class/", typ.fields[0].Name),
|
|
666
|
+
if (addToSet(concat("class/", typ.fields[0].Name), seenAliases)) {
|
|
771
667
|
void (result.push(typ));
|
|
772
668
|
}
|
|
773
669
|
break;
|
|
@@ -780,10 +676,10 @@ function mergeTypes(types) {
|
|
|
780
676
|
finally {
|
|
781
677
|
disposeSafe(enumerator);
|
|
782
678
|
}
|
|
783
|
-
return
|
|
679
|
+
return ofSeq_2(result);
|
|
784
680
|
}
|
|
785
681
|
|
|
786
|
-
function mergeModules(types) {
|
|
682
|
+
function mergeModules(aliases, types) {
|
|
787
683
|
const indexes = new Map([]);
|
|
788
684
|
const result = [];
|
|
789
685
|
const enumerator = getEnumerator(types);
|
|
@@ -792,13 +688,13 @@ function mergeModules(types) {
|
|
|
792
688
|
const typ = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
793
689
|
if (typ.tag === 4) {
|
|
794
690
|
const moduleInfo = typ.fields[0];
|
|
795
|
-
const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(mergeTypes(moduleInfo.Types)));
|
|
691
|
+
const newModuleInfo = new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, moduleInfo.Types)));
|
|
796
692
|
if (indexes.has(moduleInfo.Name)) {
|
|
797
693
|
const index = getItemFromDict(indexes, moduleInfo.Name) | 0;
|
|
798
694
|
const existing = item(index, result);
|
|
799
695
|
if (existing.tag === 4) {
|
|
800
696
|
const existingModuleInfo = existing.fields[0];
|
|
801
|
-
setItem(result, index, new FSharpType(/* Module */ 4, [new FSharpModule(existingModuleInfo.Name, existingModuleInfo.IsRecursive, existingModuleInfo.ImportSpecifier, mergeModules(mergeTypes(append(existingModuleInfo.Types, newModuleInfo.Types))))]));
|
|
697
|
+
setItem(result, index, new FSharpType(/* Module */ 4, [new FSharpModule(existingModuleInfo.Name, existingModuleInfo.IsRecursive, existingModuleInfo.ImportSpecifier, mergeModules(aliases, mergeTypes(aliases, append(existingModuleInfo.Types, newModuleInfo.Types))))]));
|
|
802
698
|
}
|
|
803
699
|
else {
|
|
804
700
|
throw new Exception("Invalid state");
|
|
@@ -817,7 +713,7 @@ function mergeModules(types) {
|
|
|
817
713
|
finally {
|
|
818
714
|
disposeSafe(enumerator);
|
|
819
715
|
}
|
|
820
|
-
return
|
|
716
|
+
return ofSeq_2(result);
|
|
821
717
|
}
|
|
822
718
|
|
|
823
719
|
function dropEmptyModules(types) {
|
|
@@ -841,23 +737,23 @@ function dropEmptyModules(types) {
|
|
|
841
737
|
}, types);
|
|
842
738
|
}
|
|
843
739
|
|
|
844
|
-
function distinctMembers(types) {
|
|
740
|
+
function distinctMembers(aliases, types) {
|
|
845
741
|
return map((typ) => {
|
|
846
742
|
switch (typ.tag) {
|
|
847
743
|
case 5: {
|
|
848
744
|
const interfaceInfo = typ.fields[0];
|
|
849
|
-
return new FSharpType(/* Interface */ 5, [new FSharpInterface(interfaceInfo.Attributes, interfaceInfo.Name, interfaceInfo.XmlDoc, interfaceInfo.OriginalName, interfaceInfo.TypeParameters, distinctBySignature(interfaceInfo.Members), interfaceInfo.Inheritance)]);
|
|
745
|
+
return new FSharpType(/* Interface */ 5, [new FSharpInterface(interfaceInfo.Attributes, interfaceInfo.Name, interfaceInfo.XmlDoc, interfaceInfo.OriginalName, interfaceInfo.TypeParameters, distinctBySignature(aliases, interfaceInfo.Members), interfaceInfo.Inheritance)]);
|
|
850
746
|
}
|
|
851
747
|
case 17: {
|
|
852
748
|
const classInfo = typ.fields[0];
|
|
853
|
-
return new FSharpType(/* Class */ 17, [new FSharpClass(classInfo.Attributes, classInfo.XmlDoc, classInfo.Name, classInfo.TypeParameters, classInfo.PrimaryConstructor, List_distinctBy((constructorInfo) => parametersSignature(constructorInfo.Parameters), classInfo.SecondaryConstructors, {
|
|
749
|
+
return new FSharpType(/* Class */ 17, [new FSharpClass(classInfo.Attributes, classInfo.XmlDoc, classInfo.Name, classInfo.TypeParameters, classInfo.PrimaryConstructor, List_distinctBy((constructorInfo) => parametersSignature(aliases, constructorInfo.Parameters), classInfo.SecondaryConstructors, {
|
|
854
750
|
Equals: equals,
|
|
855
751
|
GetHashCode: (x) => (safeHash(x) | 0),
|
|
856
752
|
}), classInfo.ExplicitFields)]);
|
|
857
753
|
}
|
|
858
754
|
case 4: {
|
|
859
755
|
const moduleInfo = typ.fields[0];
|
|
860
|
-
return new FSharpType(/* Module */ 4, [new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, distinctMembers(moduleInfo.Types))]);
|
|
756
|
+
return new FSharpType(/* Module */ 4, [new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, distinctMembers(aliases, moduleInfo.Types))]);
|
|
861
757
|
}
|
|
862
758
|
default:
|
|
863
759
|
return typ;
|
|
@@ -865,10 +761,146 @@ function distinctMembers(types) {
|
|
|
865
761
|
}, types);
|
|
866
762
|
}
|
|
867
763
|
|
|
764
|
+
/**
|
|
765
|
+
* TypeScript resolves a call to the first declaration it matches
|
|
766
|
+
*/
|
|
767
|
+
export function disambiguateOverloads(aliases, types) {
|
|
768
|
+
const requiredKey = (fsharpMember) => {
|
|
769
|
+
const key = (name, isStatic, typeParameters, parameters) => {
|
|
770
|
+
if (isEmpty_1(parameters)) {
|
|
771
|
+
return undefined;
|
|
772
|
+
}
|
|
773
|
+
else {
|
|
774
|
+
return [name, isStatic, typeParameters, parametersSignature(aliases, filter((parameter) => !parameter.IsOptional, parameters))];
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
switch (fsharpMember.tag) {
|
|
778
|
+
case 2: {
|
|
779
|
+
const info_1 = fsharpMember.fields[0];
|
|
780
|
+
return key(info_1.Name, true, info_1.TypeParameters, info_1.Parameters);
|
|
781
|
+
}
|
|
782
|
+
case 1:
|
|
783
|
+
return undefined;
|
|
784
|
+
default: {
|
|
785
|
+
const info = fsharpMember.fields[0];
|
|
786
|
+
return key(info.Name, info.IsStatic, info.TypeParameters, info.Parameters);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
};
|
|
790
|
+
return map((_arg_1) => {
|
|
791
|
+
let taken;
|
|
792
|
+
switch (_arg_1.tag) {
|
|
793
|
+
case 5: {
|
|
794
|
+
const interfaceInfo = _arg_1.fields[0];
|
|
795
|
+
return new FSharpType(/* Interface */ 5, [new FSharpInterface(interfaceInfo.Attributes, interfaceInfo.Name, interfaceInfo.XmlDoc, interfaceInfo.OriginalName, interfaceInfo.TypeParameters, (taken = (new HashSet([], {
|
|
796
|
+
Equals: equalArrays,
|
|
797
|
+
GetHashCode: (x) => (arrayHash(x) | 0),
|
|
798
|
+
})), choose((fsharpMember_2) => {
|
|
799
|
+
const matchValue_1 = requiredKey(fsharpMember_2);
|
|
800
|
+
if (matchValue_1 != null) {
|
|
801
|
+
const free = (candidate_mut, key_2_mut) => {
|
|
802
|
+
free:
|
|
803
|
+
while (true) {
|
|
804
|
+
const candidate = candidate_mut, key_2 = key_2_mut;
|
|
805
|
+
if (!taken.has(key_2)) {
|
|
806
|
+
addToSet(key_2, taken);
|
|
807
|
+
return candidate;
|
|
808
|
+
}
|
|
809
|
+
else {
|
|
810
|
+
let matchValue_2;
|
|
811
|
+
const fsharpMember_1 = candidate;
|
|
812
|
+
const promote = (parameters_2) => {
|
|
813
|
+
const matchValue = tryFindIndex((_arg) => _arg.IsOptional, parameters_2);
|
|
814
|
+
if (matchValue != null) {
|
|
815
|
+
const index = matchValue | 0;
|
|
816
|
+
return mapIndexed((currentIndex, parameter_1) => {
|
|
817
|
+
if (currentIndex === index) {
|
|
818
|
+
return new FSharpParameter(parameter_1.Attributes, parameter_1.Name, false, parameter_1.Type, parameter_1.OriginalGlueMember);
|
|
819
|
+
}
|
|
820
|
+
else {
|
|
821
|
+
return parameter_1;
|
|
822
|
+
}
|
|
823
|
+
}, parameters_2);
|
|
824
|
+
}
|
|
825
|
+
else {
|
|
826
|
+
return undefined;
|
|
827
|
+
}
|
|
828
|
+
};
|
|
829
|
+
switch (fsharpMember_1.tag) {
|
|
830
|
+
case 2: {
|
|
831
|
+
const info_3 = fsharpMember_1.fields[0];
|
|
832
|
+
const option_3 = promote(info_3.Parameters);
|
|
833
|
+
matchValue_2 = ((option_3 != null) ? (new FSharpMember(/* StaticMember */ 2, [new FSharpStaticMemberInfo(info_3.Attributes, info_3.Name, info_3.OriginalName, info_3.TypeParameters, option_3, info_3.Type, info_3.IsOptional, info_3.Accessor, info_3.Accessibility, info_3.XmlDoc)])) : undefined);
|
|
834
|
+
break;
|
|
835
|
+
}
|
|
836
|
+
case 1: {
|
|
837
|
+
matchValue_2 = fsharpMember_1;
|
|
838
|
+
break;
|
|
839
|
+
}
|
|
840
|
+
default: {
|
|
841
|
+
const info_2 = fsharpMember_1.fields[0];
|
|
842
|
+
const option_1 = promote(info_2.Parameters);
|
|
843
|
+
matchValue_2 = ((option_1 != null) ? (new FSharpMember(/* Method */ 0, [new FSharpMemberInfo(info_2.Attributes, info_2.Name, info_2.OriginalName, info_2.TypeParameters, option_1, info_2.Type, info_2.IsOptional, info_2.IsStatic, info_2.Accessor, info_2.Accessibility, info_2.XmlDoc, info_2.Body)])) : undefined);
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
if (matchValue_2 != null) {
|
|
847
|
+
const promoted = matchValue_2;
|
|
848
|
+
const matchValue_3 = requiredKey(promoted);
|
|
849
|
+
if (matchValue_3 != null) {
|
|
850
|
+
candidate_mut = promoted;
|
|
851
|
+
key_2_mut = matchValue_3;
|
|
852
|
+
continue free;
|
|
853
|
+
}
|
|
854
|
+
else {
|
|
855
|
+
return undefined;
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
else {
|
|
859
|
+
return undefined;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
break;
|
|
863
|
+
}
|
|
864
|
+
};
|
|
865
|
+
return free(fsharpMember_2, matchValue_1);
|
|
866
|
+
}
|
|
867
|
+
else {
|
|
868
|
+
return fsharpMember_2;
|
|
869
|
+
}
|
|
870
|
+
}, interfaceInfo.Members)), interfaceInfo.Inheritance)]);
|
|
871
|
+
}
|
|
872
|
+
case 4: {
|
|
873
|
+
const moduleInfo = _arg_1.fields[0];
|
|
874
|
+
return new FSharpType(/* Module */ 4, [new FSharpModule(moduleInfo.Name, moduleInfo.IsRecursive, moduleInfo.ImportSpecifier, disambiguateOverloads(aliases, moduleInfo.Types))]);
|
|
875
|
+
}
|
|
876
|
+
default:
|
|
877
|
+
return _arg_1;
|
|
878
|
+
}
|
|
879
|
+
}, types);
|
|
880
|
+
}
|
|
881
|
+
|
|
882
|
+
/**
|
|
883
|
+
* If a type is declared twice, merge them into one.
|
|
884
|
+
*
|
|
885
|
+
* This can happens because TypeScript allows multiple declarations of the same type.
|
|
886
|
+
*
|
|
887
|
+
* Example:
|
|
888
|
+
*
|
|
889
|
+
* <code lang="typescript">
|
|
890
|
+
* interface A {
|
|
891
|
+
* a: string;
|
|
892
|
+
* }
|
|
893
|
+
*
|
|
894
|
+
* interface A {
|
|
895
|
+
* b: number;
|
|
896
|
+
* }
|
|
897
|
+
* </code>
|
|
898
|
+
*/
|
|
899
|
+
export function applyWith(aliases, types) {
|
|
900
|
+
return distinctMembers(aliases, dropEmptyModules(mergeModules(aliases, mergeTypes(aliases, types))));
|
|
901
|
+
}
|
|
902
|
+
|
|
868
903
|
export function apply(types) {
|
|
869
|
-
|
|
870
|
-
genericAliasTargets.clear();
|
|
871
|
-
collectAliases(empty_1(), types);
|
|
872
|
-
return distinctMembers(dropEmptyModules(mergeModules(mergeTypes(types))));
|
|
904
|
+
return applyWith(aliasesOf(types), types);
|
|
873
905
|
}
|
|
874
906
|
|