firefly-compiler 0.5.35 → 0.5.37
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/.hintrc +4 -4
- package/.vscode/settings.json +4 -4
- package/bin/Release.ff +157 -154
- package/bin/firefly.mjs +1 -1
- package/compiler/Builder.ff +275 -277
- package/compiler/Compiler.ff +234 -233
- package/compiler/Dependencies.ff +186 -187
- package/compiler/DependencyLock.ff +17 -17
- package/compiler/Deriver.ff +23 -31
- package/compiler/Dictionaries.ff +1 -1
- package/compiler/Inference.ff +43 -20
- package/compiler/JsEmitter.ff +1437 -1282
- package/compiler/LspHook.ff +202 -202
- package/compiler/Main.ff +25 -24
- package/compiler/ModuleCache.ff +178 -178
- package/compiler/Parser.ff +36 -109
- package/compiler/Resolver.ff +5 -8
- package/compiler/Substitution.ff +1 -1
- package/compiler/Syntax.ff +1 -16
- package/compiler/Token.ff +9 -0
- package/compiler/Tokenizer.ff +4 -0
- package/compiler/Workspace.ff +88 -88
- package/core/.firefly/include/package.json +5 -5
- package/core/.firefly/package.ff +2 -2
- package/core/Any.ff +26 -30
- package/core/Array.ff +298 -265
- package/core/Atomic.ff +63 -64
- package/core/Box.ff +7 -7
- package/core/BrowserSystem.ff +40 -40
- package/core/Buffer.ff +185 -152
- package/core/BuildSystem.ff +156 -148
- package/core/Channel.ff +95 -92
- package/core/Char.ff +3 -2
- package/core/Core.ff +16 -23
- package/core/Crypto.ff +94 -96
- package/core/Equal.ff +41 -36
- package/core/Error.ff +15 -10
- package/core/FileHandle.ff +45 -37
- package/core/Float.ff +176 -200
- package/core/HttpClient.ff +142 -148
- package/core/Instant.ff +6 -8
- package/core/Int.ff +40 -24
- package/core/IntMap.ff +61 -39
- package/core/Js.ff +305 -0
- package/core/JsSystem.ff +135 -114
- package/core/JsValue.ff +303 -159
- package/core/Json.ff +423 -443
- package/core/List.ff +482 -486
- package/core/Lock.ff +108 -144
- package/core/Log.ff +25 -14
- package/core/NodeSystem.ff +198 -191
- package/core/Ordering.ff +160 -161
- package/core/Path.ff +377 -409
- package/core/Queue.ff +90 -0
- package/core/Random.ff +140 -134
- package/core/RbMap.ff +216 -216
- package/core/Serializable.ff +16 -13
- package/core/Show.ff +44 -43
- package/core/SourceLocation.ff +68 -68
- package/core/Stream.ff +1 -1
- package/core/String.ff +224 -202
- package/core/StringMap.ff +58 -36
- package/core/Task.ff +165 -149
- package/experimental/benchmarks/ListGrab.ff +23 -23
- package/experimental/benchmarks/ListGrab.java +55 -55
- package/experimental/benchmarks/Pyrotek45.ff +30 -30
- package/experimental/benchmarks/Pyrotek45.java +64 -64
- package/experimental/bidirectional/Bidi.ff +88 -88
- package/experimental/lines/Main.ff +40 -0
- package/experimental/random/Index.ff +53 -53
- package/experimental/random/Process.ff +120 -120
- package/experimental/random/RunLength.ff +65 -65
- package/experimental/random/Scrape.ff +51 -51
- package/experimental/random/Symbols.ff +73 -73
- package/experimental/random/Tensor.ff +52 -52
- package/experimental/random/Units.ff +36 -36
- package/experimental/s3/S3TestAuthorizationHeader.ff +39 -39
- package/experimental/s3/S3TestPut.ff +16 -16
- package/experimental/tests/TestJson.ff +26 -26
- package/firefly.sh +0 -0
- package/fireflysite/.firefly/package.ff +4 -4
- package/fireflysite/CommunityOverview.ff +20 -20
- package/fireflysite/CountingButtonDemo.ff +58 -58
- package/fireflysite/DocumentParser.ff +325 -331
- package/fireflysite/ExamplesOverview.ff +40 -40
- package/fireflysite/FrontPage.ff +344 -344
- package/fireflysite/GettingStarted.ff +45 -45
- package/fireflysite/Guide.ff +456 -456
- package/fireflysite/Main.ff +163 -152
- package/fireflysite/MatchingPasswordsDemo.ff +82 -82
- package/fireflysite/PackagesOverview.ff +49 -49
- package/fireflysite/PostgresqlDemo.ff +34 -34
- package/fireflysite/ReferenceAll.ff +18 -18
- package/fireflysite/ReferenceIntroduction.ff +11 -11
- package/fireflysite/Styles.ff +567 -567
- package/fireflysite/Test.ff +121 -62
- package/fireflysite/assets/markdown/reference/BaseTypes.md +209 -209
- package/fireflysite/assets/markdown/reference/EmittedJavascript.md +65 -65
- package/fireflysite/assets/markdown/reference/Exceptions.md +101 -101
- package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +364 -364
- package/fireflysite/assets/markdown/reference/JavascriptInterop.md +235 -172
- package/fireflysite/assets/markdown/reference/ModulesAndPackages.md +162 -162
- package/fireflysite/assets/markdown/reference/OldStructuredConcurrency.md +48 -48
- package/fireflysite/assets/markdown/reference/PatternMatching.md +224 -224
- package/fireflysite/assets/markdown/reference/StatementsAndExpressions.md +86 -86
- package/fireflysite/assets/markdown/reference/StructuredConcurrency.md +99 -99
- package/fireflysite/assets/markdown/reference/TraitsAndInstances.md +100 -100
- package/fireflysite/assets/markdown/reference/UserDefinedTypes.md +184 -184
- package/fireflysite/assets/markdown/scratch/ControlFlow.md +136 -136
- package/fireflysite/assets/markdown/scratch/Toc.md +40 -40
- package/lsp/.firefly/package.ff +1 -1
- package/lsp/CompletionHandler.ff +827 -827
- package/lsp/Handler.ff +714 -714
- package/lsp/HoverHandler.ff +79 -79
- package/lsp/LanguageServer.ff +272 -272
- package/lsp/SignatureHelpHandler.ff +55 -55
- package/lsp/SymbolHandler.ff +181 -181
- package/lsp/TestReferences.ff +17 -17
- package/lsp/TestReferencesCase.ff +7 -7
- package/lsp/stderr.txt +1 -1
- package/lsp/stdout.txt +34 -34
- package/lux/.firefly/package.ff +1 -1
- package/lux/Css.ff +648 -648
- package/lux/CssTest.ff +48 -48
- package/lux/Lux.ff +608 -617
- package/lux/LuxEvent.ff +79 -116
- package/lux/Main.ff +123 -123
- package/lux/Main2.ff +143 -143
- package/lux/TestDry.ff +28 -28
- package/output/js/ff/compiler/Builder.mjs +72 -71
- package/output/js/ff/compiler/Compiler.mjs +19 -13
- package/output/js/ff/compiler/Dependencies.mjs +8 -7
- package/output/js/ff/compiler/DependencyLock.mjs +6 -4
- package/output/js/ff/compiler/Deriver.mjs +26 -24
- package/output/js/ff/compiler/Dictionaries.mjs +14 -18
- package/output/js/ff/compiler/Environment.mjs +6 -4
- package/output/js/ff/compiler/Inference.mjs +238 -164
- package/output/js/ff/compiler/JsEmitter.mjs +1160 -350
- package/output/js/ff/compiler/JsImporter.mjs +20 -18
- package/output/js/ff/compiler/LspHook.mjs +12 -10
- package/output/js/ff/compiler/Main.mjs +61 -41
- package/output/js/ff/compiler/ModuleCache.mjs +10 -8
- package/output/js/ff/compiler/Parser.mjs +153 -669
- package/output/js/ff/compiler/Patterns.mjs +12 -10
- package/output/js/ff/compiler/Resolver.mjs +52 -78
- package/output/js/ff/compiler/Substitution.mjs +12 -16
- package/output/js/ff/compiler/Syntax.mjs +50 -341
- package/output/js/ff/compiler/Token.mjs +126 -4
- package/output/js/ff/compiler/Tokenizer.mjs +62 -52
- package/output/js/ff/compiler/Unification.mjs +74 -90
- package/output/js/ff/compiler/Wildcards.mjs +4 -2
- package/output/js/ff/compiler/Workspace.mjs +26 -20
- package/output/js/ff/core/Any.mjs +20 -20
- package/output/js/ff/core/Array.mjs +268 -175
- package/output/js/ff/core/AssetSystem.mjs +8 -6
- package/output/js/ff/core/Atomic.mjs +84 -52
- package/output/js/ff/core/Bool.mjs +6 -4
- package/output/js/ff/core/BrowserSystem.mjs +38 -29
- package/output/js/ff/core/Buffer.mjs +285 -133
- package/output/js/ff/core/BuildSystem.mjs +36 -56
- package/output/js/ff/core/Channel.mjs +250 -97
- package/output/js/ff/core/Char.mjs +5 -3
- package/output/js/ff/core/Core.mjs +28 -34
- package/output/js/ff/core/Crypto.mjs +30 -52
- package/output/js/ff/core/Duration.mjs +4 -2
- package/output/js/ff/core/Equal.mjs +14 -12
- package/output/js/ff/core/Error.mjs +17 -11
- package/output/js/ff/core/FileHandle.mjs +76 -38
- package/output/js/ff/core/Float.mjs +92 -160
- package/output/js/ff/core/HttpClient.mjs +208 -76
- package/output/js/ff/core/Instant.mjs +8 -10
- package/output/js/ff/core/Int.mjs +36 -26
- package/output/js/ff/core/IntMap.mjs +79 -33
- package/output/js/ff/core/Js.mjs +751 -0
- package/output/js/ff/core/JsSystem.mjs +54 -60
- package/output/js/ff/core/JsValue.mjs +294 -143
- package/output/js/ff/core/Json.mjs +443 -253
- package/output/js/ff/core/List.mjs +262 -214
- package/output/js/ff/core/Lock.mjs +156 -125
- package/output/js/ff/core/Log.mjs +20 -10
- package/output/js/ff/core/Map.mjs +10 -8
- package/output/js/ff/core/NodeSystem.mjs +189 -123
- package/output/js/ff/core/Nothing.mjs +4 -2
- package/output/js/ff/core/Option.mjs +40 -38
- package/output/js/ff/core/Ordering.mjs +26 -20
- package/output/js/ff/core/Pair.mjs +4 -2
- package/output/js/ff/core/Path.mjs +517 -315
- package/output/js/ff/core/Queue.mjs +306 -0
- package/output/js/ff/core/Random.mjs +141 -77
- package/output/js/ff/core/RbMap.mjs +36 -34
- package/output/js/ff/core/Serializable.mjs +44 -28
- package/output/js/ff/core/Set.mjs +6 -4
- package/output/js/ff/core/Show.mjs +8 -6
- package/output/js/ff/core/SourceLocation.mjs +4 -2
- package/output/js/ff/core/Stream.mjs +30 -50
- package/output/js/ff/core/String.mjs +263 -172
- package/output/js/ff/core/StringMap.mjs +77 -31
- package/output/js/ff/core/Task.mjs +91 -76
- package/output/js/ff/core/Try.mjs +20 -18
- package/output/js/ff/core/Unit.mjs +4 -2
- package/package.json +1 -1
- package/postgresql/Pg.ff +53 -59
- package/rpc/.firefly/package.ff +1 -1
- package/rpc/Rpc.ff +70 -70
- package/s3/.firefly/package.ff +1 -1
- package/s3/S3.ff +92 -94
- package/vscode/LICENSE.txt +21 -21
- package/vscode/Prepublish.ff +15 -15
- package/vscode/README.md +16 -16
- package/vscode/client/package-lock.json +544 -544
- package/vscode/client/package.json +22 -22
- package/vscode/client/src/extension.ts +104 -104
- package/vscode/icons/firefly-icon.svg +10 -10
- package/vscode/language-configuration.json +61 -61
- package/vscode/package-lock.json +3623 -3623
- package/vscode/package.json +1 -1
- package/vscode/snippets.json +241 -241
- package/vscode/syntaxes/firefly-markdown-injection.json +45 -45
- package/webserver/.firefly/include/package.json +5 -5
- package/webserver/.firefly/package.ff +2 -2
- package/webserver/WebServer.ff +647 -685
- package/websocket/.firefly/package.ff +1 -1
- package/websocket/WebSocket.ff +100 -131
- package/core/UnsafeJs.ff +0 -42
- package/output/js/ff/core/UnsafeJs.mjs +0 -191
|
@@ -50,6 +50,8 @@ import * as ff_core_Int from "../../ff/core/Int.mjs"
|
|
|
50
50
|
|
|
51
51
|
import * as ff_core_IntMap from "../../ff/core/IntMap.mjs"
|
|
52
52
|
|
|
53
|
+
import * as ff_core_Js from "../../ff/core/Js.mjs"
|
|
54
|
+
|
|
53
55
|
import * as ff_core_JsSystem from "../../ff/core/JsSystem.mjs"
|
|
54
56
|
|
|
55
57
|
import * as ff_core_JsValue from "../../ff/core/JsValue.mjs"
|
|
@@ -76,6 +78,8 @@ import * as ff_core_Pair from "../../ff/core/Pair.mjs"
|
|
|
76
78
|
|
|
77
79
|
import * as ff_core_Path from "../../ff/core/Path.mjs"
|
|
78
80
|
|
|
81
|
+
import * as ff_core_Queue from "../../ff/core/Queue.mjs"
|
|
82
|
+
|
|
79
83
|
import * as ff_core_Random from "../../ff/core/Random.mjs"
|
|
80
84
|
|
|
81
85
|
import * as ff_core_Serializable from "../../ff/core/Serializable.mjs"
|
|
@@ -98,8 +102,6 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
|
|
|
98
102
|
|
|
99
103
|
import * as ff_core_Unit from "../../ff/core/Unit.mjs"
|
|
100
104
|
|
|
101
|
-
import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
|
|
102
|
-
|
|
103
105
|
// type JsEmitter
|
|
104
106
|
export function JsEmitter(otherModules_, jsImporter_, emitTarget_, isMainModule_, compilerModuleFileUrl_, packagePair_, moduleName_, emittingAsync_, tailCallUsed_) {
|
|
105
107
|
return {otherModules_, jsImporter_, emitTarget_, isMainModule_, compilerModuleFileUrl_, packagePair_, moduleName_, emittingAsync_, tailCallUsed_};
|
|
@@ -253,7 +255,7 @@ const at_ = type_a.at_;
|
|
|
253
255
|
const index_ = type_a.index_;
|
|
254
256
|
return ff_compiler_JsEmitter.fail_(at_, ("Unexpected type variable: $" + index_))
|
|
255
257
|
}
|
|
256
|
-
|
|
258
|
+
{
|
|
257
259
|
const t_ = type_a;
|
|
258
260
|
return t_.name_
|
|
259
261
|
}
|
|
@@ -266,7 +268,7 @@ if(_1.TConstructor) {
|
|
|
266
268
|
const t_ = _1;
|
|
267
269
|
return t_.name_
|
|
268
270
|
}
|
|
269
|
-
|
|
271
|
+
{
|
|
270
272
|
const t_ = _1;
|
|
271
273
|
return ff_compiler_JsEmitter.fail_(t_.at_, " is still a unification variable")
|
|
272
274
|
}
|
|
@@ -362,7 +364,7 @@ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/NodeSystem
|
|
|
362
364
|
const a_ = _1.arguments_[0];
|
|
363
365
|
return ff_compiler_JsEmitter.noSideEffects_(a_.value_)
|
|
364
366
|
}
|
|
365
|
-
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/
|
|
367
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Js.jsSystem") {
|
|
366
368
|
return true
|
|
367
369
|
}
|
|
368
370
|
if(_1.EString) {
|
|
@@ -506,7 +508,7 @@ const at_ = type_a.at_;
|
|
|
506
508
|
const index_ = type_a.index_;
|
|
507
509
|
return ff_compiler_JsEmitter.fail_(at_, ("Unexpected type variable: $" + index_))
|
|
508
510
|
}
|
|
509
|
-
|
|
511
|
+
{
|
|
510
512
|
const t_ = type_a;
|
|
511
513
|
return t_.name_
|
|
512
514
|
}
|
|
@@ -519,7 +521,7 @@ if(_1.TConstructor) {
|
|
|
519
521
|
const t_ = _1;
|
|
520
522
|
return t_.name_
|
|
521
523
|
}
|
|
522
|
-
|
|
524
|
+
{
|
|
523
525
|
const t_ = _1;
|
|
524
526
|
return ff_compiler_JsEmitter.fail_(t_.at_, " is still a unification variable")
|
|
525
527
|
}
|
|
@@ -615,7 +617,7 @@ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/NodeSystem
|
|
|
615
617
|
const a_ = _1.arguments_[0];
|
|
616
618
|
return ff_compiler_JsEmitter.noSideEffects_(a_.value_)
|
|
617
619
|
}
|
|
618
|
-
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/
|
|
620
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Js.jsSystem") {
|
|
619
621
|
return true
|
|
620
622
|
}
|
|
621
623
|
if(_1.EString) {
|
|
@@ -704,7 +706,7 @@ return (_w1.signature_.name_ === "main")
|
|
|
704
706
|
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_map(mainFunction_, ((_w1) => {
|
|
705
707
|
return _w1.signature_.name_
|
|
706
708
|
})), ((mainName_) => {
|
|
707
|
-
return [ff_core_List.List_join(["export async function $run$(fireflyPath_, arguments_) {", "Error.stackTraceLimit = 50", "const $task = {
|
|
709
|
+
return [ff_core_List.List_join(["export async function $run$(fireflyPath_, arguments_) {", "Error.stackTraceLimit = 50", "const $task = {controller_: new AbortController(), subtasks_: new Set(), promise_: new Promise(() => {}), started_: performance.now() * 0.001}", ...(ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget)
|
|
708
710
|
? ["let interval = setInterval(() => {}, 24 * 60 * 60 * 1000)"]
|
|
709
711
|
: []), "let system = {", "task_: $task,", "array_: arguments_,", "fireflyPath_: fireflyPath_,", (((("mainPackagePair_: {group_: \"" + mainPackagePair_.group_) + "\", name_: \"") + mainPackagePair_.name_) + "\"},"), (("executableMode_: " + (ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitExecutable())
|
|
710
712
|
? "true"
|
|
@@ -784,13 +786,13 @@ const name_ = ff_compiler_JsEmitter.makeDictionaryName_(definition_.traitName_,
|
|
|
784
786
|
const methods_ = ff_core_List.List_map(ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
785
787
|
return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, _w1, false, "")
|
|
786
788
|
})), ((_w1) => {
|
|
787
|
-
return ff_core_String.String_dropFirst(_w1,
|
|
789
|
+
return ff_core_String.String_dropFirst(_w1, "function ".length)
|
|
788
790
|
}));
|
|
789
791
|
const asyncMethods_ = ff_compiler_JsEmitter.JsEmitter_withEmittingAsync(self_, (() => {
|
|
790
792
|
return ff_core_List.List_map(ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
791
793
|
return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, _w1, true, "")
|
|
792
794
|
})), ((_w1) => {
|
|
793
|
-
return ("async " + ff_core_String.String_dropFirst(_w1,
|
|
795
|
+
return ("async " + ff_core_String.String_dropFirst(_w1, "async function ".length))
|
|
794
796
|
}))
|
|
795
797
|
}));
|
|
796
798
|
const body_ = (("{\n" + ff_core_List.List_join([...methods_, ...asyncMethods_], ",\n")) + "\n}");
|
|
@@ -812,25 +814,7 @@ return (((((("export function " + name_) + "(") + ff_core_List.List_join(diction
|
|
|
812
814
|
export function JsEmitter_emitFunctionDefinition(self_, definition_, async_, suffix_ = "") {
|
|
813
815
|
const signature_ = ff_compiler_JsEmitter.JsEmitter_emitSignature(self_, definition_.signature_, async_, suffix_);
|
|
814
816
|
{
|
|
815
|
-
const _1 =
|
|
816
|
-
if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.None) {
|
|
817
|
-
return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in sync context.');\n}")
|
|
818
|
-
}
|
|
819
|
-
if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.None) {
|
|
820
|
-
return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in async context.');\n}")
|
|
821
|
-
}
|
|
822
|
-
if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.Some) {
|
|
823
|
-
const code_ = _1.second_.syncCode_.value_;
|
|
824
|
-
return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
|
|
825
|
-
}
|
|
826
|
-
if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.Some) {
|
|
827
|
-
const code_ = _1.second_.asyncCode_.value_;
|
|
828
|
-
return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
|
|
829
|
-
}
|
|
830
|
-
if(_1.second_.FireflyTarget) {
|
|
831
|
-
const lambda_ = _1.second_.lambda_;
|
|
832
|
-
{
|
|
833
|
-
const _1 = lambda_;
|
|
817
|
+
const _1 = definition_.body_;
|
|
834
818
|
if(_1.cases_.length === 1) {
|
|
835
819
|
const effect_ = _1.effect_;
|
|
836
820
|
const matchCase_ = _1.cases_[0];
|
|
@@ -843,7 +827,7 @@ return false
|
|
|
843
827
|
}
|
|
844
828
|
}))) {
|
|
845
829
|
const body_ = ff_compiler_JsEmitter.JsEmitter_emitTailCall(self_, (() => {
|
|
846
|
-
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, true, async_)
|
|
830
|
+
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, true, false, async_)
|
|
847
831
|
}));
|
|
848
832
|
return (((signature_ + " {\n") + body_) + "\n}")
|
|
849
833
|
}
|
|
@@ -859,17 +843,19 @@ const shadowingWorkaround_ = ff_core_List.List_join(ff_core_List.List_map(defini
|
|
|
859
843
|
return (((("const " + p_.name_) + "_a = ") + ff_compiler_JsEmitter.escapeKeyword_(p_.name_)) + ";")
|
|
860
844
|
})), "\n");
|
|
861
845
|
const body_ = ff_compiler_JsEmitter.JsEmitter_emitTailCall(self_, (() => {
|
|
862
|
-
const casesString_ = ff_core_List.List_join(ff_core_List.List_map(cases_, ((
|
|
863
|
-
|
|
846
|
+
const casesString_ = ff_core_List.List_join(ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
847
|
+
{
|
|
848
|
+
const i_ = _1.first_;
|
|
849
|
+
const c_ = _1.second_;
|
|
850
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
851
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, c_, [], [], true, true, false, lastCase_, async_)
|
|
852
|
+
}
|
|
864
853
|
})), "\n");
|
|
865
854
|
return ((shadowingWorkaround_ + "\n") + casesString_)
|
|
866
855
|
}));
|
|
867
856
|
return (((signature_ + " {\n") + body_) + "\n}")
|
|
868
857
|
}
|
|
869
858
|
}
|
|
870
|
-
return
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
859
|
}
|
|
874
860
|
|
|
875
861
|
export function JsEmitter_emitTailCall(self_, body_) {
|
|
@@ -1082,7 +1068,7 @@ const parameters_ = ff_core_List.List_join([...patternParameters_, ...controller
|
|
|
1082
1068
|
const prefix_ = (newAsync_
|
|
1083
1069
|
? "async "
|
|
1084
1070
|
: "");
|
|
1085
|
-
return (((((("(" + prefix_) + "(") + parameters_) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, newAsync_)) + "\n})")
|
|
1071
|
+
return (((((("(" + prefix_) + "(") + parameters_) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, false, newAsync_)) + "\n})")
|
|
1086
1072
|
}
|
|
1087
1073
|
}
|
|
1088
1074
|
if(_1.ELambda) {
|
|
@@ -1094,14 +1080,19 @@ const controller_ = (newAsync_
|
|
|
1094
1080
|
? ["$task"]
|
|
1095
1081
|
: []);
|
|
1096
1082
|
ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
|
|
1097
|
-
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs((cases_[0] ?? ff_core_List.
|
|
1083
|
+
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs((cases_[0] ?? ff_core_List.List_grab(cases_, 0)).patterns_), ((_w1) => {
|
|
1098
1084
|
return ("_" + (_w1.first_ + 1))
|
|
1099
1085
|
}));
|
|
1100
1086
|
const escapedArguments_ = ff_core_List.List_map(arguments_, ((word_) => {
|
|
1101
1087
|
return ff_compiler_JsEmitter.escapeKeyword_(word_)
|
|
1102
1088
|
}));
|
|
1103
|
-
const caseStrings_ = ff_core_List.List_map(cases_, ((
|
|
1104
|
-
|
|
1089
|
+
const caseStrings_ = ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
1090
|
+
{
|
|
1091
|
+
const i_ = _1.first_;
|
|
1092
|
+
const c_ = _1.second_;
|
|
1093
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
1094
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, c_, [], [], true, true, false, lastCase_, newAsync_)
|
|
1095
|
+
}
|
|
1105
1096
|
}));
|
|
1106
1097
|
const prefix_ = (newAsync_
|
|
1107
1098
|
? "async "
|
|
@@ -1179,7 +1170,7 @@ const typeArguments_ = _1.typeArguments_;
|
|
|
1179
1170
|
const arguments_ = _1.arguments_;
|
|
1180
1171
|
const dictionaries_ = _1.dictionaries_;
|
|
1181
1172
|
if(ff_core_String.String_contains(name_, "bundleForBrowser")) {
|
|
1182
|
-
if((!ff_core_Option.Option_contains((arguments_[0] ?? ff_core_List.
|
|
1173
|
+
if((!ff_core_Option.Option_contains((arguments_[0] ?? ff_core_List.List_grab(arguments_, 0)).name_, "system", ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String))) {
|
|
1183
1174
|
ff_core_Log.debug_(("Wrong arguments for bundleForBrowser: " + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Option.ff_core_Show_Show$ff_core_Option_Option(ff_core_Show.ff_core_Show_Show$ff_core_String_String)).show_(ff_core_List.List_map(arguments_, ((_w1) => {
|
|
1184
1175
|
return _w1.name_
|
|
1185
1176
|
})))));
|
|
@@ -1286,10 +1277,10 @@ ff_compiler_JsEmitter.fail_(at_, "Unbound wildcard")
|
|
|
1286
1277
|
return ("_w" + index_)
|
|
1287
1278
|
}
|
|
1288
1279
|
if(async_) {
|
|
1289
|
-
return (("(await (async function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, async_)) + "\n})())")
|
|
1280
|
+
return (("(await (async function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, false, async_)) + "\n})())")
|
|
1290
1281
|
}
|
|
1291
1282
|
{
|
|
1292
|
-
return (("(function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, async_)) + "\n})()")
|
|
1283
|
+
return (("(function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, false, async_)) + "\n})()")
|
|
1293
1284
|
}
|
|
1294
1285
|
}
|
|
1295
1286
|
}
|
|
@@ -1325,7 +1316,7 @@ return ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, _w1)
|
|
|
1325
1316
|
}
|
|
1326
1317
|
}
|
|
1327
1318
|
|
|
1328
|
-
export function JsEmitter_emitStatements(self_, term_, last_, async_) {
|
|
1319
|
+
export function JsEmitter_emitStatements(self_, term_, last_, break_, async_) {
|
|
1329
1320
|
{
|
|
1330
1321
|
const _1 = term_;
|
|
1331
1322
|
if(_1.EFunctions) {
|
|
@@ -1336,7 +1327,7 @@ const functionStrings_ = ff_core_List.List_map(functions_, ((f_) => {
|
|
|
1336
1327
|
const newAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(f_.signature_.effect_));
|
|
1337
1328
|
return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, f_, newAsync_, "")
|
|
1338
1329
|
}));
|
|
1339
|
-
return ((ff_core_List.List_join(functionStrings_, "\n") + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_))
|
|
1330
|
+
return ((ff_core_List.List_join(functionStrings_, "\n") + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_))
|
|
1340
1331
|
}
|
|
1341
1332
|
if(_1.ELet) {
|
|
1342
1333
|
const at_ = _1.at_;
|
|
@@ -1345,7 +1336,7 @@ const name_ = _1.name_;
|
|
|
1345
1336
|
const valueType_ = _1.valueType_;
|
|
1346
1337
|
const value_ = _1.value_;
|
|
1347
1338
|
const body_ = _1.body_;
|
|
1348
|
-
return ((ff_compiler_JsEmitter.JsEmitter_emitLetDefinition(self_, ff_compiler_Syntax.DLet(at_, name_, valueType_, value_), mutable_, async_) + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_))
|
|
1339
|
+
return ((ff_compiler_JsEmitter.JsEmitter_emitLetDefinition(self_, ff_compiler_Syntax.DLet(at_, name_, valueType_, value_), mutable_, async_) + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_))
|
|
1349
1340
|
}
|
|
1350
1341
|
if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
|
|
1351
1342
|
const at_ = _1.at_;
|
|
@@ -1353,17 +1344,17 @@ return ""
|
|
|
1353
1344
|
}
|
|
1354
1345
|
if(_1.ESequential && _1.before_.EVariant && _1.before_.name_ === "ff:core/Unit.Unit") {
|
|
1355
1346
|
const after_ = _1.after_;
|
|
1356
|
-
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, async_)
|
|
1347
|
+
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, break_, async_)
|
|
1357
1348
|
}
|
|
1358
1349
|
if(_1.ESequential && _1.after_.EVariant && _1.after_.name_ === "ff:core/Unit.Unit") {
|
|
1359
1350
|
const before_ = _1.before_;
|
|
1360
|
-
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_)
|
|
1351
|
+
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, break_, async_)
|
|
1361
1352
|
}
|
|
1362
1353
|
if(_1.ESequential) {
|
|
1363
1354
|
const at_ = _1.at_;
|
|
1364
1355
|
const before_ = _1.before_;
|
|
1365
1356
|
const after_ = _1.after_;
|
|
1366
|
-
return ((ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, async_))
|
|
1357
|
+
return ((ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, false, async_) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, break_, async_))
|
|
1367
1358
|
}
|
|
1368
1359
|
if(_1.EAssign) {
|
|
1369
1360
|
const at_ = _1.at_;
|
|
@@ -1415,11 +1406,16 @@ const at_ = _1.at_;
|
|
|
1415
1406
|
const value_ = _1.value_;
|
|
1416
1407
|
const cases_ = _1.function_.lambda_.cases_;
|
|
1417
1408
|
ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
|
|
1418
|
-
return ((((((((!last_)
|
|
1409
|
+
return (((((((((!last_) && (!break_))
|
|
1419
1410
|
? "do "
|
|
1420
|
-
: "") + "{\nconst _1 = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ";\n") + ff_core_List.List_join(ff_core_List.List_map(cases_, ((
|
|
1421
|
-
|
|
1422
|
-
|
|
1411
|
+
: "") + "{\nconst _1 = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ";\n") + ff_core_List.List_join(ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
1412
|
+
{
|
|
1413
|
+
const i_ = _1.first_;
|
|
1414
|
+
const c_ = _1.second_;
|
|
1415
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
1416
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, ["_1"], c_, [], [], true, last_, break_, lastCase_, async_)
|
|
1417
|
+
}
|
|
1418
|
+
})), "\n")) + "\n}") + (((!last_) && (!break_))
|
|
1423
1419
|
? " while(false)"
|
|
1424
1420
|
: ""))
|
|
1425
1421
|
return
|
|
@@ -1428,7 +1424,9 @@ return
|
|
|
1428
1424
|
{
|
|
1429
1425
|
const _1 = ff_compiler_JsEmitter.detectIfElse_(term_);
|
|
1430
1426
|
if(_1.length === 0) {
|
|
1431
|
-
if(
|
|
1427
|
+
if(break_) {
|
|
1428
|
+
return (("if(!" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, term_, async_)) + ") break")
|
|
1429
|
+
} else if(last_) {
|
|
1432
1430
|
return ("return " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, term_, async_))
|
|
1433
1431
|
} else {
|
|
1434
1432
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, term_, async_)
|
|
@@ -1438,13 +1436,13 @@ return
|
|
|
1438
1436
|
if(_1.length >= 1 && _1[0].first_.EVariant && _1[0].first_.name_ === "ff:core/Bool.True") {
|
|
1439
1437
|
const elseBody_ = _1[0].second_;
|
|
1440
1438
|
const list_ = _1.slice(1);
|
|
1441
|
-
const initial_ = (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, elseBody_, last_, async_)) + "\n}");
|
|
1439
|
+
const initial_ = (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, elseBody_, last_, break_, async_)) + "\n}");
|
|
1442
1440
|
return ff_core_List.List_foldLeft(list_, initial_, ((_1, _2) => {
|
|
1443
1441
|
{
|
|
1444
1442
|
const otherwise_ = _1;
|
|
1445
1443
|
const condition_ = _2.first_;
|
|
1446
1444
|
const body_ = _2.second_;
|
|
1447
|
-
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n} else ") + otherwise_)
|
|
1445
|
+
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_)) + "\n} else ") + otherwise_)
|
|
1448
1446
|
}
|
|
1449
1447
|
}))
|
|
1450
1448
|
return
|
|
@@ -1457,7 +1455,7 @@ return ff_core_List.List_foldLeft(list_, "{}", ((_1, _2) => {
|
|
|
1457
1455
|
const otherwise_ = _1;
|
|
1458
1456
|
const condition_ = _2.first_;
|
|
1459
1457
|
const body_ = _2.second_;
|
|
1460
|
-
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n} else ") + otherwise_)
|
|
1458
|
+
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_)) + "\n} else ") + otherwise_)
|
|
1461
1459
|
}
|
|
1462
1460
|
}))
|
|
1463
1461
|
return
|
|
@@ -1515,18 +1513,20 @@ const e2_ = _guard2[1];
|
|
|
1515
1513
|
if((ff_compiler_JsEmitter.noSideEffects_(e1_) && ff_compiler_JsEmitter.noSideEffects_(e2_))) {
|
|
1516
1514
|
const code1_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_);
|
|
1517
1515
|
const code2_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_);
|
|
1518
|
-
return ff_core_Option.Some(((((((((("(" + code1_) + "[") + code2_) + "] ?? ") + "ff_core_List.
|
|
1516
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + "[") + code2_) + "] ?? ") + "ff_core_List.List_grab(") + code1_) + ", ") + code2_) + "))"))
|
|
1519
1517
|
}
|
|
1520
1518
|
}
|
|
1521
1519
|
}
|
|
1522
1520
|
if(_1 === "ff:core/Array.Array_grab") {
|
|
1523
|
-
const
|
|
1524
|
-
if(
|
|
1525
|
-
const e1_ =
|
|
1526
|
-
const e2_ =
|
|
1521
|
+
const _guard2 = arguments_;
|
|
1522
|
+
if(_guard2.length === 2) {
|
|
1523
|
+
const e1_ = _guard2[0];
|
|
1524
|
+
const e2_ = _guard2[1];
|
|
1525
|
+
if((ff_compiler_JsEmitter.noSideEffects_(e1_) && ff_compiler_JsEmitter.noSideEffects_(e2_))) {
|
|
1527
1526
|
const code1_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_);
|
|
1528
1527
|
const code2_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_);
|
|
1529
|
-
return ff_core_Option.Some(((((((((("(" + code1_) + ".array[") + code2_) + "] ?? ") + "ff_core_Array.
|
|
1528
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + ".array[") + code2_) + "] ?? ") + "ff_core_Array.Array_grab(") + code1_) + ", ") + code2_) + "))"))
|
|
1529
|
+
}
|
|
1530
1530
|
}
|
|
1531
1531
|
}
|
|
1532
1532
|
if(_1 === "ff:core/List.List_size") {
|
|
@@ -1543,6 +1543,13 @@ const e_ = _guard1[0];
|
|
|
1543
1543
|
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_) + ".array.length"))
|
|
1544
1544
|
}
|
|
1545
1545
|
}
|
|
1546
|
+
if(_1 === "ff:core/String.String_size") {
|
|
1547
|
+
const _guard1 = arguments_;
|
|
1548
|
+
if(_guard1.length === 1) {
|
|
1549
|
+
const e_ = _guard1[0];
|
|
1550
|
+
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_) + ".length"))
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1546
1553
|
if(_1 === "ff:core/Equal.equals") {
|
|
1547
1554
|
const _guard3 = arguments_;
|
|
1548
1555
|
if(_guard3.length === 2) {
|
|
@@ -1654,75 +1661,224 @@ return ff_core_Option.Some(((((((((((((((((((await_ + "((() => {\n") + "const si
|
|
|
1654
1661
|
}
|
|
1655
1662
|
}
|
|
1656
1663
|
}
|
|
1657
|
-
if(_1 === "ff:core/
|
|
1664
|
+
if(_1 === "ff:core/Js.import") {
|
|
1665
|
+
const _guard1 = arguments_;
|
|
1666
|
+
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
1667
|
+
const url_ = _guard1[0].value_;
|
|
1668
|
+
{
|
|
1669
|
+
const _1 = self_.emitTarget_;
|
|
1670
|
+
if(_1.EmitBrowser) {
|
|
1671
|
+
return ff_core_Option.Some("(() => {throw new Error('Node.js imports are not supported in the browser')})()")
|
|
1672
|
+
}
|
|
1673
|
+
{
|
|
1674
|
+
return ff_core_Option.Some(ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", "")))
|
|
1675
|
+
}
|
|
1676
|
+
}
|
|
1677
|
+
return
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
if(_1 === "ff:core/Js.browserImport") {
|
|
1658
1681
|
const _guard1 = arguments_;
|
|
1659
1682
|
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
1660
1683
|
const url_ = _guard1[0].value_;
|
|
1684
|
+
{
|
|
1685
|
+
const _1 = self_.emitTarget_;
|
|
1686
|
+
if(_1.EmitBrowser) {
|
|
1661
1687
|
return ff_core_Option.Some(ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", "")))
|
|
1662
1688
|
}
|
|
1689
|
+
{
|
|
1690
|
+
return ff_core_Option.Some("(() => {throw new Error('Browser imports are not supported in Node.js')})()")
|
|
1691
|
+
}
|
|
1692
|
+
}
|
|
1693
|
+
return
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
if(_1 === "ff:core/Js.dynamicImport") {
|
|
1697
|
+
const _guard1 = arguments_;
|
|
1698
|
+
if(_guard1.length === 1) {
|
|
1699
|
+
const url_ = _guard1[0];
|
|
1700
|
+
return ff_core_Option.Some((("import(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, url_, async_)) + ")"))
|
|
1701
|
+
}
|
|
1663
1702
|
}
|
|
1664
|
-
if(_1 === "ff:core/
|
|
1703
|
+
if(_1 === "ff:core/Js.await") {
|
|
1665
1704
|
const _guard1 = arguments_;
|
|
1666
1705
|
if(_guard1.length === 1) {
|
|
1667
1706
|
const body_ = _guard1[0];
|
|
1668
1707
|
if(async_) {
|
|
1669
|
-
return ff_core_Option.Some((("(await " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + "
|
|
1708
|
+
return ff_core_Option.Some((("(await " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + ")"))
|
|
1670
1709
|
} else {
|
|
1671
|
-
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_,
|
|
1710
|
+
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_))
|
|
1711
|
+
}
|
|
1712
|
+
return
|
|
1713
|
+
}
|
|
1714
|
+
}
|
|
1715
|
+
{
|
|
1716
|
+
const name_ = _1;
|
|
1717
|
+
const _guard4 = ff_core_String.String_removeFirst(name_, "ff:core/Js.async");
|
|
1718
|
+
if(_guard4.Some) {
|
|
1719
|
+
const n_ = _guard4.value_;
|
|
1720
|
+
const _guard3 = ff_core_String.String_all(n_, ((_w1) => {
|
|
1721
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
1722
|
+
}));
|
|
1723
|
+
if(_guard3) {
|
|
1724
|
+
const _guard2 = arguments_;
|
|
1725
|
+
if(_guard2.length === 1 && _guard2[0].ELambda && _guard2[0].lambda_.cases_.length === 1 && _guard2[0].lambda_.cases_[0].guards_.length === 0) {
|
|
1726
|
+
const at_ = _guard2[0].at_;
|
|
1727
|
+
const effect_ = _guard2[0].lambda_.effect_;
|
|
1728
|
+
const patterns_ = _guard2[0].lambda_.cases_[0].patterns_;
|
|
1729
|
+
const body_ = _guard2[0].lambda_.cases_[0].body_;
|
|
1730
|
+
if(ff_core_List.List_all(patterns_, ((_1) => {
|
|
1731
|
+
if(_1.PVariable) {
|
|
1732
|
+
return true
|
|
1733
|
+
}
|
|
1734
|
+
{
|
|
1735
|
+
return false
|
|
1672
1736
|
}
|
|
1737
|
+
}))) {
|
|
1738
|
+
const patternParameters_ = ff_core_List.List_map(patterns_, ((_1) => {
|
|
1739
|
+
if(_1.PVariable) {
|
|
1740
|
+
const p_ = _1;
|
|
1741
|
+
return ff_core_Option.Option_else(ff_core_Option.Option_map(p_.name_, ((word_) => {
|
|
1742
|
+
return ff_compiler_JsEmitter.escapeKeyword_(word_)
|
|
1743
|
+
})), (() => {
|
|
1744
|
+
return "_"
|
|
1745
|
+
}))
|
|
1673
1746
|
return
|
|
1674
1747
|
}
|
|
1748
|
+
{
|
|
1749
|
+
return ff_core_Core.panic_("!")
|
|
1750
|
+
}
|
|
1751
|
+
}));
|
|
1752
|
+
return ff_core_Option.Some((((("async (" + ff_core_List.List_join(patternParameters_, ", ")) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, false, false)) + "\n}"))
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
{
|
|
1759
|
+
const name_ = _1;
|
|
1760
|
+
if(ff_core_String.String_startsWith(name_, "ff:core/Js.async", 0)) {
|
|
1761
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(term_.at_, "JS async functions must take a simple parameter list"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
1675
1762
|
}
|
|
1676
|
-
|
|
1763
|
+
}
|
|
1764
|
+
if(_1 === "ff:core/Js.cancelled") {
|
|
1677
1765
|
return ff_core_Option.Some((async_
|
|
1678
|
-
? "$task.
|
|
1766
|
+
? "$task.controller_.signal.aborted"
|
|
1679
1767
|
: "false"))
|
|
1680
1768
|
return
|
|
1681
1769
|
}
|
|
1682
|
-
if(_1 === "ff:core/
|
|
1770
|
+
if(_1 === "ff:core/Js.throwIfCancelled") {
|
|
1683
1771
|
return ff_core_Option.Some((async_
|
|
1684
1772
|
? "((() => ff_core_Task.Task_throwIfAborted($task))())"
|
|
1685
1773
|
: ""))
|
|
1686
1774
|
return
|
|
1687
1775
|
}
|
|
1688
|
-
if(_1 === "ff:core/
|
|
1776
|
+
if(_1 === "ff:core/Js.currentTask") {
|
|
1777
|
+
return ff_core_Option.Some("$task")
|
|
1778
|
+
}
|
|
1779
|
+
if(_1 === "ff:core/Js.controller") {
|
|
1780
|
+
return ff_core_Option.Some("$task.controller_")
|
|
1781
|
+
}
|
|
1782
|
+
if(_1 === "ff:core/Js.setController") {
|
|
1783
|
+
const _guard1 = arguments_;
|
|
1784
|
+
if(_guard1.length === 1) {
|
|
1785
|
+
const a_ = _guard1[0];
|
|
1786
|
+
return ff_core_Option.Some((("($task.controller_ = " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a_, async_)) + ")"))
|
|
1787
|
+
}
|
|
1788
|
+
}
|
|
1789
|
+
if(_1 === "ff:core/Js.inAsync") {
|
|
1689
1790
|
return ff_core_Option.Some((self_.emittingAsync_
|
|
1690
1791
|
? "true"
|
|
1691
1792
|
: "false"))
|
|
1692
1793
|
return
|
|
1693
1794
|
}
|
|
1694
|
-
if(_1 === "ff:core/
|
|
1795
|
+
if(_1 === "ff:core/Js.inBrowser") {
|
|
1695
1796
|
return ff_core_Option.Some((ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser())
|
|
1696
1797
|
? "true"
|
|
1697
1798
|
: "false"))
|
|
1698
1799
|
return
|
|
1699
1800
|
}
|
|
1700
|
-
if(_1 === "ff:core/
|
|
1801
|
+
if(_1 === "ff:core/Js.inNode") {
|
|
1701
1802
|
return ff_core_Option.Some((ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitNode())
|
|
1702
1803
|
? "true"
|
|
1703
1804
|
: "false"))
|
|
1704
1805
|
return
|
|
1705
1806
|
}
|
|
1706
|
-
if(_1 === "ff:core/
|
|
1807
|
+
if(_1 === "ff:core/Js.inBuild") {
|
|
1707
1808
|
return ff_core_Option.Some((ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBuild())
|
|
1708
1809
|
? "true"
|
|
1709
1810
|
: "false"))
|
|
1710
1811
|
return
|
|
1711
1812
|
}
|
|
1712
|
-
if(_1 === "ff:core/
|
|
1813
|
+
if(_1 === "ff:core/Js.value") {
|
|
1713
1814
|
const _guard1 = arguments_;
|
|
1714
1815
|
if(_guard1.length === 1) {
|
|
1715
1816
|
const e_ = _guard1[0];
|
|
1716
1817
|
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_))
|
|
1717
1818
|
}
|
|
1718
1819
|
}
|
|
1719
|
-
if(_1 === "ff:core/
|
|
1820
|
+
if(_1 === "ff:core/Js.fromValue") {
|
|
1720
1821
|
const _guard1 = arguments_;
|
|
1721
1822
|
if(_guard1.length === 1) {
|
|
1722
1823
|
const e_ = _guard1[0];
|
|
1723
1824
|
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_))
|
|
1724
1825
|
}
|
|
1725
1826
|
}
|
|
1827
|
+
if(_1 === "ff:core/Js.rawIdentifier") {
|
|
1828
|
+
const _guard1 = arguments_;
|
|
1829
|
+
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
1830
|
+
const op_ = _guard1[0].value_;
|
|
1831
|
+
return ff_core_Option.Some(ff_core_String.String_replace(op_, "\"", ""))
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
if(_1 === "ff:core/Js.unaryOperator") {
|
|
1835
|
+
const _guard1 = arguments_;
|
|
1836
|
+
if(_guard1.length === 2 && _guard1[0].EString) {
|
|
1837
|
+
const op_ = _guard1[0].value_;
|
|
1838
|
+
const a1_ = _guard1[1];
|
|
1839
|
+
return ff_core_Option.Some(((("(" + ff_core_String.String_replace(op_, "\"", "")) + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_, async_)) + ")"))
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
if(_1 === "ff:core/Js.binaryOperator") {
|
|
1843
|
+
const _guard1 = arguments_;
|
|
1844
|
+
if(_guard1.length === 3 && _guard1[0].EString) {
|
|
1845
|
+
const op_ = _guard1[0].value_;
|
|
1846
|
+
const a1_ = _guard1[1];
|
|
1847
|
+
const a2_ = _guard1[2];
|
|
1848
|
+
return ff_core_Option.Some((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_, async_)) + " ") + ff_core_String.String_replace(op_, "\"", "")) + " ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_, async_)) + ")"))
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
if(_1 === "ff:core/Js.shortCircuitingOperator") {
|
|
1852
|
+
const _guard1 = arguments_;
|
|
1853
|
+
if(_guard1.length === 3 && _guard1[0].EString) {
|
|
1854
|
+
const op_ = _guard1[0].value_;
|
|
1855
|
+
const a1_ = _guard1[1];
|
|
1856
|
+
const a2_ = _guard1[2];
|
|
1857
|
+
return ff_core_Option.Some((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_, async_)) + " ") + ff_core_String.String_replace(op_, "\"", "")) + " ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(a2_), async_)) + ")"))
|
|
1858
|
+
}
|
|
1859
|
+
}
|
|
1860
|
+
if(_1 === "ff:core/JsValue.JsValue_spreadToArray") {
|
|
1861
|
+
const _guard1 = arguments_;
|
|
1862
|
+
if(_guard1.length === 1) {
|
|
1863
|
+
const e1_ = _guard1[0];
|
|
1864
|
+
return ff_core_Option.Some((("[..." + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "]"))
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
if(_1 === "ff:core/JsValue.JsValue_typeof") {
|
|
1868
|
+
const _guard1 = arguments_;
|
|
1869
|
+
if(_guard1.length === 1) {
|
|
1870
|
+
const e_ = _guard1[0];
|
|
1871
|
+
return ff_core_Option.Some((("(typeof " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)) + ")"))
|
|
1872
|
+
}
|
|
1873
|
+
}
|
|
1874
|
+
if(_1 === "ff:core/JsValue.JsValue_instanceof") {
|
|
1875
|
+
const _guard1 = arguments_;
|
|
1876
|
+
if(_guard1.length === 2) {
|
|
1877
|
+
const e1_ = _guard1[0];
|
|
1878
|
+
const e2_ = _guard1[1];
|
|
1879
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " instanceof ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1726
1882
|
if(_1 === "ff:core/JsValue.JsValue_get") {
|
|
1727
1883
|
const _guard1 = arguments_;
|
|
1728
1884
|
if(_guard1.length === 2) {
|
|
@@ -1731,6 +1887,46 @@ const e2_ = _guard1[1];
|
|
|
1731
1887
|
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_) + ff_compiler_JsEmitter.JsEmitter_emitField(self_, e2_, async_, ".")))
|
|
1732
1888
|
}
|
|
1733
1889
|
}
|
|
1890
|
+
if(_1 === "ff:core/JsValue.JsValue_equals") {
|
|
1891
|
+
const _guard1 = arguments_;
|
|
1892
|
+
if(_guard1.length === 2) {
|
|
1893
|
+
const e1_ = _guard1[0];
|
|
1894
|
+
const e2_ = _guard1[1];
|
|
1895
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " === ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
if(_1 === "ff:core/JsValue.JsValue_notEquals") {
|
|
1899
|
+
const _guard1 = arguments_;
|
|
1900
|
+
if(_guard1.length === 2) {
|
|
1901
|
+
const e1_ = _guard1[0];
|
|
1902
|
+
const e2_ = _guard1[1];
|
|
1903
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " !== ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
if(_1 === "ff:core/Int.Int_bitAnd") {
|
|
1907
|
+
const _guard1 = arguments_;
|
|
1908
|
+
if(_guard1.length === 2) {
|
|
1909
|
+
const e1_ = _guard1[0];
|
|
1910
|
+
const e2_ = _guard1[1];
|
|
1911
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " & ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
1912
|
+
}
|
|
1913
|
+
}
|
|
1914
|
+
if(_1 === "ff:core/Int.Int_bitRightUnsigned") {
|
|
1915
|
+
const _guard1 = arguments_;
|
|
1916
|
+
if(_guard1.length === 2) {
|
|
1917
|
+
const e1_ = _guard1[0];
|
|
1918
|
+
const e2_ = _guard1[1];
|
|
1919
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " >>> ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
1920
|
+
}
|
|
1921
|
+
}
|
|
1922
|
+
if(_1 === "ff:core/Int.Int_bitRight") {
|
|
1923
|
+
const _guard1 = arguments_;
|
|
1924
|
+
if(_guard1.length === 2) {
|
|
1925
|
+
const e1_ = _guard1[0];
|
|
1926
|
+
const e2_ = _guard1[1];
|
|
1927
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " >> ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
1928
|
+
}
|
|
1929
|
+
}
|
|
1734
1930
|
{
|
|
1735
1931
|
const name_ = _1;
|
|
1736
1932
|
const _guard3 = ff_core_String.String_removeFirst(name_, "ff:core/JsValue.JsValue_call");
|
|
@@ -1810,11 +2006,13 @@ if((n_ === name_)) {
|
|
|
1810
2006
|
return go_(a1_.value_, [ff_core_Pair.Pair(a2_.value_, a3_.value_), ...fields_])
|
|
1811
2007
|
}
|
|
1812
2008
|
}
|
|
1813
|
-
if(_1.ECall && _1.target_.StaticCall
|
|
2009
|
+
if(_1.ECall && _1.target_.StaticCall) {
|
|
1814
2010
|
const n_ = _1.target_.name_;
|
|
1815
|
-
const
|
|
1816
|
-
const _guard2 = ((((n_ === "ff:core/JsSystem.JsSystem_object") || (n_ === "ff:core/JsSystem.JsSystem_new0")) || (n_ === "ff:core/Json.Json_object")) || (n_ === "ff:core/Json.Json_new0"));
|
|
1817
|
-
if(_guard2 &&
|
|
2011
|
+
const as_ = _1.arguments_;
|
|
2012
|
+
const _guard2 = ((((((n_ === "ff:core/JsSystem.JsSystem_object") || (n_ === "ff:core/JsSystem.JsSystem_new0")) || (n_ === "ff:core/Js.object")) || (n_ === "ff:core/Js.new0")) || (n_ === "ff:core/Json.Json_object")) || (n_ === "ff:core/Json.Json_new0"));
|
|
2013
|
+
if(_guard2 && ff_core_List.List_all(as_, ((_w1) => {
|
|
2014
|
+
return ff_compiler_JsEmitter.noSideEffects_(_w1.value_)
|
|
2015
|
+
}))) {
|
|
1818
2016
|
return (("{" + ff_core_List.List_join(ff_core_List.List_map(fields_, ((p_) => {
|
|
1819
2017
|
return ((ff_compiler_JsEmitter.JsEmitter_emitField(self_, p_.first_, async_, "") + ": ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, p_.second_, async_))
|
|
1820
2018
|
})), ", ")) + "}")
|
|
@@ -1937,6 +2135,89 @@ return ff_core_Option.Some("(void 0)")
|
|
|
1937
2135
|
}
|
|
1938
2136
|
}
|
|
1939
2137
|
}
|
|
2138
|
+
{
|
|
2139
|
+
const name_ = _1;
|
|
2140
|
+
const _guard3 = ff_core_String.String_removeFirst(name_, "ff:core/Js.call");
|
|
2141
|
+
if(_guard3.Some) {
|
|
2142
|
+
const n_ = _guard3.value_;
|
|
2143
|
+
const _guard2 = ff_core_String.String_all(n_, ((_w1) => {
|
|
2144
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2145
|
+
}));
|
|
2146
|
+
if(_guard2) {
|
|
2147
|
+
const _guard1 = arguments_;
|
|
2148
|
+
if(_guard1.length >= 1 && _guard1[0].EString) {
|
|
2149
|
+
const e1_ = _guard1[0];
|
|
2150
|
+
const q_ = _guard1[0].value_;
|
|
2151
|
+
const es_ = _guard1.slice(1);
|
|
2152
|
+
const argumentCode_ = ff_core_List.List_join(ff_core_List.List_map(es_, ((_w1) => {
|
|
2153
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, _w1, async_)
|
|
2154
|
+
})), ", ");
|
|
2155
|
+
return ff_core_Option.Some((((ff_core_Option.Option_else(ff_compiler_JsEmitter.safeBare_(q_), (() => {
|
|
2156
|
+
return (("globalThis[" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "]")
|
|
2157
|
+
})) + "(") + argumentCode_) + ")"))
|
|
2158
|
+
return
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2163
|
+
{
|
|
2164
|
+
const name_ = _1;
|
|
2165
|
+
const _guard4 = ff_core_String.String_removeFirst(name_, "ff:core/Js.function");
|
|
2166
|
+
if(_guard4.Some) {
|
|
2167
|
+
const n_ = _guard4.value_;
|
|
2168
|
+
const _guard3 = ff_core_String.String_all(n_, ((_w1) => {
|
|
2169
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2170
|
+
}));
|
|
2171
|
+
if(_guard3) {
|
|
2172
|
+
const _guard2 = arguments_;
|
|
2173
|
+
if(_guard2.length === 1) {
|
|
2174
|
+
const e1_ = _guard2[0];
|
|
2175
|
+
const _guard1 = term_;
|
|
2176
|
+
if(_guard1.ECall) {
|
|
2177
|
+
const call_ = _guard1;
|
|
2178
|
+
if((self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(call_.effect_))) {
|
|
2179
|
+
const argumentCode_ = ff_core_List.List_join(ff_core_List.List_map(ff_core_Int.Int_to(1, ff_core_String.String_grabInt(n_)), ((_w1) => {
|
|
2180
|
+
return ("a_" + _w1)
|
|
2181
|
+
})), ", ");
|
|
2182
|
+
const taskCode_ = ((argumentCode_ === "")
|
|
2183
|
+
? "$task"
|
|
2184
|
+
: ", $task");
|
|
2185
|
+
return ff_core_Option.Some(((((((("(async (" + argumentCode_) + ") => await ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "(") + argumentCode_) + taskCode_) + "))"))
|
|
2186
|
+
} else {
|
|
2187
|
+
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_))
|
|
2188
|
+
}
|
|
2189
|
+
return
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
if(_1 === "ff:core/Js.get") {
|
|
2196
|
+
const _guard1 = arguments_;
|
|
2197
|
+
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
2198
|
+
const e1_ = _guard1[0];
|
|
2199
|
+
const q_ = _guard1[0].value_;
|
|
2200
|
+
return ff_core_Option.Some(ff_core_Option.Option_else(ff_compiler_JsEmitter.safeBare_(q_), (() => {
|
|
2201
|
+
return (("globalThis[" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "]")
|
|
2202
|
+
})))
|
|
2203
|
+
return
|
|
2204
|
+
}
|
|
2205
|
+
}
|
|
2206
|
+
if(_1 === "ff:core/Js.object") {
|
|
2207
|
+
return ff_core_Option.Some("{}")
|
|
2208
|
+
}
|
|
2209
|
+
if(_1 === "ff:core/Js.new0") {
|
|
2210
|
+
return ff_core_Option.Some("{}")
|
|
2211
|
+
}
|
|
2212
|
+
if(_1 === "ff:core/Js.null") {
|
|
2213
|
+
return ff_core_Option.Some("null")
|
|
2214
|
+
}
|
|
2215
|
+
if(_1 === "ff:core/Js.undefined") {
|
|
2216
|
+
return ff_core_Option.Some("(void 0)")
|
|
2217
|
+
}
|
|
2218
|
+
if(_1 === "ff:core/Js.globalThis") {
|
|
2219
|
+
return ff_core_Option.Some("globalThis")
|
|
2220
|
+
}
|
|
1940
2221
|
if(_1 === "ff:core/BrowserSystem.BrowserSystem_js") {
|
|
1941
2222
|
const _guard2 = arguments_;
|
|
1942
2223
|
if(_guard2.length === 1) {
|
|
@@ -1964,7 +2245,7 @@ return ff_core_Option.Some("globalThis")
|
|
|
1964
2245
|
}
|
|
1965
2246
|
}
|
|
1966
2247
|
}
|
|
1967
|
-
if(_1 === "ff:core/
|
|
2248
|
+
if(_1 === "ff:core/Js.jsSystem") {
|
|
1968
2249
|
return ff_core_Option.Some("globalThis")
|
|
1969
2250
|
}
|
|
1970
2251
|
if(_1 === "ff:core/Json.string") {
|
|
@@ -2030,19 +2311,7 @@ const _guard1 = arguments_;
|
|
|
2030
2311
|
if(_guard1.length === 2) {
|
|
2031
2312
|
const condition_ = _guard1[0];
|
|
2032
2313
|
const body_ = _guard1[1];
|
|
2033
|
-
return ff_core_Option.Some((((("while(" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, ff_compiler_JsEmitter.invokeImmediately_(condition_), async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, async_)) + "\n}"))
|
|
2034
|
-
}
|
|
2035
|
-
}
|
|
2036
|
-
if(_1 === "ff:core/Core.doWhile") {
|
|
2037
|
-
const _guard2 = arguments_;
|
|
2038
|
-
if(_guard2.length === 1) {
|
|
2039
|
-
const doWhileBody_ = _guard2[0];
|
|
2040
|
-
const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
|
|
2041
|
-
if(_guard1.ESequential) {
|
|
2042
|
-
const body_ = _guard1.before_;
|
|
2043
|
-
const condition_ = _guard1.after_;
|
|
2044
|
-
return ff_core_Option.Some(((((("while(true) {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, false, async_)) + "\nif(!") + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") break") + "\n}"))
|
|
2045
|
-
}
|
|
2314
|
+
return ff_core_Option.Some((((("while(" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, ff_compiler_JsEmitter.invokeImmediately_(condition_), async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, false, async_)) + "\n}"))
|
|
2046
2315
|
}
|
|
2047
2316
|
}
|
|
2048
2317
|
if(_1 === "ff:core/Core.doWhile") {
|
|
@@ -2052,7 +2321,7 @@ const doWhileBody_ = _guard2[0];
|
|
|
2052
2321
|
const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
|
|
2053
2322
|
{
|
|
2054
2323
|
const body_ = _guard1;
|
|
2055
|
-
return ff_core_Option.Some((("while(" + ff_compiler_JsEmitter.
|
|
2324
|
+
return ff_core_Option.Some((("while(true) {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, false, true, async_)) + "\n}"))
|
|
2056
2325
|
}
|
|
2057
2326
|
}
|
|
2058
2327
|
}
|
|
@@ -2062,15 +2331,18 @@ if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.lengt
|
|
|
2062
2331
|
const list_ = _guard1[0];
|
|
2063
2332
|
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
2064
2333
|
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
2065
|
-
return ff_core_Option.Some(((((("
|
|
2066
|
-
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " =
|
|
2334
|
+
return ff_core_Option.Some(((((("{\nconst if_o = " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_)) + "\nif(if_o.Some) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
2335
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = if_o.value_;\n")
|
|
2067
2336
|
})), (() => {
|
|
2068
2337
|
return ""
|
|
2069
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\
|
|
2338
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, false, async_)) + "\n}\n}"))
|
|
2070
2339
|
return
|
|
2071
2340
|
}
|
|
2072
2341
|
}
|
|
2073
|
-
|
|
2342
|
+
{
|
|
2343
|
+
const n_ = _1;
|
|
2344
|
+
const _guard3 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
2345
|
+
if(_guard3) {
|
|
2074
2346
|
const _guard2 = arguments_;
|
|
2075
2347
|
if(_guard2.length === 2 && _guard2[0].ECall && _guard2[0].target_.StaticCall && _guard2[0].arguments_.length === 2 && _guard2[1].ELambda && _guard2[1].lambda_.cases_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_[0].PVariable && _guard2[1].lambda_.cases_[0].guards_.length === 0) {
|
|
2076
2348
|
const r_ = _guard2[0].target_.name_;
|
|
@@ -2088,63 +2360,122 @@ return ff_core_Option.Some((((((((((("for(let " + "for_i = ") + startCode_) + ",
|
|
|
2088
2360
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
2089
2361
|
})), (() => {
|
|
2090
2362
|
return ""
|
|
2091
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n}"))
|
|
2363
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
2092
2364
|
return
|
|
2093
2365
|
}
|
|
2094
2366
|
}
|
|
2095
2367
|
}
|
|
2096
|
-
if(_1 === "ff:core/List.List_each") {
|
|
2097
|
-
const _guard1 = arguments_;
|
|
2098
|
-
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
2099
|
-
const list_ = _guard1[0];
|
|
2100
|
-
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
2101
|
-
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
2102
|
-
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, list_, async_);
|
|
2103
|
-
const start_ = fusion_.second_.first_;
|
|
2104
|
-
const end_ = fusion_.second_.second_;
|
|
2105
|
-
const listCode_ = fusion_.first_;
|
|
2106
|
-
return ff_core_Option.Some(((((((((("for(let for_i = " + start_) + ", for_a = ") + listCode_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
2107
|
-
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
2108
|
-
})), (() => {
|
|
2109
|
-
return ""
|
|
2110
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n}"))
|
|
2111
|
-
return
|
|
2112
|
-
}
|
|
2113
2368
|
}
|
|
2114
|
-
|
|
2115
|
-
const
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
const
|
|
2119
|
-
|
|
2120
|
-
const
|
|
2121
|
-
const
|
|
2369
|
+
{
|
|
2370
|
+
const n_ = _1;
|
|
2371
|
+
const _guard3 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
2372
|
+
if(_guard3) {
|
|
2373
|
+
const _guard2 = arguments_;
|
|
2374
|
+
if(_guard2.length === 2 && _guard2[0].ECall && _guard2[0].target_.StaticCall && _guard2[0].target_.name_ === "ff:core/List.List_reverse" && _guard2[0].arguments_.length === 1 && _guard2[0].arguments_[0].value_.ECall && _guard2[0].arguments_[0].value_.target_.StaticCall && _guard2[0].arguments_[0].value_.arguments_.length === 2 && _guard2[1].ELambda && _guard2[1].lambda_.cases_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_[0].PVariable && _guard2[1].lambda_.cases_[0].guards_.length === 0) {
|
|
2375
|
+
const r_ = _guard2[0].arguments_[0].value_.target_.name_;
|
|
2376
|
+
const start_ = _guard2[0].arguments_[0].value_.arguments_[0];
|
|
2377
|
+
const end_ = _guard2[0].arguments_[0].value_.arguments_[1];
|
|
2378
|
+
const name_ = _guard2[1].lambda_.cases_[0].patterns_[0].name_;
|
|
2379
|
+
const body_ = _guard2[1].lambda_.cases_[0].body_;
|
|
2380
|
+
if(((r_ === "ff:core/Int.Int_until") || (r_ === "ff:core/Int.Int_to"))) {
|
|
2381
|
+
const startCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, start_.value_, async_);
|
|
2382
|
+
const endCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, end_.value_, async_);
|
|
2383
|
+
const delta_ = ((r_ === "ff:core/Int.Int_until")
|
|
2384
|
+
? " - 1"
|
|
2385
|
+
: "");
|
|
2386
|
+
return ff_core_Option.Some(((((((((("for(let " + "for_e = ") + startCode_) + ", for_i = ") + endCode_) + delta_) + "; for_i >= for_e; for_i--) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
2387
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
2388
|
+
})), (() => {
|
|
2389
|
+
return ""
|
|
2390
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
2391
|
+
return
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
{
|
|
2397
|
+
const n_ = _1;
|
|
2398
|
+
const _guard2 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
2399
|
+
if(_guard2) {
|
|
2400
|
+
const _guard1 = arguments_;
|
|
2401
|
+
if(_guard1.length === 2 && _guard1[0].ECall && _guard1[0].target_.StaticCall && _guard1[0].target_.name_ === "ff:core/List.List_zip" && _guard1[0].arguments_.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariant && _guard1[1].lambda_.cases_[0].patterns_[0].name_ === "ff:core/Pair.Pair" && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_.length === 2 && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
2402
|
+
const list1_ = _guard1[0].arguments_[0];
|
|
2403
|
+
const list2_ = _guard1[0].arguments_[1];
|
|
2404
|
+
const name1_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].name_;
|
|
2405
|
+
const name2_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].name_;
|
|
2406
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
2407
|
+
const fusion1_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a", list1_.value_, async_);
|
|
2408
|
+
const fusion2_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a2", list2_.value_, async_);
|
|
2409
|
+
const start1_ = fusion1_.second_.first_;
|
|
2410
|
+
const end1_ = fusion1_.second_.second_;
|
|
2411
|
+
const listCode1_ = fusion1_.first_;
|
|
2412
|
+
const start2_ = fusion2_.second_.first_;
|
|
2413
|
+
const end2_ = fusion2_.second_.second_;
|
|
2414
|
+
const listCode2_ = fusion2_.first_;
|
|
2415
|
+
return ff_core_Option.Some(((((((((((((((((("for(let for_a = " + listCode1_) + ", for_i = ") + start1_) + ", for_l = ") + end1_) + ", ") + "for_a2 = ") + listCode2_) + ", for_i2 = ") + start2_) + ", for_l2 = ") + end2_) + "; for_i < for_l && for_i2 < for_l2; for_i++, for_i2++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name1_, ((_w1) => {
|
|
2416
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
2417
|
+
})), (() => {
|
|
2418
|
+
return ""
|
|
2419
|
+
}))) + ff_core_Option.Option_else(ff_core_Option.Option_map(name2_, ((_w1) => {
|
|
2420
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a2[for_i2];\n")
|
|
2421
|
+
})), (() => {
|
|
2422
|
+
return ""
|
|
2423
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
2424
|
+
return
|
|
2425
|
+
}
|
|
2426
|
+
}
|
|
2427
|
+
}
|
|
2428
|
+
{
|
|
2429
|
+
const n_ = _1;
|
|
2430
|
+
const _guard2 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
2431
|
+
if(_guard2) {
|
|
2432
|
+
const _guard1 = arguments_;
|
|
2433
|
+
if(_guard1.length === 2 && _guard1[0].ECall && _guard1[0].target_.StaticCall && _guard1[0].target_.name_ === "ff:core/List.List_pairs" && _guard1[0].arguments_.length === 1 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariant && _guard1[1].lambda_.cases_[0].patterns_[0].name_ === "ff:core/Pair.Pair" && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_.length === 2 && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
2434
|
+
const list_ = _guard1[0].arguments_[0];
|
|
2435
|
+
const name1_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].name_;
|
|
2436
|
+
const name2_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].name_;
|
|
2437
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
2438
|
+
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a", list_.value_, async_);
|
|
2122
2439
|
const start_ = fusion_.second_.first_;
|
|
2123
2440
|
const end_ = fusion_.second_.second_;
|
|
2124
2441
|
const listCode_ = fusion_.first_;
|
|
2125
|
-
return ff_core_Option.Some(((((((((((
|
|
2442
|
+
return ff_core_Option.Some((((((((((("for(let for_a = " + listCode_) + ", for_i = ") + start_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name1_, ((_w1) => {
|
|
2443
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
2444
|
+
})), (() => {
|
|
2445
|
+
return ""
|
|
2446
|
+
}))) + ff_core_Option.Option_else(ff_core_Option.Option_map(name2_, ((_w1) => {
|
|
2126
2447
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
2127
2448
|
})), (() => {
|
|
2128
2449
|
return ""
|
|
2129
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_,
|
|
2450
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
2130
2451
|
return
|
|
2131
2452
|
}
|
|
2132
2453
|
}
|
|
2133
|
-
|
|
2454
|
+
}
|
|
2455
|
+
{
|
|
2456
|
+
const n_ = _1;
|
|
2457
|
+
const _guard2 = ((((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile")) || (n_ === "ff:core/Array.Array_each")) || (n_ === "ff:core/Array.Array_eachWhile"));
|
|
2458
|
+
if(_guard2) {
|
|
2134
2459
|
const _guard1 = arguments_;
|
|
2135
2460
|
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
2136
2461
|
const list_ = _guard1[0];
|
|
2137
2462
|
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
2138
|
-
const
|
|
2139
|
-
const
|
|
2140
|
-
|
|
2463
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
2464
|
+
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a", list_, async_);
|
|
2465
|
+
const start_ = fusion_.second_.first_;
|
|
2466
|
+
const end_ = fusion_.second_.second_;
|
|
2467
|
+
const listCode_ = (fusion_.first_ + (ff_core_String.String_startsWith(n_, "ff:core/Array.", 0)
|
|
2468
|
+
? ".array"
|
|
2469
|
+
: ""));
|
|
2470
|
+
return ff_core_Option.Some(((((((((("for(let for_a = " + listCode_) + ", for_i = ") + start_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
2141
2471
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
2142
2472
|
})), (() => {
|
|
2143
2473
|
return ""
|
|
2144
|
-
}))) +
|
|
2474
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
2145
2475
|
return
|
|
2146
2476
|
}
|
|
2147
2477
|
}
|
|
2478
|
+
}
|
|
2148
2479
|
if(_1 === "ff:core/Array.Array_push") {
|
|
2149
2480
|
const _guard1 = arguments_;
|
|
2150
2481
|
if(_guard1.length === 2) {
|
|
@@ -2160,7 +2491,7 @@ const condition_ = _guard1[0];
|
|
|
2160
2491
|
const body_ = _guard1[1];
|
|
2161
2492
|
return ff_core_Option.Some(((("if(" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") {\n") + (last_
|
|
2162
2493
|
? (("return ff_core_Option.Some(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), async_)) + ")\n} else return ff_core_Option.None()")
|
|
2163
|
-
: (ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, async_) + "\n}"))))
|
|
2494
|
+
: (ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, false, async_) + "\n}"))))
|
|
2164
2495
|
return
|
|
2165
2496
|
}
|
|
2166
2497
|
}
|
|
@@ -2202,12 +2533,23 @@ const code_ = _guard1.value_;
|
|
|
2202
2533
|
return ff_core_Option.Some(code_)
|
|
2203
2534
|
}
|
|
2204
2535
|
}
|
|
2205
|
-
if(_1 === "ff:core/
|
|
2536
|
+
if(_1 === "ff:core/Js.throwIfCancelled") {
|
|
2206
2537
|
return ff_core_Option.Some((async_
|
|
2207
2538
|
? "ff_core_Task.Task_throwIfAborted($task)"
|
|
2208
2539
|
: ""))
|
|
2209
2540
|
return
|
|
2210
2541
|
}
|
|
2542
|
+
if(_1 === "ff:core/Js.throw") {
|
|
2543
|
+
const _guard2 = term_;
|
|
2544
|
+
if(_guard2.ECall) {
|
|
2545
|
+
const c_ = _guard2;
|
|
2546
|
+
const _guard1 = c_.arguments_;
|
|
2547
|
+
if(_guard1.length === 1) {
|
|
2548
|
+
const argument_ = _guard1[0];
|
|
2549
|
+
return ff_core_Option.Some(("throw " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, argument_.value_, async_)))
|
|
2550
|
+
}
|
|
2551
|
+
}
|
|
2552
|
+
}
|
|
2211
2553
|
if(_1 === "ff:core/JsValue.JsValue_set") {
|
|
2212
2554
|
const _guard1 = arguments_;
|
|
2213
2555
|
if(_guard1.length === 3) {
|
|
@@ -2283,15 +2625,51 @@ return ff_core_Option.Some(((s_ + " -= ") + ff_compiler_JsEmitter.JsEmitter_emit
|
|
|
2283
2625
|
}
|
|
2284
2626
|
}
|
|
2285
2627
|
}
|
|
2628
|
+
if(_1 === "ff:core/Js.set") {
|
|
2629
|
+
const _guard2 = arguments_;
|
|
2630
|
+
if(_guard2.length === 2 && _guard2[0].EString) {
|
|
2631
|
+
const q_ = _guard2[0].value_;
|
|
2632
|
+
const e2_ = _guard2[1];
|
|
2633
|
+
const _guard1 = ff_compiler_JsEmitter.safeBare_(q_);
|
|
2634
|
+
if(_guard1.Some) {
|
|
2635
|
+
const s_ = _guard1.value_;
|
|
2636
|
+
return ff_core_Option.Some(((s_ + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)))
|
|
2637
|
+
}
|
|
2638
|
+
}
|
|
2639
|
+
}
|
|
2640
|
+
if(_1 === "ff:core/Js.increment") {
|
|
2641
|
+
const _guard2 = arguments_;
|
|
2642
|
+
if(_guard2.length === 2 && _guard2[0].EString) {
|
|
2643
|
+
const q_ = _guard2[0].value_;
|
|
2644
|
+
const e2_ = _guard2[1];
|
|
2645
|
+
const _guard1 = ff_compiler_JsEmitter.safeBare_(q_);
|
|
2646
|
+
if(_guard1.Some) {
|
|
2647
|
+
const s_ = _guard1.value_;
|
|
2648
|
+
return ff_core_Option.Some(((s_ + " += ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)))
|
|
2649
|
+
}
|
|
2650
|
+
}
|
|
2651
|
+
}
|
|
2652
|
+
if(_1 === "ff:core/Js.decrement") {
|
|
2653
|
+
const _guard2 = arguments_;
|
|
2654
|
+
if(_guard2.length === 2 && _guard2[0].EString) {
|
|
2655
|
+
const q_ = _guard2[0].value_;
|
|
2656
|
+
const e2_ = _guard2[1];
|
|
2657
|
+
const _guard1 = ff_compiler_JsEmitter.safeBare_(q_);
|
|
2658
|
+
if(_guard1.Some) {
|
|
2659
|
+
const s_ = _guard1.value_;
|
|
2660
|
+
return ff_core_Option.Some(((s_ + " -= ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)))
|
|
2661
|
+
}
|
|
2662
|
+
}
|
|
2663
|
+
}
|
|
2286
2664
|
{
|
|
2287
2665
|
return ff_core_Option.None()
|
|
2288
2666
|
}
|
|
2289
2667
|
}
|
|
2290
2668
|
}
|
|
2291
2669
|
|
|
2292
|
-
export function JsEmitter_emitLightFusion(self_, list_, async_) {
|
|
2670
|
+
export function JsEmitter_emitLightFusion(self_, listName_, list_, async_) {
|
|
2293
2671
|
let start_ = "0";
|
|
2294
|
-
let end_ = "
|
|
2672
|
+
let end_ = (listName_ + ".length");
|
|
2295
2673
|
const listCode_ = (((_1) => {
|
|
2296
2674
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
2297
2675
|
const a1_ = _1.arguments_[0];
|
|
@@ -2326,7 +2704,7 @@ return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
|
2326
2704
|
})))) {
|
|
2327
2705
|
end_ = (("Math.max(" + end_) + ", 0)")
|
|
2328
2706
|
};
|
|
2329
|
-
end_ = (("Math.min(" + end_) + ",
|
|
2707
|
+
end_ = (((("Math.min(" + end_) + ", ") + listName_) + ".length)");
|
|
2330
2708
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2331
2709
|
}
|
|
2332
2710
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_takeLast" && _1.arguments_.length === 2) {
|
|
@@ -2336,9 +2714,9 @@ const count_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async
|
|
|
2336
2714
|
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
2337
2715
|
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2338
2716
|
})))) {
|
|
2339
|
-
start_ = (("Math.max(
|
|
2717
|
+
start_ = (((("Math.max(" + listName_) + ".length - Math.max(") + count_) + ", 0), 0)")
|
|
2340
2718
|
} else {
|
|
2341
|
-
start_ = (("Math.max(
|
|
2719
|
+
start_ = (((("Math.max(" + listName_) + ".length - ") + count_) + ", 0)")
|
|
2342
2720
|
};
|
|
2343
2721
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2344
2722
|
}
|
|
@@ -2358,12 +2736,17 @@ const arguments_ = ["_exception.value_", "_error"];
|
|
|
2358
2736
|
const _1 = cases_;
|
|
2359
2737
|
if(_1.length === 1) {
|
|
2360
2738
|
const case_ = _1[0];
|
|
2361
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, case_, [], [], false, last_, catchAsync_)
|
|
2739
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, case_, [], [], false, last_, false, true, catchAsync_)
|
|
2362
2740
|
}
|
|
2363
2741
|
{
|
|
2364
2742
|
const cs_ = _1;
|
|
2365
|
-
const caseStrings_ = ff_core_List.List_map(cases_, ((
|
|
2366
|
-
|
|
2743
|
+
const caseStrings_ = ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
2744
|
+
{
|
|
2745
|
+
const i_ = _1.first_;
|
|
2746
|
+
const c_ = _1.second_;
|
|
2747
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
2748
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, c_, [], [], true, last_, false, lastCase_, catchAsync_)
|
|
2749
|
+
}
|
|
2367
2750
|
}));
|
|
2368
2751
|
if(last_) {
|
|
2369
2752
|
return ff_core_List.List_join(caseStrings_, "\n")
|
|
@@ -2383,7 +2766,21 @@ const finallyEffect_ = _1.arguments_[1].value_.lambda_.effect_;
|
|
|
2383
2766
|
const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
|
|
2384
2767
|
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
2385
2768
|
const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
|
|
2386
|
-
return ff_core_Option.Some((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, tryAsync_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, finallyAsync_)) + "\n}"))
|
|
2769
|
+
return ff_core_Option.Some((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, false, finallyAsync_)) + "\n}"))
|
|
2770
|
+
}
|
|
2771
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catchAny" && _1.arguments_.length === 2 && _1.arguments_[0].value_.ECall && _1.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.target_.name_ === "ff:core/Core.try" && _1.arguments_[0].value_.arguments_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.ELambda && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0 && _1.arguments_[1].value_.ELambda && _1.arguments_[1].value_.lambda_.cases_.length === 1 && _1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 1 && _1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].PVariable && _1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
|
|
2772
|
+
const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
|
|
2773
|
+
const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
|
|
2774
|
+
const catchEffect_ = _1.arguments_[1].value_.lambda_.effect_;
|
|
2775
|
+
const name_ = _1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].name_;
|
|
2776
|
+
const catchBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
|
|
2777
|
+
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
2778
|
+
return ff_core_Option.Some((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} catch") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
2779
|
+
return (("(" + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + ")")
|
|
2780
|
+
})), (() => {
|
|
2781
|
+
return ""
|
|
2782
|
+
}))) + " {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, catchBody_, last_, false, tryAsync_)) + "\n}"))
|
|
2783
|
+
return
|
|
2387
2784
|
}
|
|
2388
2785
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catch" && _1.arguments_.length === 2 && _1.arguments_[0].value_.ECall && _1.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.target_.name_ === "ff:core/Core.try" && _1.arguments_[0].value_.arguments_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.ELambda && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0 && _1.arguments_[1].value_.ELambda && _1.dictionaries_.length === 1) {
|
|
2389
2786
|
const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
|
|
@@ -2393,7 +2790,7 @@ const cases_ = _1.arguments_[1].value_.lambda_.cases_;
|
|
|
2393
2790
|
const dictionary_ = _1.dictionaries_[0];
|
|
2394
2791
|
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
2395
2792
|
const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
|
|
2396
|
-
return ff_core_Option.Some(((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n}"))
|
|
2793
|
+
return ff_core_Option.Some(((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n}"))
|
|
2397
2794
|
}
|
|
2398
2795
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_finally" && _1.arguments_.length === 2 && _1.arguments_[0].value_.ECall && _1.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.target_.name_ === "ff:core/Try.Try_catch" && _1.arguments_[0].value_.arguments_.length === 2 && _1.arguments_[0].value_.arguments_[0].value_.ECall && _1.arguments_[0].value_.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.arguments_[0].value_.target_.name_ === "ff:core/Core.try" && _1.arguments_[0].value_.arguments_[0].value_.arguments_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.ELambda && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0 && _1.arguments_[0].value_.arguments_[1].value_.ELambda && _1.arguments_[0].value_.dictionaries_.length === 1 && _1.arguments_[1].value_.ELambda && _1.arguments_[1].value_.lambda_.cases_.length === 1 && _1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
|
|
2399
2796
|
const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
|
|
@@ -2406,7 +2803,7 @@ const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
|
|
|
2406
2803
|
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
2407
2804
|
const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
|
|
2408
2805
|
const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
|
|
2409
|
-
return ff_core_Option.Some(((((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, finallyAsync_)) + "\n}"))
|
|
2806
|
+
return ff_core_Option.Some(((((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, false, finallyAsync_)) + "\n}"))
|
|
2410
2807
|
}
|
|
2411
2808
|
{
|
|
2412
2809
|
return ff_core_Option.None()
|
|
@@ -2414,7 +2811,7 @@ return ff_core_Option.None()
|
|
|
2414
2811
|
}
|
|
2415
2812
|
}
|
|
2416
2813
|
|
|
2417
|
-
export function JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_) {
|
|
2814
|
+
export function JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, break_, lastCase_, async_) {
|
|
2418
2815
|
function emitWrapper_(code_) {
|
|
2419
2816
|
return ((((ff_core_List.List_isEmpty(conditions_)
|
|
2420
2817
|
? "{\n"
|
|
@@ -2425,9 +2822,9 @@ const _1 = ff_core_Pair.Pair(matchCase_.patterns_, matchCase_.guards_);
|
|
|
2425
2822
|
if(_1.first_.length >= 1) {
|
|
2426
2823
|
const p_ = _1.first_[0];
|
|
2427
2824
|
const ps_ = _1.first_.slice(1);
|
|
2428
|
-
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, (arguments_[0] ?? ff_core_List.
|
|
2825
|
+
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, (arguments_[0] ?? ff_core_List.List_grab(arguments_, 0)), p_, ff_core_List.List_dropFirst(arguments_, 1), (((_c) => {
|
|
2429
2826
|
return ff_compiler_Syntax.MatchCase(_c.at_, ps_, _c.guards_, _c.body_)
|
|
2430
|
-
}))(matchCase_), conditions_, variables_, jump_, last_, async_)
|
|
2827
|
+
}))(matchCase_), conditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2431
2828
|
return
|
|
2432
2829
|
}
|
|
2433
2830
|
if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
|
|
@@ -2436,7 +2833,7 @@ if(ff_core_List.List_isEmpty(variables_)) {
|
|
|
2436
2833
|
const newCase_ = (((_c) => {
|
|
2437
2834
|
return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
|
|
2438
2835
|
}))(matchCase_);
|
|
2439
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [...conditions_, ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, async_)
|
|
2836
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [...conditions_, ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, break_, lastCase_, async_)
|
|
2440
2837
|
}
|
|
2441
2838
|
}
|
|
2442
2839
|
if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
|
|
@@ -2444,7 +2841,7 @@ const e_ = _1.second_[0].term_;
|
|
|
2444
2841
|
const newCase_ = (((_c) => {
|
|
2445
2842
|
return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
|
|
2446
2843
|
}))(matchCase_);
|
|
2447
|
-
const code_ = ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, async_);
|
|
2844
|
+
const code_ = ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, break_, lastCase_, async_);
|
|
2448
2845
|
return emitWrapper_(code_)
|
|
2449
2846
|
}
|
|
2450
2847
|
if(_1.first_.length === 0 && _1.second_.length >= 1) {
|
|
@@ -2454,45 +2851,54 @@ const guardName_ = ("_guard" + (guards_.length + 1));
|
|
|
2454
2851
|
const newCase_ = (((_c) => {
|
|
2455
2852
|
return ff_compiler_Syntax.MatchCase(_c.at_, [guard_.pattern_], guards_, _c.body_)
|
|
2456
2853
|
}))(matchCase_);
|
|
2457
|
-
const code_ = ((((("const " + guardName_) + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, guard_.term_, async_)) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [guardName_], newCase_, [], [], jump_, last_, async_));
|
|
2854
|
+
const code_ = ((((("const " + guardName_) + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, guard_.term_, async_)) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [guardName_], newCase_, [], [], jump_, last_, break_, lastCase_, async_));
|
|
2458
2855
|
return emitWrapper_(code_)
|
|
2459
2856
|
}
|
|
2460
|
-
|
|
2461
|
-
const statementsCode_ = ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, last_, async_);
|
|
2857
|
+
{
|
|
2858
|
+
const statementsCode_ = ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, last_, break_, async_);
|
|
2462
2859
|
const lastLine_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(statementsCode_), ((_w1) => {
|
|
2463
2860
|
return (_w1 !== 10)
|
|
2464
2861
|
})));
|
|
2465
2862
|
const returns_ = ((((((ff_core_String.String_startsWith(lastLine_, "return ", 0) || ff_core_String.String_startsWith(lastLine_, "break ", 0)) || ff_core_String.String_startsWith(lastLine_, "continue ", 0)) || ff_core_String.String_startsWith(lastLine_, "return;", 0)) || ff_core_String.String_startsWith(lastLine_, "break;", 0)) || ff_core_String.String_startsWith(lastLine_, "continue;", 0)) || ff_core_String.String_startsWith(lastLine_, "throw ", 0));
|
|
2466
2863
|
const code_ = (statementsCode_ + (((jump_ && last_) && (!returns_))
|
|
2467
2864
|
? "\nreturn"
|
|
2468
|
-
: (jump_ && (!returns_))
|
|
2469
|
-
?
|
|
2865
|
+
: ((jump_ && (!returns_)) && (!lastCase_))
|
|
2866
|
+
? (break_
|
|
2867
|
+
? "\ncontinue"
|
|
2868
|
+
: "\nbreak")
|
|
2470
2869
|
: ""));
|
|
2471
2870
|
return emitWrapper_(code_)
|
|
2472
2871
|
}
|
|
2473
2872
|
}
|
|
2474
2873
|
}
|
|
2475
2874
|
|
|
2476
|
-
export function JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_) {
|
|
2875
|
+
export function JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, variables_, jump_, last_, break_, lastCase_, async_) {
|
|
2876
|
+
function addCondition_(condition_) {
|
|
2877
|
+
if(lastCase_) {
|
|
2878
|
+
return conditions_
|
|
2879
|
+
} else {
|
|
2880
|
+
return [...conditions_, condition_]
|
|
2881
|
+
}
|
|
2882
|
+
}
|
|
2477
2883
|
{
|
|
2478
2884
|
const _1 = pattern_;
|
|
2479
2885
|
if(_1.PString) {
|
|
2480
2886
|
const value_ = _1.value_;
|
|
2481
|
-
const newConditions_ =
|
|
2482
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
2887
|
+
const newConditions_ = addCondition_(((argument_ + " === ") + value_));
|
|
2888
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2483
2889
|
}
|
|
2484
2890
|
if(_1.PInt) {
|
|
2485
2891
|
const value_ = _1.value_;
|
|
2486
|
-
const newConditions_ =
|
|
2487
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
2892
|
+
const newConditions_ = addCondition_(((argument_ + " === ") + value_));
|
|
2893
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2488
2894
|
}
|
|
2489
2895
|
if(_1.PChar) {
|
|
2490
2896
|
const value_ = _1.value_;
|
|
2491
|
-
const newConditions_ =
|
|
2492
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
2897
|
+
const newConditions_ = addCondition_(((argument_ + " === ") + ff_compiler_JsEmitter.charLiteralToNumber_(value_)));
|
|
2898
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2493
2899
|
}
|
|
2494
2900
|
if(_1.PVariable && _1.name_.None) {
|
|
2495
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_)
|
|
2901
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2496
2902
|
}
|
|
2497
2903
|
if(_1.PVariable && _1.name_.Some) {
|
|
2498
2904
|
const name_ = _1.name_.value_;
|
|
@@ -2500,13 +2906,13 @@ const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(name_);
|
|
|
2500
2906
|
const newVariables_ = ((escaped_ !== argument_)
|
|
2501
2907
|
? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
|
|
2502
2908
|
: variables_);
|
|
2503
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_)
|
|
2909
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, break_, lastCase_, async_)
|
|
2504
2910
|
}
|
|
2505
2911
|
if(_1.PVariant && _1.name_ === "ff:core/Bool.False" && _1.patterns_.length === 0) {
|
|
2506
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_,
|
|
2912
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, addCondition_(("!" + argument_)), variables_, jump_, last_, break_, lastCase_, async_)
|
|
2507
2913
|
}
|
|
2508
2914
|
if(_1.PVariant && _1.name_ === "ff:core/Bool.True" && _1.patterns_.length === 0) {
|
|
2509
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_,
|
|
2915
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, addCondition_(argument_), variables_, jump_, last_, break_, lastCase_, async_)
|
|
2510
2916
|
}
|
|
2511
2917
|
if(_1.PVariant) {
|
|
2512
2918
|
const emptyOrLink_ = _1.name_;
|
|
@@ -2547,8 +2953,8 @@ return ">="
|
|
|
2547
2953
|
})), (() => {
|
|
2548
2954
|
return "==="
|
|
2549
2955
|
}));
|
|
2550
|
-
const newConditions_ =
|
|
2551
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
2956
|
+
const newConditions_ = addCondition_(((((argument_ + ".length ") + operator_) + " ") + patterns_.length));
|
|
2957
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2552
2958
|
}
|
|
2553
2959
|
}
|
|
2554
2960
|
if(_1.PVariant) {
|
|
@@ -2558,11 +2964,11 @@ const processed_ = ff_compiler_JsEmitter.JsEmitter_processVariantCase(self_, nam
|
|
|
2558
2964
|
const newMatchCase_ = (((_c) => {
|
|
2559
2965
|
return ff_compiler_Syntax.MatchCase(_c.at_, [...patterns_, ...matchCase_.patterns_], _c.guards_, _c.body_)
|
|
2560
2966
|
}))(matchCase_);
|
|
2561
|
-
const newConditions_ = (processed_.loneVariant_
|
|
2967
|
+
const newConditions_ = ((processed_.loneVariant_ || lastCase_)
|
|
2562
2968
|
? conditions_
|
|
2563
2969
|
: [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
|
|
2564
2970
|
const newArguments_ = [...processed_.arguments_, ...arguments_];
|
|
2565
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
2971
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
2566
2972
|
}
|
|
2567
2973
|
if(_1.PVariantAs) {
|
|
2568
2974
|
const at_ = _1.at_;
|
|
@@ -2570,7 +2976,7 @@ const name_ = _1.name_;
|
|
|
2570
2976
|
const variableAt_ = _1.variableAt_;
|
|
2571
2977
|
const variable_ = _1.variable_;
|
|
2572
2978
|
const processed_ = ff_compiler_JsEmitter.JsEmitter_processVariantCase(self_, name_, argument_);
|
|
2573
|
-
const newConditions_ = (processed_.loneVariant_
|
|
2979
|
+
const newConditions_ = ((processed_.loneVariant_ || lastCase_)
|
|
2574
2980
|
? conditions_
|
|
2575
2981
|
: [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
|
|
2576
2982
|
const newVariables_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(ff_core_Option.Option_map(variable_, ((word_) => {
|
|
@@ -2582,16 +2988,16 @@ return [...variables_, (((("const " + _w1) + " = ") + argument_) + ";\n")]
|
|
|
2582
2988
|
})), (() => {
|
|
2583
2989
|
return []
|
|
2584
2990
|
}));
|
|
2585
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, newVariables_, jump_, last_, async_)
|
|
2991
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, newVariables_, jump_, last_, break_, lastCase_, async_)
|
|
2586
2992
|
}
|
|
2587
|
-
|
|
2993
|
+
{
|
|
2588
2994
|
const pattern_ = _1.pattern_;
|
|
2589
2995
|
const variable_ = _1.variable_;
|
|
2590
2996
|
const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(variable_);
|
|
2591
2997
|
const newVariables_ = ((escaped_ !== argument_)
|
|
2592
2998
|
? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
|
|
2593
2999
|
: variables_);
|
|
2594
|
-
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_)
|
|
3000
|
+
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, break_, lastCase_, async_)
|
|
2595
3001
|
}
|
|
2596
3002
|
}
|
|
2597
3003
|
}
|
|
@@ -2602,7 +3008,7 @@ if(!_1.second_) {
|
|
|
2602
3008
|
const item_ = _1.first_;
|
|
2603
3009
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, item_, async_)
|
|
2604
3010
|
}
|
|
2605
|
-
|
|
3011
|
+
{
|
|
2606
3012
|
const item_ = _1.first_;
|
|
2607
3013
|
return ("..." + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, item_, async_))
|
|
2608
3014
|
}
|
|
@@ -2614,7 +3020,7 @@ const variantNameUnqualified_ = ff_core_String.String_reverse(ff_core_String.Str
|
|
|
2614
3020
|
return (_w1 !== 46)
|
|
2615
3021
|
})));
|
|
2616
3022
|
const variantName_ = ff_compiler_JsEmitter.escapeKeyword_(variantNameUnqualified_);
|
|
2617
|
-
const moduleName_ = ff_core_String.String_dropLast(name_, (
|
|
3023
|
+
const moduleName_ = ff_core_String.String_dropLast(name_, (variantNameUnqualified_.length + 1));
|
|
2618
3024
|
const variantModule_ = ff_core_Map.Map_grab(self_.otherModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2619
3025
|
let newtype_ = false;
|
|
2620
3026
|
let loneVariant_ = false;
|
|
@@ -2648,7 +3054,7 @@ const variantNameUnqualified_ = ff_core_String.String_reverse(ff_core_String.Str
|
|
|
2648
3054
|
return (_w1 !== 46)
|
|
2649
3055
|
})));
|
|
2650
3056
|
const variantName_ = ff_compiler_JsEmitter.escapeKeyword_(variantNameUnqualified_);
|
|
2651
|
-
const moduleName_ = ff_core_String.String_dropLast(name_, (
|
|
3057
|
+
const moduleName_ = ff_core_String.String_dropLast(name_, (variantNameUnqualified_.length + 1));
|
|
2652
3058
|
const variantModule_ = ff_core_Map.Map_grab(self_.otherModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2653
3059
|
let newtype_ = false;
|
|
2654
3060
|
const newArguments_ = ff_core_Option.Option_grab(ff_core_List.List_collectFirst(variantModule_.types_, ((definition_) => {
|
|
@@ -2684,7 +3090,7 @@ const before2_ = _1.before_.before_.after_;
|
|
|
2684
3090
|
const before3_ = _1.before_.after_;
|
|
2685
3091
|
const after_ = _1.after_;
|
|
2686
3092
|
if((((ff_compiler_JsEmitter.safeCommable_(before1_) && ff_compiler_JsEmitter.safeCommable_(before2_)) && ff_compiler_JsEmitter.safeCommable_(before3_)) && ff_compiler_JsEmitter.safeCommable_(after_))) {
|
|
2687
|
-
return (((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before3_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
3093
|
+
return (((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before3_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
2688
3094
|
}
|
|
2689
3095
|
}
|
|
2690
3096
|
if(_1.ESequential && _1.before_.ESequential) {
|
|
@@ -2692,14 +3098,14 @@ const before1_ = _1.before_.before_;
|
|
|
2692
3098
|
const before2_ = _1.before_.after_;
|
|
2693
3099
|
const after_ = _1.after_;
|
|
2694
3100
|
if(((ff_compiler_JsEmitter.safeCommable_(before1_) && ff_compiler_JsEmitter.safeCommable_(before2_)) && ff_compiler_JsEmitter.safeCommable_(after_))) {
|
|
2695
|
-
return (((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
3101
|
+
return (((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
2696
3102
|
}
|
|
2697
3103
|
}
|
|
2698
3104
|
if(_1.ESequential) {
|
|
2699
3105
|
const before_ = _1.before_;
|
|
2700
3106
|
const after_ = _1.after_;
|
|
2701
3107
|
if((ff_compiler_JsEmitter.safeCommable_(before_) && ff_compiler_JsEmitter.safeCommable_(after_))) {
|
|
2702
|
-
return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
3108
|
+
return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
2703
3109
|
}
|
|
2704
3110
|
}
|
|
2705
3111
|
{
|
|
@@ -2776,7 +3182,7 @@ return (_w1.signature_.name_ === "main")
|
|
|
2776
3182
|
return ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_map(mainFunction_, ((_w1) => {
|
|
2777
3183
|
return _w1.signature_.name_
|
|
2778
3184
|
})), ((mainName_) => {
|
|
2779
|
-
return [ff_core_List.List_join(["export async function $run$(fireflyPath_, arguments_) {", "Error.stackTraceLimit = 50", "const $task = {
|
|
3185
|
+
return [ff_core_List.List_join(["export async function $run$(fireflyPath_, arguments_) {", "Error.stackTraceLimit = 50", "const $task = {controller_: new AbortController(), subtasks_: new Set(), promise_: new Promise(() => {}), started_: performance.now() * 0.001}", ...(ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget)
|
|
2780
3186
|
? ["let interval = setInterval(() => {}, 24 * 60 * 60 * 1000)"]
|
|
2781
3187
|
: []), "let system = {", "task_: $task,", "array_: arguments_,", "fireflyPath_: fireflyPath_,", (((("mainPackagePair_: {group_: \"" + mainPackagePair_.group_) + "\", name_: \"") + mainPackagePair_.name_) + "\"},"), (("executableMode_: " + (ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitExecutable())
|
|
2782
3188
|
? "true"
|
|
@@ -2856,13 +3262,13 @@ const name_ = ff_compiler_JsEmitter.makeDictionaryName_(definition_.traitName_,
|
|
|
2856
3262
|
const methods_ = ff_core_List.List_map(ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
2857
3263
|
return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, _w1, false, "")
|
|
2858
3264
|
})), ((_w1) => {
|
|
2859
|
-
return ff_core_String.String_dropFirst(_w1,
|
|
3265
|
+
return ff_core_String.String_dropFirst(_w1, "function ".length)
|
|
2860
3266
|
}));
|
|
2861
3267
|
const asyncMethods_ = ff_compiler_JsEmitter.JsEmitter_withEmittingAsync(self_, (() => {
|
|
2862
3268
|
return ff_core_List.List_map(ff_core_List.List_map(definition_.methods_, ((_w1) => {
|
|
2863
3269
|
return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, _w1, true, "")
|
|
2864
3270
|
})), ((_w1) => {
|
|
2865
|
-
return ("async " + ff_core_String.String_dropFirst(_w1,
|
|
3271
|
+
return ("async " + ff_core_String.String_dropFirst(_w1, "async function ".length))
|
|
2866
3272
|
}))
|
|
2867
3273
|
}));
|
|
2868
3274
|
const body_ = (("{\n" + ff_core_List.List_join([...methods_, ...asyncMethods_], ",\n")) + "\n}");
|
|
@@ -2884,25 +3290,7 @@ return (((((("export function " + name_) + "(") + ff_core_List.List_join(diction
|
|
|
2884
3290
|
export async function JsEmitter_emitFunctionDefinition$(self_, definition_, async_, suffix_ = "", $task) {
|
|
2885
3291
|
const signature_ = ff_compiler_JsEmitter.JsEmitter_emitSignature(self_, definition_.signature_, async_, suffix_);
|
|
2886
3292
|
{
|
|
2887
|
-
const _1 =
|
|
2888
|
-
if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.None) {
|
|
2889
|
-
return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in sync context.');\n}")
|
|
2890
|
-
}
|
|
2891
|
-
if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.None) {
|
|
2892
|
-
return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in async context.');\n}")
|
|
2893
|
-
}
|
|
2894
|
-
if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.Some) {
|
|
2895
|
-
const code_ = _1.second_.syncCode_.value_;
|
|
2896
|
-
return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
|
|
2897
|
-
}
|
|
2898
|
-
if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.Some) {
|
|
2899
|
-
const code_ = _1.second_.asyncCode_.value_;
|
|
2900
|
-
return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
|
|
2901
|
-
}
|
|
2902
|
-
if(_1.second_.FireflyTarget) {
|
|
2903
|
-
const lambda_ = _1.second_.lambda_;
|
|
2904
|
-
{
|
|
2905
|
-
const _1 = lambda_;
|
|
3293
|
+
const _1 = definition_.body_;
|
|
2906
3294
|
if(_1.cases_.length === 1) {
|
|
2907
3295
|
const effect_ = _1.effect_;
|
|
2908
3296
|
const matchCase_ = _1.cases_[0];
|
|
@@ -2915,7 +3303,7 @@ return false
|
|
|
2915
3303
|
}
|
|
2916
3304
|
}))) {
|
|
2917
3305
|
const body_ = ff_compiler_JsEmitter.JsEmitter_emitTailCall(self_, (() => {
|
|
2918
|
-
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, true, async_)
|
|
3306
|
+
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, true, false, async_)
|
|
2919
3307
|
}));
|
|
2920
3308
|
return (((signature_ + " {\n") + body_) + "\n}")
|
|
2921
3309
|
}
|
|
@@ -2931,17 +3319,19 @@ const shadowingWorkaround_ = ff_core_List.List_join(ff_core_List.List_map(defini
|
|
|
2931
3319
|
return (((("const " + p_.name_) + "_a = ") + ff_compiler_JsEmitter.escapeKeyword_(p_.name_)) + ";")
|
|
2932
3320
|
})), "\n");
|
|
2933
3321
|
const body_ = ff_compiler_JsEmitter.JsEmitter_emitTailCall(self_, (() => {
|
|
2934
|
-
const casesString_ = ff_core_List.List_join(ff_core_List.List_map(cases_, ((
|
|
2935
|
-
|
|
3322
|
+
const casesString_ = ff_core_List.List_join(ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
3323
|
+
{
|
|
3324
|
+
const i_ = _1.first_;
|
|
3325
|
+
const c_ = _1.second_;
|
|
3326
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
3327
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, c_, [], [], true, true, false, lastCase_, async_)
|
|
3328
|
+
}
|
|
2936
3329
|
})), "\n");
|
|
2937
3330
|
return ((shadowingWorkaround_ + "\n") + casesString_)
|
|
2938
3331
|
}));
|
|
2939
3332
|
return (((signature_ + " {\n") + body_) + "\n}")
|
|
2940
3333
|
}
|
|
2941
3334
|
}
|
|
2942
|
-
return
|
|
2943
|
-
}
|
|
2944
|
-
}
|
|
2945
3335
|
}
|
|
2946
3336
|
|
|
2947
3337
|
export async function JsEmitter_emitTailCall$(self_, body_, $task) {
|
|
@@ -3154,7 +3544,7 @@ const parameters_ = ff_core_List.List_join([...patternParameters_, ...controller
|
|
|
3154
3544
|
const prefix_ = (newAsync_
|
|
3155
3545
|
? "async "
|
|
3156
3546
|
: "");
|
|
3157
|
-
return (((((("(" + prefix_) + "(") + parameters_) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, newAsync_)) + "\n})")
|
|
3547
|
+
return (((((("(" + prefix_) + "(") + parameters_) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, false, newAsync_)) + "\n})")
|
|
3158
3548
|
}
|
|
3159
3549
|
}
|
|
3160
3550
|
if(_1.ELambda) {
|
|
@@ -3166,14 +3556,19 @@ const controller_ = (newAsync_
|
|
|
3166
3556
|
? ["$task"]
|
|
3167
3557
|
: []);
|
|
3168
3558
|
ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
|
|
3169
|
-
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs((cases_[0] ?? ff_core_List.
|
|
3559
|
+
const arguments_ = ff_core_List.List_map(ff_core_List.List_pairs((cases_[0] ?? ff_core_List.List_grab(cases_, 0)).patterns_), ((_w1) => {
|
|
3170
3560
|
return ("_" + (_w1.first_ + 1))
|
|
3171
3561
|
}));
|
|
3172
3562
|
const escapedArguments_ = ff_core_List.List_map(arguments_, ((word_) => {
|
|
3173
3563
|
return ff_compiler_JsEmitter.escapeKeyword_(word_)
|
|
3174
3564
|
}));
|
|
3175
|
-
const caseStrings_ = ff_core_List.List_map(cases_, ((
|
|
3176
|
-
|
|
3565
|
+
const caseStrings_ = ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
3566
|
+
{
|
|
3567
|
+
const i_ = _1.first_;
|
|
3568
|
+
const c_ = _1.second_;
|
|
3569
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
3570
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, c_, [], [], true, true, false, lastCase_, newAsync_)
|
|
3571
|
+
}
|
|
3177
3572
|
}));
|
|
3178
3573
|
const prefix_ = (newAsync_
|
|
3179
3574
|
? "async "
|
|
@@ -3251,7 +3646,7 @@ const typeArguments_ = _1.typeArguments_;
|
|
|
3251
3646
|
const arguments_ = _1.arguments_;
|
|
3252
3647
|
const dictionaries_ = _1.dictionaries_;
|
|
3253
3648
|
if(ff_core_String.String_contains(name_, "bundleForBrowser")) {
|
|
3254
|
-
if((!ff_core_Option.Option_contains((arguments_[0] ?? ff_core_List.
|
|
3649
|
+
if((!ff_core_Option.Option_contains((arguments_[0] ?? ff_core_List.List_grab(arguments_, 0)).name_, "system", ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String))) {
|
|
3255
3650
|
ff_core_Log.debug_(("Wrong arguments for bundleForBrowser: " + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Option.ff_core_Show_Show$ff_core_Option_Option(ff_core_Show.ff_core_Show_Show$ff_core_String_String)).show_(ff_core_List.List_map(arguments_, ((_w1) => {
|
|
3256
3651
|
return _w1.name_
|
|
3257
3652
|
})))));
|
|
@@ -3358,10 +3753,10 @@ ff_compiler_JsEmitter.fail_(at_, "Unbound wildcard")
|
|
|
3358
3753
|
return ("_w" + index_)
|
|
3359
3754
|
}
|
|
3360
3755
|
if(async_) {
|
|
3361
|
-
return (("(await (async function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, async_)) + "\n})())")
|
|
3756
|
+
return (("(await (async function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, false, async_)) + "\n})())")
|
|
3362
3757
|
}
|
|
3363
3758
|
{
|
|
3364
|
-
return (("(function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, async_)) + "\n})()")
|
|
3759
|
+
return (("(function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, false, async_)) + "\n})()")
|
|
3365
3760
|
}
|
|
3366
3761
|
}
|
|
3367
3762
|
}
|
|
@@ -3397,7 +3792,7 @@ return ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, _w1)
|
|
|
3397
3792
|
}
|
|
3398
3793
|
}
|
|
3399
3794
|
|
|
3400
|
-
export async function JsEmitter_emitStatements$(self_, term_, last_, async_, $task) {
|
|
3795
|
+
export async function JsEmitter_emitStatements$(self_, term_, last_, break_, async_, $task) {
|
|
3401
3796
|
{
|
|
3402
3797
|
const _1 = term_;
|
|
3403
3798
|
if(_1.EFunctions) {
|
|
@@ -3408,7 +3803,7 @@ const functionStrings_ = ff_core_List.List_map(functions_, ((f_) => {
|
|
|
3408
3803
|
const newAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(f_.signature_.effect_));
|
|
3409
3804
|
return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, f_, newAsync_, "")
|
|
3410
3805
|
}));
|
|
3411
|
-
return ((ff_core_List.List_join(functionStrings_, "\n") + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_))
|
|
3806
|
+
return ((ff_core_List.List_join(functionStrings_, "\n") + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_))
|
|
3412
3807
|
}
|
|
3413
3808
|
if(_1.ELet) {
|
|
3414
3809
|
const at_ = _1.at_;
|
|
@@ -3417,7 +3812,7 @@ const name_ = _1.name_;
|
|
|
3417
3812
|
const valueType_ = _1.valueType_;
|
|
3418
3813
|
const value_ = _1.value_;
|
|
3419
3814
|
const body_ = _1.body_;
|
|
3420
|
-
return ((ff_compiler_JsEmitter.JsEmitter_emitLetDefinition(self_, ff_compiler_Syntax.DLet(at_, name_, valueType_, value_), mutable_, async_) + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_))
|
|
3815
|
+
return ((ff_compiler_JsEmitter.JsEmitter_emitLetDefinition(self_, ff_compiler_Syntax.DLet(at_, name_, valueType_, value_), mutable_, async_) + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_))
|
|
3421
3816
|
}
|
|
3422
3817
|
if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
|
|
3423
3818
|
const at_ = _1.at_;
|
|
@@ -3425,17 +3820,17 @@ return ""
|
|
|
3425
3820
|
}
|
|
3426
3821
|
if(_1.ESequential && _1.before_.EVariant && _1.before_.name_ === "ff:core/Unit.Unit") {
|
|
3427
3822
|
const after_ = _1.after_;
|
|
3428
|
-
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, async_)
|
|
3823
|
+
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, break_, async_)
|
|
3429
3824
|
}
|
|
3430
3825
|
if(_1.ESequential && _1.after_.EVariant && _1.after_.name_ === "ff:core/Unit.Unit") {
|
|
3431
3826
|
const before_ = _1.before_;
|
|
3432
|
-
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_)
|
|
3827
|
+
return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, break_, async_)
|
|
3433
3828
|
}
|
|
3434
3829
|
if(_1.ESequential) {
|
|
3435
3830
|
const at_ = _1.at_;
|
|
3436
3831
|
const before_ = _1.before_;
|
|
3437
3832
|
const after_ = _1.after_;
|
|
3438
|
-
return ((ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, async_))
|
|
3833
|
+
return ((ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, false, async_) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, break_, async_))
|
|
3439
3834
|
}
|
|
3440
3835
|
if(_1.EAssign) {
|
|
3441
3836
|
const at_ = _1.at_;
|
|
@@ -3487,11 +3882,16 @@ const at_ = _1.at_;
|
|
|
3487
3882
|
const value_ = _1.value_;
|
|
3488
3883
|
const cases_ = _1.function_.lambda_.cases_;
|
|
3489
3884
|
ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
|
|
3490
|
-
return ((((((((!last_)
|
|
3885
|
+
return (((((((((!last_) && (!break_))
|
|
3491
3886
|
? "do "
|
|
3492
|
-
: "") + "{\nconst _1 = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ";\n") + ff_core_List.List_join(ff_core_List.List_map(cases_, ((
|
|
3493
|
-
|
|
3494
|
-
|
|
3887
|
+
: "") + "{\nconst _1 = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ";\n") + ff_core_List.List_join(ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
3888
|
+
{
|
|
3889
|
+
const i_ = _1.first_;
|
|
3890
|
+
const c_ = _1.second_;
|
|
3891
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
3892
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, ["_1"], c_, [], [], true, last_, break_, lastCase_, async_)
|
|
3893
|
+
}
|
|
3894
|
+
})), "\n")) + "\n}") + (((!last_) && (!break_))
|
|
3495
3895
|
? " while(false)"
|
|
3496
3896
|
: ""))
|
|
3497
3897
|
return
|
|
@@ -3500,7 +3900,9 @@ return
|
|
|
3500
3900
|
{
|
|
3501
3901
|
const _1 = ff_compiler_JsEmitter.detectIfElse_(term_);
|
|
3502
3902
|
if(_1.length === 0) {
|
|
3503
|
-
if(
|
|
3903
|
+
if(break_) {
|
|
3904
|
+
return (("if(!" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, term_, async_)) + ") break")
|
|
3905
|
+
} else if(last_) {
|
|
3504
3906
|
return ("return " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, term_, async_))
|
|
3505
3907
|
} else {
|
|
3506
3908
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, term_, async_)
|
|
@@ -3510,13 +3912,13 @@ return
|
|
|
3510
3912
|
if(_1.length >= 1 && _1[0].first_.EVariant && _1[0].first_.name_ === "ff:core/Bool.True") {
|
|
3511
3913
|
const elseBody_ = _1[0].second_;
|
|
3512
3914
|
const list_ = _1.slice(1);
|
|
3513
|
-
const initial_ = (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, elseBody_, last_, async_)) + "\n}");
|
|
3915
|
+
const initial_ = (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, elseBody_, last_, break_, async_)) + "\n}");
|
|
3514
3916
|
return ff_core_List.List_foldLeft(list_, initial_, ((_1, _2) => {
|
|
3515
3917
|
{
|
|
3516
3918
|
const otherwise_ = _1;
|
|
3517
3919
|
const condition_ = _2.first_;
|
|
3518
3920
|
const body_ = _2.second_;
|
|
3519
|
-
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n} else ") + otherwise_)
|
|
3921
|
+
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_)) + "\n} else ") + otherwise_)
|
|
3520
3922
|
}
|
|
3521
3923
|
}))
|
|
3522
3924
|
return
|
|
@@ -3529,7 +3931,7 @@ return ff_core_List.List_foldLeft(list_, "{}", ((_1, _2) => {
|
|
|
3529
3931
|
const otherwise_ = _1;
|
|
3530
3932
|
const condition_ = _2.first_;
|
|
3531
3933
|
const body_ = _2.second_;
|
|
3532
|
-
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n} else ") + otherwise_)
|
|
3934
|
+
return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, break_, async_)) + "\n} else ") + otherwise_)
|
|
3533
3935
|
}
|
|
3534
3936
|
}))
|
|
3535
3937
|
return
|
|
@@ -3587,18 +3989,20 @@ const e2_ = _guard2[1];
|
|
|
3587
3989
|
if((ff_compiler_JsEmitter.noSideEffects_(e1_) && ff_compiler_JsEmitter.noSideEffects_(e2_))) {
|
|
3588
3990
|
const code1_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_);
|
|
3589
3991
|
const code2_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_);
|
|
3590
|
-
return ff_core_Option.Some(((((((((("(" + code1_) + "[") + code2_) + "] ?? ") + "ff_core_List.
|
|
3992
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + "[") + code2_) + "] ?? ") + "ff_core_List.List_grab(") + code1_) + ", ") + code2_) + "))"))
|
|
3591
3993
|
}
|
|
3592
3994
|
}
|
|
3593
3995
|
}
|
|
3594
3996
|
if(_1 === "ff:core/Array.Array_grab") {
|
|
3595
|
-
const
|
|
3596
|
-
if(
|
|
3597
|
-
const e1_ =
|
|
3598
|
-
const e2_ =
|
|
3997
|
+
const _guard2 = arguments_;
|
|
3998
|
+
if(_guard2.length === 2) {
|
|
3999
|
+
const e1_ = _guard2[0];
|
|
4000
|
+
const e2_ = _guard2[1];
|
|
4001
|
+
if((ff_compiler_JsEmitter.noSideEffects_(e1_) && ff_compiler_JsEmitter.noSideEffects_(e2_))) {
|
|
3599
4002
|
const code1_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_);
|
|
3600
4003
|
const code2_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_);
|
|
3601
|
-
return ff_core_Option.Some(((((((((("(" + code1_) + ".array[") + code2_) + "] ?? ") + "ff_core_Array.
|
|
4004
|
+
return ff_core_Option.Some(((((((((("(" + code1_) + ".array[") + code2_) + "] ?? ") + "ff_core_Array.Array_grab(") + code1_) + ", ") + code2_) + "))"))
|
|
4005
|
+
}
|
|
3602
4006
|
}
|
|
3603
4007
|
}
|
|
3604
4008
|
if(_1 === "ff:core/List.List_size") {
|
|
@@ -3615,6 +4019,13 @@ const e_ = _guard1[0];
|
|
|
3615
4019
|
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_) + ".array.length"))
|
|
3616
4020
|
}
|
|
3617
4021
|
}
|
|
4022
|
+
if(_1 === "ff:core/String.String_size") {
|
|
4023
|
+
const _guard1 = arguments_;
|
|
4024
|
+
if(_guard1.length === 1) {
|
|
4025
|
+
const e_ = _guard1[0];
|
|
4026
|
+
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_) + ".length"))
|
|
4027
|
+
}
|
|
4028
|
+
}
|
|
3618
4029
|
if(_1 === "ff:core/Equal.equals") {
|
|
3619
4030
|
const _guard3 = arguments_;
|
|
3620
4031
|
if(_guard3.length === 2) {
|
|
@@ -3726,75 +4137,224 @@ return ff_core_Option.Some(((((((((((((((((((await_ + "((() => {\n") + "const si
|
|
|
3726
4137
|
}
|
|
3727
4138
|
}
|
|
3728
4139
|
}
|
|
3729
|
-
if(_1 === "ff:core/
|
|
4140
|
+
if(_1 === "ff:core/Js.import") {
|
|
4141
|
+
const _guard1 = arguments_;
|
|
4142
|
+
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
4143
|
+
const url_ = _guard1[0].value_;
|
|
4144
|
+
{
|
|
4145
|
+
const _1 = self_.emitTarget_;
|
|
4146
|
+
if(_1.EmitBrowser) {
|
|
4147
|
+
return ff_core_Option.Some("(() => {throw new Error('Node.js imports are not supported in the browser')})()")
|
|
4148
|
+
}
|
|
4149
|
+
{
|
|
4150
|
+
return ff_core_Option.Some(ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", "")))
|
|
4151
|
+
}
|
|
4152
|
+
}
|
|
4153
|
+
return
|
|
4154
|
+
}
|
|
4155
|
+
}
|
|
4156
|
+
if(_1 === "ff:core/Js.browserImport") {
|
|
3730
4157
|
const _guard1 = arguments_;
|
|
3731
4158
|
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
3732
4159
|
const url_ = _guard1[0].value_;
|
|
4160
|
+
{
|
|
4161
|
+
const _1 = self_.emitTarget_;
|
|
4162
|
+
if(_1.EmitBrowser) {
|
|
3733
4163
|
return ff_core_Option.Some(ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", "")))
|
|
3734
4164
|
}
|
|
4165
|
+
{
|
|
4166
|
+
return ff_core_Option.Some("(() => {throw new Error('Browser imports are not supported in Node.js')})()")
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
return
|
|
4170
|
+
}
|
|
3735
4171
|
}
|
|
3736
|
-
if(_1 === "ff:core/
|
|
4172
|
+
if(_1 === "ff:core/Js.dynamicImport") {
|
|
4173
|
+
const _guard1 = arguments_;
|
|
4174
|
+
if(_guard1.length === 1) {
|
|
4175
|
+
const url_ = _guard1[0];
|
|
4176
|
+
return ff_core_Option.Some((("import(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, url_, async_)) + ")"))
|
|
4177
|
+
}
|
|
4178
|
+
}
|
|
4179
|
+
if(_1 === "ff:core/Js.await") {
|
|
3737
4180
|
const _guard1 = arguments_;
|
|
3738
4181
|
if(_guard1.length === 1) {
|
|
3739
4182
|
const body_ = _guard1[0];
|
|
3740
4183
|
if(async_) {
|
|
3741
|
-
return ff_core_Option.Some((("(await " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + "
|
|
4184
|
+
return ff_core_Option.Some((("(await " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + ")"))
|
|
3742
4185
|
} else {
|
|
3743
|
-
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_,
|
|
4186
|
+
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_))
|
|
3744
4187
|
}
|
|
3745
4188
|
return
|
|
3746
4189
|
}
|
|
3747
4190
|
}
|
|
3748
|
-
|
|
4191
|
+
{
|
|
4192
|
+
const name_ = _1;
|
|
4193
|
+
const _guard4 = ff_core_String.String_removeFirst(name_, "ff:core/Js.async");
|
|
4194
|
+
if(_guard4.Some) {
|
|
4195
|
+
const n_ = _guard4.value_;
|
|
4196
|
+
const _guard3 = ff_core_String.String_all(n_, ((_w1) => {
|
|
4197
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4198
|
+
}));
|
|
4199
|
+
if(_guard3) {
|
|
4200
|
+
const _guard2 = arguments_;
|
|
4201
|
+
if(_guard2.length === 1 && _guard2[0].ELambda && _guard2[0].lambda_.cases_.length === 1 && _guard2[0].lambda_.cases_[0].guards_.length === 0) {
|
|
4202
|
+
const at_ = _guard2[0].at_;
|
|
4203
|
+
const effect_ = _guard2[0].lambda_.effect_;
|
|
4204
|
+
const patterns_ = _guard2[0].lambda_.cases_[0].patterns_;
|
|
4205
|
+
const body_ = _guard2[0].lambda_.cases_[0].body_;
|
|
4206
|
+
if(ff_core_List.List_all(patterns_, ((_1) => {
|
|
4207
|
+
if(_1.PVariable) {
|
|
4208
|
+
return true
|
|
4209
|
+
}
|
|
4210
|
+
{
|
|
4211
|
+
return false
|
|
4212
|
+
}
|
|
4213
|
+
}))) {
|
|
4214
|
+
const patternParameters_ = ff_core_List.List_map(patterns_, ((_1) => {
|
|
4215
|
+
if(_1.PVariable) {
|
|
4216
|
+
const p_ = _1;
|
|
4217
|
+
return ff_core_Option.Option_else(ff_core_Option.Option_map(p_.name_, ((word_) => {
|
|
4218
|
+
return ff_compiler_JsEmitter.escapeKeyword_(word_)
|
|
4219
|
+
})), (() => {
|
|
4220
|
+
return "_"
|
|
4221
|
+
}))
|
|
4222
|
+
return
|
|
4223
|
+
}
|
|
4224
|
+
{
|
|
4225
|
+
return ff_core_Core.panic_("!")
|
|
4226
|
+
}
|
|
4227
|
+
}));
|
|
4228
|
+
return ff_core_Option.Some((((("async (" + ff_core_List.List_join(patternParameters_, ", ")) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, false, false)) + "\n}"))
|
|
4229
|
+
}
|
|
4230
|
+
}
|
|
4231
|
+
}
|
|
4232
|
+
}
|
|
4233
|
+
}
|
|
4234
|
+
{
|
|
4235
|
+
const name_ = _1;
|
|
4236
|
+
if(ff_core_String.String_startsWith(name_, "ff:core/Js.async", 0)) {
|
|
4237
|
+
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(term_.at_, "JS async functions must take a simple parameter list"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
4238
|
+
}
|
|
4239
|
+
}
|
|
4240
|
+
if(_1 === "ff:core/Js.cancelled") {
|
|
3749
4241
|
return ff_core_Option.Some((async_
|
|
3750
|
-
? "$task.
|
|
4242
|
+
? "$task.controller_.signal.aborted"
|
|
3751
4243
|
: "false"))
|
|
3752
4244
|
return
|
|
3753
4245
|
}
|
|
3754
|
-
if(_1 === "ff:core/
|
|
4246
|
+
if(_1 === "ff:core/Js.throwIfCancelled") {
|
|
3755
4247
|
return ff_core_Option.Some((async_
|
|
3756
4248
|
? "((() => ff_core_Task.Task_throwIfAborted($task))())"
|
|
3757
4249
|
: ""))
|
|
3758
4250
|
return
|
|
3759
4251
|
}
|
|
3760
|
-
if(_1 === "ff:core/
|
|
4252
|
+
if(_1 === "ff:core/Js.currentTask") {
|
|
4253
|
+
return ff_core_Option.Some("$task")
|
|
4254
|
+
}
|
|
4255
|
+
if(_1 === "ff:core/Js.controller") {
|
|
4256
|
+
return ff_core_Option.Some("$task.controller_")
|
|
4257
|
+
}
|
|
4258
|
+
if(_1 === "ff:core/Js.setController") {
|
|
4259
|
+
const _guard1 = arguments_;
|
|
4260
|
+
if(_guard1.length === 1) {
|
|
4261
|
+
const a_ = _guard1[0];
|
|
4262
|
+
return ff_core_Option.Some((("($task.controller_ = " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a_, async_)) + ")"))
|
|
4263
|
+
}
|
|
4264
|
+
}
|
|
4265
|
+
if(_1 === "ff:core/Js.inAsync") {
|
|
3761
4266
|
return ff_core_Option.Some((self_.emittingAsync_
|
|
3762
4267
|
? "true"
|
|
3763
4268
|
: "false"))
|
|
3764
4269
|
return
|
|
3765
4270
|
}
|
|
3766
|
-
if(_1 === "ff:core/
|
|
4271
|
+
if(_1 === "ff:core/Js.inBrowser") {
|
|
3767
4272
|
return ff_core_Option.Some((ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser())
|
|
3768
4273
|
? "true"
|
|
3769
4274
|
: "false"))
|
|
3770
4275
|
return
|
|
3771
4276
|
}
|
|
3772
|
-
if(_1 === "ff:core/
|
|
4277
|
+
if(_1 === "ff:core/Js.inNode") {
|
|
3773
4278
|
return ff_core_Option.Some((ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitNode())
|
|
3774
4279
|
? "true"
|
|
3775
4280
|
: "false"))
|
|
3776
4281
|
return
|
|
3777
4282
|
}
|
|
3778
|
-
if(_1 === "ff:core/
|
|
4283
|
+
if(_1 === "ff:core/Js.inBuild") {
|
|
3779
4284
|
return ff_core_Option.Some((ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBuild())
|
|
3780
4285
|
? "true"
|
|
3781
4286
|
: "false"))
|
|
3782
4287
|
return
|
|
3783
4288
|
}
|
|
3784
|
-
if(_1 === "ff:core/
|
|
4289
|
+
if(_1 === "ff:core/Js.value") {
|
|
3785
4290
|
const _guard1 = arguments_;
|
|
3786
4291
|
if(_guard1.length === 1) {
|
|
3787
4292
|
const e_ = _guard1[0];
|
|
3788
4293
|
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_))
|
|
3789
4294
|
}
|
|
3790
4295
|
}
|
|
3791
|
-
if(_1 === "ff:core/
|
|
4296
|
+
if(_1 === "ff:core/Js.fromValue") {
|
|
3792
4297
|
const _guard1 = arguments_;
|
|
3793
4298
|
if(_guard1.length === 1) {
|
|
3794
4299
|
const e_ = _guard1[0];
|
|
3795
4300
|
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_))
|
|
3796
4301
|
}
|
|
3797
4302
|
}
|
|
4303
|
+
if(_1 === "ff:core/Js.rawIdentifier") {
|
|
4304
|
+
const _guard1 = arguments_;
|
|
4305
|
+
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
4306
|
+
const op_ = _guard1[0].value_;
|
|
4307
|
+
return ff_core_Option.Some(ff_core_String.String_replace(op_, "\"", ""))
|
|
4308
|
+
}
|
|
4309
|
+
}
|
|
4310
|
+
if(_1 === "ff:core/Js.unaryOperator") {
|
|
4311
|
+
const _guard1 = arguments_;
|
|
4312
|
+
if(_guard1.length === 2 && _guard1[0].EString) {
|
|
4313
|
+
const op_ = _guard1[0].value_;
|
|
4314
|
+
const a1_ = _guard1[1];
|
|
4315
|
+
return ff_core_Option.Some(((("(" + ff_core_String.String_replace(op_, "\"", "")) + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_, async_)) + ")"))
|
|
4316
|
+
}
|
|
4317
|
+
}
|
|
4318
|
+
if(_1 === "ff:core/Js.binaryOperator") {
|
|
4319
|
+
const _guard1 = arguments_;
|
|
4320
|
+
if(_guard1.length === 3 && _guard1[0].EString) {
|
|
4321
|
+
const op_ = _guard1[0].value_;
|
|
4322
|
+
const a1_ = _guard1[1];
|
|
4323
|
+
const a2_ = _guard1[2];
|
|
4324
|
+
return ff_core_Option.Some((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_, async_)) + " ") + ff_core_String.String_replace(op_, "\"", "")) + " ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_, async_)) + ")"))
|
|
4325
|
+
}
|
|
4326
|
+
}
|
|
4327
|
+
if(_1 === "ff:core/Js.shortCircuitingOperator") {
|
|
4328
|
+
const _guard1 = arguments_;
|
|
4329
|
+
if(_guard1.length === 3 && _guard1[0].EString) {
|
|
4330
|
+
const op_ = _guard1[0].value_;
|
|
4331
|
+
const a1_ = _guard1[1];
|
|
4332
|
+
const a2_ = _guard1[2];
|
|
4333
|
+
return ff_core_Option.Some((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_, async_)) + " ") + ff_core_String.String_replace(op_, "\"", "")) + " ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(a2_), async_)) + ")"))
|
|
4334
|
+
}
|
|
4335
|
+
}
|
|
4336
|
+
if(_1 === "ff:core/JsValue.JsValue_spreadToArray") {
|
|
4337
|
+
const _guard1 = arguments_;
|
|
4338
|
+
if(_guard1.length === 1) {
|
|
4339
|
+
const e1_ = _guard1[0];
|
|
4340
|
+
return ff_core_Option.Some((("[..." + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "]"))
|
|
4341
|
+
}
|
|
4342
|
+
}
|
|
4343
|
+
if(_1 === "ff:core/JsValue.JsValue_typeof") {
|
|
4344
|
+
const _guard1 = arguments_;
|
|
4345
|
+
if(_guard1.length === 1) {
|
|
4346
|
+
const e_ = _guard1[0];
|
|
4347
|
+
return ff_core_Option.Some((("(typeof " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)) + ")"))
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
if(_1 === "ff:core/JsValue.JsValue_instanceof") {
|
|
4351
|
+
const _guard1 = arguments_;
|
|
4352
|
+
if(_guard1.length === 2) {
|
|
4353
|
+
const e1_ = _guard1[0];
|
|
4354
|
+
const e2_ = _guard1[1];
|
|
4355
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " instanceof ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
4356
|
+
}
|
|
4357
|
+
}
|
|
3798
4358
|
if(_1 === "ff:core/JsValue.JsValue_get") {
|
|
3799
4359
|
const _guard1 = arguments_;
|
|
3800
4360
|
if(_guard1.length === 2) {
|
|
@@ -3803,6 +4363,46 @@ const e2_ = _guard1[1];
|
|
|
3803
4363
|
return ff_core_Option.Some((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_) + ff_compiler_JsEmitter.JsEmitter_emitField(self_, e2_, async_, ".")))
|
|
3804
4364
|
}
|
|
3805
4365
|
}
|
|
4366
|
+
if(_1 === "ff:core/JsValue.JsValue_equals") {
|
|
4367
|
+
const _guard1 = arguments_;
|
|
4368
|
+
if(_guard1.length === 2) {
|
|
4369
|
+
const e1_ = _guard1[0];
|
|
4370
|
+
const e2_ = _guard1[1];
|
|
4371
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " === ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
4372
|
+
}
|
|
4373
|
+
}
|
|
4374
|
+
if(_1 === "ff:core/JsValue.JsValue_notEquals") {
|
|
4375
|
+
const _guard1 = arguments_;
|
|
4376
|
+
if(_guard1.length === 2) {
|
|
4377
|
+
const e1_ = _guard1[0];
|
|
4378
|
+
const e2_ = _guard1[1];
|
|
4379
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " !== ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
4380
|
+
}
|
|
4381
|
+
}
|
|
4382
|
+
if(_1 === "ff:core/Int.Int_bitAnd") {
|
|
4383
|
+
const _guard1 = arguments_;
|
|
4384
|
+
if(_guard1.length === 2) {
|
|
4385
|
+
const e1_ = _guard1[0];
|
|
4386
|
+
const e2_ = _guard1[1];
|
|
4387
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " & ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
4388
|
+
}
|
|
4389
|
+
}
|
|
4390
|
+
if(_1 === "ff:core/Int.Int_bitRightUnsigned") {
|
|
4391
|
+
const _guard1 = arguments_;
|
|
4392
|
+
if(_guard1.length === 2) {
|
|
4393
|
+
const e1_ = _guard1[0];
|
|
4394
|
+
const e2_ = _guard1[1];
|
|
4395
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " >>> ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
4396
|
+
}
|
|
4397
|
+
}
|
|
4398
|
+
if(_1 === "ff:core/Int.Int_bitRight") {
|
|
4399
|
+
const _guard1 = arguments_;
|
|
4400
|
+
if(_guard1.length === 2) {
|
|
4401
|
+
const e1_ = _guard1[0];
|
|
4402
|
+
const e2_ = _guard1[1];
|
|
4403
|
+
return ff_core_Option.Some((((("(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + " >> ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)) + ")"))
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
3806
4406
|
{
|
|
3807
4407
|
const name_ = _1;
|
|
3808
4408
|
const _guard3 = ff_core_String.String_removeFirst(name_, "ff:core/JsValue.JsValue_call");
|
|
@@ -3882,11 +4482,13 @@ if((n_ === name_)) {
|
|
|
3882
4482
|
return go_(a1_.value_, [ff_core_Pair.Pair(a2_.value_, a3_.value_), ...fields_])
|
|
3883
4483
|
}
|
|
3884
4484
|
}
|
|
3885
|
-
if(_1.ECall && _1.target_.StaticCall
|
|
4485
|
+
if(_1.ECall && _1.target_.StaticCall) {
|
|
3886
4486
|
const n_ = _1.target_.name_;
|
|
3887
|
-
const
|
|
3888
|
-
const _guard2 = ((((n_ === "ff:core/JsSystem.JsSystem_object") || (n_ === "ff:core/JsSystem.JsSystem_new0")) || (n_ === "ff:core/Json.Json_object")) || (n_ === "ff:core/Json.Json_new0"));
|
|
3889
|
-
if(_guard2 &&
|
|
4487
|
+
const as_ = _1.arguments_;
|
|
4488
|
+
const _guard2 = ((((((n_ === "ff:core/JsSystem.JsSystem_object") || (n_ === "ff:core/JsSystem.JsSystem_new0")) || (n_ === "ff:core/Js.object")) || (n_ === "ff:core/Js.new0")) || (n_ === "ff:core/Json.Json_object")) || (n_ === "ff:core/Json.Json_new0"));
|
|
4489
|
+
if(_guard2 && ff_core_List.List_all(as_, ((_w1) => {
|
|
4490
|
+
return ff_compiler_JsEmitter.noSideEffects_(_w1.value_)
|
|
4491
|
+
}))) {
|
|
3890
4492
|
return (("{" + ff_core_List.List_join(ff_core_List.List_map(fields_, ((p_) => {
|
|
3891
4493
|
return ((ff_compiler_JsEmitter.JsEmitter_emitField(self_, p_.first_, async_, "") + ": ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, p_.second_, async_))
|
|
3892
4494
|
})), ", ")) + "}")
|
|
@@ -4009,6 +4611,89 @@ return ff_core_Option.Some("(void 0)")
|
|
|
4009
4611
|
}
|
|
4010
4612
|
}
|
|
4011
4613
|
}
|
|
4614
|
+
{
|
|
4615
|
+
const name_ = _1;
|
|
4616
|
+
const _guard3 = ff_core_String.String_removeFirst(name_, "ff:core/Js.call");
|
|
4617
|
+
if(_guard3.Some) {
|
|
4618
|
+
const n_ = _guard3.value_;
|
|
4619
|
+
const _guard2 = ff_core_String.String_all(n_, ((_w1) => {
|
|
4620
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4621
|
+
}));
|
|
4622
|
+
if(_guard2) {
|
|
4623
|
+
const _guard1 = arguments_;
|
|
4624
|
+
if(_guard1.length >= 1 && _guard1[0].EString) {
|
|
4625
|
+
const e1_ = _guard1[0];
|
|
4626
|
+
const q_ = _guard1[0].value_;
|
|
4627
|
+
const es_ = _guard1.slice(1);
|
|
4628
|
+
const argumentCode_ = ff_core_List.List_join(ff_core_List.List_map(es_, ((_w1) => {
|
|
4629
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, _w1, async_)
|
|
4630
|
+
})), ", ");
|
|
4631
|
+
return ff_core_Option.Some((((ff_core_Option.Option_else(ff_compiler_JsEmitter.safeBare_(q_), (() => {
|
|
4632
|
+
return (("globalThis[" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "]")
|
|
4633
|
+
})) + "(") + argumentCode_) + ")"))
|
|
4634
|
+
return
|
|
4635
|
+
}
|
|
4636
|
+
}
|
|
4637
|
+
}
|
|
4638
|
+
}
|
|
4639
|
+
{
|
|
4640
|
+
const name_ = _1;
|
|
4641
|
+
const _guard4 = ff_core_String.String_removeFirst(name_, "ff:core/Js.function");
|
|
4642
|
+
if(_guard4.Some) {
|
|
4643
|
+
const n_ = _guard4.value_;
|
|
4644
|
+
const _guard3 = ff_core_String.String_all(n_, ((_w1) => {
|
|
4645
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4646
|
+
}));
|
|
4647
|
+
if(_guard3) {
|
|
4648
|
+
const _guard2 = arguments_;
|
|
4649
|
+
if(_guard2.length === 1) {
|
|
4650
|
+
const e1_ = _guard2[0];
|
|
4651
|
+
const _guard1 = term_;
|
|
4652
|
+
if(_guard1.ECall) {
|
|
4653
|
+
const call_ = _guard1;
|
|
4654
|
+
if((self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(call_.effect_))) {
|
|
4655
|
+
const argumentCode_ = ff_core_List.List_join(ff_core_List.List_map(ff_core_Int.Int_to(1, ff_core_String.String_grabInt(n_)), ((_w1) => {
|
|
4656
|
+
return ("a_" + _w1)
|
|
4657
|
+
})), ", ");
|
|
4658
|
+
const taskCode_ = ((argumentCode_ === "")
|
|
4659
|
+
? "$task"
|
|
4660
|
+
: ", $task");
|
|
4661
|
+
return ff_core_Option.Some(((((((("(async (" + argumentCode_) + ") => await ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "(") + argumentCode_) + taskCode_) + "))"))
|
|
4662
|
+
} else {
|
|
4663
|
+
return ff_core_Option.Some(ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_))
|
|
4664
|
+
}
|
|
4665
|
+
return
|
|
4666
|
+
}
|
|
4667
|
+
}
|
|
4668
|
+
}
|
|
4669
|
+
}
|
|
4670
|
+
}
|
|
4671
|
+
if(_1 === "ff:core/Js.get") {
|
|
4672
|
+
const _guard1 = arguments_;
|
|
4673
|
+
if(_guard1.length === 1 && _guard1[0].EString) {
|
|
4674
|
+
const e1_ = _guard1[0];
|
|
4675
|
+
const q_ = _guard1[0].value_;
|
|
4676
|
+
return ff_core_Option.Some(ff_core_Option.Option_else(ff_compiler_JsEmitter.safeBare_(q_), (() => {
|
|
4677
|
+
return (("globalThis[" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e1_, async_)) + "]")
|
|
4678
|
+
})))
|
|
4679
|
+
return
|
|
4680
|
+
}
|
|
4681
|
+
}
|
|
4682
|
+
if(_1 === "ff:core/Js.object") {
|
|
4683
|
+
return ff_core_Option.Some("{}")
|
|
4684
|
+
}
|
|
4685
|
+
if(_1 === "ff:core/Js.new0") {
|
|
4686
|
+
return ff_core_Option.Some("{}")
|
|
4687
|
+
}
|
|
4688
|
+
if(_1 === "ff:core/Js.null") {
|
|
4689
|
+
return ff_core_Option.Some("null")
|
|
4690
|
+
}
|
|
4691
|
+
if(_1 === "ff:core/Js.undefined") {
|
|
4692
|
+
return ff_core_Option.Some("(void 0)")
|
|
4693
|
+
}
|
|
4694
|
+
if(_1 === "ff:core/Js.globalThis") {
|
|
4695
|
+
return ff_core_Option.Some("globalThis")
|
|
4696
|
+
}
|
|
4012
4697
|
if(_1 === "ff:core/BrowserSystem.BrowserSystem_js") {
|
|
4013
4698
|
const _guard2 = arguments_;
|
|
4014
4699
|
if(_guard2.length === 1) {
|
|
@@ -4036,7 +4721,7 @@ return ff_core_Option.Some("globalThis")
|
|
|
4036
4721
|
}
|
|
4037
4722
|
}
|
|
4038
4723
|
}
|
|
4039
|
-
if(_1 === "ff:core/
|
|
4724
|
+
if(_1 === "ff:core/Js.jsSystem") {
|
|
4040
4725
|
return ff_core_Option.Some("globalThis")
|
|
4041
4726
|
}
|
|
4042
4727
|
if(_1 === "ff:core/Json.string") {
|
|
@@ -4102,19 +4787,7 @@ const _guard1 = arguments_;
|
|
|
4102
4787
|
if(_guard1.length === 2) {
|
|
4103
4788
|
const condition_ = _guard1[0];
|
|
4104
4789
|
const body_ = _guard1[1];
|
|
4105
|
-
return ff_core_Option.Some((((("while(" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, ff_compiler_JsEmitter.invokeImmediately_(condition_), async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, async_)) + "\n}"))
|
|
4106
|
-
}
|
|
4107
|
-
}
|
|
4108
|
-
if(_1 === "ff:core/Core.doWhile") {
|
|
4109
|
-
const _guard2 = arguments_;
|
|
4110
|
-
if(_guard2.length === 1) {
|
|
4111
|
-
const doWhileBody_ = _guard2[0];
|
|
4112
|
-
const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
|
|
4113
|
-
if(_guard1.ESequential) {
|
|
4114
|
-
const body_ = _guard1.before_;
|
|
4115
|
-
const condition_ = _guard1.after_;
|
|
4116
|
-
return ff_core_Option.Some(((((("while(true) {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, false, async_)) + "\nif(!") + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") break") + "\n}"))
|
|
4117
|
-
}
|
|
4790
|
+
return ff_core_Option.Some((((("while(" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, ff_compiler_JsEmitter.invokeImmediately_(condition_), async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, false, async_)) + "\n}"))
|
|
4118
4791
|
}
|
|
4119
4792
|
}
|
|
4120
4793
|
if(_1 === "ff:core/Core.doWhile") {
|
|
@@ -4124,7 +4797,7 @@ const doWhileBody_ = _guard2[0];
|
|
|
4124
4797
|
const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
|
|
4125
4798
|
{
|
|
4126
4799
|
const body_ = _guard1;
|
|
4127
|
-
return ff_core_Option.Some((("while(" + ff_compiler_JsEmitter.
|
|
4800
|
+
return ff_core_Option.Some((("while(true) {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, false, true, async_)) + "\n}"))
|
|
4128
4801
|
}
|
|
4129
4802
|
}
|
|
4130
4803
|
}
|
|
@@ -4134,15 +4807,18 @@ if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.lengt
|
|
|
4134
4807
|
const list_ = _guard1[0];
|
|
4135
4808
|
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
4136
4809
|
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
4137
|
-
return ff_core_Option.Some(((((("
|
|
4138
|
-
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " =
|
|
4810
|
+
return ff_core_Option.Some(((((("{\nconst if_o = " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_)) + "\nif(if_o.Some) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
4811
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = if_o.value_;\n")
|
|
4139
4812
|
})), (() => {
|
|
4140
4813
|
return ""
|
|
4141
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\
|
|
4814
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, false, async_)) + "\n}\n}"))
|
|
4142
4815
|
return
|
|
4143
4816
|
}
|
|
4144
4817
|
}
|
|
4145
|
-
|
|
4818
|
+
{
|
|
4819
|
+
const n_ = _1;
|
|
4820
|
+
const _guard3 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
4821
|
+
if(_guard3) {
|
|
4146
4822
|
const _guard2 = arguments_;
|
|
4147
4823
|
if(_guard2.length === 2 && _guard2[0].ECall && _guard2[0].target_.StaticCall && _guard2[0].arguments_.length === 2 && _guard2[1].ELambda && _guard2[1].lambda_.cases_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_[0].PVariable && _guard2[1].lambda_.cases_[0].guards_.length === 0) {
|
|
4148
4824
|
const r_ = _guard2[0].target_.name_;
|
|
@@ -4160,63 +4836,122 @@ return ff_core_Option.Some((((((((((("for(let " + "for_i = ") + startCode_) + ",
|
|
|
4160
4836
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
4161
4837
|
})), (() => {
|
|
4162
4838
|
return ""
|
|
4163
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n}"))
|
|
4839
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
4164
4840
|
return
|
|
4165
4841
|
}
|
|
4166
4842
|
}
|
|
4167
4843
|
}
|
|
4168
|
-
|
|
4844
|
+
}
|
|
4845
|
+
{
|
|
4846
|
+
const n_ = _1;
|
|
4847
|
+
const _guard3 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
4848
|
+
if(_guard3) {
|
|
4849
|
+
const _guard2 = arguments_;
|
|
4850
|
+
if(_guard2.length === 2 && _guard2[0].ECall && _guard2[0].target_.StaticCall && _guard2[0].target_.name_ === "ff:core/List.List_reverse" && _guard2[0].arguments_.length === 1 && _guard2[0].arguments_[0].value_.ECall && _guard2[0].arguments_[0].value_.target_.StaticCall && _guard2[0].arguments_[0].value_.arguments_.length === 2 && _guard2[1].ELambda && _guard2[1].lambda_.cases_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_[0].PVariable && _guard2[1].lambda_.cases_[0].guards_.length === 0) {
|
|
4851
|
+
const r_ = _guard2[0].arguments_[0].value_.target_.name_;
|
|
4852
|
+
const start_ = _guard2[0].arguments_[0].value_.arguments_[0];
|
|
4853
|
+
const end_ = _guard2[0].arguments_[0].value_.arguments_[1];
|
|
4854
|
+
const name_ = _guard2[1].lambda_.cases_[0].patterns_[0].name_;
|
|
4855
|
+
const body_ = _guard2[1].lambda_.cases_[0].body_;
|
|
4856
|
+
if(((r_ === "ff:core/Int.Int_until") || (r_ === "ff:core/Int.Int_to"))) {
|
|
4857
|
+
const startCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, start_.value_, async_);
|
|
4858
|
+
const endCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, end_.value_, async_);
|
|
4859
|
+
const delta_ = ((r_ === "ff:core/Int.Int_until")
|
|
4860
|
+
? " - 1"
|
|
4861
|
+
: "");
|
|
4862
|
+
return ff_core_Option.Some(((((((((("for(let " + "for_e = ") + startCode_) + ", for_i = ") + endCode_) + delta_) + "; for_i >= for_e; for_i--) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
4863
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
4864
|
+
})), (() => {
|
|
4865
|
+
return ""
|
|
4866
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
4867
|
+
return
|
|
4868
|
+
}
|
|
4869
|
+
}
|
|
4870
|
+
}
|
|
4871
|
+
}
|
|
4872
|
+
{
|
|
4873
|
+
const n_ = _1;
|
|
4874
|
+
const _guard2 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
4875
|
+
if(_guard2) {
|
|
4169
4876
|
const _guard1 = arguments_;
|
|
4170
|
-
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
4171
|
-
const
|
|
4172
|
-
const
|
|
4877
|
+
if(_guard1.length === 2 && _guard1[0].ECall && _guard1[0].target_.StaticCall && _guard1[0].target_.name_ === "ff:core/List.List_zip" && _guard1[0].arguments_.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariant && _guard1[1].lambda_.cases_[0].patterns_[0].name_ === "ff:core/Pair.Pair" && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_.length === 2 && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
4878
|
+
const list1_ = _guard1[0].arguments_[0];
|
|
4879
|
+
const list2_ = _guard1[0].arguments_[1];
|
|
4880
|
+
const name1_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].name_;
|
|
4881
|
+
const name2_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].name_;
|
|
4173
4882
|
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
4174
|
-
const
|
|
4175
|
-
const
|
|
4176
|
-
const
|
|
4177
|
-
const
|
|
4178
|
-
|
|
4883
|
+
const fusion1_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a", list1_.value_, async_);
|
|
4884
|
+
const fusion2_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a2", list2_.value_, async_);
|
|
4885
|
+
const start1_ = fusion1_.second_.first_;
|
|
4886
|
+
const end1_ = fusion1_.second_.second_;
|
|
4887
|
+
const listCode1_ = fusion1_.first_;
|
|
4888
|
+
const start2_ = fusion2_.second_.first_;
|
|
4889
|
+
const end2_ = fusion2_.second_.second_;
|
|
4890
|
+
const listCode2_ = fusion2_.first_;
|
|
4891
|
+
return ff_core_Option.Some(((((((((((((((((("for(let for_a = " + listCode1_) + ", for_i = ") + start1_) + ", for_l = ") + end1_) + ", ") + "for_a2 = ") + listCode2_) + ", for_i2 = ") + start2_) + ", for_l2 = ") + end2_) + "; for_i < for_l && for_i2 < for_l2; for_i++, for_i2++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name1_, ((_w1) => {
|
|
4179
4892
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
4180
4893
|
})), (() => {
|
|
4181
4894
|
return ""
|
|
4182
|
-
}))) +
|
|
4895
|
+
}))) + ff_core_Option.Option_else(ff_core_Option.Option_map(name2_, ((_w1) => {
|
|
4896
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a2[for_i2];\n")
|
|
4897
|
+
})), (() => {
|
|
4898
|
+
return ""
|
|
4899
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
4183
4900
|
return
|
|
4184
4901
|
}
|
|
4185
4902
|
}
|
|
4186
|
-
|
|
4903
|
+
}
|
|
4904
|
+
{
|
|
4905
|
+
const n_ = _1;
|
|
4906
|
+
const _guard2 = ((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile"));
|
|
4907
|
+
if(_guard2) {
|
|
4187
4908
|
const _guard1 = arguments_;
|
|
4188
|
-
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].
|
|
4189
|
-
const list_ = _guard1[0];
|
|
4190
|
-
const
|
|
4191
|
-
const
|
|
4192
|
-
const
|
|
4193
|
-
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, list_, async_);
|
|
4909
|
+
if(_guard1.length === 2 && _guard1[0].ECall && _guard1[0].target_.StaticCall && _guard1[0].target_.name_ === "ff:core/List.List_pairs" && _guard1[0].arguments_.length === 1 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariant && _guard1[1].lambda_.cases_[0].patterns_[0].name_ === "ff:core/Pair.Pair" && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_.length === 2 && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
4910
|
+
const list_ = _guard1[0].arguments_[0];
|
|
4911
|
+
const name1_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[0].name_;
|
|
4912
|
+
const name2_ = _guard1[1].lambda_.cases_[0].patterns_[0].patterns_[1].name_;
|
|
4913
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
4914
|
+
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a", list_.value_, async_);
|
|
4194
4915
|
const start_ = fusion_.second_.first_;
|
|
4195
4916
|
const end_ = fusion_.second_.second_;
|
|
4196
4917
|
const listCode_ = fusion_.first_;
|
|
4197
|
-
return ff_core_Option.Some(((((((((((
|
|
4918
|
+
return ff_core_Option.Some((((((((((("for(let for_a = " + listCode_) + ", for_i = ") + start_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name1_, ((_w1) => {
|
|
4919
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
4920
|
+
})), (() => {
|
|
4921
|
+
return ""
|
|
4922
|
+
}))) + ff_core_Option.Option_else(ff_core_Option.Option_map(name2_, ((_w1) => {
|
|
4198
4923
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
4199
4924
|
})), (() => {
|
|
4200
4925
|
return ""
|
|
4201
|
-
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_,
|
|
4926
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
4202
4927
|
return
|
|
4203
4928
|
}
|
|
4204
4929
|
}
|
|
4205
|
-
|
|
4930
|
+
}
|
|
4931
|
+
{
|
|
4932
|
+
const n_ = _1;
|
|
4933
|
+
const _guard2 = ((((n_ === "ff:core/List.List_each") || (n_ === "ff:core/List.List_eachWhile")) || (n_ === "ff:core/Array.Array_each")) || (n_ === "ff:core/Array.Array_eachWhile"));
|
|
4934
|
+
if(_guard2) {
|
|
4206
4935
|
const _guard1 = arguments_;
|
|
4207
4936
|
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
4208
4937
|
const list_ = _guard1[0];
|
|
4209
4938
|
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
4210
|
-
const
|
|
4211
|
-
const
|
|
4212
|
-
|
|
4939
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
4940
|
+
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, "for_a", list_, async_);
|
|
4941
|
+
const start_ = fusion_.second_.first_;
|
|
4942
|
+
const end_ = fusion_.second_.second_;
|
|
4943
|
+
const listCode_ = (fusion_.first_ + (ff_core_String.String_startsWith(n_, "ff:core/Array.", 0)
|
|
4944
|
+
? ".array"
|
|
4945
|
+
: ""));
|
|
4946
|
+
return ff_core_Option.Some(((((((((("for(let for_a = " + listCode_) + ", for_i = ") + start_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
4213
4947
|
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
4214
4948
|
})), (() => {
|
|
4215
4949
|
return ""
|
|
4216
|
-
}))) +
|
|
4950
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, ff_core_String.String_endsWith(n_, "eachWhile"), async_)) + "\n}"))
|
|
4217
4951
|
return
|
|
4218
4952
|
}
|
|
4219
4953
|
}
|
|
4954
|
+
}
|
|
4220
4955
|
if(_1 === "ff:core/Array.Array_push") {
|
|
4221
4956
|
const _guard1 = arguments_;
|
|
4222
4957
|
if(_guard1.length === 2) {
|
|
@@ -4232,7 +4967,7 @@ const condition_ = _guard1[0];
|
|
|
4232
4967
|
const body_ = _guard1[1];
|
|
4233
4968
|
return ff_core_Option.Some(((("if(" + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") {\n") + (last_
|
|
4234
4969
|
? (("return ff_core_Option.Some(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), async_)) + ")\n} else return ff_core_Option.None()")
|
|
4235
|
-
: (ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, async_) + "\n}"))))
|
|
4970
|
+
: (ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), false, false, async_) + "\n}"))))
|
|
4236
4971
|
return
|
|
4237
4972
|
}
|
|
4238
4973
|
}
|
|
@@ -4274,12 +5009,23 @@ const code_ = _guard1.value_;
|
|
|
4274
5009
|
return ff_core_Option.Some(code_)
|
|
4275
5010
|
}
|
|
4276
5011
|
}
|
|
4277
|
-
if(_1 === "ff:core/
|
|
5012
|
+
if(_1 === "ff:core/Js.throwIfCancelled") {
|
|
4278
5013
|
return ff_core_Option.Some((async_
|
|
4279
5014
|
? "ff_core_Task.Task_throwIfAborted($task)"
|
|
4280
5015
|
: ""))
|
|
4281
5016
|
return
|
|
4282
5017
|
}
|
|
5018
|
+
if(_1 === "ff:core/Js.throw") {
|
|
5019
|
+
const _guard2 = term_;
|
|
5020
|
+
if(_guard2.ECall) {
|
|
5021
|
+
const c_ = _guard2;
|
|
5022
|
+
const _guard1 = c_.arguments_;
|
|
5023
|
+
if(_guard1.length === 1) {
|
|
5024
|
+
const argument_ = _guard1[0];
|
|
5025
|
+
return ff_core_Option.Some(("throw " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, argument_.value_, async_)))
|
|
5026
|
+
}
|
|
5027
|
+
}
|
|
5028
|
+
}
|
|
4283
5029
|
if(_1 === "ff:core/JsValue.JsValue_set") {
|
|
4284
5030
|
const _guard1 = arguments_;
|
|
4285
5031
|
if(_guard1.length === 3) {
|
|
@@ -4355,15 +5101,51 @@ return ff_core_Option.Some(((s_ + " -= ") + ff_compiler_JsEmitter.JsEmitter_emit
|
|
|
4355
5101
|
}
|
|
4356
5102
|
}
|
|
4357
5103
|
}
|
|
5104
|
+
if(_1 === "ff:core/Js.set") {
|
|
5105
|
+
const _guard2 = arguments_;
|
|
5106
|
+
if(_guard2.length === 2 && _guard2[0].EString) {
|
|
5107
|
+
const q_ = _guard2[0].value_;
|
|
5108
|
+
const e2_ = _guard2[1];
|
|
5109
|
+
const _guard1 = ff_compiler_JsEmitter.safeBare_(q_);
|
|
5110
|
+
if(_guard1.Some) {
|
|
5111
|
+
const s_ = _guard1.value_;
|
|
5112
|
+
return ff_core_Option.Some(((s_ + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)))
|
|
5113
|
+
}
|
|
5114
|
+
}
|
|
5115
|
+
}
|
|
5116
|
+
if(_1 === "ff:core/Js.increment") {
|
|
5117
|
+
const _guard2 = arguments_;
|
|
5118
|
+
if(_guard2.length === 2 && _guard2[0].EString) {
|
|
5119
|
+
const q_ = _guard2[0].value_;
|
|
5120
|
+
const e2_ = _guard2[1];
|
|
5121
|
+
const _guard1 = ff_compiler_JsEmitter.safeBare_(q_);
|
|
5122
|
+
if(_guard1.Some) {
|
|
5123
|
+
const s_ = _guard1.value_;
|
|
5124
|
+
return ff_core_Option.Some(((s_ + " += ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)))
|
|
5125
|
+
}
|
|
5126
|
+
}
|
|
5127
|
+
}
|
|
5128
|
+
if(_1 === "ff:core/Js.decrement") {
|
|
5129
|
+
const _guard2 = arguments_;
|
|
5130
|
+
if(_guard2.length === 2 && _guard2[0].EString) {
|
|
5131
|
+
const q_ = _guard2[0].value_;
|
|
5132
|
+
const e2_ = _guard2[1];
|
|
5133
|
+
const _guard1 = ff_compiler_JsEmitter.safeBare_(q_);
|
|
5134
|
+
if(_guard1.Some) {
|
|
5135
|
+
const s_ = _guard1.value_;
|
|
5136
|
+
return ff_core_Option.Some(((s_ + " -= ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e2_, async_)))
|
|
5137
|
+
}
|
|
5138
|
+
}
|
|
5139
|
+
}
|
|
4358
5140
|
{
|
|
4359
5141
|
return ff_core_Option.None()
|
|
4360
5142
|
}
|
|
4361
5143
|
}
|
|
4362
5144
|
}
|
|
4363
5145
|
|
|
4364
|
-
export async function JsEmitter_emitLightFusion$(self_, list_, async_, $task) {
|
|
5146
|
+
export async function JsEmitter_emitLightFusion$(self_, listName_, list_, async_, $task) {
|
|
4365
5147
|
let start_ = "0";
|
|
4366
|
-
let end_ = "
|
|
5148
|
+
let end_ = (listName_ + ".length");
|
|
4367
5149
|
const listCode_ = (((_1) => {
|
|
4368
5150
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
4369
5151
|
const a1_ = _1.arguments_[0];
|
|
@@ -4398,7 +5180,7 @@ return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
|
4398
5180
|
})))) {
|
|
4399
5181
|
end_ = (("Math.max(" + end_) + ", 0)")
|
|
4400
5182
|
};
|
|
4401
|
-
end_ = (("Math.min(" + end_) + ",
|
|
5183
|
+
end_ = (((("Math.min(" + end_) + ", ") + listName_) + ".length)");
|
|
4402
5184
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
4403
5185
|
}
|
|
4404
5186
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_takeLast" && _1.arguments_.length === 2) {
|
|
@@ -4408,9 +5190,9 @@ const count_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async
|
|
|
4408
5190
|
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
4409
5191
|
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4410
5192
|
})))) {
|
|
4411
|
-
start_ = (("Math.max(
|
|
5193
|
+
start_ = (((("Math.max(" + listName_) + ".length - Math.max(") + count_) + ", 0), 0)")
|
|
4412
5194
|
} else {
|
|
4413
|
-
start_ = (("Math.max(
|
|
5195
|
+
start_ = (((("Math.max(" + listName_) + ".length - ") + count_) + ", 0)")
|
|
4414
5196
|
};
|
|
4415
5197
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
4416
5198
|
}
|
|
@@ -4430,12 +5212,17 @@ const arguments_ = ["_exception.value_", "_error"];
|
|
|
4430
5212
|
const _1 = cases_;
|
|
4431
5213
|
if(_1.length === 1) {
|
|
4432
5214
|
const case_ = _1[0];
|
|
4433
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, case_, [], [], false, last_, catchAsync_)
|
|
5215
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, case_, [], [], false, last_, false, true, catchAsync_)
|
|
4434
5216
|
}
|
|
4435
5217
|
{
|
|
4436
5218
|
const cs_ = _1;
|
|
4437
|
-
const caseStrings_ = ff_core_List.List_map(cases_, ((
|
|
4438
|
-
|
|
5219
|
+
const caseStrings_ = ff_core_List.List_map(ff_core_List.List_pairs(cases_), ((_1) => {
|
|
5220
|
+
{
|
|
5221
|
+
const i_ = _1.first_;
|
|
5222
|
+
const c_ = _1.second_;
|
|
5223
|
+
const lastCase_ = (i_ === (cases_.length - 1));
|
|
5224
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, c_, [], [], true, last_, false, lastCase_, catchAsync_)
|
|
5225
|
+
}
|
|
4439
5226
|
}));
|
|
4440
5227
|
if(last_) {
|
|
4441
5228
|
return ff_core_List.List_join(caseStrings_, "\n")
|
|
@@ -4455,7 +5242,21 @@ const finallyEffect_ = _1.arguments_[1].value_.lambda_.effect_;
|
|
|
4455
5242
|
const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
|
|
4456
5243
|
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
4457
5244
|
const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
|
|
4458
|
-
return ff_core_Option.Some((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, tryAsync_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, finallyAsync_)) + "\n}"))
|
|
5245
|
+
return ff_core_Option.Some((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, false, finallyAsync_)) + "\n}"))
|
|
5246
|
+
}
|
|
5247
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catchAny" && _1.arguments_.length === 2 && _1.arguments_[0].value_.ECall && _1.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.target_.name_ === "ff:core/Core.try" && _1.arguments_[0].value_.arguments_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.ELambda && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0 && _1.arguments_[1].value_.ELambda && _1.arguments_[1].value_.lambda_.cases_.length === 1 && _1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 1 && _1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].PVariable && _1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
|
|
5248
|
+
const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
|
|
5249
|
+
const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
|
|
5250
|
+
const catchEffect_ = _1.arguments_[1].value_.lambda_.effect_;
|
|
5251
|
+
const name_ = _1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].name_;
|
|
5252
|
+
const catchBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
|
|
5253
|
+
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
5254
|
+
return ff_core_Option.Some((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} catch") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
5255
|
+
return (("(" + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + ")")
|
|
5256
|
+
})), (() => {
|
|
5257
|
+
return ""
|
|
5258
|
+
}))) + " {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, catchBody_, last_, false, tryAsync_)) + "\n}"))
|
|
5259
|
+
return
|
|
4459
5260
|
}
|
|
4460
5261
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catch" && _1.arguments_.length === 2 && _1.arguments_[0].value_.ECall && _1.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.target_.name_ === "ff:core/Core.try" && _1.arguments_[0].value_.arguments_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.ELambda && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0 && _1.arguments_[1].value_.ELambda && _1.dictionaries_.length === 1) {
|
|
4461
5262
|
const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
|
|
@@ -4465,7 +5266,7 @@ const cases_ = _1.arguments_[1].value_.lambda_.cases_;
|
|
|
4465
5266
|
const dictionary_ = _1.dictionaries_[0];
|
|
4466
5267
|
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
4467
5268
|
const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
|
|
4468
|
-
return ff_core_Option.Some(((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n}"))
|
|
5269
|
+
return ff_core_Option.Some(((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n}"))
|
|
4469
5270
|
}
|
|
4470
5271
|
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_finally" && _1.arguments_.length === 2 && _1.arguments_[0].value_.ECall && _1.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.target_.name_ === "ff:core/Try.Try_catch" && _1.arguments_[0].value_.arguments_.length === 2 && _1.arguments_[0].value_.arguments_[0].value_.ECall && _1.arguments_[0].value_.arguments_[0].value_.target_.StaticCall && _1.arguments_[0].value_.arguments_[0].value_.target_.name_ === "ff:core/Core.try" && _1.arguments_[0].value_.arguments_[0].value_.arguments_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.ELambda && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1 && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0 && _1.arguments_[0].value_.arguments_[1].value_.ELambda && _1.arguments_[0].value_.dictionaries_.length === 1 && _1.arguments_[1].value_.ELambda && _1.arguments_[1].value_.lambda_.cases_.length === 1 && _1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 0 && _1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
|
|
4471
5272
|
const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
|
|
@@ -4478,7 +5279,7 @@ const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
|
|
|
4478
5279
|
const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
|
|
4479
5280
|
const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
|
|
4480
5281
|
const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
|
|
4481
|
-
return ff_core_Option.Some(((((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, finallyAsync_)) + "\n}"))
|
|
5282
|
+
return ff_core_Option.Some(((((((((((("try {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, tryBody_, last_, false, tryAsync_)) + "\n} catch(_error) {\n") + "if(!_error.ffException) throw _error\n") + "const _exception = ff_core_Any.fromAny_(_error.ffException, ") + d_) + ")\n") + "if(!_exception.Some) throw _error\n") + emitCatch_(catchEffect_, cases_)) + "\n} finally {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, finallyBody_, last_, false, finallyAsync_)) + "\n}"))
|
|
4482
5283
|
}
|
|
4483
5284
|
{
|
|
4484
5285
|
return ff_core_Option.None()
|
|
@@ -4486,7 +5287,7 @@ return ff_core_Option.None()
|
|
|
4486
5287
|
}
|
|
4487
5288
|
}
|
|
4488
5289
|
|
|
4489
|
-
export async function JsEmitter_emitCase$(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_, $task) {
|
|
5290
|
+
export async function JsEmitter_emitCase$(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, break_, lastCase_, async_, $task) {
|
|
4490
5291
|
function emitWrapper_(code_) {
|
|
4491
5292
|
return ((((ff_core_List.List_isEmpty(conditions_)
|
|
4492
5293
|
? "{\n"
|
|
@@ -4497,9 +5298,9 @@ const _1 = ff_core_Pair.Pair(matchCase_.patterns_, matchCase_.guards_);
|
|
|
4497
5298
|
if(_1.first_.length >= 1) {
|
|
4498
5299
|
const p_ = _1.first_[0];
|
|
4499
5300
|
const ps_ = _1.first_.slice(1);
|
|
4500
|
-
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, (arguments_[0] ?? ff_core_List.
|
|
5301
|
+
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, (arguments_[0] ?? ff_core_List.List_grab(arguments_, 0)), p_, ff_core_List.List_dropFirst(arguments_, 1), (((_c) => {
|
|
4501
5302
|
return ff_compiler_Syntax.MatchCase(_c.at_, ps_, _c.guards_, _c.body_)
|
|
4502
|
-
}))(matchCase_), conditions_, variables_, jump_, last_, async_)
|
|
5303
|
+
}))(matchCase_), conditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4503
5304
|
return
|
|
4504
5305
|
}
|
|
4505
5306
|
if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
|
|
@@ -4508,7 +5309,7 @@ if(ff_core_List.List_isEmpty(variables_)) {
|
|
|
4508
5309
|
const newCase_ = (((_c) => {
|
|
4509
5310
|
return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
|
|
4510
5311
|
}))(matchCase_);
|
|
4511
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [...conditions_, ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, async_)
|
|
5312
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [...conditions_, ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, break_, lastCase_, async_)
|
|
4512
5313
|
}
|
|
4513
5314
|
}
|
|
4514
5315
|
if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
|
|
@@ -4516,7 +5317,7 @@ const e_ = _1.second_[0].term_;
|
|
|
4516
5317
|
const newCase_ = (((_c) => {
|
|
4517
5318
|
return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
|
|
4518
5319
|
}))(matchCase_);
|
|
4519
|
-
const code_ = ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, async_);
|
|
5320
|
+
const code_ = ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, break_, lastCase_, async_);
|
|
4520
5321
|
return emitWrapper_(code_)
|
|
4521
5322
|
}
|
|
4522
5323
|
if(_1.first_.length === 0 && _1.second_.length >= 1) {
|
|
@@ -4526,45 +5327,54 @@ const guardName_ = ("_guard" + (guards_.length + 1));
|
|
|
4526
5327
|
const newCase_ = (((_c) => {
|
|
4527
5328
|
return ff_compiler_Syntax.MatchCase(_c.at_, [guard_.pattern_], guards_, _c.body_)
|
|
4528
5329
|
}))(matchCase_);
|
|
4529
|
-
const code_ = ((((("const " + guardName_) + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, guard_.term_, async_)) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [guardName_], newCase_, [], [], jump_, last_, async_));
|
|
5330
|
+
const code_ = ((((("const " + guardName_) + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, guard_.term_, async_)) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [guardName_], newCase_, [], [], jump_, last_, break_, lastCase_, async_));
|
|
4530
5331
|
return emitWrapper_(code_)
|
|
4531
5332
|
}
|
|
4532
|
-
|
|
4533
|
-
const statementsCode_ = ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, last_, async_);
|
|
5333
|
+
{
|
|
5334
|
+
const statementsCode_ = ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, last_, break_, async_);
|
|
4534
5335
|
const lastLine_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(statementsCode_), ((_w1) => {
|
|
4535
5336
|
return (_w1 !== 10)
|
|
4536
5337
|
})));
|
|
4537
5338
|
const returns_ = ((((((ff_core_String.String_startsWith(lastLine_, "return ", 0) || ff_core_String.String_startsWith(lastLine_, "break ", 0)) || ff_core_String.String_startsWith(lastLine_, "continue ", 0)) || ff_core_String.String_startsWith(lastLine_, "return;", 0)) || ff_core_String.String_startsWith(lastLine_, "break;", 0)) || ff_core_String.String_startsWith(lastLine_, "continue;", 0)) || ff_core_String.String_startsWith(lastLine_, "throw ", 0));
|
|
4538
5339
|
const code_ = (statementsCode_ + (((jump_ && last_) && (!returns_))
|
|
4539
5340
|
? "\nreturn"
|
|
4540
|
-
: (jump_ && (!returns_))
|
|
4541
|
-
?
|
|
5341
|
+
: ((jump_ && (!returns_)) && (!lastCase_))
|
|
5342
|
+
? (break_
|
|
5343
|
+
? "\ncontinue"
|
|
5344
|
+
: "\nbreak")
|
|
4542
5345
|
: ""));
|
|
4543
5346
|
return emitWrapper_(code_)
|
|
4544
5347
|
}
|
|
4545
5348
|
}
|
|
4546
5349
|
}
|
|
4547
5350
|
|
|
4548
|
-
export async function JsEmitter_emitPattern$(self_, argument_, pattern_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_, $task) {
|
|
5351
|
+
export async function JsEmitter_emitPattern$(self_, argument_, pattern_, arguments_, matchCase_, conditions_, variables_, jump_, last_, break_, lastCase_, async_, $task) {
|
|
5352
|
+
function addCondition_(condition_) {
|
|
5353
|
+
if(lastCase_) {
|
|
5354
|
+
return conditions_
|
|
5355
|
+
} else {
|
|
5356
|
+
return [...conditions_, condition_]
|
|
5357
|
+
}
|
|
5358
|
+
}
|
|
4549
5359
|
{
|
|
4550
5360
|
const _1 = pattern_;
|
|
4551
5361
|
if(_1.PString) {
|
|
4552
5362
|
const value_ = _1.value_;
|
|
4553
|
-
const newConditions_ =
|
|
4554
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
5363
|
+
const newConditions_ = addCondition_(((argument_ + " === ") + value_));
|
|
5364
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4555
5365
|
}
|
|
4556
5366
|
if(_1.PInt) {
|
|
4557
5367
|
const value_ = _1.value_;
|
|
4558
|
-
const newConditions_ =
|
|
4559
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
5368
|
+
const newConditions_ = addCondition_(((argument_ + " === ") + value_));
|
|
5369
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4560
5370
|
}
|
|
4561
5371
|
if(_1.PChar) {
|
|
4562
5372
|
const value_ = _1.value_;
|
|
4563
|
-
const newConditions_ =
|
|
4564
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
5373
|
+
const newConditions_ = addCondition_(((argument_ + " === ") + ff_compiler_JsEmitter.charLiteralToNumber_(value_)));
|
|
5374
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4565
5375
|
}
|
|
4566
5376
|
if(_1.PVariable && _1.name_.None) {
|
|
4567
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_)
|
|
5377
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4568
5378
|
}
|
|
4569
5379
|
if(_1.PVariable && _1.name_.Some) {
|
|
4570
5380
|
const name_ = _1.name_.value_;
|
|
@@ -4572,13 +5382,13 @@ const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(name_);
|
|
|
4572
5382
|
const newVariables_ = ((escaped_ !== argument_)
|
|
4573
5383
|
? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
|
|
4574
5384
|
: variables_);
|
|
4575
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_)
|
|
5385
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, break_, lastCase_, async_)
|
|
4576
5386
|
}
|
|
4577
5387
|
if(_1.PVariant && _1.name_ === "ff:core/Bool.False" && _1.patterns_.length === 0) {
|
|
4578
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_,
|
|
5388
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, addCondition_(("!" + argument_)), variables_, jump_, last_, break_, lastCase_, async_)
|
|
4579
5389
|
}
|
|
4580
5390
|
if(_1.PVariant && _1.name_ === "ff:core/Bool.True" && _1.patterns_.length === 0) {
|
|
4581
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_,
|
|
5391
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, addCondition_(argument_), variables_, jump_, last_, break_, lastCase_, async_)
|
|
4582
5392
|
}
|
|
4583
5393
|
if(_1.PVariant) {
|
|
4584
5394
|
const emptyOrLink_ = _1.name_;
|
|
@@ -4619,8 +5429,8 @@ return ">="
|
|
|
4619
5429
|
})), (() => {
|
|
4620
5430
|
return "==="
|
|
4621
5431
|
}));
|
|
4622
|
-
const newConditions_ =
|
|
4623
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
5432
|
+
const newConditions_ = addCondition_(((((argument_ + ".length ") + operator_) + " ") + patterns_.length));
|
|
5433
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4624
5434
|
}
|
|
4625
5435
|
}
|
|
4626
5436
|
if(_1.PVariant) {
|
|
@@ -4630,11 +5440,11 @@ const processed_ = ff_compiler_JsEmitter.JsEmitter_processVariantCase(self_, nam
|
|
|
4630
5440
|
const newMatchCase_ = (((_c) => {
|
|
4631
5441
|
return ff_compiler_Syntax.MatchCase(_c.at_, [...patterns_, ...matchCase_.patterns_], _c.guards_, _c.body_)
|
|
4632
5442
|
}))(matchCase_);
|
|
4633
|
-
const newConditions_ = (processed_.loneVariant_
|
|
5443
|
+
const newConditions_ = ((processed_.loneVariant_ || lastCase_)
|
|
4634
5444
|
? conditions_
|
|
4635
5445
|
: [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
|
|
4636
5446
|
const newArguments_ = [...processed_.arguments_, ...arguments_];
|
|
4637
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
|
|
5447
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, break_, lastCase_, async_)
|
|
4638
5448
|
}
|
|
4639
5449
|
if(_1.PVariantAs) {
|
|
4640
5450
|
const at_ = _1.at_;
|
|
@@ -4642,7 +5452,7 @@ const name_ = _1.name_;
|
|
|
4642
5452
|
const variableAt_ = _1.variableAt_;
|
|
4643
5453
|
const variable_ = _1.variable_;
|
|
4644
5454
|
const processed_ = ff_compiler_JsEmitter.JsEmitter_processVariantCase(self_, name_, argument_);
|
|
4645
|
-
const newConditions_ = (processed_.loneVariant_
|
|
5455
|
+
const newConditions_ = ((processed_.loneVariant_ || lastCase_)
|
|
4646
5456
|
? conditions_
|
|
4647
5457
|
: [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
|
|
4648
5458
|
const newVariables_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(ff_core_Option.Option_map(variable_, ((word_) => {
|
|
@@ -4654,16 +5464,16 @@ return [...variables_, (((("const " + _w1) + " = ") + argument_) + ";\n")]
|
|
|
4654
5464
|
})), (() => {
|
|
4655
5465
|
return []
|
|
4656
5466
|
}));
|
|
4657
|
-
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, newVariables_, jump_, last_, async_)
|
|
5467
|
+
return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, newVariables_, jump_, last_, break_, lastCase_, async_)
|
|
4658
5468
|
}
|
|
4659
|
-
|
|
5469
|
+
{
|
|
4660
5470
|
const pattern_ = _1.pattern_;
|
|
4661
5471
|
const variable_ = _1.variable_;
|
|
4662
5472
|
const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(variable_);
|
|
4663
5473
|
const newVariables_ = ((escaped_ !== argument_)
|
|
4664
5474
|
? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
|
|
4665
5475
|
: variables_);
|
|
4666
|
-
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_)
|
|
5476
|
+
return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, break_, lastCase_, async_)
|
|
4667
5477
|
}
|
|
4668
5478
|
}
|
|
4669
5479
|
}
|
|
@@ -4674,7 +5484,7 @@ if(!_1.second_) {
|
|
|
4674
5484
|
const item_ = _1.first_;
|
|
4675
5485
|
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, item_, async_)
|
|
4676
5486
|
}
|
|
4677
|
-
|
|
5487
|
+
{
|
|
4678
5488
|
const item_ = _1.first_;
|
|
4679
5489
|
return ("..." + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, item_, async_))
|
|
4680
5490
|
}
|
|
@@ -4686,7 +5496,7 @@ const variantNameUnqualified_ = ff_core_String.String_reverse(ff_core_String.Str
|
|
|
4686
5496
|
return (_w1 !== 46)
|
|
4687
5497
|
})));
|
|
4688
5498
|
const variantName_ = ff_compiler_JsEmitter.escapeKeyword_(variantNameUnqualified_);
|
|
4689
|
-
const moduleName_ = ff_core_String.String_dropLast(name_, (
|
|
5499
|
+
const moduleName_ = ff_core_String.String_dropLast(name_, (variantNameUnqualified_.length + 1));
|
|
4690
5500
|
const variantModule_ = ff_core_Map.Map_grab(self_.otherModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
4691
5501
|
let newtype_ = false;
|
|
4692
5502
|
let loneVariant_ = false;
|
|
@@ -4720,7 +5530,7 @@ const variantNameUnqualified_ = ff_core_String.String_reverse(ff_core_String.Str
|
|
|
4720
5530
|
return (_w1 !== 46)
|
|
4721
5531
|
})));
|
|
4722
5532
|
const variantName_ = ff_compiler_JsEmitter.escapeKeyword_(variantNameUnqualified_);
|
|
4723
|
-
const moduleName_ = ff_core_String.String_dropLast(name_, (
|
|
5533
|
+
const moduleName_ = ff_core_String.String_dropLast(name_, (variantNameUnqualified_.length + 1));
|
|
4724
5534
|
const variantModule_ = ff_core_Map.Map_grab(self_.otherModules_, moduleName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
4725
5535
|
let newtype_ = false;
|
|
4726
5536
|
const newArguments_ = ff_core_Option.Option_grab(ff_core_List.List_collectFirst(variantModule_.types_, ((definition_) => {
|
|
@@ -4756,7 +5566,7 @@ const before2_ = _1.before_.before_.after_;
|
|
|
4756
5566
|
const before3_ = _1.before_.after_;
|
|
4757
5567
|
const after_ = _1.after_;
|
|
4758
5568
|
if((((ff_compiler_JsEmitter.safeCommable_(before1_) && ff_compiler_JsEmitter.safeCommable_(before2_)) && ff_compiler_JsEmitter.safeCommable_(before3_)) && ff_compiler_JsEmitter.safeCommable_(after_))) {
|
|
4759
|
-
return (((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before3_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
5569
|
+
return (((((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before3_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
4760
5570
|
}
|
|
4761
5571
|
}
|
|
4762
5572
|
if(_1.ESequential && _1.before_.ESequential) {
|
|
@@ -4764,14 +5574,14 @@ const before1_ = _1.before_.before_;
|
|
|
4764
5574
|
const before2_ = _1.before_.after_;
|
|
4765
5575
|
const after_ = _1.after_;
|
|
4766
5576
|
if(((ff_compiler_JsEmitter.safeCommable_(before1_) && ff_compiler_JsEmitter.safeCommable_(before2_)) && ff_compiler_JsEmitter.safeCommable_(after_))) {
|
|
4767
|
-
return (((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
5577
|
+
return (((((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before1_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before2_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
4768
5578
|
}
|
|
4769
5579
|
}
|
|
4770
5580
|
if(_1.ESequential) {
|
|
4771
5581
|
const before_ = _1.before_;
|
|
4772
5582
|
const after_ = _1.after_;
|
|
4773
5583
|
if((ff_compiler_JsEmitter.safeCommable_(before_) && ff_compiler_JsEmitter.safeCommable_(after_))) {
|
|
4774
|
-
return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
5584
|
+
return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, false, async_)) + ", ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, after_, async_)) + ")")
|
|
4775
5585
|
}
|
|
4776
5586
|
}
|
|
4777
5587
|
{
|
|
@@ -4813,7 +5623,7 @@ if(value_a.EmitBuild) {
|
|
|
4813
5623
|
const z_ = value_a;
|
|
4814
5624
|
return "EmitBuild"
|
|
4815
5625
|
}
|
|
4816
|
-
|
|
5626
|
+
{
|
|
4817
5627
|
const z_ = value_a;
|
|
4818
5628
|
return "EmitExecutable"
|
|
4819
5629
|
}
|
|
@@ -4832,7 +5642,7 @@ if(value_a.EmitBuild) {
|
|
|
4832
5642
|
const z_ = value_a;
|
|
4833
5643
|
return "EmitBuild"
|
|
4834
5644
|
}
|
|
4835
|
-
|
|
5645
|
+
{
|
|
4836
5646
|
const z_ = value_a;
|
|
4837
5647
|
return "EmitExecutable"
|
|
4838
5648
|
}
|
|
@@ -4921,7 +5731,7 @@ return 1
|
|
|
4921
5731
|
if(z_a.EmitBuild) {
|
|
4922
5732
|
return 2
|
|
4923
5733
|
}
|
|
4924
|
-
|
|
5734
|
+
{
|
|
4925
5735
|
return 3
|
|
4926
5736
|
}
|
|
4927
5737
|
}
|
|
@@ -4946,7 +5756,7 @@ return 1
|
|
|
4946
5756
|
if(z_a.EmitBuild) {
|
|
4947
5757
|
return 2
|
|
4948
5758
|
}
|
|
4949
|
-
|
|
5759
|
+
{
|
|
4950
5760
|
return 3
|
|
4951
5761
|
}
|
|
4952
5762
|
}
|
|
@@ -5048,7 +5858,7 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 2
|
|
|
5048
5858
|
serialization_.offset_ += 1
|
|
5049
5859
|
return
|
|
5050
5860
|
}
|
|
5051
|
-
|
|
5861
|
+
{
|
|
5052
5862
|
const v_ = value_a;
|
|
5053
5863
|
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 36), 0);
|
|
5054
5864
|
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|
|
@@ -5110,7 +5920,7 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 2
|
|
|
5110
5920
|
serialization_.offset_ += 1
|
|
5111
5921
|
return
|
|
5112
5922
|
}
|
|
5113
|
-
|
|
5923
|
+
{
|
|
5114
5924
|
const v_ = value_a;
|
|
5115
5925
|
serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 36), 0);
|
|
5116
5926
|
ff_core_Serializable.Serialization_autoResize(serialization_, 1);
|