@magnusopera/fscript 0.81.4 → 0.81.6
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/FScript.Language/Eval.js +100 -71
- package/dist/FScript.Language/HostInterop.js +28 -6
- package/dist/FScript.Language/Interactive.js +2 -1
- package/dist/FScript.Language/TypeInfer.js +74 -45
- package/dist/FScript.Language/Types.js +15 -0
- package/dist/FScript.Language/Value.js +4 -3
- package/package.json +1 -1
|
@@ -2006,88 +2006,112 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
|
|
|
2006
2006
|
const target_2 = expr.fields[0];
|
|
2007
2007
|
const span_12 = expr.fields[2];
|
|
2008
2008
|
const fieldName = expr.fields[1];
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
matchResult_2 = 1;
|
|
2017
|
-
}
|
|
2018
|
-
}
|
|
2019
|
-
else {
|
|
2020
|
-
matchResult_2 = 1;
|
|
2021
|
-
}
|
|
2022
|
-
switch (matchResult_2) {
|
|
2023
|
-
case 0: {
|
|
2024
|
-
const matchValue_11 = FSharpMap__TryFind(env, concat(moduleName_1, ".", fieldName));
|
|
2025
|
-
if (matchValue_11 == null) {
|
|
2026
|
-
const matchValue_12 = evalExpr(runtime, typeDefs, env, target_2);
|
|
2027
|
-
let matchResult_3, fields_4;
|
|
2028
|
-
switch (matchValue_12.tag) {
|
|
2029
|
-
case 7: {
|
|
2030
|
-
matchResult_3 = 0;
|
|
2031
|
-
fields_4 = matchValue_12.fields[0];
|
|
2032
|
-
break;
|
|
2033
|
-
}
|
|
2034
|
-
case 16: {
|
|
2035
|
-
matchResult_3 = 0;
|
|
2036
|
-
fields_4 = matchValue_12.fields[0].Fields;
|
|
2037
|
-
break;
|
|
2038
|
-
}
|
|
2039
|
-
default:
|
|
2040
|
-
matchResult_3 = 1;
|
|
2009
|
+
const qualifiedTarget = (_arg_1) => {
|
|
2010
|
+
let matchResult_2, name_10, name_11, parent;
|
|
2011
|
+
switch (_arg_1.tag) {
|
|
2012
|
+
case 2: {
|
|
2013
|
+
if (!FSharpMap__ContainsKey(env, _arg_1.fields[0])) {
|
|
2014
|
+
matchResult_2 = 0;
|
|
2015
|
+
name_10 = _arg_1.fields[0];
|
|
2041
2016
|
}
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
const matchValue_13 = FSharpMap__TryFind(fields_4, fieldName);
|
|
2045
|
-
if (matchValue_13 == null) {
|
|
2046
|
-
throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
|
|
2047
|
-
}
|
|
2048
|
-
else {
|
|
2049
|
-
return matchValue_13;
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
default:
|
|
2053
|
-
throw new EvalException(new EvalError$("Field access requires a record value", span_12));
|
|
2017
|
+
else {
|
|
2018
|
+
matchResult_2 = 2;
|
|
2054
2019
|
}
|
|
2020
|
+
break;
|
|
2055
2021
|
}
|
|
2056
|
-
|
|
2057
|
-
|
|
2022
|
+
case 21: {
|
|
2023
|
+
matchResult_2 = 1;
|
|
2024
|
+
name_11 = _arg_1.fields[1];
|
|
2025
|
+
parent = _arg_1.fields[0];
|
|
2026
|
+
break;
|
|
2058
2027
|
}
|
|
2028
|
+
default:
|
|
2029
|
+
matchResult_2 = 2;
|
|
2059
2030
|
}
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2031
|
+
switch (matchResult_2) {
|
|
2032
|
+
case 0:
|
|
2033
|
+
return name_10;
|
|
2034
|
+
case 1: {
|
|
2035
|
+
const option_1 = qualifiedTarget(parent);
|
|
2036
|
+
if (option_1 != null) {
|
|
2037
|
+
return (option_1 + ".") + name_11;
|
|
2038
|
+
}
|
|
2039
|
+
else {
|
|
2040
|
+
return undefined;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
default:
|
|
2044
|
+
return undefined;
|
|
2045
|
+
}
|
|
2046
|
+
};
|
|
2047
|
+
const matchValue_11 = qualifiedTarget(target_2);
|
|
2048
|
+
if (matchValue_11 != null) {
|
|
2049
|
+
const matchValue_12 = FSharpMap__TryFind(env, concat(matchValue_11, ".", fieldName));
|
|
2050
|
+
if (matchValue_12 == null) {
|
|
2051
|
+
const matchValue_13 = evalExpr(runtime, typeDefs, env, target_2);
|
|
2052
|
+
let matchResult_3, fields_4;
|
|
2053
|
+
switch (matchValue_13.tag) {
|
|
2064
2054
|
case 7: {
|
|
2065
|
-
|
|
2066
|
-
|
|
2055
|
+
matchResult_3 = 0;
|
|
2056
|
+
fields_4 = matchValue_13.fields[0];
|
|
2067
2057
|
break;
|
|
2068
2058
|
}
|
|
2069
2059
|
case 16: {
|
|
2070
|
-
|
|
2071
|
-
|
|
2060
|
+
matchResult_3 = 0;
|
|
2061
|
+
fields_4 = matchValue_13.fields[0].Fields;
|
|
2072
2062
|
break;
|
|
2073
2063
|
}
|
|
2074
2064
|
default:
|
|
2075
|
-
|
|
2065
|
+
matchResult_3 = 1;
|
|
2076
2066
|
}
|
|
2077
|
-
switch (
|
|
2067
|
+
switch (matchResult_3) {
|
|
2078
2068
|
case 0: {
|
|
2079
|
-
const
|
|
2080
|
-
if (
|
|
2069
|
+
const matchValue_14 = FSharpMap__TryFind(fields_4, fieldName);
|
|
2070
|
+
if (matchValue_14 == null) {
|
|
2081
2071
|
throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
|
|
2082
2072
|
}
|
|
2083
2073
|
else {
|
|
2084
|
-
return
|
|
2074
|
+
return matchValue_14;
|
|
2085
2075
|
}
|
|
2086
2076
|
}
|
|
2087
2077
|
default:
|
|
2088
2078
|
throw new EvalException(new EvalError$("Field access requires a record value", span_12));
|
|
2089
2079
|
}
|
|
2090
2080
|
}
|
|
2081
|
+
else {
|
|
2082
|
+
return matchValue_12;
|
|
2083
|
+
}
|
|
2084
|
+
}
|
|
2085
|
+
else {
|
|
2086
|
+
const matchValue_15 = evalExpr(runtime, typeDefs, env, target_2);
|
|
2087
|
+
let matchResult_4, fields_5;
|
|
2088
|
+
switch (matchValue_15.tag) {
|
|
2089
|
+
case 7: {
|
|
2090
|
+
matchResult_4 = 0;
|
|
2091
|
+
fields_5 = matchValue_15.fields[0];
|
|
2092
|
+
break;
|
|
2093
|
+
}
|
|
2094
|
+
case 16: {
|
|
2095
|
+
matchResult_4 = 0;
|
|
2096
|
+
fields_5 = matchValue_15.fields[0].Fields;
|
|
2097
|
+
break;
|
|
2098
|
+
}
|
|
2099
|
+
default:
|
|
2100
|
+
matchResult_4 = 1;
|
|
2101
|
+
}
|
|
2102
|
+
switch (matchResult_4) {
|
|
2103
|
+
case 0: {
|
|
2104
|
+
const matchValue_16 = FSharpMap__TryFind(fields_5, fieldName);
|
|
2105
|
+
if (matchValue_16 == null) {
|
|
2106
|
+
throw new EvalException(new EvalError$(toText(printf("Record field \'%s\' not found"))(fieldName), span_12));
|
|
2107
|
+
}
|
|
2108
|
+
else {
|
|
2109
|
+
return matchValue_16;
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
default:
|
|
2113
|
+
throw new EvalException(new EvalError$("Field access requires a record value", span_12));
|
|
2114
|
+
}
|
|
2091
2115
|
}
|
|
2092
2116
|
}
|
|
2093
2117
|
case 22: {
|
|
@@ -2428,22 +2452,22 @@ function evalExpr(runtime_mut, typeDefs_mut, env_mut, expr_mut) {
|
|
|
2428
2452
|
case 27:
|
|
2429
2453
|
return new Value(/* VOption */ 9, [undefined]);
|
|
2430
2454
|
case 28: {
|
|
2431
|
-
const
|
|
2432
|
-
const
|
|
2433
|
-
if (
|
|
2434
|
-
throw new EvalException(new EvalError$(concat("Unknown type \'",
|
|
2455
|
+
const name_12 = expr.fields[0];
|
|
2456
|
+
const matchValue_25 = FSharpMap__TryFind(typeDefs, name_12);
|
|
2457
|
+
if (matchValue_25 == null) {
|
|
2458
|
+
throw new EvalException(new EvalError$(concat("Unknown type \'", name_12, "\'"), expr.fields[1]));
|
|
2435
2459
|
}
|
|
2436
2460
|
else {
|
|
2437
|
-
return new Value(/* VTypeToken */ 12, [
|
|
2461
|
+
return new Value(/* VTypeToken */ 12, [matchValue_25]);
|
|
2438
2462
|
}
|
|
2439
2463
|
}
|
|
2440
2464
|
case 29: {
|
|
2441
|
-
const
|
|
2442
|
-
if (FSharpMap__ContainsKey(env,
|
|
2443
|
-
return new Value(/* VString */ 4, [
|
|
2465
|
+
const name_13 = expr.fields[0];
|
|
2466
|
+
if (FSharpMap__ContainsKey(env, name_13)) {
|
|
2467
|
+
return new Value(/* VString */ 4, [name_13]);
|
|
2444
2468
|
}
|
|
2445
2469
|
else {
|
|
2446
|
-
throw new EvalException(new EvalError$(concat("Unbound variable \'",
|
|
2470
|
+
throw new EvalException(new EvalError$(concat("Unbound variable \'", name_13, "\'"), expr.fields[1]));
|
|
2447
2471
|
}
|
|
2448
2472
|
}
|
|
2449
2473
|
case 30: {
|
|
@@ -2811,9 +2835,14 @@ export function evalProgramWithRegistrationState(registration, program) {
|
|
|
2811
2835
|
return ofArray([[caseName_2, value], [concat(typeName, ".", caseName_2), value]]);
|
|
2812
2836
|
}, tupledArg_6[1].Cases);
|
|
2813
2837
|
}, toList(decls));
|
|
2838
|
+
const constructorValues_1 = append(collect((descriptor) => collect((tupledArg_8) => {
|
|
2839
|
+
const caseName_3 = tupledArg_8[0];
|
|
2840
|
+
const value_1 = (tupledArg_8[1] == null) ? (new Value(/* VUnionCase */ 10, [descriptor.Name, caseName_3, undefined])) : (new Value(/* VUnionCtor */ 11, [descriptor.Name, caseName_3]));
|
|
2841
|
+
return ofArray([[caseName_3, value_1], [concat(descriptor.Name, ".", caseName_3), value_1]]);
|
|
2842
|
+
}, toList(descriptor.Cases)), registration.Unions), constructorValues);
|
|
2814
2843
|
const externContext = createExternContext(runtime, typeDefs_1, unknownSpan);
|
|
2815
2844
|
let env;
|
|
2816
|
-
const
|
|
2845
|
+
const list_15 = append(builtinExterns, externs);
|
|
2817
2846
|
env = fold_1((acc_1, ext_2) => {
|
|
2818
2847
|
if (ext_2.Arity === 0) {
|
|
2819
2848
|
return FSharpMap__Add(acc_1, ext_2.Name, invoke(typeDefs_1, ext_2, externContext, empty()));
|
|
@@ -2823,8 +2852,8 @@ export function evalProgramWithRegistrationState(registration, program) {
|
|
|
2823
2852
|
}
|
|
2824
2853
|
}, empty_1({
|
|
2825
2854
|
Compare: (x_7, y_8) => (comparePrimitives(x_7, y_8) | 0),
|
|
2826
|
-
}),
|
|
2827
|
-
env = fold_1((acc_2,
|
|
2855
|
+
}), list_15);
|
|
2856
|
+
env = fold_1((acc_2, tupledArg_9) => FSharpMap__Add(acc_2, tupledArg_9[0], tupledArg_9[1]), env, constructorValues_1);
|
|
2828
2857
|
return evaluateStatements(runtime, typeDefs_1, env, program);
|
|
2829
2858
|
}
|
|
2830
2859
|
|
|
@@ -4,11 +4,11 @@ import { EvalException, EvalError$ } from "./Error.js";
|
|
|
4
4
|
import { tail as tail_1, head, isEmpty as isEmpty_1, iterate2, iterate as iterate_1, tryFind as tryFind_1, forAll2, length, forAll as forAll_1, contains, map, ofArray, append, empty as empty_1 } from "../fable_modules/fable-library-js.5.13.0/List.js";
|
|
5
5
|
import { Value, HostManagedValue, ExtensionRegistration } from "./Value.js";
|
|
6
6
|
import { typeDefs } from "./BuiltinTypes.js";
|
|
7
|
-
import { FSharpMap__get_Item, iterate, map as map_1, FSharpMap__get_Count, FSharpMap__TryFind, tryFind, forAll, FSharpMap__Add, containsKey, empty as empty_2 } from "../fable_modules/fable-library-js.5.13.0/Map.js";
|
|
7
|
+
import { FSharpMap__get_Item, iterate, map as map_1, FSharpMap__get_Count, FSharpMap__TryFind, tryFind, forAll, exists, FSharpMap__get_IsEmpty, FSharpMap__Add, containsKey, empty as empty_2 } from "../fable_modules/fable-library-js.5.13.0/Map.js";
|
|
8
8
|
import { curry2, stringHash, disposeSafe, getEnumerator, comparePrimitives } from "../fable_modules/fable-library-js.5.13.0/Util.js";
|
|
9
9
|
import { concat, isNullOrWhiteSpace } from "../fable_modules/fable-library-js.5.13.0/String.js";
|
|
10
10
|
import { Types_ftvType, Types_typeToString, Type } from "./Types.js";
|
|
11
|
-
import { exists } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
|
|
11
|
+
import { exists as exists_1 } from "../fable_modules/fable-library-js.5.13.0/Seq.js";
|
|
12
12
|
import { value as value_4, toArray } from "../fable_modules/fable-library-js.5.13.0/Option.js";
|
|
13
13
|
import { minElement, isEmpty } from "../fable_modules/fable-library-js.5.13.0/Set.js";
|
|
14
14
|
import { min } from "../fable_modules/fable-library-js.5.13.0/Double.js";
|
|
@@ -19,10 +19,10 @@ function fail(message) {
|
|
|
19
19
|
throw new EvalException(new EvalError$(message, span));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export const empty = new ExtensionRegistration(empty_1(), empty_1());
|
|
22
|
+
export const empty = new ExtensionRegistration(empty_1(), empty_1(), empty_1());
|
|
23
23
|
|
|
24
24
|
export function ofExterns(functions) {
|
|
25
|
-
return new ExtensionRegistration(empty.Types, functions);
|
|
25
|
+
return new ExtensionRegistration(empty.Types, empty.Unions, functions);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function typeDefinitions(registration, scriptNames) {
|
|
@@ -49,6 +49,28 @@ export function typeDefinitions(registration, scriptNames) {
|
|
|
49
49
|
finally {
|
|
50
50
|
disposeSafe(enumerator);
|
|
51
51
|
}
|
|
52
|
+
const enumerator_1 = getEnumerator(registration.Unions);
|
|
53
|
+
try {
|
|
54
|
+
while (enumerator_1["System.Collections.IEnumerator.MoveNext"]()) {
|
|
55
|
+
const descriptor_1 = enumerator_1["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
56
|
+
if (isNullOrWhiteSpace(descriptor_1.Name) ? true : FSharpMap__get_IsEmpty(descriptor_1.Cases)) {
|
|
57
|
+
fail("Host unions require a name and at least one case");
|
|
58
|
+
}
|
|
59
|
+
if (contains(descriptor_1.Name, reserved, {
|
|
60
|
+
Equals: (x_2, y_2) => (x_2 === y_2),
|
|
61
|
+
GetHashCode: (x_2) => (stringHash(x_2) | 0),
|
|
62
|
+
}) ? true : containsKey(descriptor_1.Name, definitions)) {
|
|
63
|
+
fail(concat("Host type name conflict: \'", descriptor_1.Name, "\'"));
|
|
64
|
+
}
|
|
65
|
+
if (exists((name, _arg) => isNullOrWhiteSpace(name), descriptor_1.Cases)) {
|
|
66
|
+
fail(concat("Host union \'", descriptor_1.Name, "\' has an empty case name"));
|
|
67
|
+
}
|
|
68
|
+
definitions = FSharpMap__Add(definitions, descriptor_1.Name, new Type(/* TUnion */ 13, [descriptor_1.Name, descriptor_1.Cases]));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
finally {
|
|
72
|
+
disposeSafe(enumerator_1);
|
|
73
|
+
}
|
|
52
74
|
return definitions;
|
|
53
75
|
}
|
|
54
76
|
|
|
@@ -56,7 +78,7 @@ export function matches(definitions_mut, expected_mut, value_mut) {
|
|
|
56
78
|
matches:
|
|
57
79
|
while (true) {
|
|
58
80
|
const definitions = definitions_mut, expected = expected_mut, value = value_mut;
|
|
59
|
-
const fieldsMatch = (fields, values) => forAll((name, fieldType) =>
|
|
81
|
+
const fieldsMatch = (fields, values) => forAll((name, fieldType) => exists_1((value_1) => matches(definitions, fieldType, value_1), toArray(tryFind(name, values))), fields);
|
|
60
82
|
let matchResult, name_1, fields_1, host, name_2, fields_2, values_1, constructible, fields_3, host_1, fields_4, values_2, t_1, values_3, ts, values_4, t_2, v, t_3, values_5, actualName, caseName, cases, name_3, payload;
|
|
61
83
|
switch (expected.tag) {
|
|
62
84
|
case 17: {
|
|
@@ -264,7 +286,7 @@ export function matches(definitions_mut, expected_mut, value_mut) {
|
|
|
264
286
|
}
|
|
265
287
|
switch (matchResult) {
|
|
266
288
|
case 0:
|
|
267
|
-
return
|
|
289
|
+
return exists_1((t) => matches(definitions, t, value), toArray(FSharpMap__TryFind(definitions, name_1)));
|
|
268
290
|
case 1:
|
|
269
291
|
if (((host.Descriptor.HostManaged && (host.Descriptor.Name === name_2)) && host.Descriptor.Fields.Equals(fields_1)) && (FSharpMap__get_Count(host.Fields) === FSharpMap__get_Count(fields_1))) {
|
|
270
292
|
return fieldsMatch(fields_1, host.Fields);
|
|
@@ -111,6 +111,7 @@ export function retainedCount(session) {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
export function submit(session, program) {
|
|
114
|
+
let bind$0040;
|
|
114
115
|
const retainedRev = appendRetained(session.RetainedProgramRev, program);
|
|
115
116
|
const retainedCount_1 = length(retainedRev) | 0;
|
|
116
117
|
const containsTypeDeclaration = exists((_arg) => {
|
|
@@ -133,7 +134,7 @@ export function submit(session, program) {
|
|
|
133
134
|
}
|
|
134
135
|
else {
|
|
135
136
|
const previousState = matchValue;
|
|
136
|
-
const typed_2 = inferProgramWithRegistration(new ExtensionRegistration(
|
|
137
|
+
const typed_2 = inferProgramWithRegistration((bind$0040 = session.Registration, new ExtensionRegistration(bind$0040.Types, bind$0040.Unions, append(session.Registration.Functions, toList_1(values(session.InferenceBindings))))), append(session.TypeDeclarations, program));
|
|
137
138
|
const submittedTyped_1 = skip(length(session.TypeDeclarations), typed_2);
|
|
138
139
|
const state_2 = evalProgramFromState(previousState, submittedTyped_1);
|
|
139
140
|
return new Submission(new Session(session.Registration, retainedRev, session.TypeDeclarations, updateInferenceBindings(session.InferenceBindings, submittedTyped_1), state_2), submittedTyped_1, state_2, retainedCount_1);
|
|
@@ -2935,39 +2935,63 @@ function inferExprRaw(telemetry, typeDefs, constructors, env, expr) {
|
|
|
2935
2935
|
throw new TypeException(new TypeError$("Field access requires a record value", span_18));
|
|
2936
2936
|
}
|
|
2937
2937
|
};
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2938
|
+
const qualifiedTarget = (_arg_9) => {
|
|
2939
|
+
let matchResult_6, name_21, name_22, parent;
|
|
2940
|
+
switch (_arg_9.tag) {
|
|
2941
|
+
case 2: {
|
|
2942
|
+
if (!FSharpMap__ContainsKey(env, _arg_9.fields[0])) {
|
|
2943
|
+
matchResult_6 = 0;
|
|
2944
|
+
name_21 = _arg_9.fields[0];
|
|
2945
|
+
}
|
|
2946
|
+
else {
|
|
2947
|
+
matchResult_6 = 2;
|
|
2948
|
+
}
|
|
2949
|
+
break;
|
|
2950
|
+
}
|
|
2951
|
+
case 21: {
|
|
2952
|
+
matchResult_6 = 1;
|
|
2953
|
+
name_22 = _arg_9.fields[1];
|
|
2954
|
+
parent = _arg_9.fields[0];
|
|
2955
|
+
break;
|
|
2956
|
+
}
|
|
2957
|
+
default:
|
|
2958
|
+
matchResult_6 = 2;
|
|
2959
|
+
}
|
|
2960
|
+
switch (matchResult_6) {
|
|
2961
|
+
case 0:
|
|
2962
|
+
return name_21;
|
|
2963
|
+
case 1: {
|
|
2964
|
+
const option_2 = qualifiedTarget(parent);
|
|
2965
|
+
if (option_2 != null) {
|
|
2966
|
+
return (option_2 + ".") + name_22;
|
|
2967
|
+
}
|
|
2968
|
+
else {
|
|
2969
|
+
return undefined;
|
|
2970
|
+
}
|
|
2971
|
+
}
|
|
2972
|
+
default:
|
|
2973
|
+
return undefined;
|
|
2974
|
+
}
|
|
2975
|
+
};
|
|
2976
|
+
const matchValue_16 = qualifiedTarget(target);
|
|
2977
|
+
if (matchValue_16 != null) {
|
|
2978
|
+
const matchValue_17 = FSharpMap__TryFind(env, concat(matchValue_16, ".", fieldName));
|
|
2979
|
+
if (matchValue_17 == null) {
|
|
2980
|
+
const patternInput_37 = inferExpr(telemetry, typeDefs, constructors, env, target);
|
|
2981
|
+
const patternInput_38 = inferRecordField(patternInput_37[0], patternInput_37[1]);
|
|
2982
|
+
const tField_7 = patternInput_38[1];
|
|
2983
|
+
return [patternInput_38[0], tField_7, asTyped(expr, tField_7)];
|
|
2943
2984
|
}
|
|
2944
2985
|
else {
|
|
2945
|
-
|
|
2986
|
+
const t_7 = instantiate(matchValue_17);
|
|
2987
|
+
return [emptySubst, t_7, asTyped(expr, t_7)];
|
|
2946
2988
|
}
|
|
2947
2989
|
}
|
|
2948
2990
|
else {
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
const matchValue_16 = FSharpMap__TryFind(env, concat(moduleName_1, ".", fieldName));
|
|
2954
|
-
if (matchValue_16 == null) {
|
|
2955
|
-
const patternInput_37 = inferExpr(telemetry, typeDefs, constructors, env, target);
|
|
2956
|
-
const patternInput_38 = inferRecordField(patternInput_37[0], patternInput_37[1]);
|
|
2957
|
-
const tField_7 = patternInput_38[1];
|
|
2958
|
-
return [patternInput_38[0], tField_7, asTyped(expr, tField_7)];
|
|
2959
|
-
}
|
|
2960
|
-
else {
|
|
2961
|
-
const t_7 = instantiate(matchValue_16);
|
|
2962
|
-
return [emptySubst, t_7, asTyped(expr, t_7)];
|
|
2963
|
-
}
|
|
2964
|
-
}
|
|
2965
|
-
default: {
|
|
2966
|
-
const patternInput_39 = inferExpr(telemetry, typeDefs, constructors, env, target);
|
|
2967
|
-
const patternInput_40 = inferRecordField(patternInput_39[0], patternInput_39[1]);
|
|
2968
|
-
const tField_8 = patternInput_40[1];
|
|
2969
|
-
return [patternInput_40[0], tField_8, asTyped(expr, tField_8)];
|
|
2970
|
-
}
|
|
2991
|
+
const patternInput_39 = inferExpr(telemetry, typeDefs, constructors, env, target);
|
|
2992
|
+
const patternInput_40 = inferRecordField(patternInput_39[0], patternInput_39[1]);
|
|
2993
|
+
const tField_8 = patternInput_40[1];
|
|
2994
|
+
return [patternInput_40[0], tField_8, asTyped(expr, tField_8)];
|
|
2971
2995
|
}
|
|
2972
2996
|
}
|
|
2973
2997
|
case 22: {
|
|
@@ -3240,6 +3264,7 @@ function topLevelBindingNames(program) {
|
|
|
3240
3264
|
}
|
|
3241
3265
|
|
|
3242
3266
|
function inferProgramWithExternsRawAndLocals(captureLocalVariables, registration, program) {
|
|
3267
|
+
let list_11;
|
|
3243
3268
|
let hostDefinitions;
|
|
3244
3269
|
try {
|
|
3245
3270
|
hostDefinitions = typeDefinitions(registration, append(map_1((d) => d.Name, typeDefs_2), choose((_arg) => {
|
|
@@ -3285,7 +3310,7 @@ function inferProgramWithExternsRawAndLocals(captureLocalVariables, registration
|
|
|
3285
3310
|
})]);
|
|
3286
3311
|
}
|
|
3287
3312
|
}, decls), hostDefinitions);
|
|
3288
|
-
const constructors = ofList(collect((tupledArg_2) => {
|
|
3313
|
+
const constructors = ofList((list_11 = collect((tupledArg_2) => {
|
|
3289
3314
|
const typeName = tupledArg_2[0];
|
|
3290
3315
|
return collect((tupledArg_3) => {
|
|
3291
3316
|
let option_3;
|
|
@@ -3293,16 +3318,20 @@ function inferProgramWithExternsRawAndLocals(captureLocalVariables, registration
|
|
|
3293
3318
|
const sigInfo = new ConstructorSig(typeName, (option_3 = tupledArg_3[1], (option_3 != null) ? typeFromRef(decls, singleton(typeName), option_3) : undefined));
|
|
3294
3319
|
return ofArray([[caseName_1, sigInfo], [concat(typeName, ".", caseName_1), sigInfo]]);
|
|
3295
3320
|
}, tupledArg_2[1].Cases);
|
|
3296
|
-
}, toList(decls)), {
|
|
3321
|
+
}, toList(decls)), append(collect((descriptor) => collect((tupledArg_4) => {
|
|
3322
|
+
const caseName_2 = tupledArg_4[0];
|
|
3323
|
+
const info = new ConstructorSig(descriptor.Name, tupledArg_4[1]);
|
|
3324
|
+
return ofArray([[caseName_2, info], [concat(descriptor.Name, ".", caseName_2), info]]);
|
|
3325
|
+
}, toList(descriptor.Cases)), registration.Unions), list_11)), {
|
|
3297
3326
|
Compare: (x_3, y_3) => (comparePrimitives(x_3, y_3) | 0),
|
|
3298
3327
|
});
|
|
3299
|
-
const constructorSchemes = map_1((
|
|
3328
|
+
const constructorSchemes = map_1((tupledArg_5) => {
|
|
3300
3329
|
let matchValue_1;
|
|
3301
|
-
const sigInfo_1 =
|
|
3330
|
+
const sigInfo_1 = tupledArg_5[1];
|
|
3302
3331
|
const unionType = new Type(/* TNamed */ 12, [sigInfo_1.UnionName]);
|
|
3303
|
-
return [
|
|
3332
|
+
return [tupledArg_5[0], new Scheme(empty_2(), (matchValue_1 = sigInfo_1.Payload, (matchValue_1 != null) ? (new Type(/* TFun */ 11, [matchValue_1, unionType])) : unionType))];
|
|
3304
3333
|
}, toList(constructors));
|
|
3305
|
-
let env = fold((acc_1,
|
|
3334
|
+
let env = fold((acc_1, tupledArg_6) => FSharpMap__Add(acc_1, tupledArg_6[0], tupledArg_6[1]), envFromExterns(registration.Functions), constructorSchemes);
|
|
3306
3335
|
const telemetry = captureLocalVariables ? createTelemetry() : undefined;
|
|
3307
3336
|
const typed = [];
|
|
3308
3337
|
try {
|
|
@@ -3397,15 +3426,15 @@ function inferProgramWithExternsRawAndLocals(captureLocalVariables, registration
|
|
|
3397
3426
|
const t_4 = telemetry;
|
|
3398
3427
|
startIndex_2 = t_4.LocalVariableTypes.length;
|
|
3399
3428
|
}
|
|
3400
|
-
const foldedBindings = map_1((
|
|
3401
|
-
const args_1 =
|
|
3402
|
-
const bindingSpan =
|
|
3429
|
+
const foldedBindings = map_1((tupledArg_7) => {
|
|
3430
|
+
const args_1 = tupledArg_7[1];
|
|
3431
|
+
const bindingSpan = tupledArg_7[4];
|
|
3403
3432
|
if (isEmpty_1(args_1)) {
|
|
3404
3433
|
throw new TypeException(new TypeError$("\'let rec ... and ...\' requires function arguments for each binding", bindingSpan));
|
|
3405
3434
|
}
|
|
3406
|
-
return [
|
|
3435
|
+
return [tupledArg_7[0], tupledArg_7[2], foldBack((arg_1, acc_3) => (new Expr(/* ELambda */ 4, [arg_1, acc_3, bindingSpan])), args_1, tupledArg_7[3]), bindingSpan];
|
|
3407
3436
|
}, stmt.fields[0]);
|
|
3408
|
-
const freshByName = ofList(map_1((
|
|
3437
|
+
const freshByName = ofList(map_1((tupledArg_8) => [tupledArg_8[0], Types_freshVar()], foldedBindings), {
|
|
3409
3438
|
Compare: (x_4, y_4) => (comparePrimitives(x_4, y_4) | 0),
|
|
3410
3439
|
});
|
|
3411
3440
|
const envRec_1 = fold_1((acc_4, name_7, tv_1) => add(name_7, new Scheme(empty_2(), tv_1), acc_4), env, freshByName);
|
|
@@ -3443,17 +3472,17 @@ function inferProgramWithExternsRawAndLocals(captureLocalVariables, registration
|
|
|
3443
3472
|
}
|
|
3444
3473
|
applySubstToCapturedLocals(telemetry, startIndex_2, sRec);
|
|
3445
3474
|
const envGeneralize = applyEnv(sRec, env);
|
|
3446
|
-
const schemes = map_1((
|
|
3447
|
-
const name_10 =
|
|
3475
|
+
const schemes = map_1((tupledArg_9) => {
|
|
3476
|
+
const name_10 = tupledArg_9[0];
|
|
3448
3477
|
const inferred_2 = applyType(sRec, FSharpMap__get_Item(freshByName, name_10));
|
|
3449
3478
|
validateMapKeyTypes(typeDefs_1, span_3, inferred_2);
|
|
3450
3479
|
return [name_10, Types_generalize(envGeneralize, inferred_2)];
|
|
3451
3480
|
}, foldedBindings);
|
|
3452
|
-
const typedBindings_1 = map_1((
|
|
3453
|
-
const name_11 =
|
|
3454
|
-
return [name_11,
|
|
3481
|
+
const typedBindings_1 = map_1((tupledArg_10) => {
|
|
3482
|
+
const name_11 = tupledArg_10[0];
|
|
3483
|
+
return [name_11, tupledArg_10[2], applyType(sRec, FSharpMap__get_Item(freshByName, name_11)), tupledArg_10[3]];
|
|
3455
3484
|
}, foldedBindings);
|
|
3456
|
-
env = fold((acc_5,
|
|
3485
|
+
env = fold((acc_5, tupledArg_11) => add(tupledArg_11[0], tupledArg_11[1], acc_5), envGeneralize, schemes);
|
|
3457
3486
|
void (typed.push(new TypedStmt(/* TSLetRecGroup */ 3, [typedBindings_1, stmt.fields[1], span_3])));
|
|
3458
3487
|
break;
|
|
3459
3488
|
}
|
|
@@ -42,6 +42,21 @@ export function HostTypeDescriptor_$reflection() {
|
|
|
42
42
|
return record_type("FScript.Language.HostTypeDescriptor", [], HostTypeDescriptor, () => [["Name", string_type], ["Fields", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Type_$reflection()])], ["HostManaged", bool_type]]);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/**
|
|
46
|
+
* Script-constructible union supplied by a host; payloads use ordinary script types.
|
|
47
|
+
*/
|
|
48
|
+
export class HostUnionDescriptor extends Record {
|
|
49
|
+
constructor(Name, Cases) {
|
|
50
|
+
super();
|
|
51
|
+
this.Name = Name;
|
|
52
|
+
this.Cases = Cases;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function HostUnionDescriptor_$reflection() {
|
|
57
|
+
return record_type("FScript.Language.HostUnionDescriptor", [], HostUnionDescriptor, () => [["Name", string_type], ["Cases", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, option_type(Type_$reflection())])]]);
|
|
58
|
+
}
|
|
59
|
+
|
|
45
60
|
export class Scheme extends Union {
|
|
46
61
|
constructor(Item1, Item2) {
|
|
47
62
|
super();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { Record, FSharpRef, Union } from "../fable_modules/fable-library-js.5.13.0/Types.js";
|
|
3
3
|
import { int32_type, unit_type, lambda_type, obj_type, record_type, option_type, class_type, list_type, float64_type, union_type, bool_type, int64_type, string_type } from "../fable_modules/fable-library-js.5.13.0/Reflection.js";
|
|
4
|
-
import { Scheme_$reflection, HostTypeDescriptor_$reflection, Type_$reflection } from "./Types.js";
|
|
4
|
+
import { HostUnionDescriptor_$reflection, Scheme_$reflection, HostTypeDescriptor_$reflection, Type_$reflection } from "./Types.js";
|
|
5
5
|
import { Expr_$reflection } from "./Ast.js";
|
|
6
6
|
import { EvalError$_$reflection } from "./Error.js";
|
|
7
7
|
|
|
@@ -104,14 +104,15 @@ export function ExternalFunction_$reflection() {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
export class ExtensionRegistration extends Record {
|
|
107
|
-
constructor(Types, Functions) {
|
|
107
|
+
constructor(Types, Unions, Functions) {
|
|
108
108
|
super();
|
|
109
109
|
this.Types = Types;
|
|
110
|
+
this.Unions = Unions;
|
|
110
111
|
this.Functions = Functions;
|
|
111
112
|
}
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
export function ExtensionRegistration_$reflection() {
|
|
115
|
-
return record_type("FScript.Language.ExtensionRegistration", [], ExtensionRegistration, () => [["Types", list_type(HostTypeDescriptor_$reflection())], ["Functions", list_type(ExternalFunction_$reflection())]]);
|
|
116
|
+
return record_type("FScript.Language.ExtensionRegistration", [], ExtensionRegistration, () => [["Types", list_type(HostTypeDescriptor_$reflection())], ["Unions", list_type(HostUnionDescriptor_$reflection())], ["Functions", list_type(ExternalFunction_$reflection())]]);
|
|
116
117
|
}
|
|
117
118
|
|