@glutinum/cli 1.0.0-beta.1 → 1.0.0-beta.11
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 +16 -39
- package/dist/Glutinum.Converter/DelegateExtensions.js +378 -0
- package/dist/Glutinum.Converter/FreeTypeParameters.js +211 -0
- package/dist/Glutinum.Converter/FsharpAST.js +117 -66
- package/dist/Glutinum.Converter/Generate.js +52 -26
- package/dist/Glutinum.Converter/GlueAST.js +85 -46
- package/dist/Glutinum.Converter/Hosting.js +148 -174
- package/dist/Glutinum.Converter/Merge.js +463 -355
- package/dist/Glutinum.Converter/Packages.js +387 -97
- package/dist/Glutinum.Converter/Printer.js +439 -400
- package/dist/Glutinum.Converter/Read.js +362 -100
- package/dist/Glutinum.Converter/Reader/ClassDeclaration.js +7 -7
- package/dist/Glutinum.Converter/Reader/ConditionalTypeNode.js +90 -0
- package/dist/Glutinum.Converter/Reader/Declaration.js +13 -19
- package/dist/Glutinum.Converter/Reader/Deferred.js +706 -0
- package/dist/Glutinum.Converter/Reader/Documentation.js +28 -40
- package/dist/Glutinum.Converter/Reader/EnumDeclaration.js +2 -2
- package/dist/Glutinum.Converter/Reader/ExportAssignment.js +104 -37
- package/dist/Glutinum.Converter/Reader/ExportDeclaration.js +24 -39
- package/dist/Glutinum.Converter/Reader/ExpressionWithTypeArguments.js +59 -0
- package/dist/Glutinum.Converter/Reader/FunctionDeclaration.js +30 -17
- package/dist/Glutinum.Converter/Reader/IndexedAccessType.js +16 -22
- package/dist/Glutinum.Converter/Reader/InterfaceDeclaration.js +49 -6
- package/dist/Glutinum.Converter/Reader/IntersectionTypeNode.js +178 -0
- package/dist/Glutinum.Converter/Reader/MappedTypeNode.js +4 -4
- package/dist/Glutinum.Converter/Reader/MemberTypes.js +126 -0
- package/dist/Glutinum.Converter/Reader/ModuleDeclaration.js +54 -6
- package/dist/Glutinum.Converter/Reader/Node.js +11 -14
- package/dist/Glutinum.Converter/Reader/Parameters.js +39 -30
- package/dist/Glutinum.Converter/Reader/Report.js +4 -4
- package/dist/Glutinum.Converter/Reader/TypeNode.js +390 -1584
- package/dist/Glutinum.Converter/Reader/TypeOperatorNode.js +80 -53
- package/dist/Glutinum.Converter/Reader/TypeParameters.js +2 -2
- package/dist/Glutinum.Converter/Reader/TypeQueryNode.js +24 -47
- package/dist/Glutinum.Converter/Reader/TypeScriptReader.js +24 -6
- package/dist/Glutinum.Converter/Reader/Types.js +297 -17
- package/dist/Glutinum.Converter/Reader/UnionTypeNode.js +16 -30
- package/dist/Glutinum.Converter/Reader/UtilityType.js +811 -0
- package/dist/Glutinum.Converter/Reader/Utils.js +497 -111
- package/dist/Glutinum.Converter/Reader/VariableStatement.js +7 -8
- package/dist/Glutinum.Converter/Transform.js +2915 -8180
- 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 +1087 -0
- package/dist/Glutinum.Converter/Transformer/Context.js +678 -0
- package/dist/Glutinum.Converter/Transformer/Enum.js +80 -0
- package/dist/Glutinum.Converter/Transformer/Exports.js +704 -0
- package/dist/Glutinum.Converter/Transformer/Heritage.js +493 -0
- package/dist/Glutinum.Converter/Transformer/KeyOfMaps.js +488 -0
- package/dist/Glutinum.Converter/Transformer/ParamObjectCandidate.js +460 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameter.js +219 -0
- package/dist/Glutinum.Converter/Transformer/TypeParameters.js +448 -0
- package/dist/Glutinum.Converter/Transformer/UnionOverloads.js +338 -0
- package/dist/Glutinum.Converter/Transformer/Utils.js +341 -0
- package/dist/Glutinum.Converter/TypeScript.Extensions.js +0 -10
- package/dist/Glutinum.Converter/Utils/Keywords.js +3 -3
- package/dist/Glutinum.Converter/Utils/List.js +2 -2
- package/dist/Glutinum.Converter/Utils/Naming.js +6 -6
- package/dist/Glutinum.Converter/Utils/String.js +16 -5
- package/dist/Program.js +104 -241
- package/dist/fable_modules/Fable.Promise.3.2.1/AsyncIterable.fs.js +2 -2
- package/dist/fable_modules/Fable.Promise.3.2.1/Promise.fs.js +4 -4
- package/dist/fable_modules/Fable.Promise.3.2.1/PromiseImpl.fs.js +2 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Array.fs.js +5 -5
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Async.fs.js +4 -4
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncOptionCE.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOption.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncResultOptionCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/AsyncValidationCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/List.fs.js +4 -4
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/OptionCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResult.fs.js +3 -3
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncResultCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ParallelAsyncValidationCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Result.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultCE.fs.js +2 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOption.fs.js +2 -2
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ResultOptionCE.fs.js +1 -1
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/Seq.fs.js +7 -7
- package/dist/fable_modules/FsToolkit.ErrorHandling.5.2.0/ValidationCE.fs.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Async.js +21 -7
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/AsyncBuilder.js +51 -6
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CHANGELOG.md +23 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/CollectionUtil.js +10 -16
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MailboxProcessor.js +19 -3
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableMap.js +5 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MutableSet.js +5 -1
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Util.js +15 -3
- package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/package.json +1 -1
- package/package.json +3 -2
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Array.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BigInt.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/BitConverter.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Date.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOffset.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeFormat.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeOffsetTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/DateTimeTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Decimal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Directory.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Double.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Encoding.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Environment.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Event.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/FSharp.Core.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/File.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Global.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Guid.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Int32.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/List.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Long.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Map.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Numeric.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Observable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Option.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Path.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Random.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Range.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Reflection.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/RegExp.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Seq2.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Set.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/String.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Collections.Generic.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.Text.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/System.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Task.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TaskBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/TimeSpanTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Types.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/Uri.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/big.d.ts +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/lib/big.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.17.2 → fable-library-js.5.21.0}/quotation.js +0 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
|
|
2
|
+
import { singleton as singleton_1, collect as collect_1, append, mapIndexed, empty, choose, tryFindIndex, ofArray, take, map, tail, head, isEmpty, contains } from "../../fable_modules/fable-library-js.5.21.0/List.js";
|
|
3
|
+
import { FSharpMember, FSharpMemberInfo, FSharpFunctionType, FSharpPrimitive, FSharpParameter, FSharpType, FSharpAttribute } from "../FsharpAST.js";
|
|
4
|
+
import { comparePrimitives, safeHash, equals } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
|
|
5
|
+
import { ofSeq, FSharpSet__Contains } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
|
|
6
|
+
import { append as append_1, singleton, collect, delay, toList } from "../../fable_modules/fable-library-js.5.21.0/Seq.js";
|
|
7
|
+
import { declaredTypeParameters } from "./TypeParameters.js";
|
|
8
|
+
import { rangeDouble } from "../../fable_modules/fable-library-js.5.21.0/Range.js";
|
|
9
|
+
|
|
10
|
+
const MAX_ARITY = 3;
|
|
11
|
+
|
|
12
|
+
function isAnyFunction(typ) {
|
|
13
|
+
let matchResult, attributes;
|
|
14
|
+
if (typ.tag === 16) {
|
|
15
|
+
if (!isEmpty(typ.fields[0].Parameters)) {
|
|
16
|
+
if (head(typ.fields[0].Parameters).Type.tag === 8) {
|
|
17
|
+
if (head(typ.fields[0].Parameters).Type.fields[0].tag === 6) {
|
|
18
|
+
if (isEmpty(tail(typ.fields[0].Parameters))) {
|
|
19
|
+
if (typ.fields[0].ReturnType.tag === 8) {
|
|
20
|
+
if (typ.fields[0].ReturnType.fields[0].tag === 4) {
|
|
21
|
+
matchResult = 0;
|
|
22
|
+
attributes = head(typ.fields[0].Parameters).Attributes;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
matchResult = 1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
matchResult = 1;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
matchResult = 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
matchResult = 1;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
matchResult = 1;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
matchResult = 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
matchResult = 1;
|
|
50
|
+
}
|
|
51
|
+
switch (matchResult) {
|
|
52
|
+
case 0:
|
|
53
|
+
return contains(FSharpAttribute.ParamArray, attributes, {
|
|
54
|
+
Equals: equals,
|
|
55
|
+
GetHashCode: (x) => (safeHash(x) | 0),
|
|
56
|
+
});
|
|
57
|
+
default:
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function typeParameterNames(taken, arity) {
|
|
63
|
+
return map((name) => {
|
|
64
|
+
if (FSharpSet__Contains(taken, name)) {
|
|
65
|
+
return name + "1";
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
return name;
|
|
69
|
+
}
|
|
70
|
+
}, take(arity, ofArray(["A", "B", "C"])));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function expand(info) {
|
|
74
|
+
const matchValue = tryFindIndex((parameter) => isAnyFunction(parameter.Type), info.Parameters);
|
|
75
|
+
if (matchValue != null) {
|
|
76
|
+
const index = matchValue | 0;
|
|
77
|
+
const taken = ofSeq(choose((_arg) => {
|
|
78
|
+
if (_arg.tag === 0) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
return _arg.fields[0].Name;
|
|
83
|
+
}
|
|
84
|
+
}, info.TypeParameters), {
|
|
85
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
86
|
+
});
|
|
87
|
+
return toList(delay(() => collect((arity) => {
|
|
88
|
+
let Parameters;
|
|
89
|
+
const names = typeParameterNames(taken, arity);
|
|
90
|
+
const lambda = new FSharpType(/* Function */ 16, [new FSharpFunctionType(map((name) => (new FSharpParameter(empty(), name.toLowerCase(), false, new FSharpType(/* TypeParameter */ 13, [name]), undefined)), names), new FSharpType(/* Primitive */ 8, [FSharpPrimitive.Unit]))]);
|
|
91
|
+
return singleton((Parameters = mapIndexed((i, parameter_1) => {
|
|
92
|
+
if (i === index) {
|
|
93
|
+
return new FSharpParameter(parameter_1.Attributes, parameter_1.Name, parameter_1.IsOptional, lambda, parameter_1.OriginalGlueMember);
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
return parameter_1;
|
|
97
|
+
}
|
|
98
|
+
}, info.Parameters), new FSharpMemberInfo(info.Attributes, info.Name, info.OriginalName, append(info.TypeParameters, declaredTypeParameters(names)), Parameters, info.Type, info.IsOptional, info.IsStatic, info.Accessor, info.Accessibility, info.XmlDoc, info.Body)));
|
|
99
|
+
}, rangeDouble(1, 1, MAX_ARITY))));
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
return empty();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function expandMembers(members) {
|
|
107
|
+
return collect_1((fsharpMember) => {
|
|
108
|
+
if (fsharpMember.tag === 0) {
|
|
109
|
+
return toList(delay(() => append_1(map((Item) => (new FSharpMember(/* Method */ 0, [Item])), expand(fsharpMember.fields[0])), delay(() => singleton(fsharpMember)))));
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
return singleton_1(fsharpMember);
|
|
113
|
+
}
|
|
114
|
+
}, members);
|
|
115
|
+
}
|
|
116
|
+
|
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
|
|
2
|
+
import { collect, forAll, singleton, contains, filter, choose, map, head, tail, isEmpty, empty as empty_1, tryPick, exists } from "../../fable_modules/fable-library-js.5.21.0/List.js";
|
|
3
|
+
import { empty, FSharpSet__Contains, FSharpSet__Add } from "../../fable_modules/fable-library-js.5.21.0/Set.js";
|
|
4
|
+
import { iteratorNames } from "./Utils.js";
|
|
5
|
+
import { stringHash, comparePrimitives } from "../../fable_modules/fable-library-js.5.21.0/Util.js";
|
|
6
|
+
import { GlueMethodSignature, GlueSubstitution_substitute, GlueMember, GlueSubstitution_substituteMember, GlueSubstitution_ofTypeArguments, GlueFunctionType, GlueParameter, GlueTypeUnion, GlueType, GlueTypeReference, GlueCallSignature } from "../GlueAST.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Whether one of the base interfaces declares `[Symbol.iterator]`, directly or through its bases
|
|
10
|
+
*/
|
|
11
|
+
export function inheritsIterable(typeMemory, heritageClauses) {
|
|
12
|
+
const check = (visited, heritageClauses_1) => exists((heritageClause) => {
|
|
13
|
+
let typeReference;
|
|
14
|
+
let matchResult, typeReference_2, typeReference_3;
|
|
15
|
+
if (heritageClause.tag === 13) {
|
|
16
|
+
if ((typeReference = heritageClause.fields[0], typeReference.IsStandardLibrary && ((typeReference.Name === "Iterable") ? true : FSharpSet__Contains(iteratorNames, typeReference.Name)))) {
|
|
17
|
+
matchResult = 0;
|
|
18
|
+
typeReference_2 = heritageClause.fields[0];
|
|
19
|
+
}
|
|
20
|
+
else if (!FSharpSet__Contains(visited, heritageClause.fields[0].FullName)) {
|
|
21
|
+
matchResult = 1;
|
|
22
|
+
typeReference_3 = heritageClause.fields[0];
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
matchResult = 2;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
matchResult = 2;
|
|
30
|
+
}
|
|
31
|
+
switch (matchResult) {
|
|
32
|
+
case 0:
|
|
33
|
+
return true;
|
|
34
|
+
case 1:
|
|
35
|
+
return exists((glueType) => {
|
|
36
|
+
let matchResult_1, candidate_1;
|
|
37
|
+
if (glueType.tag === 1) {
|
|
38
|
+
if (glueType.fields[0].FullName === typeReference_3.FullName) {
|
|
39
|
+
matchResult_1 = 0;
|
|
40
|
+
candidate_1 = glueType.fields[0];
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
matchResult_1 = 1;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
matchResult_1 = 1;
|
|
48
|
+
}
|
|
49
|
+
switch (matchResult_1) {
|
|
50
|
+
case 0:
|
|
51
|
+
if (exists((_arg) => {
|
|
52
|
+
let matchResult_2;
|
|
53
|
+
if (_arg.tag === 6) {
|
|
54
|
+
if (_arg.fields[0].Name === "[Symbol.iterator]") {
|
|
55
|
+
matchResult_2 = 0;
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
matchResult_2 = 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
matchResult_2 = 1;
|
|
63
|
+
}
|
|
64
|
+
switch (matchResult_2) {
|
|
65
|
+
case 0:
|
|
66
|
+
return true;
|
|
67
|
+
default:
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
}, candidate_1.Members)) {
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
return check(FSharpSet__Add(visited, typeReference_3.FullName), candidate_1.HeritageClauses);
|
|
75
|
+
}
|
|
76
|
+
default:
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}, typeMemory);
|
|
80
|
+
default:
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
}, heritageClauses_1);
|
|
84
|
+
return check(empty({
|
|
85
|
+
Compare: (x, y) => (comparePrimitives(x, y) | 0),
|
|
86
|
+
}), heritageClauses);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* The call signature of a base type generated as a delegate, F# can't inherit it
|
|
91
|
+
*/
|
|
92
|
+
export function tryCallableHeritageAt(depth, typeMemory, heritageClause) {
|
|
93
|
+
let matchResult, typeReference_1;
|
|
94
|
+
if (heritageClause.tag === 13) {
|
|
95
|
+
if (depth < 5) {
|
|
96
|
+
matchResult = 0;
|
|
97
|
+
typeReference_1 = heritageClause.fields[0];
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
matchResult = 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
matchResult = 1;
|
|
105
|
+
}
|
|
106
|
+
switch (matchResult) {
|
|
107
|
+
case 0:
|
|
108
|
+
return tryPick((glueType) => {
|
|
109
|
+
let matchResult_1, fullName_3, functionType_1, callSignature_1, fullName_4, baseHeritage_1, fullName_5;
|
|
110
|
+
switch (glueType.tag) {
|
|
111
|
+
case 5: {
|
|
112
|
+
if (glueType.fields[0].Type.tag === 15) {
|
|
113
|
+
if (glueType.fields[0].FullName === typeReference_1.FullName) {
|
|
114
|
+
matchResult_1 = 0;
|
|
115
|
+
fullName_3 = glueType.fields[0].FullName;
|
|
116
|
+
functionType_1 = glueType.fields[0].Type.fields[0];
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
matchResult_1 = 3;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
matchResult_1 = 3;
|
|
124
|
+
}
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
case 1: {
|
|
128
|
+
if (isEmpty(glueType.fields[0].Members)) {
|
|
129
|
+
if (!isEmpty(glueType.fields[0].HeritageClauses)) {
|
|
130
|
+
if (isEmpty(tail(glueType.fields[0].HeritageClauses))) {
|
|
131
|
+
if (glueType.fields[0].FullName === typeReference_1.FullName) {
|
|
132
|
+
matchResult_1 = 2;
|
|
133
|
+
baseHeritage_1 = head(glueType.fields[0].HeritageClauses);
|
|
134
|
+
fullName_5 = glueType.fields[0].FullName;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
matchResult_1 = 3;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
matchResult_1 = 3;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
matchResult_1 = 3;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
else if (head(glueType.fields[0].Members).tag === 4) {
|
|
149
|
+
if (isEmpty(tail(glueType.fields[0].Members))) {
|
|
150
|
+
if (isEmpty(glueType.fields[0].HeritageClauses)) {
|
|
151
|
+
if (glueType.fields[0].FullName === typeReference_1.FullName) {
|
|
152
|
+
matchResult_1 = 1;
|
|
153
|
+
callSignature_1 = head(glueType.fields[0].Members).fields[0];
|
|
154
|
+
fullName_4 = glueType.fields[0].FullName;
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
matchResult_1 = 3;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
matchResult_1 = 3;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
matchResult_1 = 3;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
matchResult_1 = 3;
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
default:
|
|
174
|
+
matchResult_1 = 3;
|
|
175
|
+
}
|
|
176
|
+
switch (matchResult_1) {
|
|
177
|
+
case 0:
|
|
178
|
+
return new GlueCallSignature(empty_1(), functionType_1.Parameters, functionType_1.Type);
|
|
179
|
+
case 1:
|
|
180
|
+
return callSignature_1;
|
|
181
|
+
case 2:
|
|
182
|
+
return tryCallableHeritageAt(depth + 1, typeMemory, baseHeritage_1);
|
|
183
|
+
default:
|
|
184
|
+
return undefined;
|
|
185
|
+
}
|
|
186
|
+
}, typeMemory);
|
|
187
|
+
default:
|
|
188
|
+
return undefined;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export function tryCallableHeritage(typeMemory, heritageClause) {
|
|
193
|
+
return tryCallableHeritageAt(0, typeMemory, heritageClause);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
function isCallSignature(glueMember) {
|
|
197
|
+
if (glueMember.tag === 4) {
|
|
198
|
+
return true;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
return false;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function qualify(modulePath, glueType) {
|
|
206
|
+
const qualify_1 = (glueType_1) => qualify(modulePath, glueType_1);
|
|
207
|
+
switch (glueType.tag) {
|
|
208
|
+
case 13: {
|
|
209
|
+
const typeReference = glueType.fields[0];
|
|
210
|
+
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(typeReference.Name, typeReference.FullName, (isEmpty(typeReference.ModulePath) && !typeReference.IsStandardLibrary) ? modulePath : typeReference.ModulePath, map(qualify_1, typeReference.TypeArguments), typeReference.IsStandardLibrary)]);
|
|
211
|
+
}
|
|
212
|
+
case 14:
|
|
213
|
+
return new GlueType(/* Array */ 14, [qualify_1(glueType.fields[0])]);
|
|
214
|
+
case 30:
|
|
215
|
+
return new GlueType(/* ReadOnly */ 30, [qualify_1(glueType.fields[0])]);
|
|
216
|
+
case 23:
|
|
217
|
+
return new GlueType(/* OptionalType */ 23, [qualify_1(glueType.fields[0])]);
|
|
218
|
+
case 7:
|
|
219
|
+
return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(qualify_1, glueType.fields[0].fields[0]))]);
|
|
220
|
+
case 18:
|
|
221
|
+
return new GlueType(/* TupleType */ 18, [map(qualify_1, glueType.fields[0])]);
|
|
222
|
+
case 15: {
|
|
223
|
+
const functionType = glueType.fields[0];
|
|
224
|
+
return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(functionType.Documentation, qualify_1(functionType.Type), functionType.TypeParameters, functionType.OwnTypeParameterNames, map((parameter) => (new GlueParameter(parameter.Name, parameter.IsOptional, parameter.IsSpread, qualify_1(parameter.Type))), functionType.Parameters))]);
|
|
225
|
+
}
|
|
226
|
+
default:
|
|
227
|
+
return glueType;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function replaceThis(reference, glueType) {
|
|
232
|
+
const replaceThis_1 = (glueType_1) => replaceThis(reference, glueType_1);
|
|
233
|
+
switch (glueType.tag) {
|
|
234
|
+
case 17:
|
|
235
|
+
return reference;
|
|
236
|
+
case 13: {
|
|
237
|
+
const typeReference = glueType.fields[0];
|
|
238
|
+
return new GlueType(/* TypeReference */ 13, [new GlueTypeReference(typeReference.Name, typeReference.FullName, typeReference.ModulePath, map(replaceThis_1, typeReference.TypeArguments), typeReference.IsStandardLibrary)]);
|
|
239
|
+
}
|
|
240
|
+
case 14:
|
|
241
|
+
return new GlueType(/* Array */ 14, [replaceThis_1(glueType.fields[0])]);
|
|
242
|
+
case 23:
|
|
243
|
+
return new GlueType(/* OptionalType */ 23, [replaceThis_1(glueType.fields[0])]);
|
|
244
|
+
case 7:
|
|
245
|
+
return new GlueType(/* Union */ 7, [new GlueTypeUnion(map(replaceThis_1, glueType.fields[0].fields[0]))]);
|
|
246
|
+
case 15: {
|
|
247
|
+
const functionType = glueType.fields[0];
|
|
248
|
+
return new GlueType(/* FunctionType */ 15, [new GlueFunctionType(functionType.Documentation, replaceThis_1(functionType.Type), functionType.TypeParameters, functionType.OwnTypeParameterNames, functionType.Parameters)]);
|
|
249
|
+
}
|
|
250
|
+
default:
|
|
251
|
+
return glueType;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function qualifySignature(reference, callSignature) {
|
|
256
|
+
const modulePath = (reference.tag === 13) ? reference.fields[0].ModulePath : empty_1();
|
|
257
|
+
const adapt = (glueType) => {
|
|
258
|
+
const glueType_1 = replaceThis(reference, glueType);
|
|
259
|
+
if (isEmpty(modulePath)) {
|
|
260
|
+
return glueType_1;
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
263
|
+
return qualify(modulePath, glueType_1);
|
|
264
|
+
}
|
|
265
|
+
};
|
|
266
|
+
const Type = adapt(callSignature.Type);
|
|
267
|
+
return new GlueCallSignature(callSignature.TypeParameters, map((parameter) => (new GlueParameter(parameter.Name, parameter.IsOptional, parameter.IsSpread, adapt(parameter.Type))), callSignature.Parameters), Type);
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
function callSignatures(members) {
|
|
271
|
+
return choose((_arg) => {
|
|
272
|
+
if (_arg.tag === 4) {
|
|
273
|
+
return _arg.fields[0];
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
}, members);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function signaturesOf(typeMemory, depth, glueType) {
|
|
282
|
+
let members;
|
|
283
|
+
let matchResult, members_1, typeReference_1;
|
|
284
|
+
switch (glueType.tag) {
|
|
285
|
+
case 20: {
|
|
286
|
+
if ((members = glueType.fields[0], !isEmpty(members) && forAll(isCallSignature, members))) {
|
|
287
|
+
matchResult = 0;
|
|
288
|
+
members_1 = glueType.fields[0];
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
matchResult = 2;
|
|
292
|
+
}
|
|
293
|
+
break;
|
|
294
|
+
}
|
|
295
|
+
case 13: {
|
|
296
|
+
if (depth < 5) {
|
|
297
|
+
matchResult = 1;
|
|
298
|
+
typeReference_1 = glueType.fields[0];
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
matchResult = 2;
|
|
302
|
+
}
|
|
303
|
+
break;
|
|
304
|
+
}
|
|
305
|
+
default:
|
|
306
|
+
matchResult = 2;
|
|
307
|
+
}
|
|
308
|
+
switch (matchResult) {
|
|
309
|
+
case 0:
|
|
310
|
+
return callSignatures(members_1);
|
|
311
|
+
case 1:
|
|
312
|
+
return tryPick((candidate) => {
|
|
313
|
+
let members_2, info, info_1;
|
|
314
|
+
let matchResult_1, info_2, info_3;
|
|
315
|
+
switch (candidate.tag) {
|
|
316
|
+
case 1: {
|
|
317
|
+
if ((info = candidate.fields[0], ((((info.FullName === typeReference_1.FullName) && (info.FullName !== "")) && !isEmpty(info.Members)) && forAll(isCallSignature, info.Members)) && isEmpty(info.HeritageClauses))) {
|
|
318
|
+
matchResult_1 = 0;
|
|
319
|
+
info_2 = candidate.fields[0];
|
|
320
|
+
}
|
|
321
|
+
else {
|
|
322
|
+
matchResult_1 = 2;
|
|
323
|
+
}
|
|
324
|
+
break;
|
|
325
|
+
}
|
|
326
|
+
case 5: {
|
|
327
|
+
if ((info_1 = candidate.fields[0], (info_1.FullName === typeReference_1.FullName) && (info_1.FullName !== ""))) {
|
|
328
|
+
matchResult_1 = 1;
|
|
329
|
+
info_3 = candidate.fields[0];
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
matchResult_1 = 2;
|
|
333
|
+
}
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
336
|
+
default:
|
|
337
|
+
matchResult_1 = 2;
|
|
338
|
+
}
|
|
339
|
+
switch (matchResult_1) {
|
|
340
|
+
case 0: {
|
|
341
|
+
const substitutions = GlueSubstitution_ofTypeArguments(info_2.TypeParameters, typeReference_1.TypeArguments);
|
|
342
|
+
return map((callSignature) => {
|
|
343
|
+
const matchValue = GlueSubstitution_substituteMember(substitutions, new GlueMember(/* CallSignature */ 4, [callSignature]));
|
|
344
|
+
if (matchValue.tag === 4) {
|
|
345
|
+
return matchValue.fields[0];
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
return callSignature;
|
|
349
|
+
}
|
|
350
|
+
}, callSignatures(info_2.Members));
|
|
351
|
+
}
|
|
352
|
+
case 1: {
|
|
353
|
+
const substitutions_1 = GlueSubstitution_ofTypeArguments(info_3.TypeParameters, typeReference_1.TypeArguments);
|
|
354
|
+
const matchValue_1 = info_3.Type;
|
|
355
|
+
let matchResult_2, functionType, members_3, target;
|
|
356
|
+
switch (matchValue_1.tag) {
|
|
357
|
+
case 15: {
|
|
358
|
+
matchResult_2 = 0;
|
|
359
|
+
functionType = matchValue_1.fields[0];
|
|
360
|
+
break;
|
|
361
|
+
}
|
|
362
|
+
case 20: {
|
|
363
|
+
if ((members_2 = matchValue_1.fields[0], !isEmpty(members_2) && forAll(isCallSignature, members_2))) {
|
|
364
|
+
matchResult_2 = 1;
|
|
365
|
+
members_3 = matchValue_1.fields[0];
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
matchResult_2 = 3;
|
|
369
|
+
}
|
|
370
|
+
break;
|
|
371
|
+
}
|
|
372
|
+
case 13: {
|
|
373
|
+
matchResult_2 = 2;
|
|
374
|
+
target = matchValue_1;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
default:
|
|
378
|
+
matchResult_2 = 3;
|
|
379
|
+
}
|
|
380
|
+
switch (matchResult_2) {
|
|
381
|
+
case 0: {
|
|
382
|
+
const matchValue_2 = GlueSubstitution_substituteMember(substitutions_1, new GlueMember(/* CallSignature */ 4, [new GlueCallSignature(filter((typeParameter) => contains(typeParameter.Name, functionType.OwnTypeParameterNames, {
|
|
383
|
+
Equals: (x, y) => (x === y),
|
|
384
|
+
GetHashCode: (x) => (stringHash(x) | 0),
|
|
385
|
+
}), functionType.TypeParameters), functionType.Parameters, functionType.Type)]));
|
|
386
|
+
if (matchValue_2.tag === 4) {
|
|
387
|
+
return singleton(matchValue_2.fields[0]);
|
|
388
|
+
}
|
|
389
|
+
else {
|
|
390
|
+
return undefined;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
case 1:
|
|
394
|
+
return callSignatures(map((glueMember_3) => GlueSubstitution_substituteMember(substitutions_1, glueMember_3), members_3));
|
|
395
|
+
case 2:
|
|
396
|
+
return signaturesOf(typeMemory, depth + 1, GlueSubstitution_substitute(substitutions_1, target));
|
|
397
|
+
default:
|
|
398
|
+
return undefined;
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
default:
|
|
402
|
+
return undefined;
|
|
403
|
+
}
|
|
404
|
+
}, typeMemory);
|
|
405
|
+
default:
|
|
406
|
+
return undefined;
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export function asMethods(typeMemory, members) {
|
|
411
|
+
return collect((glueMember) => {
|
|
412
|
+
let property;
|
|
413
|
+
let matchResult, property_1;
|
|
414
|
+
if (glueMember.tag === 1) {
|
|
415
|
+
if ((property = glueMember.fields[0], !property.IsOptional && !property.IsStatic)) {
|
|
416
|
+
matchResult = 0;
|
|
417
|
+
property_1 = glueMember.fields[0];
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
420
|
+
matchResult = 1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
else {
|
|
424
|
+
matchResult = 1;
|
|
425
|
+
}
|
|
426
|
+
switch (matchResult) {
|
|
427
|
+
case 0: {
|
|
428
|
+
const matchValue = signaturesOf(typeMemory, 0, property_1.Type);
|
|
429
|
+
let matchResult_1, callSignatures_1;
|
|
430
|
+
if (matchValue != null) {
|
|
431
|
+
if (!isEmpty(matchValue)) {
|
|
432
|
+
matchResult_1 = 0;
|
|
433
|
+
callSignatures_1 = matchValue;
|
|
434
|
+
}
|
|
435
|
+
else {
|
|
436
|
+
matchResult_1 = 1;
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
else {
|
|
440
|
+
matchResult_1 = 1;
|
|
441
|
+
}
|
|
442
|
+
switch (matchResult_1) {
|
|
443
|
+
case 0:
|
|
444
|
+
return map((callSignature_1) => (new GlueMember(/* MethodSignature */ 6, [new GlueMethodSignature(property_1.Name, property_1.Documentation, callSignature_1.TypeParameters, callSignature_1.Parameters, callSignature_1.Type, property_1.IsOptional)])), map((callSignature) => qualifySignature(property_1.Type, callSignature), callSignatures_1));
|
|
445
|
+
default:
|
|
446
|
+
return singleton(glueMember);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
default:
|
|
450
|
+
return singleton(glueMember);
|
|
451
|
+
}
|
|
452
|
+
}, members);
|
|
453
|
+
}
|
|
454
|
+
|