@magnusopera/fscript 0.88.0 → 0.90.1
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 +15 -0
- package/dist/FScript.Language/Ast.js +2 -2
- package/dist/FScript.Language/BuiltinFunctions.js +61 -68
- package/dist/FScript.Language/BuiltinSignatures.js +6 -6
- package/dist/FScript.Language/BuiltinTypes.js +1 -1
- package/dist/FScript.Language/Error.js +2 -2
- package/dist/FScript.Language/Eval.js +176 -127
- package/dist/FScript.Language/Execution.js +8 -7
- package/dist/FScript.Language/ExportSignatures.js +5 -5
- package/dist/FScript.Language/HostInterop.js +41 -11
- package/dist/FScript.Language/IncludeResolver.js +15 -19
- package/dist/FScript.Language/Interactive.js +9 -9
- package/dist/FScript.Language/Lexer.js +39 -39
- package/dist/FScript.Language/Parser.js +17 -17
- package/dist/FScript.Language/Pretty.js +5 -5
- package/dist/FScript.Language/Span.js +2 -2
- package/dist/FScript.Language/SupportCollections.js +34 -33
- package/dist/FScript.Language/SupportLibrary.js +21 -20
- package/dist/FScript.Language/TaskFunctions.js +51 -7
- package/dist/FScript.Language/TaskSharingAnalysis.js +310 -129
- package/dist/FScript.Language/Token.js +2 -2
- package/dist/FScript.Language/TypeInfer.js +21 -25
- package/dist/FScript.Language/Types.js +9 -9
- package/dist/FScript.Language/Value.js +11 -8
- package/dist/Library.js +54 -28
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Array.js +325 -198
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/BigInt.js +18 -6
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/CHANGELOG.md +64 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Date.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Decimal.js +33 -47
- package/dist/fable_modules/fable-library-js.5.27.0/Double.js +78 -0
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Core.js +7 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Global.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Int32.js +10 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/List.js +230 -157
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Long.js +7 -2
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Map.js +46 -39
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableMap.js +76 -96
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MutableSet.js +58 -80
- package/dist/fable_modules/fable-library-js.5.27.0/NumberStyles.js +56 -0
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Numeric.js +72 -4
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Random.js +26 -17
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Range.js +4 -3
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Reflection.js +7 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/RegExp.js +3 -2
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Seq.js +149 -70
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Seq2.js +4 -8
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Set.js +66 -59
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/String.js +160 -39
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Collections.Generic.js +3 -2
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.Text.js +10 -10
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/System.js +5 -5
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeOnly.js +1 -1
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Types.js +28 -10
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Util.js +151 -54
- package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/package.json +1 -1
- package/dist/fable_modules/project_cracked.json +1 -1
- package/package.json +1 -1
- package/dist/fable_modules/fable-library-js.5.24.0/Double.js +0 -53
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Async.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/AsyncBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/BitConverter.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Boolean.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Char.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Choice.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/CollectionUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/ConditionalWeakTable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOffset.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOnly.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeFormat.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeOffsetTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/DateTimeTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Directory.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Encoding.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Environment.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Event.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Collections.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/FSharp.Core.CompilerServices.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/File.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Guid.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MailboxProcessor.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/MapUtil.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Native.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Observable.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Option.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Path.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/README.md +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Result.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Stopwatch.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Task.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TaskBuilder.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeOnlyTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeSpan.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/TimeSpanTemporal.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Timer.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Unicode.13.0.0.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/Uri.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/big.d.ts +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/lib/big.js +0 -0
- /package/dist/fable_modules/{fable-library-js.5.24.0 → fable-library-js.5.27.0}/quotation.js +0 -0
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
|
|
2
|
-
import { toString, FSharpRef, Record } from "../fable_modules/fable-library-js.5.
|
|
3
|
-
import {
|
|
2
|
+
import { toString, FSharpRef, Record } from "../fable_modules/fable-library-js.5.27.0/Types.js";
|
|
3
|
+
import { array_type, bool_type, obj_type, record_type, class_type, string_type, enum_type, int32_type } from "../fable_modules/fable-library-js.5.27.0/Reflection.js";
|
|
4
4
|
import { Scheme as Scheme_1, Type, Types_typeToString, Type_$reflection } from "./Types.js";
|
|
5
5
|
import { ExternalFunction, ExternalCallContext, MapKey, Value, TaskHandle_$reflection, Value_$reflection } from "./Value.js";
|
|
6
|
-
import { EvalException, EvalError$, EvalError$_$reflection } from "./Error.js";
|
|
7
6
|
import { Span, Position } from "./Span.js";
|
|
8
|
-
import { printf, toText, join, concat } from "../fable_modules/fable-library-js.5.
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
7
|
+
import { printf, toText, float64ToString, join, concat } from "../fable_modules/fable-library-js.5.27.0/String.js";
|
|
8
|
+
import { EvalException, EvalError$ } from "./Error.js";
|
|
9
|
+
import { ofExterns, typeDefinitions, permitted, invoke, prepareCall, matches, $007CRecordFields$007C_$007C, permissionNames, allows } from "./HostInterop.js";
|
|
10
|
+
import { FSharpChoice$2 } from "../fable_modules/fable-library-js.5.27.0/Choice.js";
|
|
11
|
+
import { toList as toList_1, foldBack, head as head_2, tryPick, map, exists } from "../fable_modules/fable-library-js.5.27.0/Seq.js";
|
|
12
|
+
import { item as item_1 } from "../fable_modules/fable-library-js.5.27.0/Array.js";
|
|
13
|
+
import { curry2, compare as compare_1, defaultOf, disposeSafe, getEnumerator, comparePrimitives, equals as equals_1, int64ToString } from "../fable_modules/fable-library-js.5.27.0/Util.js";
|
|
14
|
+
import { ofArray, collect, tryFindIndex, choose, tryFind as tryFind_1, tryPick as tryPick_1, reverse, append, zip, fold as fold_1, singleton, forAll as forAll_1, empty, cons, tail as tail_2, head as head_1, isEmpty, forAll2, length, map as map_1 } from "../fable_modules/fable-library-js.5.27.0/List.js";
|
|
15
|
+
import { keys, map as map_2, containsKey, FSharpMap__Add, fold, empty as empty_1, FSharpMap__get_Item, FSharpMap__Remove, FSharpMap__get_IsEmpty, FSharpMap__ContainsKey, add as add_1, FSharpMap__TryFind, toSeq, ofList, tryFind, forAll, FSharpMap__get_Count, toList } from "../fable_modules/fable-library-js.5.27.0/Map.js";
|
|
16
|
+
import { compare, op_Modulus, op_Division, op_Multiply, op_Subtraction, op_Addition, toInt64_unchecked, equals } from "../fable_modules/fable-library-js.5.27.0/BigInt.js";
|
|
17
|
+
import { some, toArray } from "../fable_modules/fable-library-js.5.27.0/Option.js";
|
|
16
18
|
import { Ast_spanOfExpr, Expr, Ast_spanOfPattern, TypeRef } from "./Ast.js";
|
|
17
19
|
import { Execution_fold, Execution_map, Execution_execution, Execution_Builder__For_Z3A5BE4A, Execution$1__get_IsImmediate, Execution$1, Execution_run } from "./Execution.js";
|
|
18
|
-
import {
|
|
20
|
+
import { isCanonical } from "./TaskFunctions.js";
|
|
19
21
|
import { builtinExterns, tryExecution } from "./BuiltinFunctions.js";
|
|
20
|
-
import { StringBuilder__Append_Z721C83C5, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.
|
|
21
|
-
import {
|
|
22
|
+
import { StringBuilder__Append_Z721C83C5, StringBuilder_$ctor } from "../fable_modules/fable-library-js.5.27.0/System.Text.js";
|
|
23
|
+
import { Operators_InvalidOp } from "../fable_modules/fable-library-js.5.27.0/FSharp.Core.js";
|
|
24
|
+
import { contains } from "../fable_modules/fable-library-js.5.27.0/Set.js";
|
|
22
25
|
import { builtinReservedNames } from "./BuiltinSignatures.js";
|
|
23
26
|
import { typeDefs as typeDefs_2 } from "./BuiltinTypes.js";
|
|
24
27
|
|
|
25
28
|
export class ProgramState extends Record {
|
|
26
|
-
constructor(TypeDefs, Env, LastValue, ExitCode) {
|
|
29
|
+
constructor(Permissions, TypeDefs, Env, LastValue, ExitCode) {
|
|
27
30
|
super();
|
|
31
|
+
this.Permissions = Permissions;
|
|
28
32
|
this.TypeDefs = TypeDefs;
|
|
29
33
|
this.Env = Env;
|
|
30
34
|
this.LastValue = LastValue;
|
|
@@ -33,7 +37,7 @@ export class ProgramState extends Record {
|
|
|
33
37
|
}
|
|
34
38
|
|
|
35
39
|
export function ProgramState_$reflection() {
|
|
36
|
-
return record_type("FScript.Language.Eval.ProgramState", [], ProgramState, () => [["TypeDefs", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Type_$reflection()])], ["Env", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Value_$reflection()])], ["LastValue", Value_$reflection()], ["ExitCode", int32_type]]);
|
|
40
|
+
return record_type("FScript.Language.Eval.ProgramState", [], ProgramState, () => [["Permissions", enum_type("FScript.Language.HostPermissions", int32_type, [["None", 0], ["Interactive", 1], ["Threading", 2], ["IO", 4], ["Native", 8], ["All", 15]])], ["TypeDefs", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Type_$reflection()])], ["Env", class_type("Microsoft.FSharp.Collections.FSharpMap`2", [string_type, Value_$reflection()])], ["LastValue", Value_$reflection()], ["ExitCode", int32_type]]);
|
|
37
41
|
}
|
|
38
42
|
|
|
39
43
|
export class InvocationResult extends Record {
|
|
@@ -49,36 +53,85 @@ export function InvocationResult_$reflection() {
|
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
class RuntimeState extends Record {
|
|
52
|
-
constructor(SyncRoot, ExitCode, Active, PendingTasks
|
|
56
|
+
constructor(Permissions, SyncRoot, ExitCode, Active, PendingTasks) {
|
|
53
57
|
super();
|
|
58
|
+
this.Permissions = Permissions;
|
|
54
59
|
this.SyncRoot = SyncRoot;
|
|
55
60
|
this.ExitCode = ExitCode;
|
|
56
61
|
this.Active = Active;
|
|
57
62
|
this.PendingTasks = PendingTasks;
|
|
58
|
-
this.BackgroundFailure = BackgroundFailure;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
61
65
|
|
|
62
66
|
function RuntimeState_$reflection() {
|
|
63
|
-
return record_type("FScript.Language.Eval.RuntimeState", [], RuntimeState, () => [["
|
|
67
|
+
return record_type("FScript.Language.Eval.RuntimeState", [], RuntimeState, () => [["Permissions", enum_type("FScript.Language.HostPermissions", int32_type, [["None", 0], ["Interactive", 1], ["Threading", 2], ["IO", 4], ["Native", 8], ["All", 15]])], ["SyncRoot", obj_type], ["ExitCode", record_type("Microsoft.FSharp.Core.FSharpRef`1", [int32_type], FSharpRef, () => [["contents", int32_type]])], ["Active", record_type("Microsoft.FSharp.Core.FSharpRef`1", [bool_type], FSharpRef, () => [["contents", bool_type]])], ["PendingTasks", array_type(TaskHandle_$reflection())]]);
|
|
64
68
|
}
|
|
65
69
|
|
|
66
70
|
const unknownSpan = new Span(new Position(undefined, 0, 0), new Position(undefined, 0, 0));
|
|
67
71
|
|
|
68
|
-
function wrapTaskFailure(error) {
|
|
69
|
-
return new EvalError$(concat("Task failed: ", error.Message), error.Span);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
72
|
function wrapUnexpectedTaskFailure(ex) {
|
|
73
73
|
return new EvalError$(concat("Task failed: ", ex.message), unknownSpan);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
function checkRuntime(runtime) {
|
|
77
|
+
if (!runtime.Active.contents) {
|
|
78
|
+
throw new EvalException(new EvalError$("Script task scope has ended", unknownSpan));
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function checkPermissions(runtime, required) {
|
|
83
|
+
checkRuntime(runtime);
|
|
84
|
+
if (!allows(runtime.Permissions, required)) {
|
|
85
|
+
throw new EvalException(new EvalError$(concat("Host permissions denied: ", permissionNames(required)), unknownSpan));
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function joinRuntime(runtime) {
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function runRuntime(runtime, action) {
|
|
93
|
+
let outcome;
|
|
94
|
+
try {
|
|
95
|
+
outcome = (new FSharpChoice$2(/* Choice1Of2 */ 0, [action()]));
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
outcome = (new FSharpChoice$2(/* Choice2Of2 */ 1, [error]));
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
joinRuntime(runtime);
|
|
102
|
+
const failures = [];
|
|
103
|
+
const add = (error_1) => {
|
|
104
|
+
if (!exists((existing) => (existing === error_1), failures)) {
|
|
105
|
+
void (failures.push(error_1));
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
if (outcome.tag === 1) {
|
|
109
|
+
if (outcome.fields[0] instanceof EvalException) {
|
|
110
|
+
add(outcome.fields[0].Data0);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
add(new EvalError$(outcome.fields[0].message, unknownSpan));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
if (failures.length === 1) {
|
|
117
|
+
if (outcome.tag === 1) {
|
|
118
|
+
throw outcome.fields[0];
|
|
119
|
+
}
|
|
120
|
+
throw new EvalException(item_1(0, failures));
|
|
121
|
+
}
|
|
122
|
+
else if (failures.length > 1) {
|
|
123
|
+
throw new EvalException(new EvalError$(`Script execution failed with ${failures.length} errors:
|
|
124
|
+
${join("\n", map((error_5) => ("- " + error_5.Message), failures))}`, item_1(0, failures).Span));
|
|
125
|
+
}
|
|
126
|
+
if (outcome.tag === 1) {
|
|
127
|
+
throw outcome.fields[0];
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
return outcome.fields[0];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
runtime.Active.contents = false;
|
|
82
135
|
}
|
|
83
136
|
}
|
|
84
137
|
|
|
@@ -196,7 +249,7 @@ function valueToInterpolationString(v) {
|
|
|
196
249
|
case 1:
|
|
197
250
|
return int64ToString(i);
|
|
198
251
|
case 2:
|
|
199
|
-
return f
|
|
252
|
+
return float64ToString(f);
|
|
200
253
|
case 3:
|
|
201
254
|
if (b) {
|
|
202
255
|
return "true";
|
|
@@ -207,22 +260,22 @@ function valueToInterpolationString(v) {
|
|
|
207
260
|
case 4:
|
|
208
261
|
return s;
|
|
209
262
|
case 5: {
|
|
210
|
-
const arg = join(";",
|
|
263
|
+
const arg = join(";", map_1(valueToInterpolationString, xs));
|
|
211
264
|
return toText(printf("[%s]"))(arg);
|
|
212
265
|
}
|
|
213
266
|
case 6: {
|
|
214
|
-
const arg_1 = join(", ",
|
|
267
|
+
const arg_1 = join(", ", map_1(valueToInterpolationString, xs_1));
|
|
215
268
|
return toText(printf("(%s)"))(arg_1);
|
|
216
269
|
}
|
|
217
270
|
case 7: {
|
|
218
|
-
const arg_4 = join("; ",
|
|
271
|
+
const arg_4 = join("; ", map_1((tupledArg) => {
|
|
219
272
|
const arg_3 = valueToInterpolationString(tupledArg[1]);
|
|
220
273
|
return toText(printf("%s = %s"))(tupledArg[0])(arg_3);
|
|
221
274
|
}, toList(fields)));
|
|
222
275
|
return toText(printf("{ %s }"))(arg_4);
|
|
223
276
|
}
|
|
224
277
|
case 8: {
|
|
225
|
-
const arg_7 = join("; ",
|
|
278
|
+
const arg_7 = join("; ", map_1((tupledArg_1) => {
|
|
226
279
|
let arg_5;
|
|
227
280
|
const key = tupledArg_1[0];
|
|
228
281
|
arg_5 = ((key.tag === 1) ? int64ToString(key.fields[0]) : ((key.tag === 2) ? (key.fields[0] ? "true" : "false") : ((key.tag === 3) ? concat(key.fields[0], ".", key.fields[1]) : concat("\"", key.fields[0], "\""))));
|
|
@@ -1144,7 +1197,7 @@ function patternMatch(typeDefs_mut, pat_mut, value_mut) {
|
|
|
1144
1197
|
const k = activePatternResult[0];
|
|
1145
1198
|
const matchValue = FSharpMap__TryFind(merged, k);
|
|
1146
1199
|
if (matchValue == null) {
|
|
1147
|
-
merged =
|
|
1200
|
+
merged = add_1(k, v, merged);
|
|
1148
1201
|
}
|
|
1149
1202
|
else if (!valueEquals(matchValue, v)) {
|
|
1150
1203
|
const existing_1 = matchValue;
|
|
@@ -1500,7 +1553,7 @@ function patternMatch(typeDefs_mut, pat_mut, value_mut) {
|
|
|
1500
1553
|
}
|
|
1501
1554
|
switch (matchResult_2) {
|
|
1502
1555
|
case 0:
|
|
1503
|
-
return fold((acc, k_1, v_3) =>
|
|
1556
|
+
return fold((acc, k_1, v_3) => add_1(k_1, v_3, acc), env1, env2);
|
|
1504
1557
|
default:
|
|
1505
1558
|
return undefined;
|
|
1506
1559
|
}
|
|
@@ -1524,7 +1577,7 @@ function patternMatch(typeDefs_mut, pat_mut, value_mut) {
|
|
|
1524
1577
|
}
|
|
1525
1578
|
switch (matchResult_3) {
|
|
1526
1579
|
case 0:
|
|
1527
|
-
return fold((state, k_2, value_3) =>
|
|
1580
|
+
return fold((state, k_2, value_3) => add_1(k_2, value_3, state), acc_1, next);
|
|
1528
1581
|
default:
|
|
1529
1582
|
return undefined;
|
|
1530
1583
|
}
|
|
@@ -1555,7 +1608,7 @@ function patternMatch(typeDefs_mut, pat_mut, value_mut) {
|
|
|
1555
1608
|
return undefined;
|
|
1556
1609
|
}
|
|
1557
1610
|
else {
|
|
1558
|
-
return fold((state_2, k_3, v_5) =>
|
|
1611
|
+
return fold((state_2, k_3, v_5) => add_1(k_3, v_5, state_2), acc_2, matchValue_22);
|
|
1559
1612
|
}
|
|
1560
1613
|
}
|
|
1561
1614
|
default:
|
|
@@ -1838,24 +1891,31 @@ function binaryOperator(span, op, av, bv) {
|
|
|
1838
1891
|
}
|
|
1839
1892
|
|
|
1840
1893
|
function createExternContext(runtime, typeDefs, span) {
|
|
1841
|
-
return new ExternalCallContext(runtime.SyncRoot, () => runtime.Active.contents, (f_1, a) => Execution_run(applyFunctionValue(runtime, typeDefs, span, f_1, a)), (thunk) =>
|
|
1842
|
-
|
|
1894
|
+
return new ExternalCallContext(runtime.SyncRoot, () => runtime.Active.contents, (f_1, a) => Execution_run(applyFunctionValue(runtime, typeDefs, span, f_1, a)), (thunk) => {
|
|
1895
|
+
checkPermissions(runtime, 2);
|
|
1896
|
+
return spawnTaskValue(runtime, typeDefs, thunk);
|
|
1897
|
+
}, (task) => {
|
|
1898
|
+
checkPermissions(runtime, 2);
|
|
1899
|
+
return awaitTaskValue(runtime, task);
|
|
1900
|
+
}, () => {
|
|
1901
|
+
checkRuntime(runtime);
|
|
1843
1902
|
}, (value) => {
|
|
1903
|
+
}, (required) => {
|
|
1904
|
+
checkPermissions(runtime, required);
|
|
1844
1905
|
});
|
|
1845
1906
|
}
|
|
1846
1907
|
|
|
1847
1908
|
function spawnTaskValue(runtime, typeDefs, thunk) {
|
|
1848
|
-
raiseIfBackgroundFailed(runtime);
|
|
1849
1909
|
throw new EvalException(new EvalError$("Task.spawn is not supported in Fable builds", unknownSpan));
|
|
1850
1910
|
}
|
|
1851
1911
|
|
|
1852
1912
|
function awaitTaskValue(runtime, taskValue) {
|
|
1853
|
-
|
|
1913
|
+
checkRuntime(runtime);
|
|
1854
1914
|
throw new EvalException(new EvalError$("Task.await is not supported in Fable builds", unknownSpan));
|
|
1855
1915
|
}
|
|
1856
1916
|
|
|
1857
1917
|
function applyFunctionValue(runtime, typeDefs, span, fnValue, argValue) {
|
|
1858
|
-
|
|
1918
|
+
checkRuntime(runtime);
|
|
1859
1919
|
switch (fnValue.tag) {
|
|
1860
1920
|
case 14:
|
|
1861
1921
|
if (fnValue.fields[1].tag === 4) {
|
|
@@ -1918,11 +1978,11 @@ function invokeExternal(runtime, typeDefs, span, ext, args) {
|
|
|
1918
1978
|
}
|
|
1919
1979
|
|
|
1920
1980
|
function invokeExternalUnchecked(runtime, typeDefs, span, ext, args) {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1981
|
+
checkPermissions(runtime, ext.RequiredPermissions);
|
|
1982
|
+
if (isCanonical(ext)) {
|
|
1983
|
+
return new Execution$1((() => {
|
|
1984
|
+
throw new EvalException(new EvalError$(concat(ext.Name, " is not supported in Fable builds"), span));
|
|
1985
|
+
})(), defaultOf());
|
|
1926
1986
|
}
|
|
1927
1987
|
else {
|
|
1928
1988
|
const matchValue = tryExecution(ext);
|
|
@@ -1947,7 +2007,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
1947
2007
|
const second = () => {
|
|
1948
2008
|
const body_1 = evalExpr(runtime, typeDefs, env, _arg_1[1]);
|
|
1949
2009
|
if (Execution$1__get_IsImmediate(body_1)) {
|
|
1950
|
-
result =
|
|
2010
|
+
result = add_1(name, body_1.Value, result);
|
|
1951
2011
|
return new Execution$1(undefined, defaultOf());
|
|
1952
2012
|
}
|
|
1953
2013
|
else {
|
|
@@ -1955,7 +2015,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
1955
2015
|
const execution_1 = body_1;
|
|
1956
2016
|
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
1957
2017
|
let execution;
|
|
1958
|
-
result =
|
|
2018
|
+
result = add_1(name, execution_1.Value, result);
|
|
1959
2019
|
execution = (new Execution$1(undefined, defaultOf()));
|
|
1960
2020
|
const continuation_1 = continuation;
|
|
1961
2021
|
if (Execution$1__get_IsImmediate(execution)) {
|
|
@@ -1968,7 +2028,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
1968
2028
|
else {
|
|
1969
2029
|
return execution_1.Resume((value_4) => {
|
|
1970
2030
|
let execution;
|
|
1971
|
-
result =
|
|
2031
|
+
result = add_1(name, value_4, result);
|
|
1972
2032
|
execution = (new Execution$1(undefined, defaultOf()));
|
|
1973
2033
|
const continuation_1 = continuation;
|
|
1974
2034
|
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
@@ -2052,7 +2112,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2052
2112
|
const second = () => {
|
|
2053
2113
|
const body_1 = evalExpr(runtime, typeDefs, env, _arg_1[1]);
|
|
2054
2114
|
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2055
|
-
result =
|
|
2115
|
+
result = add_1(name, body_1.Value, result);
|
|
2056
2116
|
return new Execution$1(undefined, defaultOf());
|
|
2057
2117
|
}
|
|
2058
2118
|
else {
|
|
@@ -2060,7 +2120,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2060
2120
|
const execution_1 = body_1;
|
|
2061
2121
|
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2062
2122
|
let execution;
|
|
2063
|
-
result =
|
|
2123
|
+
result = add_1(name, execution_1.Value, result);
|
|
2064
2124
|
execution = (new Execution$1(undefined, defaultOf()));
|
|
2065
2125
|
const continuation_1 = continuation;
|
|
2066
2126
|
if (Execution$1__get_IsImmediate(execution)) {
|
|
@@ -2073,7 +2133,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2073
2133
|
else {
|
|
2074
2134
|
return execution_1.Resume((value_4) => {
|
|
2075
2135
|
let execution;
|
|
2076
|
-
result =
|
|
2136
|
+
result = add_1(name, value_4, result);
|
|
2077
2137
|
execution = (new Execution$1(undefined, defaultOf()));
|
|
2078
2138
|
const continuation_1 = continuation;
|
|
2079
2139
|
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
@@ -2157,7 +2217,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2157
2217
|
const second = () => {
|
|
2158
2218
|
const body_1 = evalExpr(runtime, typeDefs, env, _arg_1[1]);
|
|
2159
2219
|
if (Execution$1__get_IsImmediate(body_1)) {
|
|
2160
|
-
result =
|
|
2220
|
+
result = add_1(name, body_1.Value, result);
|
|
2161
2221
|
return new Execution$1(undefined, defaultOf());
|
|
2162
2222
|
}
|
|
2163
2223
|
else {
|
|
@@ -2165,7 +2225,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2165
2225
|
const execution_1 = body_1;
|
|
2166
2226
|
if (Execution$1__get_IsImmediate(execution_1)) {
|
|
2167
2227
|
let execution;
|
|
2168
|
-
result =
|
|
2228
|
+
result = add_1(name, execution_1.Value, result);
|
|
2169
2229
|
execution = (new Execution$1(undefined, defaultOf()));
|
|
2170
2230
|
const continuation_1 = continuation;
|
|
2171
2231
|
if (Execution$1__get_IsImmediate(execution)) {
|
|
@@ -2178,7 +2238,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2178
2238
|
else {
|
|
2179
2239
|
return execution_1.Resume((value_4) => {
|
|
2180
2240
|
let execution;
|
|
2181
|
-
result =
|
|
2241
|
+
result = add_1(name, value_4, result);
|
|
2182
2242
|
execution = (new Execution$1(undefined, defaultOf()));
|
|
2183
2243
|
const continuation_1 = continuation;
|
|
2184
2244
|
return Execution$1__get_IsImmediate(execution) ? continuation_1(execution.Value) : execution.Resume(continuation_1);
|
|
@@ -2251,7 +2311,7 @@ function updateRecord(runtime, typeDefs, env, target, updates, span, structural)
|
|
|
2251
2311
|
}
|
|
2252
2312
|
|
|
2253
2313
|
function evalExpr(runtime, typeDefs, env, expr) {
|
|
2254
|
-
|
|
2314
|
+
checkRuntime(runtime);
|
|
2255
2315
|
const immediate = (value) => (new Execution$1(value, defaultOf()));
|
|
2256
2316
|
switch (expr.tag) {
|
|
2257
2317
|
case 0:
|
|
@@ -2946,7 +3006,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
2946
3006
|
})(), defaultOf());
|
|
2947
3007
|
}
|
|
2948
3008
|
else {
|
|
2949
|
-
return evalExpr(runtime, typeDefs, fold((state, k, v) =>
|
|
3009
|
+
return evalExpr(runtime, typeDefs, fold((state, k, v) => add_1(k, v, state), env, matchValue), body_23);
|
|
2950
3010
|
}
|
|
2951
3011
|
}
|
|
2952
3012
|
else {
|
|
@@ -2957,7 +3017,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
2957
3017
|
const matchValue = patternMatch(typeDefs, pattern, execution_17.Value);
|
|
2958
3018
|
execution_16 = ((matchValue == null) ? (new Execution$1((() => {
|
|
2959
3019
|
throw new EvalException(new EvalError$("Let pattern did not match value", span_5));
|
|
2960
|
-
})(), defaultOf())) : evalExpr(runtime, typeDefs, fold((state, k, v) =>
|
|
3020
|
+
})(), defaultOf())) : evalExpr(runtime, typeDefs, fold((state, k, v) => add_1(k, v, state), env, matchValue), body_23));
|
|
2961
3021
|
const continuation_25 = continuation_24;
|
|
2962
3022
|
if (Execution$1__get_IsImmediate(execution_16)) {
|
|
2963
3023
|
return continuation_25(execution_16.Value);
|
|
@@ -2972,7 +3032,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
2972
3032
|
const matchValue = patternMatch(typeDefs, pattern, value_28);
|
|
2973
3033
|
execution_16 = ((matchValue == null) ? (new Execution$1((() => {
|
|
2974
3034
|
throw new EvalException(new EvalError$("Let pattern did not match value", span_5));
|
|
2975
|
-
})(), defaultOf())) : evalExpr(runtime, typeDefs, fold((state, k, v) =>
|
|
3035
|
+
})(), defaultOf())) : evalExpr(runtime, typeDefs, fold((state, k, v) => add_1(k, v, state), env, matchValue), body_23));
|
|
2976
3036
|
const continuation_25 = continuation_24;
|
|
2977
3037
|
return Execution$1__get_IsImmediate(execution_16) ? continuation_25(execution_16.Value) : execution_16.Resume(continuation_25);
|
|
2978
3038
|
});
|
|
@@ -2982,7 +3042,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
2982
3042
|
}
|
|
2983
3043
|
case 7: {
|
|
2984
3044
|
const recEnv_1 = new FSharpRef(env);
|
|
2985
|
-
const entries =
|
|
3045
|
+
const entries = map_1((tupledArg) => {
|
|
2986
3046
|
const args = tupledArg[1];
|
|
2987
3047
|
const bindingSpan = tupledArg[4];
|
|
2988
3048
|
if (isEmpty(args)) {
|
|
@@ -2996,7 +3056,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
2996
3056
|
throw new EvalException(new EvalError$("let rec requires a function binding", span_6));
|
|
2997
3057
|
}
|
|
2998
3058
|
}, bindings_1);
|
|
2999
|
-
recEnv_1.contents = fold_1((state_1, tupledArg_1) =>
|
|
3059
|
+
recEnv_1.contents = fold_1((state_1, tupledArg_1) => add_1(tupledArg_1[0], tupledArg_1[1], state_1), env, entries);
|
|
3000
3060
|
return evalExpr(runtime, typeDefs, recEnv_1.contents, body_27);
|
|
3001
3061
|
}
|
|
3002
3062
|
case 8: {
|
|
@@ -3012,7 +3072,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3012
3072
|
const body_29 = head_1(cases_1)[2];
|
|
3013
3073
|
const matchValue_2 = patternMatch(typeDefs, head_1(cases_1)[0], body_37.Value);
|
|
3014
3074
|
if (matchValue_2 != null) {
|
|
3015
|
-
const scope = fold((state_2, k_1, v_1) =>
|
|
3075
|
+
const scope = fold((state_2, k_1, v_1) => add_1(k_1, v_1, state_2), env, matchValue_2);
|
|
3016
3076
|
const body_34 = (guard == null) ? (new Execution$1(new Value(/* VBool */ 3, [true]), defaultOf())) : evalExpr(runtime, typeDefs, scope, guard);
|
|
3017
3077
|
if (Execution$1__get_IsImmediate(body_34)) {
|
|
3018
3078
|
const accepted = body_34.Value;
|
|
@@ -3092,7 +3152,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3092
3152
|
const body_29 = head_1(cases_1)[2];
|
|
3093
3153
|
const matchValue_2 = patternMatch(typeDefs, head_1(cases_1)[0], execution_21.Value);
|
|
3094
3154
|
if (matchValue_2 != null) {
|
|
3095
|
-
const scope = fold((state_2, k_1, v_1) =>
|
|
3155
|
+
const scope = fold((state_2, k_1, v_1) => add_1(k_1, v_1, state_2), env, matchValue_2);
|
|
3096
3156
|
const body_34 = (guard == null) ? (new Execution$1(new Value(/* VBool */ 3, [true]), defaultOf())) : evalExpr(runtime, typeDefs, scope, guard);
|
|
3097
3157
|
if (Execution$1__get_IsImmediate(body_34)) {
|
|
3098
3158
|
const accepted = body_34.Value;
|
|
@@ -3177,7 +3237,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3177
3237
|
const body_29 = head_1(cases_1)[2];
|
|
3178
3238
|
const matchValue_2 = patternMatch(typeDefs, head_1(cases_1)[0], value_38);
|
|
3179
3239
|
if (matchValue_2 != null) {
|
|
3180
|
-
const scope = fold((state_2, k_1, v_1) =>
|
|
3240
|
+
const scope = fold((state_2, k_1, v_1) => add_1(k_1, v_1, state_2), env, matchValue_2);
|
|
3181
3241
|
const body_34 = (guard == null) ? (new Execution$1(new Value(/* VBool */ 3, [true]), defaultOf())) : evalExpr(runtime, typeDefs, scope, guard);
|
|
3182
3242
|
if (Execution$1__get_IsImmediate(body_34)) {
|
|
3183
3243
|
const accepted = body_34.Value;
|
|
@@ -3847,7 +3907,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3847
3907
|
if (Execution$1__get_IsImmediate(body_55)) {
|
|
3848
3908
|
const value_65 = body_55.Value;
|
|
3849
3909
|
if (value_65.tag === 8) {
|
|
3850
|
-
return new Execution$1(fold((state_3, k_2, v_2) => (containsKey(k_2, state_3) ? state_3 :
|
|
3910
|
+
return new Execution$1(fold((state_3, k_2, v_2) => (containsKey(k_2, state_3) ? state_3 : add_1(k_2, v_2, state_3)), acc_2, value_65.fields[0]), defaultOf());
|
|
3851
3911
|
}
|
|
3852
3912
|
else {
|
|
3853
3913
|
return new Execution$1((() => {
|
|
@@ -3861,7 +3921,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3861
3921
|
if (Execution$1__get_IsImmediate(execution_39)) {
|
|
3862
3922
|
let execution_38;
|
|
3863
3923
|
const value_65 = execution_39.Value;
|
|
3864
|
-
execution_38 = ((value_65.tag === 8) ? (new Execution$1(fold((state_3, k_2, v_2) => (containsKey(k_2, state_3) ? state_3 :
|
|
3924
|
+
execution_38 = ((value_65.tag === 8) ? (new Execution$1(fold((state_3, k_2, v_2) => (containsKey(k_2, state_3) ? state_3 : add_1(k_2, v_2, state_3)), acc_2, value_65.fields[0]), defaultOf())) : (new Execution$1((() => {
|
|
3865
3925
|
throw new EvalException(new EvalError$("Map spread value must be a map", Ast_spanOfExpr(spread)));
|
|
3866
3926
|
})(), defaultOf())));
|
|
3867
3927
|
const continuation_58 = continuation_57;
|
|
@@ -3876,7 +3936,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3876
3936
|
return execution_39.Resume((value_70) => {
|
|
3877
3937
|
let execution_38;
|
|
3878
3938
|
const value_65 = value_70;
|
|
3879
|
-
execution_38 = ((value_65.tag === 8) ? (new Execution$1(fold((state_3, k_2, v_2) => (containsKey(k_2, state_3) ? state_3 :
|
|
3939
|
+
execution_38 = ((value_65.tag === 8) ? (new Execution$1(fold((state_3, k_2, v_2) => (containsKey(k_2, state_3) ? state_3 : add_1(k_2, v_2, state_3)), acc_2, value_65.fields[0]), defaultOf())) : (new Execution$1((() => {
|
|
3880
3940
|
throw new EvalException(new EvalError$("Map spread value must be a map", Ast_spanOfExpr(spread)));
|
|
3881
3941
|
})(), defaultOf())));
|
|
3882
3942
|
const continuation_58 = continuation_57;
|
|
@@ -3917,13 +3977,13 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3917
3977
|
const converted = valueToMapKey(Ast_spanOfExpr(keyExpr), key);
|
|
3918
3978
|
const body_51 = evalExpr(runtime, typeDefs, env, valueExpr_1);
|
|
3919
3979
|
if (Execution$1__get_IsImmediate(body_51)) {
|
|
3920
|
-
return new Execution$1(
|
|
3980
|
+
return new Execution$1(add_1(converted, body_51.Value, acc_2), defaultOf());
|
|
3921
3981
|
}
|
|
3922
3982
|
else {
|
|
3923
3983
|
return new Execution$1(defaultOf(), (continuation_51) => {
|
|
3924
3984
|
const execution_35 = body_51;
|
|
3925
3985
|
if (Execution$1__get_IsImmediate(execution_35)) {
|
|
3926
|
-
const execution_34 = new Execution$1(
|
|
3986
|
+
const execution_34 = new Execution$1(add_1(converted, execution_35.Value, acc_2), defaultOf());
|
|
3927
3987
|
const continuation_52 = continuation_51;
|
|
3928
3988
|
if (Execution$1__get_IsImmediate(execution_34)) {
|
|
3929
3989
|
return continuation_52(execution_34.Value);
|
|
@@ -3934,7 +3994,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3934
3994
|
}
|
|
3935
3995
|
else {
|
|
3936
3996
|
return execution_35.Resume((value_61) => {
|
|
3937
|
-
const execution_34 = new Execution$1(
|
|
3997
|
+
const execution_34 = new Execution$1(add_1(converted, value_61, acc_2), defaultOf());
|
|
3938
3998
|
const continuation_52 = continuation_51;
|
|
3939
3999
|
return Execution$1__get_IsImmediate(execution_34) ? continuation_52(execution_34.Value) : execution_34.Resume(continuation_52);
|
|
3940
4000
|
});
|
|
@@ -3978,10 +4038,10 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3978
4038
|
case 0: {
|
|
3979
4039
|
const converted = valueToMapKey(Ast_spanOfExpr(keyExpr), key);
|
|
3980
4040
|
const body_51 = evalExpr(runtime, typeDefs, env, valueExpr_1);
|
|
3981
|
-
execution_36 = (Execution$1__get_IsImmediate(body_51) ? (new Execution$1(
|
|
4041
|
+
execution_36 = (Execution$1__get_IsImmediate(body_51) ? (new Execution$1(add_1(converted, body_51.Value, acc_2), defaultOf())) : (new Execution$1(defaultOf(), (continuation_51) => {
|
|
3982
4042
|
const execution_35 = body_51;
|
|
3983
4043
|
if (Execution$1__get_IsImmediate(execution_35)) {
|
|
3984
|
-
const execution_34 = new Execution$1(
|
|
4044
|
+
const execution_34 = new Execution$1(add_1(converted, execution_35.Value, acc_2), defaultOf());
|
|
3985
4045
|
const continuation_52 = continuation_51;
|
|
3986
4046
|
if (Execution$1__get_IsImmediate(execution_34)) {
|
|
3987
4047
|
return continuation_52(execution_34.Value);
|
|
@@ -3992,7 +4052,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
3992
4052
|
}
|
|
3993
4053
|
else {
|
|
3994
4054
|
return execution_35.Resume((value_61) => {
|
|
3995
|
-
const execution_34 = new Execution$1(
|
|
4055
|
+
const execution_34 = new Execution$1(add_1(converted, value_61, acc_2), defaultOf());
|
|
3996
4056
|
const continuation_52 = continuation_51;
|
|
3997
4057
|
return Execution$1__get_IsImmediate(execution_34) ? continuation_52(execution_34.Value) : execution_34.Resume(continuation_52);
|
|
3998
4058
|
});
|
|
@@ -4041,10 +4101,10 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
4041
4101
|
case 0: {
|
|
4042
4102
|
const converted = valueToMapKey(Ast_spanOfExpr(keyExpr), key);
|
|
4043
4103
|
const body_51 = evalExpr(runtime, typeDefs, env, valueExpr_1);
|
|
4044
|
-
execution_36 = (Execution$1__get_IsImmediate(body_51) ? (new Execution$1(
|
|
4104
|
+
execution_36 = (Execution$1__get_IsImmediate(body_51) ? (new Execution$1(add_1(converted, body_51.Value, acc_2), defaultOf())) : (new Execution$1(defaultOf(), (continuation_51) => {
|
|
4045
4105
|
const execution_35 = body_51;
|
|
4046
4106
|
if (Execution$1__get_IsImmediate(execution_35)) {
|
|
4047
|
-
const execution_34 = new Execution$1(
|
|
4107
|
+
const execution_34 = new Execution$1(add_1(converted, execution_35.Value, acc_2), defaultOf());
|
|
4048
4108
|
const continuation_52 = continuation_51;
|
|
4049
4109
|
if (Execution$1__get_IsImmediate(execution_34)) {
|
|
4050
4110
|
return continuation_52(execution_34.Value);
|
|
@@ -4055,7 +4115,7 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
4055
4115
|
}
|
|
4056
4116
|
else {
|
|
4057
4117
|
return execution_35.Resume((value_61) => {
|
|
4058
|
-
const execution_34 = new Execution$1(
|
|
4118
|
+
const execution_34 = new Execution$1(add_1(converted, value_61, acc_2), defaultOf());
|
|
4059
4119
|
const continuation_52 = continuation_51;
|
|
4060
4120
|
return Execution$1__get_IsImmediate(execution_34) ? continuation_52(execution_34.Value) : execution_34.Resume(continuation_52);
|
|
4061
4121
|
});
|
|
@@ -5659,13 +5719,13 @@ function evalCompound(runtime, typeDefs, env, expr) {
|
|
|
5659
5719
|
}
|
|
5660
5720
|
default:
|
|
5661
5721
|
return new Execution$1((() => {
|
|
5662
|
-
throw
|
|
5722
|
+
throw Operators_InvalidOp("Immediate expressions are handled before compound evaluation.");
|
|
5663
5723
|
})(), defaultOf());
|
|
5664
5724
|
}
|
|
5665
5725
|
}
|
|
5666
5726
|
|
|
5667
|
-
export function
|
|
5668
|
-
const runtime = new RuntimeState({}, new FSharpRef(0), new FSharpRef(true), []
|
|
5727
|
+
export function invokeValueWithPermissionsAndExitCode(permissions, typeDefs, fnValue, args) {
|
|
5728
|
+
const runtime = new RuntimeState(permissions, {}, new FSharpRef(0), new FSharpRef(true), []);
|
|
5669
5729
|
const applyMany = (currentValue_mut, remainingArgs_mut) => {
|
|
5670
5730
|
applyMany:
|
|
5671
5731
|
while (true) {
|
|
@@ -5708,7 +5768,7 @@ export function invokeValueWithExitCode(typeDefs, fnValue, args) {
|
|
|
5708
5768
|
}
|
|
5709
5769
|
switch (matchResult) {
|
|
5710
5770
|
case 0: {
|
|
5711
|
-
envAcc_mut =
|
|
5771
|
+
envAcc_mut = add_1(param.Name, nextArg, envAcc);
|
|
5712
5772
|
exprAcc_mut = nextBody;
|
|
5713
5773
|
argsAcc_mut = rest;
|
|
5714
5774
|
continue bindLambdaChain;
|
|
@@ -5719,7 +5779,7 @@ export function invokeValueWithExitCode(typeDefs, fnValue, args) {
|
|
|
5719
5779
|
break;
|
|
5720
5780
|
}
|
|
5721
5781
|
};
|
|
5722
|
-
const patternInput = bindLambdaChain(
|
|
5782
|
+
const patternInput = bindLambdaChain(add_1(currentValue.fields[0], head_1(remainingArgs), currentValue.fields[2].contents), currentValue.fields[1], tail_2(remainingArgs));
|
|
5723
5783
|
currentValue_mut = Execution_run(evalExpr(runtime, typeDefs, patternInput[0], patternInput[1]));
|
|
5724
5784
|
remainingArgs_mut = patternInput[2];
|
|
5725
5785
|
continue applyMany;
|
|
@@ -5737,12 +5797,11 @@ export function invokeValueWithExitCode(typeDefs, fnValue, args) {
|
|
|
5737
5797
|
break;
|
|
5738
5798
|
}
|
|
5739
5799
|
};
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
}
|
|
5800
|
+
return new InvocationResult(runRuntime(runtime, () => (new InvocationResult(applyMany(fnValue, args), runtime.ExitCode.contents))).Value, runtime.ExitCode.contents);
|
|
5801
|
+
}
|
|
5802
|
+
|
|
5803
|
+
export function invokeValueWithExitCode(typeDefs, fnValue, args) {
|
|
5804
|
+
return invokeValueWithPermissionsAndExitCode(0, typeDefs, fnValue, args);
|
|
5746
5805
|
}
|
|
5747
5806
|
|
|
5748
5807
|
export function invokeValue(typeDefs, fnValue, args) {
|
|
@@ -5814,7 +5873,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5814
5873
|
try {
|
|
5815
5874
|
while (enumerator["System.Collections.IEnumerator.MoveNext"]()) {
|
|
5816
5875
|
const stmt = enumerator["System.Collections.Generic.IEnumerator`1.get_Current"]();
|
|
5817
|
-
|
|
5876
|
+
checkRuntime(runtime);
|
|
5818
5877
|
switch (stmt.tag) {
|
|
5819
5878
|
case 4: {
|
|
5820
5879
|
const name = stmt.fields[0];
|
|
@@ -5828,10 +5887,10 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5828
5887
|
return 0;
|
|
5829
5888
|
}
|
|
5830
5889
|
};
|
|
5831
|
-
const external = new ExternalFunction(name, new Scheme_1(empty(), importedType), (_arg_1, _arg_2) => {
|
|
5890
|
+
const external = new ExternalFunction(0, name, new Scheme_1(empty(), importedType), (_arg_1, _arg_2) => {
|
|
5832
5891
|
throw new EvalException(new EvalError$(`Backend import '${import$.ModulePath}.${import$.MemberName}' is not executable in the legacy evaluator`, stmt.fields[3]));
|
|
5833
5892
|
}, arity(importedType));
|
|
5834
|
-
env =
|
|
5893
|
+
env = add_1(name, new Value(/* VExternal */ 15, [external, empty()]), env);
|
|
5835
5894
|
break;
|
|
5836
5895
|
}
|
|
5837
5896
|
case 1: {
|
|
@@ -5840,7 +5899,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5840
5899
|
if (stmt.fields[3]) {
|
|
5841
5900
|
if (expr.tag === 4) {
|
|
5842
5901
|
const recEnv = new FSharpRef(env);
|
|
5843
|
-
const finalEnv =
|
|
5902
|
+
const finalEnv = add_1(name_1, new Value(/* VClosure */ 14, [expr.fields[0].Name, expr.fields[1], recEnv]), env);
|
|
5844
5903
|
recEnv.contents = finalEnv;
|
|
5845
5904
|
env = finalEnv;
|
|
5846
5905
|
}
|
|
@@ -5850,7 +5909,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5850
5909
|
}
|
|
5851
5910
|
else {
|
|
5852
5911
|
const v = Execution_run(evalExpr(runtime, typeDefs, env, expr));
|
|
5853
|
-
env =
|
|
5912
|
+
env = add_1(name_1, v, env);
|
|
5854
5913
|
}
|
|
5855
5914
|
break;
|
|
5856
5915
|
}
|
|
@@ -5861,7 +5920,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5861
5920
|
}
|
|
5862
5921
|
else {
|
|
5863
5922
|
const bindings = matchValue;
|
|
5864
|
-
env = fold((acc, k, value) =>
|
|
5923
|
+
env = fold((acc, k, value) => add_1(k, value, acc), env, bindings);
|
|
5865
5924
|
}
|
|
5866
5925
|
break;
|
|
5867
5926
|
}
|
|
@@ -5870,7 +5929,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5870
5929
|
if (!isEmpty(bindings_1)) {
|
|
5871
5930
|
const recEnv_1 = new FSharpRef(env);
|
|
5872
5931
|
let finalEnv_1;
|
|
5873
|
-
const list_1 =
|
|
5932
|
+
const list_1 = map_1((tupledArg) => {
|
|
5874
5933
|
const expr_2 = tupledArg[1];
|
|
5875
5934
|
if (expr_2.tag === 4) {
|
|
5876
5935
|
return [tupledArg[0], new Value(/* VClosure */ 14, [expr_2.fields[0].Name, expr_2.fields[1], recEnv_1])];
|
|
@@ -5879,7 +5938,7 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5879
5938
|
throw new EvalException(new EvalError$("let rec requires a function binding", tupledArg[3]));
|
|
5880
5939
|
}
|
|
5881
5940
|
}, bindings_1);
|
|
5882
|
-
finalEnv_1 = fold_1((acc_1, tupledArg_1) =>
|
|
5941
|
+
finalEnv_1 = fold_1((acc_1, tupledArg_1) => add_1(tupledArg_1[0], tupledArg_1[1], acc_1), env, list_1);
|
|
5883
5942
|
recEnv_1.contents = finalEnv_1;
|
|
5884
5943
|
env = finalEnv_1;
|
|
5885
5944
|
}
|
|
@@ -5897,32 +5956,24 @@ function evaluateStatements(runtime, typeDefs, initialEnv, program) {
|
|
|
5897
5956
|
finally {
|
|
5898
5957
|
disposeSafe(enumerator);
|
|
5899
5958
|
}
|
|
5900
|
-
|
|
5901
|
-
const unawaitedCount = length_1(filter((handle) => !handle.Awaited, runtime.PendingTasks)) | 0;
|
|
5902
|
-
if (unawaitedCount > 0) {
|
|
5903
|
-
throw new EvalException(new EvalError$(`Program completed with ${unawaitedCount} unawaited ${(unawaitedCount === 1) ? "task" : "tasks"}`, unknownSpan));
|
|
5904
|
-
}
|
|
5905
|
-
return new ProgramState(typeDefs, env, lastValue, runtime.ExitCode.contents);
|
|
5959
|
+
return new ProgramState(runtime.Permissions, typeDefs, env, lastValue, runtime.ExitCode.contents);
|
|
5906
5960
|
}
|
|
5907
5961
|
|
|
5908
5962
|
export function evalProgramFromState(state, program) {
|
|
5909
|
-
const runtime = new RuntimeState({}, new FSharpRef(state.ExitCode), new FSharpRef(true), []
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
}
|
|
5913
|
-
finally {
|
|
5914
|
-
runtime.Active.contents = false;
|
|
5915
|
-
}
|
|
5963
|
+
const runtime = new RuntimeState(state.Permissions, {}, new FSharpRef(state.ExitCode), new FSharpRef(true), []);
|
|
5964
|
+
const result = runRuntime(runtime, () => evaluateStatements(runtime, state.TypeDefs, state.Env, program));
|
|
5965
|
+
return new ProgramState(result.Permissions, result.TypeDefs, result.Env, result.LastValue, runtime.ExitCode.contents);
|
|
5916
5966
|
}
|
|
5917
5967
|
|
|
5918
5968
|
function evaluateRegistered(registration, program) {
|
|
5919
|
-
const
|
|
5920
|
-
const
|
|
5969
|
+
const registration_1 = permitted(registration);
|
|
5970
|
+
const externs = registration_1.Functions;
|
|
5971
|
+
const runtime = new RuntimeState(registration_1.Permissions, {}, new FSharpRef(0), new FSharpRef(true), []);
|
|
5921
5972
|
const option_1 = tryFind_1((ext) => contains(ext.Name, builtinReservedNames), externs);
|
|
5922
5973
|
if (option_1 != null) {
|
|
5923
5974
|
throw new EvalException(new EvalError$(concat("Host extern \'", option_1.Name, "\' collides with reserved stdlib symbol"), unknownSpan));
|
|
5924
5975
|
}
|
|
5925
|
-
const decls = ofList(append(
|
|
5976
|
+
const decls = ofList(append(map_1((def) => [def.Name, def], typeDefs_2), choose((_arg) => {
|
|
5926
5977
|
if (_arg.tag === 0) {
|
|
5927
5978
|
const def_1 = _arg.fields[0];
|
|
5928
5979
|
return [def_1.Name, def_1];
|
|
@@ -5936,7 +5987,7 @@ function evaluateRegistered(registration, program) {
|
|
|
5936
5987
|
const fromRef = (stack, tref) => {
|
|
5937
5988
|
switch (tref.tag) {
|
|
5938
5989
|
case 1:
|
|
5939
|
-
return new Type(/* TTuple */ 7, [
|
|
5990
|
+
return new Type(/* TTuple */ 7, [map_1(curry2(fromRef)(stack), tref.fields[0])]);
|
|
5940
5991
|
case 2:
|
|
5941
5992
|
return new Type(/* TFun */ 11, [fromRef(stack, tref.fields[0]), fromRef(stack, tref.fields[1])]);
|
|
5942
5993
|
case 3:
|
|
@@ -5955,11 +6006,11 @@ function evaluateRegistered(registration, program) {
|
|
|
5955
6006
|
case 4:
|
|
5956
6007
|
return new Type(/* TMap */ 9, [equals_1(tref.fields[0], new TypeRef(/* TRName */ 0, ["numeric"])) ? Type.TInt : fromRef(stack, tref.fields[0]), fromRef(stack, tref.fields[1])]);
|
|
5957
6008
|
case 5:
|
|
5958
|
-
return new Type(/* TRecord */ 8, [ofList(
|
|
6009
|
+
return new Type(/* TRecord */ 8, [ofList(map_1((tupledArg_2) => [tupledArg_2[0], fromRef(stack, tupledArg_2[1])], tref.fields[0]), {
|
|
5959
6010
|
Compare: (x_3, y_4) => (comparePrimitives(x_3, y_4) | 0),
|
|
5960
6011
|
})]);
|
|
5961
6012
|
case 6:
|
|
5962
|
-
return new Type(/* TRecord */ 8, [ofList(
|
|
6013
|
+
return new Type(/* TRecord */ 8, [ofList(map_1((tupledArg_3) => [tupledArg_3[0], fromRef(stack, tupledArg_3[1])], tref.fields[0]), {
|
|
5963
6014
|
Compare: (x_4, y_5) => (comparePrimitives(x_4, y_5) | 0),
|
|
5964
6015
|
})]);
|
|
5965
6016
|
default:
|
|
@@ -5984,7 +6035,7 @@ function evaluateRegistered(registration, program) {
|
|
|
5984
6035
|
const matchValue_1 = tryFindIndex((y_1) => (tref.fields[0] === y_1), stack);
|
|
5985
6036
|
if (matchValue_1 == null) {
|
|
5986
6037
|
if (!isEmpty(d.Cases)) {
|
|
5987
|
-
return new Type(/* TUnion */ 13, [tref.fields[0], ofList(
|
|
6038
|
+
return new Type(/* TUnion */ 13, [tref.fields[0], ofList(map_1((tupledArg) => {
|
|
5988
6039
|
let mapping_1, option_3;
|
|
5989
6040
|
return [tupledArg[0], (mapping_1 = curry2(fromRef)(cons(tref.fields[0], stack)), (option_3 = tupledArg[1], (option_3 != null) ? mapping_1(option_3) : undefined))];
|
|
5990
6041
|
}, d.Cases), {
|
|
@@ -5992,7 +6043,7 @@ function evaluateRegistered(registration, program) {
|
|
|
5992
6043
|
})]);
|
|
5993
6044
|
}
|
|
5994
6045
|
else {
|
|
5995
|
-
return new Type(/* TRecord */ 8, [ofList(
|
|
6046
|
+
return new Type(/* TRecord */ 8, [ofList(map_1((tupledArg_1) => [tupledArg_1[0], fromRef(cons(tref.fields[0], stack), tupledArg_1[1])], d.Fields), {
|
|
5996
6047
|
Compare: (x_2, y_3) => (comparePrimitives(x_2, y_3) | 0),
|
|
5997
6048
|
})]);
|
|
5998
6049
|
}
|
|
@@ -6013,9 +6064,9 @@ function evaluateRegistered(registration, program) {
|
|
|
6013
6064
|
}
|
|
6014
6065
|
}
|
|
6015
6066
|
};
|
|
6016
|
-
const typeDefs_1 = fold((acc, name_3, t_2) =>
|
|
6067
|
+
const typeDefs_1 = fold((acc, name_3, t_2) => add_1(name_3, t_2, acc), map_2((name_2, def_2) => {
|
|
6017
6068
|
if (!isEmpty(def_2.Cases)) {
|
|
6018
|
-
return new Type(/* TUnion */ 13, [name_2, ofList(
|
|
6069
|
+
return new Type(/* TUnion */ 13, [name_2, ofList(map_1((tupledArg_4) => {
|
|
6019
6070
|
let mapping_8, option_5;
|
|
6020
6071
|
return [tupledArg_4[0], (mapping_8 = curry2(fromRef)(singleton(name_2)), (option_5 = tupledArg_4[1], (option_5 != null) ? mapping_8(option_5) : undefined))];
|
|
6021
6072
|
}, def_2.Cases), {
|
|
@@ -6023,11 +6074,11 @@ function evaluateRegistered(registration, program) {
|
|
|
6023
6074
|
})]);
|
|
6024
6075
|
}
|
|
6025
6076
|
else {
|
|
6026
|
-
return new Type(/* TRecord */ 8, [ofList(
|
|
6077
|
+
return new Type(/* TRecord */ 8, [ofList(map_1((tupledArg_5) => [tupledArg_5[0], fromRef(singleton(name_2), tupledArg_5[1])], def_2.Fields), {
|
|
6027
6078
|
Compare: (x_6, y_7) => (comparePrimitives(x_6, y_7) | 0),
|
|
6028
6079
|
})]);
|
|
6029
6080
|
}
|
|
6030
|
-
}, decls), typeDefinitions(
|
|
6081
|
+
}, decls), typeDefinitions(registration_1, toList_1(keys(decls))));
|
|
6031
6082
|
const constructorValues = collect((tupledArg_6) => {
|
|
6032
6083
|
const typeName = tupledArg_6[0];
|
|
6033
6084
|
return collect((tupledArg_7) => {
|
|
@@ -6040,9 +6091,9 @@ function evaluateRegistered(registration, program) {
|
|
|
6040
6091
|
const caseName_3 = tupledArg_8[0];
|
|
6041
6092
|
const value_1 = (tupledArg_8[1] == null) ? (new Value(/* VUnionCase */ 10, [descriptor.Name, caseName_3, undefined])) : (new Value(/* VUnionCtor */ 11, [descriptor.Name, caseName_3]));
|
|
6042
6093
|
return ofArray([[caseName_3, value_1], [concat(descriptor.Name, ".", caseName_3), value_1]]);
|
|
6043
|
-
}, toList(descriptor.Cases)),
|
|
6094
|
+
}, toList(descriptor.Cases)), registration_1.Unions), constructorValues);
|
|
6044
6095
|
const externContext = createExternContext(runtime, typeDefs_1, unknownSpan);
|
|
6045
|
-
|
|
6096
|
+
const result_1 = runRuntime(runtime, () => {
|
|
6046
6097
|
let env;
|
|
6047
6098
|
const list_15 = append(builtinExterns, externs);
|
|
6048
6099
|
env = fold_1((acc_1, ext_2) => {
|
|
@@ -6062,10 +6113,8 @@ function evaluateRegistered(registration, program) {
|
|
|
6062
6113
|
catch (error) {
|
|
6063
6114
|
throw error;
|
|
6064
6115
|
}
|
|
6065
|
-
}
|
|
6066
|
-
|
|
6067
|
-
runtime.Active.contents = false;
|
|
6068
|
-
}
|
|
6116
|
+
});
|
|
6117
|
+
return new ProgramState(result_1.Permissions, result_1.TypeDefs, result_1.Env, result_1.LastValue, runtime.ExitCode.contents);
|
|
6069
6118
|
}
|
|
6070
6119
|
|
|
6071
6120
|
export function evalProgramWithRegistrationState(registration, program) {
|