firefly-compiler 0.4.19 → 0.4.21

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.
Files changed (68) hide show
  1. package/compiler/Builder.ff +23 -13
  2. package/compiler/JsEmitter.ff +120 -76
  3. package/compiler/LspHook.ff +17 -3
  4. package/compiler/Main.ff +13 -7
  5. package/compiler/Parser.ff +11 -13
  6. package/compiler/Resolver.ff +15 -15
  7. package/compiler/Syntax.ff +1 -0
  8. package/core/Array.ff +6 -4
  9. package/core/Int.ff +12 -12
  10. package/core/Json.ff +2 -2
  11. package/core/List.ff +6 -4
  12. package/experimental/benchmarks/ListGrab.ff +23 -0
  13. package/experimental/benchmarks/ListGrab.java +55 -0
  14. package/experimental/benchmarks/Pyrotek45.ff +30 -0
  15. package/experimental/benchmarks/Pyrotek45.java +64 -0
  16. package/experimental/tests/TestJson.ff +26 -0
  17. package/lsp/CompletionHandler.ff +14 -14
  18. package/lsp/Handler.ff +56 -60
  19. package/lsp/SignatureHelpHandler.ff +5 -4
  20. package/lsp/SymbolHandler.ff +18 -4
  21. package/lsp/TestReferences.ff +15 -0
  22. package/lsp/TestReferencesCase.ff +8 -0
  23. package/output/js/ff/compiler/Builder.mjs +50 -44
  24. package/output/js/ff/compiler/Dependencies.mjs +0 -2
  25. package/output/js/ff/compiler/Deriver.mjs +16 -140
  26. package/output/js/ff/compiler/Dictionaries.mjs +8 -222
  27. package/output/js/ff/compiler/Environment.mjs +12 -154
  28. package/output/js/ff/compiler/Inference.mjs +127 -1013
  29. package/output/js/ff/compiler/JsEmitter.mjs +434 -2344
  30. package/output/js/ff/compiler/JsImporter.mjs +0 -12
  31. package/output/js/ff/compiler/LspHook.mjs +548 -151
  32. package/output/js/ff/compiler/Main.mjs +96 -550
  33. package/output/js/ff/compiler/Parser.mjs +58 -390
  34. package/output/js/ff/compiler/Patterns.mjs +20 -200
  35. package/output/js/ff/compiler/Resolver.mjs +26 -340
  36. package/output/js/ff/compiler/Substitution.mjs +2 -160
  37. package/output/js/ff/compiler/Syntax.mjs +449 -3293
  38. package/output/js/ff/compiler/Token.mjs +9 -1095
  39. package/output/js/ff/compiler/Tokenizer.mjs +4 -2
  40. package/output/js/ff/compiler/Unification.mjs +26 -360
  41. package/output/js/ff/compiler/Wildcards.mjs +0 -86
  42. package/output/js/ff/compiler/Workspace.mjs +8 -96
  43. package/output/js/ff/core/Array.mjs +15 -8
  44. package/output/js/ff/core/AssetSystem.mjs +4 -14
  45. package/output/js/ff/core/Bool.mjs +0 -12
  46. package/output/js/ff/core/Core.mjs +0 -30
  47. package/output/js/ff/core/Int.mjs +24 -24
  48. package/output/js/ff/core/IntMap.mjs +0 -8
  49. package/output/js/ff/core/Json.mjs +2 -42
  50. package/output/js/ff/core/List.mjs +23 -32
  51. package/output/js/ff/core/Lock.mjs +0 -10
  52. package/output/js/ff/core/Map.mjs +0 -24
  53. package/output/js/ff/core/Option.mjs +10 -286
  54. package/output/js/ff/core/Ordering.mjs +16 -158
  55. package/output/js/ff/core/Pair.mjs +2 -34
  56. package/output/js/ff/core/Path.mjs +2 -28
  57. package/output/js/ff/core/Random.mjs +4 -4
  58. package/output/js/ff/core/RbMap.mjs +56 -644
  59. package/output/js/ff/core/Show.mjs +0 -16
  60. package/output/js/ff/core/Stream.mjs +14 -144
  61. package/output/js/ff/core/StringMap.mjs +0 -8
  62. package/output/js/ff/core/Try.mjs +4 -108
  63. package/output/js/ff/core/Unit.mjs +2 -16
  64. package/package.json +1 -1
  65. package/postgresql/Pg.ff +23 -23
  66. package/vscode/client/src/extension.ts +30 -2
  67. package/vscode/package.json +17 -1
  68. package/core/Stack.ff +0 -250
@@ -140,39 +140,18 @@ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(
140
140
  }
141
141
 
142
142
  export function detectIfElse_(term_) {
143
- {
144
143
  const term_a = term_;
145
- {
146
- if(term_a.ECall) {
144
+ if(term_a.ECall && term_a.target_.StaticCall && term_a.target_.name_ === "ff:core/Core.if" && term_a.arguments_.length === 2) {
147
145
  const at_ = term_a.at_;
148
- if(term_a.target_.StaticCall) {
149
- if(term_a.target_.name_ === "ff:core/Core.if") {
150
- if(term_a.arguments_.length > 0) {
151
146
  const condition_ = term_a.arguments_[0];
152
- if(term_a.arguments_.length > 1) {
153
147
  const body_ = term_a.arguments_[1];
154
- if(term_a.arguments_.length === 2) {
155
148
  return [ff_core_Pair.Pair(condition_.value_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_))]
156
- return
157
- }
158
- }
159
- }
160
- }
161
- }
162
149
  }
163
- }
164
- {
165
- if(term_a.ECall) {
150
+ if(term_a.ECall && term_a.target_.StaticCall && term_a.target_.name_ === "ff:core/Option.Option_elseIf" && term_a.arguments_.length === 3) {
166
151
  const at_ = term_a.at_;
167
- if(term_a.target_.StaticCall) {
168
- if(term_a.target_.name_ === "ff:core/Option.Option_elseIf") {
169
- if(term_a.arguments_.length > 0) {
170
152
  const option_ = term_a.arguments_[0];
171
- if(term_a.arguments_.length > 1) {
172
153
  const condition_ = term_a.arguments_[1];
173
- if(term_a.arguments_.length > 2) {
174
154
  const body_ = term_a.arguments_[2];
175
- if(term_a.arguments_.length === 3) {
176
155
  const list_ = ff_compiler_JsEmitter.detectIfElse_(option_.value_);
177
156
  if(ff_core_List.List_isEmpty(list_)) {
178
157
  return []
@@ -181,23 +160,10 @@ return [ff_core_Pair.Pair(ff_compiler_JsEmitter.invokeImmediately_(condition_.va
181
160
  }
182
161
  return
183
162
  }
184
- }
185
- }
186
- }
187
- }
188
- }
189
- }
190
- }
191
- {
192
- if(term_a.ECall) {
163
+ if(term_a.ECall && term_a.target_.StaticCall && term_a.target_.name_ === "ff:core/Option.Option_else" && term_a.arguments_.length === 2) {
193
164
  const at_ = term_a.at_;
194
- if(term_a.target_.StaticCall) {
195
- if(term_a.target_.name_ === "ff:core/Option.Option_else") {
196
- if(term_a.arguments_.length > 0) {
197
165
  const option_ = term_a.arguments_[0];
198
- if(term_a.arguments_.length > 1) {
199
166
  const body_ = term_a.arguments_[1];
200
- if(term_a.arguments_.length === 2) {
201
167
  const list_ = ff_compiler_JsEmitter.detectIfElse_(option_.value_);
202
168
  if(ff_core_List.List_isEmpty(list_)) {
203
169
  return []
@@ -206,82 +172,46 @@ return [ff_core_Pair.Pair(ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True",
206
172
  }
207
173
  return
208
174
  }
209
- }
210
- }
211
- }
212
- }
213
- }
214
- }
215
175
  {
216
176
  return []
217
- return
218
- }
219
177
  }
220
178
  }
221
179
 
222
180
  export function invokeImmediately_(function_) {
223
- {
224
181
  const function_a = function_;
225
- {
226
- if(function_a.ELambda) {
182
+ if(function_a.ELambda && function_a.lambda_.cases_.length === 1 && function_a.lambda_.cases_[0].patterns_.length === 0 && function_a.lambda_.cases_[0].guards_.length === 0) {
227
183
  const effect_ = function_a.lambda_.effect_;
228
- if(function_a.lambda_.cases_.length > 0) {
229
- if(function_a.lambda_.cases_[0].patterns_.length === 0) {
230
- if(function_a.lambda_.cases_[0].guards_.length === 0) {
231
184
  const body_ = function_a.lambda_.cases_[0].body_;
232
- if(function_a.lambda_.cases_.length === 1) {
233
185
  return body_
234
- return
235
- }
236
- }
237
- }
238
- }
239
- }
240
186
  }
241
187
  {
242
188
  const effect_ = ff_compiler_Syntax.TConstructor(function_.at_, "Q$", []);
243
189
  return ff_compiler_Syntax.ECall(function_.at_, ff_compiler_Syntax.DynamicCall(function_, false), effect_, [], [], [])
244
- return
245
- }
246
190
  }
247
191
  }
248
192
 
249
193
  export function extractTypeName_(type_) {
250
- {
251
194
  const type_a = type_;
252
- {
253
195
  if(type_a.TVariable) {
254
196
  const at_ = type_a.at_;
255
197
  const index_ = type_a.index_;
256
198
  return ff_compiler_JsEmitter.fail_(at_, ("Unexpected type variable: $" + index_))
257
- return
258
- }
259
199
  }
260
- {
261
200
  if(type_a.TConstructor) {
262
201
  const t_ = type_a;
263
202
  return t_.name_
264
- return
265
- }
266
- }
267
203
  }
268
204
  }
269
205
 
270
206
  export function firstTypeName_(types_) {
271
207
  return (((_1) => {
272
- {
273
208
  if(_1.TConstructor) {
274
209
  const t_ = _1;
275
210
  return t_
276
- return
277
211
  }
278
- }
279
- {
280
212
  if(_1.TVariable) {
281
213
  const t_ = _1;
282
214
  return ff_compiler_JsEmitter.fail_(t_.at_, " is still a unification variable")
283
- return
284
- }
285
215
  }
286
216
  }))(ff_core_List.List_grabFirst(types_)).name_
287
217
  }
@@ -291,43 +221,25 @@ return ((ff_core_String.String_replace(ff_core_String.String_replace(ff_core_Str
291
221
  }
292
222
 
293
223
  export function charLiteralToNumber_(charLiteral_) {
294
- {
295
224
  const charLiteral_a = charLiteral_;
296
- {
297
225
  if(charLiteral_a === "'\\t'") {
298
226
  return "9"
299
- return
300
- }
301
227
  }
302
- {
303
228
  if(charLiteral_a === "'\\n'") {
304
229
  return "10"
305
- return
306
230
  }
307
- }
308
- {
309
231
  if(charLiteral_a === "'\\r'") {
310
232
  return "13"
311
- return
312
- }
313
233
  }
314
- {
315
234
  if(charLiteral_a === "'\\\"'") {
316
235
  return "34"
317
- return
318
236
  }
319
- }
320
- {
321
237
  if(charLiteral_a === "'\\''") {
322
238
  return "39"
323
- return
324
- }
325
239
  }
326
240
  {
327
241
  const value_ = charLiteral_a;
328
242
  return ("" + ff_core_String.String_grab(value_, 1))
329
- return
330
- }
331
243
  }
332
244
  }
333
245
 
@@ -350,20 +262,12 @@ return word_
350
262
  }
351
263
 
352
264
  export function effectTypeIsAsync_(effect_) {
353
- {
354
265
  const effect_a = effect_;
355
- {
356
- if(effect_a.TConstructor) {
357
- if(effect_a.name_ === "Q$") {
266
+ if(effect_a.TConstructor && effect_a.name_ === "Q$") {
358
267
  return true
359
- return
360
- }
361
- }
362
268
  }
363
269
  {
364
270
  return false
365
- return
366
- }
367
271
  }
368
272
  }
369
273
 
@@ -379,39 +283,18 @@ return ff_core_Core.panic_(((message_ + " ") + ff_compiler_Syntax.Location_show(
379
283
  }
380
284
 
381
285
  export async function detectIfElse_$(term_, $task) {
382
- {
383
286
  const term_a = term_;
384
- {
385
- if(term_a.ECall) {
287
+ if(term_a.ECall && term_a.target_.StaticCall && term_a.target_.name_ === "ff:core/Core.if" && term_a.arguments_.length === 2) {
386
288
  const at_ = term_a.at_;
387
- if(term_a.target_.StaticCall) {
388
- if(term_a.target_.name_ === "ff:core/Core.if") {
389
- if(term_a.arguments_.length > 0) {
390
289
  const condition_ = term_a.arguments_[0];
391
- if(term_a.arguments_.length > 1) {
392
290
  const body_ = term_a.arguments_[1];
393
- if(term_a.arguments_.length === 2) {
394
291
  return [ff_core_Pair.Pair(condition_.value_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_))]
395
- return
396
- }
397
- }
398
292
  }
399
- }
400
- }
401
- }
402
- }
403
- {
404
- if(term_a.ECall) {
293
+ if(term_a.ECall && term_a.target_.StaticCall && term_a.target_.name_ === "ff:core/Option.Option_elseIf" && term_a.arguments_.length === 3) {
405
294
  const at_ = term_a.at_;
406
- if(term_a.target_.StaticCall) {
407
- if(term_a.target_.name_ === "ff:core/Option.Option_elseIf") {
408
- if(term_a.arguments_.length > 0) {
409
295
  const option_ = term_a.arguments_[0];
410
- if(term_a.arguments_.length > 1) {
411
296
  const condition_ = term_a.arguments_[1];
412
- if(term_a.arguments_.length > 2) {
413
297
  const body_ = term_a.arguments_[2];
414
- if(term_a.arguments_.length === 3) {
415
298
  const list_ = ff_compiler_JsEmitter.detectIfElse_(option_.value_);
416
299
  if(ff_core_List.List_isEmpty(list_)) {
417
300
  return []
@@ -420,23 +303,10 @@ return [ff_core_Pair.Pair(ff_compiler_JsEmitter.invokeImmediately_(condition_.va
420
303
  }
421
304
  return
422
305
  }
423
- }
424
- }
425
- }
426
- }
427
- }
428
- }
429
- }
430
- {
431
- if(term_a.ECall) {
306
+ if(term_a.ECall && term_a.target_.StaticCall && term_a.target_.name_ === "ff:core/Option.Option_else" && term_a.arguments_.length === 2) {
432
307
  const at_ = term_a.at_;
433
- if(term_a.target_.StaticCall) {
434
- if(term_a.target_.name_ === "ff:core/Option.Option_else") {
435
- if(term_a.arguments_.length > 0) {
436
308
  const option_ = term_a.arguments_[0];
437
- if(term_a.arguments_.length > 1) {
438
309
  const body_ = term_a.arguments_[1];
439
- if(term_a.arguments_.length === 2) {
440
310
  const list_ = ff_compiler_JsEmitter.detectIfElse_(option_.value_);
441
311
  if(ff_core_List.List_isEmpty(list_)) {
442
312
  return []
@@ -445,82 +315,46 @@ return [ff_core_Pair.Pair(ff_compiler_Syntax.EVariant(at_, "ff:core/Bool.True",
445
315
  }
446
316
  return
447
317
  }
448
- }
449
- }
450
- }
451
- }
452
- }
453
- }
454
318
  {
455
319
  return []
456
- return
457
- }
458
320
  }
459
321
  }
460
322
 
461
323
  export async function invokeImmediately_$(function_, $task) {
462
- {
463
324
  const function_a = function_;
464
- {
465
- if(function_a.ELambda) {
325
+ if(function_a.ELambda && function_a.lambda_.cases_.length === 1 && function_a.lambda_.cases_[0].patterns_.length === 0 && function_a.lambda_.cases_[0].guards_.length === 0) {
466
326
  const effect_ = function_a.lambda_.effect_;
467
- if(function_a.lambda_.cases_.length > 0) {
468
- if(function_a.lambda_.cases_[0].patterns_.length === 0) {
469
- if(function_a.lambda_.cases_[0].guards_.length === 0) {
470
327
  const body_ = function_a.lambda_.cases_[0].body_;
471
- if(function_a.lambda_.cases_.length === 1) {
472
328
  return body_
473
- return
474
- }
475
- }
476
- }
477
- }
478
- }
479
329
  }
480
330
  {
481
331
  const effect_ = ff_compiler_Syntax.TConstructor(function_.at_, "Q$", []);
482
332
  return ff_compiler_Syntax.ECall(function_.at_, ff_compiler_Syntax.DynamicCall(function_, false), effect_, [], [], [])
483
- return
484
- }
485
333
  }
486
334
  }
487
335
 
488
336
  export async function extractTypeName_$(type_, $task) {
489
- {
490
337
  const type_a = type_;
491
- {
492
338
  if(type_a.TVariable) {
493
339
  const at_ = type_a.at_;
494
340
  const index_ = type_a.index_;
495
341
  return ff_compiler_JsEmitter.fail_(at_, ("Unexpected type variable: $" + index_))
496
- return
497
342
  }
498
- }
499
- {
500
343
  if(type_a.TConstructor) {
501
344
  const t_ = type_a;
502
345
  return t_.name_
503
- return
504
- }
505
- }
506
346
  }
507
347
  }
508
348
 
509
349
  export async function firstTypeName_$(types_, $task) {
510
350
  return (((_1) => {
511
- {
512
351
  if(_1.TConstructor) {
513
352
  const t_ = _1;
514
353
  return t_
515
- return
516
- }
517
354
  }
518
- {
519
355
  if(_1.TVariable) {
520
356
  const t_ = _1;
521
357
  return ff_compiler_JsEmitter.fail_(t_.at_, " is still a unification variable")
522
- return
523
- }
524
358
  }
525
359
  }))(ff_core_List.List_grabFirst(types_)).name_
526
360
  }
@@ -530,43 +364,25 @@ return ((ff_core_String.String_replace(ff_core_String.String_replace(ff_core_Str
530
364
  }
531
365
 
532
366
  export async function charLiteralToNumber_$(charLiteral_, $task) {
533
- {
534
367
  const charLiteral_a = charLiteral_;
535
- {
536
368
  if(charLiteral_a === "'\\t'") {
537
369
  return "9"
538
- return
539
370
  }
540
- }
541
- {
542
371
  if(charLiteral_a === "'\\n'") {
543
372
  return "10"
544
- return
545
- }
546
373
  }
547
- {
548
374
  if(charLiteral_a === "'\\r'") {
549
375
  return "13"
550
- return
551
376
  }
552
- }
553
- {
554
377
  if(charLiteral_a === "'\\\"'") {
555
378
  return "34"
556
- return
557
- }
558
379
  }
559
- {
560
380
  if(charLiteral_a === "'\\''") {
561
381
  return "39"
562
- return
563
- }
564
382
  }
565
383
  {
566
384
  const value_ = charLiteral_a;
567
385
  return ("" + ff_core_String.String_grab(value_, 1))
568
- return
569
- }
570
386
  }
571
387
  }
572
388
 
@@ -589,20 +405,12 @@ return word_
589
405
  }
590
406
 
591
407
  export async function effectTypeIsAsync_$(effect_, $task) {
592
- {
593
408
  const effect_a = effect_;
594
- {
595
- if(effect_a.TConstructor) {
596
- if(effect_a.name_ === "Q$") {
409
+ if(effect_a.TConstructor && effect_a.name_ === "Q$") {
597
410
  return true
598
- return
599
- }
600
- }
601
411
  }
602
412
  {
603
413
  return false
604
- return
605
- }
606
414
  }
607
415
  }
608
416
 
@@ -689,30 +497,17 @@ return [ff_core_List.List_join(["export async function $run$(fireflyPath_, argum
689
497
  : []), "} finally {", ...(ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget)
690
498
  ? ["ff_core_Task.Task_abort$($task)", "clearInterval(interval)"]
691
499
  : []), "}", "}", ...(((_1) => {
692
- {
693
500
  if(_1.EmitBrowser) {
694
501
  return ["queueMicrotask(async () => {", "await $run$(null, [])", "})"]
695
- return
696
502
  }
697
- }
698
- {
699
- if(_1.EmitNode) {
700
- const _guard1 = bootstrapping_;
701
- if(_guard1) {
503
+ if(_1.EmitNode && bootstrapping_) {
702
504
  return ["import * as path from 'node:path'", "queueMicrotask(async () => {", "let fireflyPath_ = path.dirname(path.dirname(path.dirname(path.dirname(path.dirname(process.argv[1])))))", "await $run$(fireflyPath_, process.argv.slice(2))", "})"]
703
- return
704
- }
705
505
  }
706
- }
707
- {
708
506
  if(_1.EmitExecutable) {
709
507
  return ["queueMicrotask(async () => {", "await $run$(null, process.argv.slice(2))", "})"]
710
- return
711
- }
712
508
  }
713
509
  {
714
510
  return []
715
- return
716
511
  }
717
512
  }))(self_.emitTarget_)], "\n")]
718
513
  })), (() => {
@@ -776,11 +571,8 @@ return ("async " + ff_core_String.String_dropFirst(_w1, ff_core_String.String_si
776
571
  const body_ = (("{\n" + ff_core_List.List_join([...methods_, ...asyncMethods_], ",\n")) + "\n}");
777
572
  {
778
573
  const _1 = definition_.constraints_;
779
- {
780
574
  if(_1.length === 0) {
781
575
  return (((("export const " + name_) + " = ") + body_) + ";")
782
- return
783
- }
784
576
  }
785
577
  {
786
578
  const constraints_ = _1;
@@ -788,7 +580,6 @@ const dictionaries_ = ff_core_List.List_map(constraints_, ((c_) => {
788
580
  return ff_compiler_JsEmitter.makeDictionaryName_(c_.name_, ff_compiler_JsEmitter.firstTypeName_(c_.generics_))
789
581
  }));
790
582
  return (((((("export function " + name_) + "(") + ff_core_List.List_join(dictionaries_, ", ")) + ") { return ") + body_) + "}")
791
- return
792
583
  }
793
584
  }
794
585
  }
@@ -797,80 +588,39 @@ export function JsEmitter_emitFunctionDefinition(self_, definition_, async_, suf
797
588
  const signature_ = ff_compiler_JsEmitter.JsEmitter_emitSignature(self_, definition_.signature_, async_, suffix_);
798
589
  {
799
590
  const _1 = ff_core_Pair.Pair(async_, definition_.body_);
800
- {
801
- if(!_1.first_) {
802
- if(_1.second_.ForeignTarget) {
803
- if(_1.second_.syncCode_.None) {
591
+ if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.None) {
804
592
  return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in sync context.');\n}")
805
- return
806
- }
807
593
  }
808
- }
809
- }
810
- {
811
- if(_1.first_) {
812
- if(_1.second_.ForeignTarget) {
813
- if(_1.second_.asyncCode_.None) {
594
+ if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.None) {
814
595
  return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in async context.');\n}")
815
- return
816
596
  }
817
- }
818
- }
819
- }
820
- {
821
- if(!_1.first_) {
822
- if(_1.second_.ForeignTarget) {
823
- if(_1.second_.syncCode_.Some) {
597
+ if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.Some) {
824
598
  const code_ = _1.second_.syncCode_.value_;
825
599
  return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
826
- return
827
- }
828
- }
829
- }
830
600
  }
831
- {
832
- if(_1.first_) {
833
- if(_1.second_.ForeignTarget) {
834
- if(_1.second_.asyncCode_.Some) {
601
+ if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.Some) {
835
602
  const code_ = _1.second_.asyncCode_.value_;
836
603
  return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
837
- return
838
- }
839
- }
840
604
  }
841
- }
842
- {
843
605
  if(_1.second_.FireflyTarget) {
844
606
  const lambda_ = _1.second_.lambda_;
845
607
  {
846
608
  const _1 = lambda_;
847
- {
609
+ if(_1.cases_.length === 1) {
848
610
  const effect_ = _1.effect_;
849
- if(_1.cases_.length > 0) {
850
611
  const matchCase_ = _1.cases_[0];
851
- if(_1.cases_.length === 1) {
852
- const _guard1 = ff_core_List.List_all(matchCase_.patterns_, ((_1) => {
853
- {
854
- if(_1.PVariable) {
855
- if(_1.name_.None) {
612
+ if(ff_core_List.List_all(matchCase_.patterns_, ((_1) => {
613
+ if(_1.PVariable && _1.name_.None) {
856
614
  return true
857
- return
858
- }
859
- }
860
615
  }
861
616
  {
862
617
  return false
863
- return
864
618
  }
865
- }));
866
- if(_guard1) {
619
+ }))) {
867
620
  const body_ = ff_compiler_JsEmitter.JsEmitter_emitTailCall(self_, (() => {
868
621
  return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, true, async_)
869
622
  }));
870
623
  return (((signature_ + " {\n") + body_) + "\n}")
871
- return
872
- }
873
- }
874
624
  }
875
625
  }
876
626
  {
@@ -885,19 +635,17 @@ return (((("const " + p_.name_) + "_a = ") + ff_compiler_JsEmitter.escapeKeyword
885
635
  })), "\n");
886
636
  const body_ = ff_compiler_JsEmitter.JsEmitter_emitTailCall(self_, (() => {
887
637
  const casesString_ = ff_core_List.List_join(ff_core_List.List_map(cases_, ((_w1) => {
888
- return (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, _w1, true, true, async_)) + "\n}")
638
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, _w1, [], [], true, true, async_)
889
639
  })), "\n");
890
- return (((("{\n" + shadowingWorkaround_) + "\n") + casesString_) + "\n}")
640
+ return ((shadowingWorkaround_ + "\n") + casesString_)
891
641
  }));
892
642
  return (((signature_ + " {\n") + body_) + "\n}")
893
- return
894
643
  }
895
644
  }
896
645
  return
897
646
  }
898
647
  }
899
648
  }
900
- }
901
649
 
902
650
  export function JsEmitter_emitTailCall(self_, body_) {
903
651
  const outerTailCallUsed_ = self_.tailCallUsed_;
@@ -968,93 +716,55 @@ return (((((((((("export function " + definition_.name_) + "(") + fields_) + ")
968
716
  export function JsEmitter_emitTerm(self_, term_, async_) {
969
717
  {
970
718
  const _1 = term_;
971
- {
972
719
  if(_1.EString) {
973
720
  const at_ = _1.at_;
974
721
  const value_ = _1.value_;
975
- const _guard1 = ff_core_String.String_startsWith(value_, "\"\"\"", 0);
976
- if(_guard1) {
722
+ if(ff_core_String.String_startsWith(value_, "\"\"\"", 0)) {
977
723
  return (("`" + ff_core_String.String_replace(ff_core_String.String_dropLast(ff_core_String.String_dropFirst(value_, 3), 3), "`", "\\`")) + "`")
978
- return
979
- }
980
724
  }
981
725
  }
982
- {
983
726
  if(_1.EString) {
984
727
  const at_ = _1.at_;
985
728
  const value_ = _1.value_;
986
729
  return value_
987
- return
988
730
  }
989
- }
990
- {
991
731
  if(_1.EChar) {
992
732
  const at_ = _1.at_;
993
733
  const value_ = _1.value_;
994
734
  return ff_compiler_JsEmitter.charLiteralToNumber_(value_)
995
- return
996
- }
997
735
  }
998
- {
999
736
  if(_1.EInt) {
1000
737
  const at_ = _1.at_;
1001
738
  const value_ = _1.value_;
1002
739
  return value_
1003
- return
1004
740
  }
1005
- }
1006
- {
1007
741
  if(_1.EFloat) {
1008
742
  const at_ = _1.at_;
1009
743
  const value_ = _1.value_;
1010
744
  return value_
1011
- return
1012
- }
1013
745
  }
1014
- {
1015
746
  if(_1.EVariable) {
1016
747
  const at_ = _1.at_;
1017
748
  const name_ = _1.name_;
1018
749
  return ff_compiler_JsEmitter.escapeResolved_(name_)
1019
- return
1020
750
  }
1021
- }
1022
- {
1023
751
  if(_1.EList) {
1024
752
  const at_ = _1.at_;
1025
753
  const items_ = _1.items_;
1026
754
  return ff_compiler_JsEmitter.JsEmitter_emitList(self_, items_, async_)
1027
- return
1028
- }
1029
755
  }
1030
- {
1031
- if(_1.EVariant) {
756
+ if(_1.EVariant && _1.name_ === "ff:core/Bool.False") {
1032
757
  const at_ = _1.at_;
1033
- if(_1.name_ === "ff:core/Bool.False") {
1034
758
  return "false"
1035
- return
1036
- }
1037
759
  }
1038
- }
1039
- {
1040
- if(_1.EVariant) {
760
+ if(_1.EVariant && _1.name_ === "ff:core/Bool.True") {
1041
761
  const at_ = _1.at_;
1042
- if(_1.name_ === "ff:core/Bool.True") {
1043
762
  return "true"
1044
- return
1045
- }
1046
- }
1047
763
  }
1048
- {
1049
- if(_1.EVariant) {
764
+ if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
1050
765
  const at_ = _1.at_;
1051
- if(_1.name_ === "ff:core/Unit.Unit") {
1052
766
  return "(void 0)"
1053
- return
1054
- }
1055
767
  }
1056
- }
1057
- {
1058
768
  if(_1.EVariant) {
1059
769
  const at_ = _1.at_;
1060
770
  const name_ = _1.name_;
@@ -1070,35 +780,18 @@ return (((ff_compiler_JsEmitter.escapeResolved_(name_) + "(") + argumentsString_
1070
780
  }
1071
781
  return
1072
782
  }
1073
- }
1074
- {
1075
- if(_1.EVariantIs) {
783
+ if(_1.EVariantIs && _1.name_ === "ff:core/Bool.False") {
1076
784
  const at_ = _1.at_;
1077
- if(_1.name_ === "ff:core/Bool.False") {
1078
785
  return "function(_v) { return !_v ? ff_core_Option.Some(_v) : ff_core_Option.None(); }"
1079
- return
1080
- }
1081
- }
1082
786
  }
1083
- {
1084
- if(_1.EVariantIs) {
787
+ if(_1.EVariantIs && _1.name_ === "ff:core/Bool.True") {
1085
788
  const at_ = _1.at_;
1086
- if(_1.name_ === "ff:core/Bool.True") {
1087
789
  return "function(_v) { return _v ? ff_core_Option.Some(_v) : ff_core_Option.None(); }"
1088
- return
1089
- }
1090
790
  }
1091
- }
1092
- {
1093
- if(_1.EVariantIs) {
791
+ if(_1.EVariantIs && _1.name_ === "ff:core/Unit.Unit") {
1094
792
  const at_ = _1.at_;
1095
- if(_1.name_ === "ff:core/Unit.Unit") {
1096
793
  return "function(_v) { return ff_core_Option.Some(_v); }"
1097
- return
1098
794
  }
1099
- }
1100
- }
1101
- {
1102
795
  if(_1.EVariantIs) {
1103
796
  const at_ = _1.at_;
1104
797
  const name_ = _1.name_;
@@ -1106,10 +799,7 @@ const n_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core
1106
799
  return (_w1 !== 46)
1107
800
  })));
1108
801
  return (((("(function(_v) { " + "return _v.") + ff_compiler_JsEmitter.escapeResolved_(n_)) + " ? ff_core_Option.Some(_v) : ff_core_Option.None();") + "})")
1109
- return
1110
802
  }
1111
- }
1112
- {
1113
803
  if(_1.ECopy) {
1114
804
  const at_ = _1.at_;
1115
805
  const name_ = _1.name_;
@@ -1119,10 +809,7 @@ const fieldCode_ = ff_core_List.List_join(ff_core_List.List_map(fields_, ((f_) =
1119
809
  return ((ff_compiler_JsEmitter.escapeKeyword_(f_.name_) + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, f_.value_, async_))
1120
810
  })), ", ");
1121
811
  return (((("{..." + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, record_, async_)) + ", ") + fieldCode_) + "}")
1122
- return
1123
- }
1124
812
  }
1125
- {
1126
813
  if(_1.EField) {
1127
814
  const at_ = _1.at_;
1128
815
  const newtype_ = _1.newtype_;
@@ -1135,32 +822,21 @@ return ((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, record_, async_) + ".")
1135
822
  }
1136
823
  return
1137
824
  }
1138
- }
1139
- {
1140
- if(_1.ELambda) {
825
+ if(_1.ELambda && _1.lambda_.cases_.length === 1 && _1.lambda_.cases_[0].guards_.length === 0) {
1141
826
  const at_ = _1.at_;
1142
827
  const effect_ = _1.lambda_.effect_;
1143
- if(_1.lambda_.cases_.length > 0) {
1144
828
  const patterns_ = _1.lambda_.cases_[0].patterns_;
1145
- if(_1.lambda_.cases_[0].guards_.length === 0) {
1146
829
  const body_ = _1.lambda_.cases_[0].body_;
1147
- if(_1.lambda_.cases_.length === 1) {
1148
- const _guard1 = ff_core_List.List_all(patterns_, ((_1) => {
1149
- {
830
+ if(ff_core_List.List_all(patterns_, ((_1) => {
1150
831
  if(_1.PVariable) {
1151
832
  return true
1152
- return
1153
- }
1154
833
  }
1155
834
  {
1156
835
  return false
1157
- return
1158
836
  }
1159
- }));
1160
- if(_guard1) {
837
+ }))) {
1161
838
  const newAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(effect_));
1162
839
  const patternParameters_ = ff_core_List.List_map(patterns_, ((_1) => {
1163
- {
1164
840
  if(_1.PVariable) {
1165
841
  const p_ = _1;
1166
842
  return ff_core_Option.Option_else(ff_core_Option.Option_map(p_.name_, ((word_) => {
@@ -1170,10 +846,8 @@ return "_"
1170
846
  }))
1171
847
  return
1172
848
  }
1173
- }
1174
849
  {
1175
850
  return ff_core_Core.panic_("!")
1176
- return
1177
851
  }
1178
852
  }));
1179
853
  const controller_ = (newAsync_
@@ -1184,14 +858,8 @@ const prefix_ = (newAsync_
1184
858
  ? "async "
1185
859
  : "");
1186
860
  return (((((("(" + prefix_) + "(") + parameters_) + ") => {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, true, newAsync_)) + "\n})")
1187
- return
1188
- }
1189
- }
1190
- }
1191
861
  }
1192
862
  }
1193
- }
1194
- {
1195
863
  if(_1.ELambda) {
1196
864
  const at_ = _1.at_;
1197
865
  const effect_ = _1.lambda_.effect_;
@@ -1208,16 +876,13 @@ const escapedArguments_ = ff_core_List.List_map(arguments_, ((word_) => {
1208
876
  return ff_compiler_JsEmitter.escapeKeyword_(word_)
1209
877
  }));
1210
878
  const caseStrings_ = ff_core_List.List_map(cases_, ((_w1) => {
1211
- return (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, _w1, true, true, newAsync_)) + "\n}")
879
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, escapedArguments_, _w1, [], [], true, true, newAsync_)
1212
880
  }));
1213
881
  const prefix_ = (newAsync_
1214
882
  ? "async "
1215
883
  : "");
1216
884
  return ((((((("(" + prefix_) + "(") + ff_core_List.List_join([...escapedArguments_, ...controller_], ", ")) + ") => ") + "{\n") + ff_core_List.List_join(caseStrings_, "\n")) + "\n})")
1217
- return
1218
- }
1219
885
  }
1220
- {
1221
886
  if(_1.EPipe) {
1222
887
  const at_ = _1.at_;
1223
888
  const value_ = _1.value_;
@@ -1235,76 +900,43 @@ return call_
1235
900
  }
1236
901
  return
1237
902
  }
1238
- }
1239
- {
1240
- if(_1.ECall) {
903
+ if(_1.ECall && _1.target_.StaticCall && _1.typeArguments_.length === 0 && _1.arguments_.length === 1) {
1241
904
  const at_ = _1.at_;
1242
- if(_1.target_.StaticCall) {
1243
905
  const operator_ = _1.target_.name_;
1244
- if(_1.typeArguments_.length === 0) {
1245
- if(_1.arguments_.length > 0) {
1246
906
  const value_ = _1.arguments_[0];
1247
- if(_1.arguments_.length === 1) {
1248
- const _guard1 = (!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)));
1249
- if(_guard1) {
907
+ if((!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)))) {
1250
908
  return ((("(" + operator_) + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, value_, async_)) + ")")
1251
- return
1252
- }
1253
- }
1254
- }
1255
- }
1256
909
  }
1257
910
  }
1258
- }
1259
- {
1260
- if(_1.ECall) {
911
+ if(_1.ECall && _1.target_.StaticCall && _1.typeArguments_.length === 0 && _1.arguments_.length === 2) {
1261
912
  const at_ = _1.at_;
1262
- if(_1.target_.StaticCall) {
1263
913
  const operator_ = _1.target_.name_;
1264
- if(_1.typeArguments_.length === 0) {
1265
- if(_1.arguments_.length > 0) {
1266
914
  const left_ = _1.arguments_[0];
1267
- if(_1.arguments_.length > 1) {
1268
915
  const right_ = _1.arguments_[1];
1269
- if(_1.arguments_.length === 2) {
1270
- const _guard1 = (!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)));
1271
- if(_guard1) {
916
+ if((!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)))) {
1272
917
  return (((((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " ") + operator_) + " ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1273
- return
1274
- }
1275
- }
1276
- }
1277
- }
1278
918
  }
1279
919
  }
920
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_grab" && _1.arguments_.length === 2 && _1.arguments_[0].value_.EVariable && _1.arguments_[1].value_.EVariable) {
921
+ const at_ = _1.at_;
922
+ const x1_ = _1.arguments_[0].value_.name_;
923
+ const x2_ = _1.arguments_[1].value_.name_;
924
+ return ((((((((("(" + ff_compiler_JsEmitter.escapeResolved_(x1_)) + "[") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "] ?? ") + "ff_core_List.internalGrab_(") + ff_compiler_JsEmitter.escapeResolved_(x1_)) + ", ") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "))")
1280
925
  }
926
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Array.Array_grab" && _1.arguments_.length === 2 && _1.arguments_[0].value_.EVariable && _1.arguments_[1].value_.EVariable) {
927
+ const at_ = _1.at_;
928
+ const x1_ = _1.arguments_[0].value_.name_;
929
+ const x2_ = _1.arguments_[1].value_.name_;
930
+ return ((((((((("(" + ff_compiler_JsEmitter.escapeResolved_(x1_)) + ".array[") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "] ?? ") + "ff_core_Array.internalGrab_(") + ff_compiler_JsEmitter.escapeResolved_(x1_)) + ", ") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "))")
1281
931
  }
1282
- {
1283
- if(_1.ECall) {
932
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.import" && _1.arguments_.length === 1 && _1.arguments_[0].value_.EString) {
1284
933
  const at_ = _1.at_;
1285
- if(_1.target_.StaticCall) {
1286
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.import") {
1287
- if(_1.arguments_.length > 0) {
1288
- if(_1.arguments_[0].value_.EString) {
1289
934
  const url_ = _1.arguments_[0].value_.value_;
1290
- if(_1.arguments_.length === 1) {
1291
935
  return ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", ""))
1292
- return
1293
- }
1294
- }
1295
- }
1296
- }
1297
- }
1298
936
  }
1299
- }
1300
- {
1301
- if(_1.ECall) {
937
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.await" && _1.arguments_.length === 1) {
1302
938
  const at_ = _1.at_;
1303
- if(_1.target_.StaticCall) {
1304
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.await") {
1305
- if(_1.arguments_.length > 0) {
1306
939
  const body_ = _1.arguments_[0].value_;
1307
- if(_1.arguments_.length === 1) {
1308
940
  const emittedBody_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_);
1309
941
  if(async_) {
1310
942
  return (("(await " + emittedBody_) + "($task))")
@@ -1313,17 +945,8 @@ return (("(" + emittedBody_) + "())")
1313
945
  }
1314
946
  return
1315
947
  }
1316
- }
1317
- }
1318
- }
1319
- }
1320
- }
1321
- {
1322
- if(_1.ECall) {
948
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.cancelled" && _1.arguments_.length === 0) {
1323
949
  const at_ = _1.at_;
1324
- if(_1.target_.StaticCall) {
1325
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.cancelled") {
1326
- if(_1.arguments_.length === 0) {
1327
950
  if(async_) {
1328
951
  return "$task.controller.signal.aborted"
1329
952
  } else {
@@ -1331,16 +954,8 @@ return "false"
1331
954
  }
1332
955
  return
1333
956
  }
1334
- }
1335
- }
1336
- }
1337
- }
1338
- {
1339
- if(_1.ECall) {
957
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
1340
958
  const at_ = _1.at_;
1341
- if(_1.target_.StaticCall) {
1342
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled") {
1343
- if(_1.arguments_.length === 0) {
1344
959
  if(async_) {
1345
960
  return "((() => ff_core_Task.Task_throwIfAborted($task))())"
1346
961
  } else {
@@ -1348,207 +963,69 @@ return ""
1348
963
  }
1349
964
  return
1350
965
  }
1351
- }
1352
- }
1353
- }
1354
- }
1355
- {
1356
- if(_1.ECall) {
966
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Equal.equals" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
1357
967
  const at_ = _1.at_;
1358
- if(_1.target_.StaticCall) {
1359
- if(_1.target_.name_ === "ff:core/Equal.equals") {
1360
- if(_1.arguments_.length > 0) {
1361
968
  const left_ = _1.arguments_[0];
1362
- if(_1.arguments_.length > 1) {
1363
969
  const right_ = _1.arguments_[1];
1364
- if(_1.arguments_.length === 2) {
1365
- if(_1.dictionaries_.length > 0) {
1366
970
  const typeName_ = _1.dictionaries_[0].typeName_;
1367
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
1368
- if(_1.dictionaries_.length === 1) {
1369
- const _guard1 = (ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"));
1370
- if(_guard1) {
971
+ if((ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"))) {
1371
972
  return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " === ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1372
- return
1373
- }
1374
- }
1375
- }
1376
- }
1377
- }
1378
973
  }
1379
974
  }
1380
- }
1381
- }
1382
- }
1383
- }
1384
- {
1385
- if(_1.ECall) {
975
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Equal.notEquals" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
1386
976
  const at_ = _1.at_;
1387
- if(_1.target_.StaticCall) {
1388
- if(_1.target_.name_ === "ff:core/Equal.notEquals") {
1389
- if(_1.arguments_.length > 0) {
1390
977
  const left_ = _1.arguments_[0];
1391
- if(_1.arguments_.length > 1) {
1392
978
  const right_ = _1.arguments_[1];
1393
- if(_1.arguments_.length === 2) {
1394
- if(_1.dictionaries_.length > 0) {
1395
979
  const typeName_ = _1.dictionaries_[0].typeName_;
1396
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
1397
- if(_1.dictionaries_.length === 1) {
1398
- const _guard1 = (ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"));
1399
- if(_guard1) {
980
+ if((ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"))) {
1400
981
  return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " !== ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1401
- return
1402
- }
1403
- }
1404
982
  }
1405
983
  }
1406
- }
1407
- }
1408
- }
1409
- }
1410
- }
1411
- }
1412
- }
1413
- {
1414
- if(_1.ECall) {
984
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.before" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
1415
985
  const at_ = _1.at_;
1416
- if(_1.target_.StaticCall) {
1417
- if(_1.target_.name_ === "ff:core/Ordering.before") {
1418
- if(_1.arguments_.length > 0) {
1419
986
  const left_ = _1.arguments_[0];
1420
- if(_1.arguments_.length > 1) {
1421
987
  const right_ = _1.arguments_[1];
1422
- if(_1.arguments_.length === 2) {
1423
- if(_1.dictionaries_.length > 0) {
1424
988
  const typeName_ = _1.dictionaries_[0].typeName_;
1425
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
1426
- if(_1.dictionaries_.length === 1) {
1427
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1428
- if(_guard1) {
989
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
1429
990
  return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " < ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1430
- return
1431
- }
1432
- }
1433
- }
1434
- }
1435
- }
1436
- }
1437
- }
1438
991
  }
1439
992
  }
1440
- }
1441
- }
1442
- {
1443
- if(_1.ECall) {
993
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.notBefore" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
1444
994
  const at_ = _1.at_;
1445
- if(_1.target_.StaticCall) {
1446
- if(_1.target_.name_ === "ff:core/Ordering.notBefore") {
1447
- if(_1.arguments_.length > 0) {
1448
995
  const left_ = _1.arguments_[0];
1449
- if(_1.arguments_.length > 1) {
1450
996
  const right_ = _1.arguments_[1];
1451
- if(_1.arguments_.length === 2) {
1452
- if(_1.dictionaries_.length > 0) {
1453
997
  const typeName_ = _1.dictionaries_[0].typeName_;
1454
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
1455
- if(_1.dictionaries_.length === 1) {
1456
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1457
- if(_guard1) {
998
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
1458
999
  return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " >= ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1459
- return
1460
- }
1461
- }
1462
- }
1463
- }
1464
1000
  }
1465
1001
  }
1466
- }
1467
- }
1468
- }
1469
- }
1470
- }
1471
- {
1472
- if(_1.ECall) {
1002
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.after" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
1473
1003
  const at_ = _1.at_;
1474
- if(_1.target_.StaticCall) {
1475
- if(_1.target_.name_ === "ff:core/Ordering.after") {
1476
- if(_1.arguments_.length > 0) {
1477
1004
  const left_ = _1.arguments_[0];
1478
- if(_1.arguments_.length > 1) {
1479
1005
  const right_ = _1.arguments_[1];
1480
- if(_1.arguments_.length === 2) {
1481
- if(_1.dictionaries_.length > 0) {
1482
1006
  const typeName_ = _1.dictionaries_[0].typeName_;
1483
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
1484
- if(_1.dictionaries_.length === 1) {
1485
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1486
- if(_guard1) {
1007
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
1487
1008
  return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " > ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1488
- return
1489
- }
1490
1009
  }
1491
1010
  }
1492
- }
1493
- }
1494
- }
1495
- }
1496
- }
1497
- }
1498
- }
1499
- }
1500
- {
1501
- if(_1.ECall) {
1011
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.notAfter" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
1502
1012
  const at_ = _1.at_;
1503
- if(_1.target_.StaticCall) {
1504
- if(_1.target_.name_ === "ff:core/Ordering.notAfter") {
1505
- if(_1.arguments_.length > 0) {
1506
1013
  const left_ = _1.arguments_[0];
1507
- if(_1.arguments_.length > 1) {
1508
1014
  const right_ = _1.arguments_[1];
1509
- if(_1.arguments_.length === 2) {
1510
- if(_1.dictionaries_.length > 0) {
1511
1015
  const typeName_ = _1.dictionaries_[0].typeName_;
1512
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
1513
- if(_1.dictionaries_.length === 1) {
1514
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
1515
- if(_guard1) {
1016
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
1516
1017
  return (((("(" + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, left_, async_)) + " <= ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, right_, async_)) + ")")
1517
- return
1518
- }
1519
- }
1520
- }
1521
- }
1522
- }
1523
- }
1524
1018
  }
1525
1019
  }
1526
- }
1527
- }
1528
- }
1529
- {
1530
- if(_1.ECall) {
1531
- if(_1.target_.StaticCall) {
1532
- if(_1.target_.name_ === "ff:core/List.fillBy") {
1020
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.fillBy" && _1.arguments_.length === 2 && _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) {
1533
1021
  const effect_ = _1.effect_;
1534
- if(_1.arguments_.length > 0) {
1535
1022
  const size_ = _1.arguments_[0];
1536
- if(_1.arguments_.length > 1) {
1537
- if(_1.arguments_[1].value_.ELambda) {
1538
1023
  const at_ = _1.arguments_[1].value_.at_;
1539
1024
  const l_ = _1.arguments_[1].value_.lambda_;
1540
- if(_1.arguments_[1].value_.lambda_.cases_.length > 0) {
1541
1025
  const c_ = _1.arguments_[1].value_.lambda_.cases_[0];
1542
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length > 0) {
1543
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].PVariable) {
1544
1026
  const name_ = _1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].name_;
1545
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 1) {
1546
- if(_1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
1547
1027
  const body_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
1548
- if(_1.arguments_[1].value_.lambda_.cases_.length === 1) {
1549
- if(_1.arguments_.length === 2) {
1550
- const _guard1 = (!ff_compiler_JsEmitter.effectTypeIsAsync_(effect_));
1551
- if(_guard1) {
1028
+ if((!ff_compiler_JsEmitter.effectTypeIsAsync_(effect_))) {
1552
1029
  const n_ = ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
1553
1030
  return ff_compiler_JsEmitter.escapeResolved_(_w1)
1554
1031
  })), (() => {
@@ -1559,28 +1036,11 @@ const await_ = (newAsync_
1559
1036
  ? "await "
1560
1037
  : "");
1561
1038
  return ((((((((((((((((((await_ + "((() => {\n") + "const size = ") + ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, size_, async_)) + ";\n") + "const result = [];\n") + "for(let ") + n_) + " = 0; ") + n_) + " < size; ") + n_) + "++) {\n") + "result.push(") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, newAsync_)) + ");\n") + "}\n") + "return result;\n") + "})())")
1562
- return
1563
- }
1564
- }
1565
- }
1566
- }
1567
- }
1568
- }
1569
- }
1570
- }
1571
- }
1572
- }
1573
- }
1574
1039
  }
1575
1040
  }
1576
- }
1577
- }
1578
- {
1579
- if(_1.ECall) {
1041
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.instanceCall_) {
1580
1042
  const at_ = _1.at_;
1581
- if(_1.target_.StaticCall) {
1582
1043
  const name_ = _1.target_.name_;
1583
- if(_1.target_.instanceCall_) {
1584
1044
  const effect_ = _1.effect_;
1585
1045
  const typeArguments_ = _1.typeArguments_;
1586
1046
  const arguments_ = _1.arguments_;
@@ -1611,13 +1071,8 @@ return call_
1611
1071
  }
1612
1072
  return
1613
1073
  }
1614
- }
1615
- }
1616
- }
1617
- {
1618
- if(_1.ECall) {
1074
+ if(_1.ECall && _1.target_.StaticCall) {
1619
1075
  const at_ = _1.at_;
1620
- if(_1.target_.StaticCall) {
1621
1076
  const name_ = _1.target_.name_;
1622
1077
  const effect_ = _1.effect_;
1623
1078
  const typeArguments_ = _1.typeArguments_;
@@ -1633,7 +1088,6 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Core.G
1633
1088
  };
1634
1089
  {
1635
1090
  const _1 = ff_compiler_JsEmitter.detectIfElse_(term_);
1636
- {
1637
1091
  if(_1.length === 0) {
1638
1092
  const await_ = (async_ && ff_compiler_JsEmitter.effectTypeIsAsync_(effect_));
1639
1093
  const ds_ = ff_core_List.List_map(dictionaries_, ((_w1) => {
@@ -1656,11 +1110,7 @@ return call_
1656
1110
  }
1657
1111
  return
1658
1112
  }
1659
- }
1660
- {
1661
- if(_1.length > 0) {
1662
- if(_1[0].first_.EVariant) {
1663
- if(_1[0].first_.name_ === "ff:core/Bool.True") {
1113
+ if(_1.length >= 1 && _1[0].first_.EVariant && _1[0].first_.name_ === "ff:core/Bool.True") {
1664
1114
  const elseBody_ = _1[0].second_;
1665
1115
  const list_ = _1.slice(1);
1666
1116
  return (("(" + ff_core_List.List_foldLeft(list_, ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, elseBody_, async_), ((_1, _2) => {
@@ -1669,14 +1119,10 @@ const otherwise_ = _1;
1669
1119
  const condition_ = _2.first_;
1670
1120
  const body_ = _2.second_;
1671
1121
  return ((((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_) + "\n? ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + "\n: ") + otherwise_)
1672
- return
1673
1122
  }
1674
1123
  }))) + ")")
1675
1124
  return
1676
1125
  }
1677
- }
1678
- }
1679
- }
1680
1126
  {
1681
1127
  const list_ = _1;
1682
1128
  return (("(" + ff_core_List.List_foldLeft(list_, "ff_core_Option.None()", ((_1, _2) => {
@@ -1685,7 +1131,6 @@ const otherwise_ = _1;
1685
1131
  const condition_ = _2.first_;
1686
1132
  const body_ = _2.second_;
1687
1133
  return ((((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_) + "\n? ff_core_Option.Some(") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + ")\n: ") + otherwise_)
1688
- return
1689
1134
  }
1690
1135
  }))) + ")")
1691
1136
  return
@@ -1693,12 +1138,8 @@ return
1693
1138
  }
1694
1139
  return
1695
1140
  }
1696
- }
1697
- }
1698
- {
1699
- if(_1.ECall) {
1141
+ if(_1.ECall && _1.target_.DynamicCall) {
1700
1142
  const at_ = _1.at_;
1701
- if(_1.target_.DynamicCall) {
1702
1143
  const function_ = _1.target_.function_;
1703
1144
  const effect_ = _1.effect_;
1704
1145
  const typeArguments_ = _1.typeArguments_;
@@ -1723,9 +1164,6 @@ return call_
1723
1164
  }
1724
1165
  return
1725
1166
  }
1726
- }
1727
- }
1728
- {
1729
1167
  if(_1.ERecord) {
1730
1168
  const at_ = _1.at_;
1731
1169
  const fields_ = _1.fields_;
@@ -1739,8 +1177,6 @@ return (("{\n" + ff_core_List.List_join(list_, ",\n")) + "\n}")
1739
1177
  }
1740
1178
  return
1741
1179
  }
1742
- }
1743
- {
1744
1180
  if(_1.EWildcard) {
1745
1181
  const at_ = _1.at_;
1746
1182
  const index_ = _1.index_;
@@ -1748,19 +1184,12 @@ if((index_ === 0)) {
1748
1184
  ff_compiler_JsEmitter.fail_(at_, "Unbound wildcard")
1749
1185
  };
1750
1186
  return ("_w" + index_)
1751
- return
1752
1187
  }
1753
- }
1754
- {
1755
- const _guard1 = async_;
1756
- if(_guard1) {
1188
+ if(async_) {
1757
1189
  return (("(await (async function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, async_)) + "\n})())")
1758
- return
1759
- }
1760
1190
  }
1761
1191
  {
1762
1192
  return (("(function() {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, term_, true, async_)) + "\n})()")
1763
- return
1764
1193
  }
1765
1194
  }
1766
1195
  }
@@ -1782,7 +1211,6 @@ return ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, _w1)
1782
1211
  export function JsEmitter_emitStatements(self_, term_, last_, async_) {
1783
1212
  {
1784
1213
  const _1 = term_;
1785
- {
1786
1214
  if(_1.EFunctions) {
1787
1215
  const at_ = _1.at_;
1788
1216
  const functions_ = _1.functions_;
@@ -1792,10 +1220,7 @@ const newAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsy
1792
1220
  return ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition(self_, f_, newAsync_, "")
1793
1221
  }));
1794
1222
  return ((ff_core_List.List_join(functionStrings_, "\n") + "\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_))
1795
- return
1796
1223
  }
1797
- }
1798
- {
1799
1224
  if(_1.ELet) {
1800
1225
  const at_ = _1.at_;
1801
1226
  const mutable_ = _1.mutable_;
@@ -1804,64 +1229,32 @@ const valueType_ = _1.valueType_;
1804
1229
  const value_ = _1.value_;
1805
1230
  const body_ = _1.body_;
1806
1231
  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_))
1807
- return
1808
- }
1809
1232
  }
1810
- {
1811
- if(_1.EVariant) {
1233
+ if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
1812
1234
  const at_ = _1.at_;
1813
- if(_1.name_ === "ff:core/Unit.Unit") {
1814
1235
  return ""
1815
- return
1816
- }
1817
1236
  }
1818
- }
1819
- {
1820
- if(_1.ESequential) {
1821
- const at_ = _1.at_;
1822
- if(_1.before_.EVariant) {
1823
- const at_ = _1.before_.at_;
1824
- if(_1.before_.name_ === "ff:core/Unit.Unit") {
1237
+ if(_1.ESequential && _1.before_.EVariant && _1.before_.name_ === "ff:core/Unit.Unit") {
1825
1238
  const after_ = _1.after_;
1826
1239
  return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, async_)
1827
- return
1828
- }
1829
- }
1830
- }
1831
1240
  }
1832
- {
1833
- if(_1.ESequential) {
1834
- const at_ = _1.at_;
1241
+ if(_1.ESequential && _1.after_.EVariant && _1.after_.name_ === "ff:core/Unit.Unit") {
1835
1242
  const before_ = _1.before_;
1836
- if(_1.after_.EVariant) {
1837
- const at_ = _1.after_.at_;
1838
- if(_1.after_.name_ === "ff:core/Unit.Unit") {
1839
1243
  return ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_)
1840
- return
1841
1244
  }
1842
- }
1843
- }
1844
- }
1845
- {
1846
1245
  if(_1.ESequential) {
1847
1246
  const at_ = _1.at_;
1848
1247
  const before_ = _1.before_;
1849
1248
  const after_ = _1.after_;
1850
1249
  return ((ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, before_, false, async_) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, after_, last_, async_))
1851
- return
1852
- }
1853
1250
  }
1854
- {
1855
1251
  if(_1.EAssign) {
1856
1252
  const at_ = _1.at_;
1857
1253
  const operator_ = _1.operator_;
1858
1254
  const name_ = _1.variable_;
1859
1255
  const value_ = _1.value_;
1860
1256
  return ((((ff_compiler_JsEmitter.escapeKeyword_(name_) + " ") + operator_) + "= ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_))
1861
- return
1862
1257
  }
1863
- }
1864
- {
1865
1258
  if(_1.EAssignField) {
1866
1259
  const at_ = _1.at_;
1867
1260
  const operator_ = _1.operator_;
@@ -1869,235 +1262,102 @@ const record_ = _1.record_;
1869
1262
  const field_ = _1.field_;
1870
1263
  const value_ = _1.value_;
1871
1264
  return ((((((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, record_, async_) + ".") + ff_compiler_JsEmitter.escapeKeyword_(field_)) + " ") + operator_) + "= ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_))
1872
- return
1873
- }
1874
1265
  }
1875
- {
1876
- if(_1.ECall) {
1266
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.while" && _1.arguments_.length === 2) {
1877
1267
  const at_ = _1.at_;
1878
- if(_1.target_.StaticCall) {
1879
- if(_1.target_.name_ === "ff:core/Core.while") {
1880
- if(_1.arguments_.length > 0) {
1881
1268
  const condition_ = _1.arguments_[0];
1882
- if(_1.arguments_.length > 1) {
1883
1269
  const body_ = _1.arguments_[1];
1884
- if(_1.arguments_.length === 2) {
1885
1270
  return (((("while(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(condition_.value_), async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_), false, async_)) + "\n}")
1886
- return
1887
- }
1888
- }
1889
- }
1890
- }
1891
- }
1892
- }
1893
1271
  }
1894
- {
1895
- if(_1.ECall) {
1272
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.doWhile" && _1.arguments_.length === 1) {
1896
1273
  const at_ = _1.at_;
1897
- if(_1.target_.StaticCall) {
1898
- if(_1.target_.name_ === "ff:core/Core.doWhile") {
1899
- if(_1.arguments_.length > 0) {
1900
1274
  const doWhileBody_ = _1.arguments_[0].value_;
1901
- if(_1.arguments_.length === 1) {
1902
1275
  const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
1903
1276
  if(_guard1.ESequential) {
1904
1277
  const body_ = _guard1.before_;
1905
1278
  const condition_ = _guard1.after_;
1906
1279
  return ((((("while(true) {\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, false, async_)) + "\nif(!") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") break") + "\n}")
1907
- return
1908
- }
1909
- }
1910
1280
  }
1911
1281
  }
1912
- }
1913
- }
1914
- }
1915
- {
1916
- if(_1.ECall) {
1282
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.doWhile" && _1.arguments_.length === 1) {
1917
1283
  const at_ = _1.at_;
1918
- if(_1.target_.StaticCall) {
1919
- if(_1.target_.name_ === "ff:core/Core.doWhile") {
1920
- if(_1.arguments_.length > 0) {
1921
1284
  const doWhileBody_ = _1.arguments_[0].value_;
1922
- if(_1.arguments_.length === 1) {
1923
1285
  const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
1286
+ {
1924
1287
  const body_ = _guard1;
1925
1288
  return (("while(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + ") {}")
1926
- return
1927
- }
1928
- }
1929
1289
  }
1930
1290
  }
1931
- }
1932
- }
1933
- {
1934
- if(_1.ECall) {
1291
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.if" && _1.arguments_.length === 2) {
1935
1292
  const at_ = _1.at_;
1936
- if(_1.target_.StaticCall) {
1937
- if(_1.target_.name_ === "ff:core/Core.if") {
1938
- if(_1.arguments_.length > 0) {
1939
1293
  const condition_ = _1.arguments_[0];
1940
- if(_1.arguments_.length > 1) {
1941
1294
  const body_ = _1.arguments_[1];
1942
- if(_1.arguments_.length === 2) {
1943
1295
  return ((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_.value_, async_)) + ") {\n") + (last_
1944
1296
  ? (("return ff_core_Option.Some(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_), async_)) + ")\n} else return ff_core_Option.None()")
1945
1297
  : (ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_), false, async_) + "\n}")))
1946
1298
  return
1947
1299
  }
1948
- }
1949
- }
1950
- }
1951
- }
1952
- }
1953
- }
1954
- {
1955
- if(_1.ECall) {
1300
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.throw" && _1.arguments_.length === 1 && _1.dictionaries_.length === 1) {
1956
1301
  const at_ = _1.at_;
1957
- if(_1.target_.StaticCall) {
1958
- if(_1.target_.name_ === "ff:core/Core.throw") {
1959
- if(_1.arguments_.length > 0) {
1960
1302
  const argument_ = _1.arguments_[0];
1961
- if(_1.arguments_.length === 1) {
1962
- if(_1.dictionaries_.length > 0) {
1963
1303
  const dictionary_ = _1.dictionaries_[0];
1964
- if(_1.dictionaries_.length === 1) {
1965
1304
  const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
1966
1305
  const a_ = ff_compiler_JsEmitter.JsEmitter_emitArgument(self_, at_, argument_, async_);
1967
1306
  return (((("throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(" + a_) + ", ") + d_) + ")})")
1968
- return
1969
- }
1970
1307
  }
1308
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.try") {
1309
+ const at_ = _1.at_;
1310
+ if((!last_)) {
1311
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a try without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1971
1312
  }
1972
1313
  }
1314
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_map") {
1315
+ const at_ = _1.at_;
1316
+ if((!last_)) {
1317
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a map without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1973
1318
  }
1974
1319
  }
1320
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_flatMap") {
1321
+ const at_ = _1.at_;
1322
+ if((!last_)) {
1323
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a flatMap without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1975
1324
  }
1976
1325
  }
1977
- {
1978
- if(_1.ECall) {
1326
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_flatten") {
1979
1327
  const at_ = _1.at_;
1980
- if(_1.target_.StaticCall) {
1981
- if(_1.target_.name_ === "ff:core/Core.try") {
1982
- const _guard1 = (!last_);
1983
- if(_guard1) {
1984
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a try without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1985
- return
1328
+ if((!last_)) {
1329
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a flatten without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1986
1330
  }
1987
1331
  }
1332
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catch") {
1333
+ const at_ = _1.at_;
1334
+ if((!last_)) {
1335
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a catch without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1336
+ }
1988
1337
  }
1338
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catchAny") {
1339
+ const at_ = _1.at_;
1340
+ if((!last_)) {
1341
+ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a catchAny without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1989
1342
  }
1990
1343
  }
1991
- {
1992
- if(_1.ECall) {
1344
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_finally") {
1993
1345
  const at_ = _1.at_;
1994
- if(_1.target_.StaticCall) {
1995
- if(_1.target_.name_ === "ff:core/Try.Try_map") {
1996
- const _guard1 = (!last_);
1997
- if(_guard1) {
1998
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a map without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1999
- return
2000
- }
2001
- }
2002
- }
2003
- }
2004
- }
2005
- {
2006
- if(_1.ECall) {
2007
- const at_ = _1.at_;
2008
- if(_1.target_.StaticCall) {
2009
- if(_1.target_.name_ === "ff:core/Try.Try_flatMap") {
2010
- const _guard1 = (!last_);
2011
- if(_guard1) {
2012
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a flatMap without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2013
- return
2014
- }
2015
- }
2016
- }
2017
- }
2018
- }
2019
- {
2020
- if(_1.ECall) {
2021
- const at_ = _1.at_;
2022
- if(_1.target_.StaticCall) {
2023
- if(_1.target_.name_ === "ff:core/Try.Try_flatten") {
2024
- const _guard1 = (!last_);
2025
- if(_guard1) {
2026
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a flatten without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2027
- return
2028
- }
2029
- }
2030
- }
2031
- }
2032
- }
2033
- {
2034
- if(_1.ECall) {
2035
- const at_ = _1.at_;
2036
- if(_1.target_.StaticCall) {
2037
- if(_1.target_.name_ === "ff:core/Try.Try_catch") {
2038
- const _guard1 = (!last_);
2039
- if(_guard1) {
2040
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a catch without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2041
- return
2042
- }
2043
- }
2044
- }
2045
- }
2046
- }
2047
- {
2048
- if(_1.ECall) {
2049
- const at_ = _1.at_;
2050
- if(_1.target_.StaticCall) {
2051
- if(_1.target_.name_ === "ff:core/Try.Try_catchAny") {
2052
- const _guard1 = (!last_);
2053
- if(_guard1) {
2054
- throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a catchAny without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2055
- return
2056
- }
2057
- }
2058
- }
2059
- }
2060
- }
2061
- {
2062
- if(_1.ECall) {
2063
- const at_ = _1.at_;
2064
- if(_1.target_.StaticCall) {
2065
- if(_1.target_.name_ === "ff:core/Try.Try_finally") {
2066
- const _guard1 = (!last_);
2067
- if(_guard1) {
1346
+ if((!last_)) {
2068
1347
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a finally without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
2069
- return
2070
1348
  }
2071
1349
  }
2072
- }
2073
- }
2074
- }
2075
- {
2076
- if(_1.ECall) {
1350
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_grab" && _1.arguments_.length === 1) {
2077
1351
  const at_ = _1.at_;
2078
- if(_1.target_.StaticCall) {
2079
- if(_1.target_.name_ === "ff:core/Try.Try_grab") {
2080
- if(_1.arguments_.length > 0) {
2081
1352
  const argument_ = _1.arguments_[0];
2082
- if(_1.arguments_.length === 1) {
2083
1353
  const _guard1 = ff_compiler_JsEmitter.JsEmitter_emitTryCatchFinally(self_, argument_.value_, last_, async_);
2084
1354
  if(_guard1.Some) {
2085
1355
  const code_ = _guard1.value_;
2086
1356
  return code_
2087
- return
2088
- }
2089
- }
2090
- }
2091
1357
  }
2092
1358
  }
2093
- }
2094
- }
2095
- {
2096
- if(_1.ECall) {
1359
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
2097
1360
  const at_ = _1.at_;
2098
- if(_1.target_.StaticCall) {
2099
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled") {
2100
- if(_1.arguments_.length === 0) {
2101
1361
  if(async_) {
2102
1362
  return "ff_core_Task.Task_throwIfAborted($task)"
2103
1363
  } else {
@@ -2105,16 +1365,9 @@ return ""
2105
1365
  }
2106
1366
  return
2107
1367
  }
2108
- }
2109
- }
2110
- }
2111
- }
2112
- {
2113
- if(_1.ECall) {
1368
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.tailCall_) {
2114
1369
  const at_ = _1.at_;
2115
- if(_1.target_.StaticCall) {
2116
1370
  const name_ = _1.target_.name_;
2117
- if(_1.target_.tailCall_) {
2118
1371
  const instanceCall_ = _1.target_.instanceCall_;
2119
1372
  const effect_ = _1.effect_;
2120
1373
  const arguments_ = _1.arguments_;
@@ -2128,33 +1381,24 @@ return ff_core_Option.Some(ff_core_Pair.Pair((((("const " + ff_compiler_JsEmitte
2128
1381
  return _w1
2129
1382
  })));
2130
1383
  return (((("{\n" + ff_core_List.List_join(pair_.first_, "\n")) + "\n") + ff_core_List.List_join(pair_.second_, "\n")) + "\ncontinue _tailcall\n}")
2131
- return
2132
- }
2133
- }
2134
- }
2135
1384
  }
2136
- {
2137
- if(_1.EPipe) {
1385
+ if(_1.EPipe && _1.function_.ELambda) {
2138
1386
  const at_ = _1.at_;
2139
1387
  const value_ = _1.value_;
2140
- if(_1.function_.ELambda) {
2141
1388
  const cases_ = _1.function_.lambda_.cases_;
2142
1389
  ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
2143
1390
  return ((((((((!last_)
2144
1391
  ? "do "
2145
1392
  : "") + "{\nconst _1 = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ";\n") + ff_core_List.List_join(ff_core_List.List_map(cases_, ((_w1) => {
2146
- return (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, ["_1"], _w1, true, last_, async_)) + "\n}")
1393
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, ["_1"], _w1, [], [], true, last_, async_)
2147
1394
  })), "\n")) + "\n}") + ((!last_)
2148
1395
  ? " while(false)"
2149
1396
  : ""))
2150
1397
  return
2151
1398
  }
2152
- }
2153
- }
2154
1399
  {
2155
1400
  {
2156
1401
  const _1 = ff_compiler_JsEmitter.detectIfElse_(term_);
2157
- {
2158
1402
  if(_1.length === 0) {
2159
1403
  if(last_) {
2160
1404
  return ("return " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, term_, async_))
@@ -2163,11 +1407,7 @@ return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, term_, async_)
2163
1407
  }
2164
1408
  return
2165
1409
  }
2166
- }
2167
- {
2168
- if(_1.length > 0) {
2169
- if(_1[0].first_.EVariant) {
2170
- if(_1[0].first_.name_ === "ff:core/Bool.True") {
1410
+ if(_1.length >= 1 && _1[0].first_.EVariant && _1[0].first_.name_ === "ff:core/Bool.True") {
2171
1411
  const elseBody_ = _1[0].second_;
2172
1412
  const list_ = _1.slice(1);
2173
1413
  const initial_ = (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, elseBody_, last_, async_)) + "\n}");
@@ -2177,25 +1417,19 @@ const otherwise_ = _1;
2177
1417
  const condition_ = _2.first_;
2178
1418
  const body_ = _2.second_;
2179
1419
  return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n} else ") + otherwise_)
2180
- return
2181
1420
  }
2182
1421
  }))
2183
1422
  return
2184
1423
  }
2185
- }
2186
- }
2187
- }
2188
1424
  {
2189
1425
  const list_ = _1;
2190
- const _guard1 = (!last_);
2191
- if(_guard1) {
1426
+ if((!last_)) {
2192
1427
  return ff_core_List.List_foldLeft(list_, "{}", ((_1, _2) => {
2193
1428
  {
2194
1429
  const otherwise_ = _1;
2195
1430
  const condition_ = _2.first_;
2196
1431
  const body_ = _2.second_;
2197
1432
  return ((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n} else ") + otherwise_)
2198
- return
2199
1433
  }
2200
1434
  }))
2201
1435
  return
@@ -2209,7 +1443,6 @@ const otherwise_ = _1;
2209
1443
  const condition_ = _2.first_;
2210
1444
  const body_ = _2.second_;
2211
1445
  return (((((("if(" + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, condition_, async_)) + ") {\n") + "return ff_core_Option.Some(") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + ")\n} else ") + otherwise_)
2212
- return
2213
1446
  }
2214
1447
  }))
2215
1448
  return
@@ -2227,19 +1460,14 @@ ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
2227
1460
  const arguments_ = ["_exception.value_", "_error"];
2228
1461
  {
2229
1462
  const _1 = cases_;
2230
- {
2231
- if(_1.length > 0) {
2232
- const case_ = _1[0];
2233
1463
  if(_1.length === 1) {
2234
- return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, case_, false, last_, catchAsync_)
2235
- return
2236
- }
2237
- }
1464
+ const case_ = _1[0];
1465
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, case_, [], [], false, last_, catchAsync_)
2238
1466
  }
2239
1467
  {
2240
1468
  const cs_ = _1;
2241
1469
  const caseStrings_ = ff_core_List.List_map(cases_, ((_w1) => {
2242
- return (("{\n" + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, _w1, true, last_, catchAsync_)) + "\n}")
1470
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, _w1, [], [], true, last_, catchAsync_)
2243
1471
  }));
2244
1472
  if(last_) {
2245
1473
  return ff_core_List.List_join(caseStrings_, "\n")
@@ -2252,344 +1480,181 @@ return
2252
1480
  }
2253
1481
  {
2254
1482
  const _1 = term_;
2255
- {
2256
- if(_1.ECall) {
2257
- const at_ = _1.at_;
2258
- if(_1.target_.StaticCall) {
2259
- if(_1.target_.name_ === "ff:core/Try.Try_finally") {
2260
- if(_1.arguments_.length > 0) {
2261
- if(_1.arguments_[0].value_.ECall) {
2262
- const at_ = _1.arguments_[0].value_.at_;
2263
- if(_1.arguments_[0].value_.target_.StaticCall) {
2264
- if(_1.arguments_[0].value_.target_.name_ === "ff:core/Core.try") {
2265
- if(_1.arguments_[0].value_.arguments_.length > 0) {
2266
- if(_1.arguments_[0].value_.arguments_[0].value_.ELambda) {
1483
+ 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/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 === 0 && _1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
2267
1484
  const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
2268
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length > 0) {
2269
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0) {
2270
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0) {
2271
1485
  const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
2272
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1) {
2273
- if(_1.arguments_[0].value_.arguments_.length === 1) {
2274
- if(_1.arguments_.length > 1) {
2275
- if(_1.arguments_[1].value_.ELambda) {
2276
1486
  const finallyEffect_ = _1.arguments_[1].value_.lambda_.effect_;
2277
- if(_1.arguments_[1].value_.lambda_.cases_.length > 0) {
2278
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 0) {
2279
- if(_1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
2280
1487
  const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
2281
- if(_1.arguments_[1].value_.lambda_.cases_.length === 1) {
2282
- if(_1.arguments_.length === 2) {
2283
1488
  const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
2284
1489
  const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
2285
1490
  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}"))
2286
- return
2287
- }
2288
- }
2289
- }
2290
- }
2291
- }
2292
- }
2293
- }
2294
- }
2295
- }
2296
- }
2297
- }
2298
1491
  }
2299
- }
2300
- }
2301
- }
2302
- }
2303
- }
2304
- }
2305
- }
2306
- }
2307
- }
2308
- }
2309
- {
2310
- if(_1.ECall) {
2311
- const at_ = _1.at_;
2312
- if(_1.target_.StaticCall) {
2313
- if(_1.target_.name_ === "ff:core/Try.Try_catch") {
2314
- if(_1.arguments_.length > 0) {
2315
- if(_1.arguments_[0].value_.ECall) {
2316
- const at_ = _1.arguments_[0].value_.at_;
2317
- if(_1.arguments_[0].value_.target_.StaticCall) {
2318
- if(_1.arguments_[0].value_.target_.name_ === "ff:core/Core.try") {
2319
- if(_1.arguments_[0].value_.arguments_.length > 0) {
2320
- if(_1.arguments_[0].value_.arguments_[0].value_.ELambda) {
1492
+ 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) {
2321
1493
  const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
2322
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length > 0) {
2323
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0) {
2324
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0) {
2325
1494
  const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
2326
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1) {
2327
- if(_1.arguments_[0].value_.arguments_.length === 1) {
2328
- if(_1.arguments_.length > 1) {
2329
- if(_1.arguments_[1].value_.ELambda) {
2330
1495
  const catchEffect_ = _1.arguments_[1].value_.lambda_.effect_;
2331
1496
  const cases_ = _1.arguments_[1].value_.lambda_.cases_;
2332
- if(_1.arguments_.length === 2) {
2333
- if(_1.dictionaries_.length > 0) {
2334
1497
  const dictionary_ = _1.dictionaries_[0];
2335
- if(_1.dictionaries_.length === 1) {
2336
1498
  const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
2337
1499
  const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
2338
1500
  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}"))
2339
- return
2340
- }
2341
- }
2342
- }
2343
- }
2344
- }
2345
- }
2346
- }
2347
- }
2348
- }
2349
- }
2350
- }
2351
- }
2352
- }
2353
- }
2354
- }
2355
- }
2356
- }
2357
- }
2358
- }
2359
1501
  }
2360
- {
2361
- if(_1.ECall) {
2362
- const at_ = _1.at_;
2363
- if(_1.target_.StaticCall) {
2364
- if(_1.target_.name_ === "ff:core/Try.Try_finally") {
2365
- if(_1.arguments_.length > 0) {
2366
- if(_1.arguments_[0].value_.ECall) {
2367
- const at_ = _1.arguments_[0].value_.at_;
2368
- if(_1.arguments_[0].value_.target_.StaticCall) {
2369
- if(_1.arguments_[0].value_.target_.name_ === "ff:core/Try.Try_catch") {
2370
- if(_1.arguments_[0].value_.arguments_.length > 0) {
2371
- if(_1.arguments_[0].value_.arguments_[0].value_.ECall) {
2372
- const at_ = _1.arguments_[0].value_.arguments_[0].value_.at_;
2373
- if(_1.arguments_[0].value_.arguments_[0].value_.target_.StaticCall) {
2374
- if(_1.arguments_[0].value_.arguments_[0].value_.target_.name_ === "ff:core/Core.try") {
2375
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_.length > 0) {
2376
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.ELambda) {
1502
+ 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) {
2377
1503
  const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
2378
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length > 0) {
2379
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0) {
2380
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0) {
2381
1504
  const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
2382
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1) {
2383
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_.length === 1) {
2384
- if(_1.arguments_[0].value_.arguments_.length > 1) {
2385
- if(_1.arguments_[0].value_.arguments_[1].value_.ELambda) {
2386
1505
  const catchEffect_ = _1.arguments_[0].value_.arguments_[1].value_.lambda_.effect_;
2387
1506
  const cases_ = _1.arguments_[0].value_.arguments_[1].value_.lambda_.cases_;
2388
- if(_1.arguments_[0].value_.arguments_.length === 2) {
2389
- if(_1.arguments_[0].value_.dictionaries_.length > 0) {
2390
1507
  const dictionary_ = _1.arguments_[0].value_.dictionaries_[0];
2391
- if(_1.arguments_[0].value_.dictionaries_.length === 1) {
2392
- if(_1.arguments_.length > 1) {
2393
- if(_1.arguments_[1].value_.ELambda) {
2394
1508
  const finallyEffect_ = _1.arguments_[1].value_.lambda_.effect_;
2395
- if(_1.arguments_[1].value_.lambda_.cases_.length > 0) {
2396
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 0) {
2397
- if(_1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
2398
1509
  const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
2399
- if(_1.arguments_[1].value_.lambda_.cases_.length === 1) {
2400
- if(_1.arguments_.length === 2) {
2401
1510
  const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
2402
1511
  const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
2403
1512
  const d_ = ff_compiler_JsEmitter.JsEmitter_emitDictionary(self_, dictionary_);
2404
1513
  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}"))
2405
- return
2406
- }
2407
- }
2408
- }
2409
- }
2410
- }
2411
- }
2412
- }
2413
- }
2414
- }
2415
- }
2416
- }
2417
- }
2418
- }
2419
- }
2420
- }
2421
- }
2422
- }
2423
- }
2424
- }
2425
- }
2426
- }
2427
- }
2428
- }
2429
- }
2430
- }
2431
- }
2432
- }
2433
- }
2434
- }
2435
- }
2436
1514
  }
2437
1515
  {
2438
1516
  return ff_core_Option.None()
2439
- return
2440
1517
  }
2441
1518
  }
2442
1519
  }
2443
1520
 
2444
- export function JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_) {
1521
+ export function JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_) {
1522
+ function emitWrapper_(code_) {
1523
+ return ((((ff_core_List.List_isEmpty(conditions_)
1524
+ ? "{\n"
1525
+ : (("if(" + ff_core_List.List_join(conditions_, " && ")) + ") {\n")) + ff_core_List.List_join(variables_, "")) + code_) + "\n}")
1526
+ }
2445
1527
  {
2446
1528
  const _1 = ff_core_Pair.Pair(matchCase_.patterns_, matchCase_.guards_);
2447
- {
2448
- if(_1.first_.length > 0) {
1529
+ if(_1.first_.length >= 1) {
2449
1530
  const p_ = _1.first_[0];
2450
1531
  const ps_ = _1.first_.slice(1);
2451
1532
  return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, ff_core_List.List_grab(arguments_, 0), p_, ff_core_List.List_dropFirst(arguments_, 1), (((_c) => {
2452
1533
  return ff_compiler_Syntax.MatchCase(_c.at_, ps_, _c.guards_, _c.body_)
2453
- }))(matchCase_), jump_, last_, async_)
1534
+ }))(matchCase_), conditions_, variables_, jump_, last_, async_)
2454
1535
  return
2455
1536
  }
1537
+ if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
1538
+ const e_ = _1.second_[0].term_;
1539
+ if(ff_core_List.List_isEmpty(variables_)) {
1540
+ const newCase_ = (((_c) => {
1541
+ return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
1542
+ }))(matchCase_);
1543
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [...conditions_, ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, async_)
2456
1544
  }
2457
- {
2458
- if(_1.first_.length === 0) {
2459
- if(_1.second_.length > 0) {
1545
+ }
1546
+ if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
1547
+ const e_ = _1.second_[0].term_;
1548
+ const newCase_ = (((_c) => {
1549
+ return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
1550
+ }))(matchCase_);
1551
+ const code_ = ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [], newCase_, [ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)], [], jump_, last_, async_);
1552
+ return emitWrapper_(code_)
1553
+ }
1554
+ if(_1.first_.length === 0 && _1.second_.length >= 1) {
2460
1555
  const guard_ = _1.second_[0];
2461
1556
  const guards_ = _1.second_.slice(1);
2462
1557
  const guardName_ = ("_guard" + (ff_core_List.List_size(guards_) + 1));
2463
1558
  const newCase_ = (((_c) => {
2464
1559
  return ff_compiler_Syntax.MatchCase(_c.at_, [guard_.pattern_], guards_, _c.body_)
2465
1560
  }))(matchCase_);
2466
- return ((((("const " + guardName_) + " = ") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, guard_.term_, async_)) + ";\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [guardName_], newCase_, jump_, last_, async_))
2467
- return
2468
- }
2469
- }
1561
+ 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_));
1562
+ return emitWrapper_(code_)
2470
1563
  }
2471
- {
2472
- if(_1.first_.length === 0) {
2473
- if(_1.second_.length === 0) {
2474
- return (ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, last_, async_) + ((jump_ && last_)
1564
+ if(_1.first_.length === 0 && _1.second_.length === 0) {
1565
+ const statementsCode_ = ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, matchCase_.body_, last_, async_);
1566
+ const lastLine_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(statementsCode_), ((_w1) => {
1567
+ return (_w1 !== 10)
1568
+ })));
1569
+ 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));
1570
+ const code_ = (statementsCode_ + (((jump_ && last_) && (!returns_))
2475
1571
  ? "\nreturn"
2476
- : jump_
1572
+ : (jump_ && (!returns_))
2477
1573
  ? "\nbreak"
2478
- : ""))
2479
- return
2480
- }
2481
- }
1574
+ : ""));
1575
+ return emitWrapper_(code_)
2482
1576
  }
2483
1577
  }
2484
1578
  }
2485
1579
 
2486
- export function JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, jump_, last_, async_) {
1580
+ export function JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_) {
2487
1581
  {
2488
1582
  const _1 = pattern_;
2489
- {
2490
1583
  if(_1.PString) {
2491
1584
  const value_ = _1.value_;
2492
- return (((((("if(" + argument_) + " === ") + value_) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + "\n}")
2493
- return
2494
- }
1585
+ const newConditions_ = [...conditions_, ((argument_ + " === ") + value_)];
1586
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
2495
1587
  }
2496
- {
2497
1588
  if(_1.PInt) {
2498
1589
  const value_ = _1.value_;
2499
- return (((((("if(" + argument_) + " === ") + value_) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + "\n}")
2500
- return
1590
+ const newConditions_ = [...conditions_, ((argument_ + " === ") + value_)];
1591
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
2501
1592
  }
2502
- }
2503
- {
2504
1593
  if(_1.PChar) {
2505
1594
  const value_ = _1.value_;
2506
- return (((((("if(" + argument_) + " === ") + ff_compiler_JsEmitter.charLiteralToNumber_(value_)) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + "\n}")
2507
- return
2508
- }
2509
- }
2510
- {
2511
- if(_1.PVariable) {
2512
- if(_1.name_.None) {
2513
- return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)
2514
- return
1595
+ const newConditions_ = [...conditions_, ((argument_ + " === ") + ff_compiler_JsEmitter.charLiteralToNumber_(value_))];
1596
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_)
2515
1597
  }
1598
+ if(_1.PVariable && _1.name_.None) {
1599
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_)
2516
1600
  }
2517
- }
2518
- {
2519
- if(_1.PVariable) {
2520
- if(_1.name_.Some) {
1601
+ if(_1.PVariable && _1.name_.Some) {
2521
1602
  const name_ = _1.name_.value_;
2522
1603
  const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(name_);
2523
- return (((escaped_ !== argument_)
2524
- ? (((("const " + escaped_) + " = ") + argument_) + ";\n")
2525
- : "") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_))
2526
- return
1604
+ const newVariables_ = ((escaped_ !== argument_)
1605
+ ? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
1606
+ : variables_);
1607
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_)
2527
1608
  }
1609
+ if(_1.PVariant && _1.name_ === "ff:core/Bool.False" && _1.patterns_.length === 0) {
1610
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, [...conditions_, ("!" + argument_)], variables_, jump_, last_, async_)
2528
1611
  }
1612
+ if(_1.PVariant && _1.name_ === "ff:core/Bool.True" && _1.patterns_.length === 0) {
1613
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, [...conditions_, argument_], variables_, jump_, last_, async_)
2529
1614
  }
2530
- {
2531
1615
  if(_1.PVariant) {
2532
- if(_1.name_ === "ff:core/Bool.False") {
2533
- if(_1.patterns_.length === 0) {
2534
- return (((("if(!" + argument_) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + "\n}")
2535
- return
2536
- }
2537
- }
1616
+ const emptyOrLink_ = _1.name_;
1617
+ if(((emptyOrLink_ === "List$Empty") || (emptyOrLink_ === "List$Link"))) {
1618
+ let restPattern_ = ff_core_Option.None();
1619
+ function listPatterns_(matchPattern_) {
1620
+ const matchPattern_a = matchPattern_;
1621
+ if(matchPattern_a.PVariant && matchPattern_a.name_ === "List$Empty" && matchPattern_a.patterns_.length === 0) {
1622
+ return []
2538
1623
  }
1624
+ if(matchPattern_a.PVariant && matchPattern_a.name_ === "List$Link" && matchPattern_a.patterns_.length === 2) {
1625
+ const head_ = matchPattern_a.patterns_[0];
1626
+ const tail_ = matchPattern_a.patterns_[1];
1627
+ return [head_, ...listPatterns_(tail_)]
2539
1628
  }
2540
1629
  {
2541
- if(_1.PVariant) {
2542
- if(_1.name_ === "ff:core/Bool.True") {
2543
- if(_1.patterns_.length === 0) {
2544
- return (((("if(" + argument_) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + "\n}")
2545
- return
2546
- }
2547
- }
1630
+ const p_ = matchPattern_a;
1631
+ restPattern_ = ff_core_Option.Some(p_);
1632
+ return []
2548
1633
  }
2549
1634
  }
1635
+ const patterns_ = listPatterns_(pattern_);
1636
+ const itemArguments_ = ff_core_List.List_map(ff_core_List.List_pairs(patterns_), ((_1) => {
2550
1637
  {
2551
- if(_1.PVariant) {
2552
- if(_1.name_ === "List$Empty") {
2553
- if(_1.patterns_.length === 0) {
2554
- let shortArgument_ = argument_;
2555
- let shortCount_ = 0;
2556
- while(ff_core_String.String_endsWith(shortArgument_, ".slice(1)")) {
2557
- shortArgument_ = ff_core_String.String_dropLast(shortArgument_, ff_core_String.String_size(".slice(1)"));
2558
- shortCount_ += 1
2559
- };
2560
- return (((((("if(" + shortArgument_) + ".length === ") + shortCount_) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + "\n}")
2561
- return
1638
+ const i_ = _1.first_;
1639
+ return (((argument_ + "[") + i_) + "]")
2562
1640
  }
2563
- }
2564
- }
2565
- }
2566
- {
2567
- if(_1.PVariant) {
2568
- if(_1.name_ === "List$Link") {
2569
- if(_1.patterns_.length > 0) {
2570
- const head_ = _1.patterns_[0];
2571
- if(_1.patterns_.length > 1) {
2572
- const tail_ = _1.patterns_[1];
2573
- if(_1.patterns_.length === 2) {
2574
- let shortArgument_ = argument_;
2575
- let shortCount_ = 0;
2576
- while(ff_core_String.String_endsWith(shortArgument_, ".slice(1)")) {
2577
- shortArgument_ = ff_core_String.String_dropLast(shortArgument_, ff_core_String.String_size(".slice(1)"));
2578
- shortCount_ += 1
2579
- };
2580
- const newArguments_ = [(((shortArgument_ + "[") + shortCount_) + "]"), (argument_ + ".slice(1)"), ...arguments_];
1641
+ }));
1642
+ const restArgument_ = ff_core_Option.Option_map(restPattern_, ((_) => {
1643
+ return (((argument_ + ".slice(") + ff_core_List.List_size(patterns_)) + ")")
1644
+ }));
1645
+ const newArguments_ = [...itemArguments_, ...ff_core_Option.Option_toList(restArgument_), ...arguments_];
2581
1646
  const newMatchCase_ = (((_c) => {
2582
- return ff_compiler_Syntax.MatchCase(_c.at_, [head_, tail_, ...matchCase_.patterns_], _c.guards_, _c.body_)
1647
+ return ff_compiler_Syntax.MatchCase(_c.at_, [...patterns_, ...ff_core_Option.Option_toList(restPattern_), ...matchCase_.patterns_], _c.guards_, _c.body_)
2583
1648
  }))(matchCase_);
2584
- return (((((("if(" + shortArgument_) + ".length > ") + shortCount_) + ") {\n") + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, jump_, last_, async_)) + "\n}")
2585
- return
2586
- }
2587
- }
2588
- }
2589
- }
1649
+ const operator_ = ff_core_Option.Option_else(ff_core_Option.Option_map(restPattern_, ((_) => {
1650
+ return ">="
1651
+ })), (() => {
1652
+ return "==="
1653
+ }));
1654
+ const newConditions_ = [...conditions_, ((((argument_ + ".length ") + operator_) + " ") + ff_core_List.List_size(patterns_))];
1655
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
2590
1656
  }
2591
1657
  }
2592
- {
2593
1658
  if(_1.PVariant) {
2594
1659
  const name_ = _1.name_;
2595
1660
  const patterns_ = _1.patterns_;
@@ -2597,77 +1662,58 @@ const processed_ = ff_compiler_JsEmitter.JsEmitter_processVariantCase(self_, nam
2597
1662
  const newMatchCase_ = (((_c) => {
2598
1663
  return ff_compiler_Syntax.MatchCase(_c.at_, [...patterns_, ...matchCase_.patterns_], _c.guards_, _c.body_)
2599
1664
  }))(matchCase_);
2600
- return (((processed_.loneVariant_
2601
- ? ""
2602
- : (((("if(" + argument_) + ".") + processed_.variantName_) + ") {\n")) + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, [...processed_.arguments_, ...arguments_], newMatchCase_, jump_, last_, async_)) + (processed_.loneVariant_
2603
- ? ""
2604
- : "\n}"))
2605
- return
2606
- }
1665
+ const newConditions_ = (processed_.loneVariant_
1666
+ ? conditions_
1667
+ : [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
1668
+ const newArguments_ = [...processed_.arguments_, ...arguments_];
1669
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_)
2607
1670
  }
2608
- {
2609
1671
  if(_1.PVariantAs) {
2610
1672
  const at_ = _1.at_;
2611
1673
  const name_ = _1.name_;
2612
1674
  const variableAt_ = _1.variableAt_;
2613
1675
  const variable_ = _1.variable_;
2614
1676
  const processed_ = ff_compiler_JsEmitter.JsEmitter_processVariantCase(self_, name_, argument_);
2615
- return ((((processed_.loneVariant_
2616
- ? ""
2617
- : (((("if(" + argument_) + ".") + processed_.variantName_) + ") {\n")) + ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(ff_core_Option.Option_map(variable_, ((word_) => {
1677
+ const newConditions_ = (processed_.loneVariant_
1678
+ ? conditions_
1679
+ : [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
1680
+ const newVariables_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(ff_core_Option.Option_map(variable_, ((word_) => {
2618
1681
  return ff_compiler_JsEmitter.escapeKeyword_(word_)
2619
1682
  })), ((_w1) => {
2620
1683
  return (_w1 !== argument_)
2621
1684
  })), ((_w1) => {
2622
- return (((("const " + _w1) + " = ") + argument_) + ";\n")
1685
+ return [...variables_, (((("const " + _w1) + " = ") + argument_) + ";\n")]
2623
1686
  })), (() => {
2624
- return ""
2625
- }))) + ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, jump_, last_, async_)) + (processed_.loneVariant_
2626
- ? ""
2627
- : "\n}"))
2628
- return
2629
- }
1687
+ return []
1688
+ }));
1689
+ return ff_compiler_JsEmitter.JsEmitter_emitCase(self_, arguments_, matchCase_, newConditions_, newVariables_, jump_, last_, async_)
2630
1690
  }
2631
- {
2632
1691
  if(_1.PAlias) {
2633
1692
  const pattern_ = _1.pattern_;
2634
1693
  const variable_ = _1.variable_;
2635
1694
  const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(variable_);
2636
- return (((escaped_ !== argument_)
2637
- ? (((("const " + escaped_) + " = ") + argument_) + ";\n")
2638
- : "") + ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, jump_, last_, async_))
2639
- return
2640
- }
1695
+ const newVariables_ = ((escaped_ !== argument_)
1696
+ ? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
1697
+ : variables_);
1698
+ return ff_compiler_JsEmitter.JsEmitter_emitPattern(self_, argument_, pattern_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_)
2641
1699
  }
2642
1700
  }
2643
1701
  }
2644
1702
 
2645
1703
  export function JsEmitter_emitList(self_, items_, async_) {
2646
1704
  return (("[" + ff_core_List.List_join(ff_core_List.List_map(items_, ((_1) => {
2647
- {
2648
- const item_ = _1.first_;
2649
1705
  if(!_1.second_) {
1706
+ const item_ = _1.first_;
2650
1707
  return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, item_, async_)
2651
- return
2652
- }
2653
1708
  }
2654
- {
2655
- const item_ = _1.first_;
2656
1709
  if(_1.second_) {
1710
+ const item_ = _1.first_;
2657
1711
  return ("..." + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, item_, async_))
2658
- return
2659
- }
2660
1712
  }
2661
1713
  })), ", ")) + "]")
2662
1714
  }
2663
1715
 
2664
1716
  export function JsEmitter_processVariantCase(self_, name_, argument_) {
2665
- if((name_ === "List$Empty")) {
2666
- return ff_compiler_JsEmitter.ProcessedVariantCase(name_, false, false, [])
2667
- } else {
2668
- if((name_ === "List$Link")) {
2669
- return ff_compiler_JsEmitter.ProcessedVariantCase(name_, false, false, [(argument_ + "[0]"), (argument_ + ".slice(1)")])
2670
- } else {
2671
1717
  const variantNameUnqualified_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(name_), ((_w1) => {
2672
1718
  return (_w1 !== 46)
2673
1719
  })));
@@ -2697,8 +1743,6 @@ return ((argument_ + ".") + ff_compiler_JsEmitter.escapeKeyword_(field_))
2697
1743
  }));
2698
1744
  return ff_compiler_JsEmitter.ProcessedVariantCase(variantName_, newtype_, loneVariant_, newArguments_)
2699
1745
  }
2700
- }
2701
- }
2702
1746
 
2703
1747
  export function JsEmitter_processVariant(self_, name_) {
2704
1748
  if(ff_core_String.String_startsWith(name_, "List$", 0)) {
@@ -2724,21 +1768,13 @@ return newtype_
2724
1768
 
2725
1769
  export function JsEmitter_emitArgument(self_, callAt_, argument_, async_) {
2726
1770
  {
2727
- const _1 = argument_.value_;
2728
- {
2729
- if(_1.ECall) {
2730
- if(_1.target_.StaticCall) {
2731
- if(_1.target_.name_ === "ff:core/SourceLocation.callSite") {
2732
- return (((((((((("\"" + self_.moduleName_) + ":") + callAt_.line_) + ":") + callAt_.column_) + ",") + self_.packagePair_.group_) + ",") + self_.packagePair_.name_) + "\"")
2733
- return
2734
- }
2735
- }
2736
- }
1771
+ const _1 = argument_.value_;
1772
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/SourceLocation.callSite") {
1773
+ return (((((((((("\"" + self_.moduleName_) + ":") + callAt_.line_) + ":") + callAt_.column_) + ",") + self_.packagePair_.group_) + ",") + self_.packagePair_.name_) + "\"")
2737
1774
  }
2738
1775
  {
2739
1776
  const value_ = _1;
2740
1777
  return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)
2741
- return
2742
1778
  }
2743
1779
  }
2744
1780
  }
@@ -2826,30 +1862,17 @@ return [ff_core_List.List_join(["export async function $run$(fireflyPath_, argum
2826
1862
  : []), "} finally {", ...(ff_core_Equal.notEquals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser(), ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget)
2827
1863
  ? ["ff_core_Task.Task_abort$($task)", "clearInterval(interval)"]
2828
1864
  : []), "}", "}", ...(((_1) => {
2829
- {
2830
1865
  if(_1.EmitBrowser) {
2831
1866
  return ["queueMicrotask(async () => {", "await $run$(null, [])", "})"]
2832
- return
2833
- }
2834
1867
  }
2835
- {
2836
- if(_1.EmitNode) {
2837
- const _guard1 = bootstrapping_;
2838
- if(_guard1) {
1868
+ if(_1.EmitNode && bootstrapping_) {
2839
1869
  return ["import * as path from 'node:path'", "queueMicrotask(async () => {", "let fireflyPath_ = path.dirname(path.dirname(path.dirname(path.dirname(path.dirname(process.argv[1])))))", "await $run$(fireflyPath_, process.argv.slice(2))", "})"]
2840
- return
2841
1870
  }
2842
- }
2843
- }
2844
- {
2845
1871
  if(_1.EmitExecutable) {
2846
1872
  return ["queueMicrotask(async () => {", "await $run$(null, process.argv.slice(2))", "})"]
2847
- return
2848
- }
2849
1873
  }
2850
1874
  {
2851
1875
  return []
2852
- return
2853
1876
  }
2854
1877
  }))(self_.emitTarget_)], "\n")]
2855
1878
  })), (() => {
@@ -2913,11 +1936,8 @@ return ("async " + ff_core_String.String_dropFirst(_w1, ff_core_String.String_si
2913
1936
  const body_ = (("{\n" + ff_core_List.List_join([...methods_, ...asyncMethods_], ",\n")) + "\n}");
2914
1937
  {
2915
1938
  const _1 = definition_.constraints_;
2916
- {
2917
1939
  if(_1.length === 0) {
2918
1940
  return (((("export const " + name_) + " = ") + body_) + ";")
2919
- return
2920
- }
2921
1941
  }
2922
1942
  {
2923
1943
  const constraints_ = _1;
@@ -2925,7 +1945,6 @@ const dictionaries_ = ff_core_List.List_map(constraints_, ((c_) => {
2925
1945
  return ff_compiler_JsEmitter.makeDictionaryName_(c_.name_, ff_compiler_JsEmitter.firstTypeName_(c_.generics_))
2926
1946
  }));
2927
1947
  return (((((("export function " + name_) + "(") + ff_core_List.List_join(dictionaries_, ", ")) + ") { return ") + body_) + "}")
2928
- return
2929
1948
  }
2930
1949
  }
2931
1950
  }
@@ -2934,80 +1953,39 @@ export async function JsEmitter_emitFunctionDefinition$(self_, definition_, asyn
2934
1953
  const signature_ = (await ff_compiler_JsEmitter.JsEmitter_emitSignature$(self_, definition_.signature_, async_, suffix_, $task));
2935
1954
  {
2936
1955
  const _1 = ff_core_Pair.Pair(async_, definition_.body_);
2937
- {
2938
- if(!_1.first_) {
2939
- if(_1.second_.ForeignTarget) {
2940
- if(_1.second_.syncCode_.None) {
1956
+ if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.None) {
2941
1957
  return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in sync context.');\n}")
2942
- return
2943
1958
  }
2944
- }
2945
- }
2946
- }
2947
- {
2948
- if(_1.first_) {
2949
- if(_1.second_.ForeignTarget) {
2950
- if(_1.second_.asyncCode_.None) {
1959
+ if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.None) {
2951
1960
  return (((signature_ + " {\nthrow new Error('Function ") + definition_.signature_.name_) + " is missing on this target in async context.');\n}")
2952
- return
2953
- }
2954
- }
2955
- }
2956
1961
  }
2957
- {
2958
- if(!_1.first_) {
2959
- if(_1.second_.ForeignTarget) {
2960
- if(_1.second_.syncCode_.Some) {
1962
+ if(!_1.first_ && _1.second_.ForeignTarget && _1.second_.syncCode_.Some) {
2961
1963
  const code_ = _1.second_.syncCode_.value_;
2962
1964
  return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
2963
- return
2964
- }
2965
- }
2966
1965
  }
2967
- }
2968
- {
2969
- if(_1.first_) {
2970
- if(_1.second_.ForeignTarget) {
2971
- if(_1.second_.asyncCode_.Some) {
1966
+ if(_1.first_ && _1.second_.ForeignTarget && _1.second_.asyncCode_.Some) {
2972
1967
  const code_ = _1.second_.asyncCode_.value_;
2973
1968
  return (((signature_ + " {\n") + ff_compiler_JsImporter.JsImporter_process(self_.jsImporter_, definition_.at_, code_)) + "\n}")
2974
- return
2975
- }
2976
1969
  }
2977
- }
2978
- }
2979
- {
2980
1970
  if(_1.second_.FireflyTarget) {
2981
1971
  const lambda_ = _1.second_.lambda_;
2982
1972
  {
2983
1973
  const _1 = lambda_;
2984
- {
1974
+ if(_1.cases_.length === 1) {
2985
1975
  const effect_ = _1.effect_;
2986
- if(_1.cases_.length > 0) {
2987
1976
  const matchCase_ = _1.cases_[0];
2988
- if(_1.cases_.length === 1) {
2989
- const _guard1 = ff_core_List.List_all(matchCase_.patterns_, ((_1) => {
2990
- {
2991
- if(_1.PVariable) {
2992
- if(_1.name_.None) {
1977
+ if(ff_core_List.List_all(matchCase_.patterns_, ((_1) => {
1978
+ if(_1.PVariable && _1.name_.None) {
2993
1979
  return true
2994
- return
2995
- }
2996
- }
2997
1980
  }
2998
1981
  {
2999
1982
  return false
3000
- return
3001
1983
  }
3002
- }));
3003
- if(_guard1) {
1984
+ }))) {
3004
1985
  const body_ = (await ff_compiler_JsEmitter.JsEmitter_emitTailCall$(self_, (async ($task) => {
3005
1986
  return (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, matchCase_.body_, true, async_, $task))
3006
1987
  }), $task));
3007
1988
  return (((signature_ + " {\n") + body_) + "\n}")
3008
- return
3009
- }
3010
- }
3011
1989
  }
3012
1990
  }
3013
1991
  {
@@ -3022,19 +2000,17 @@ return (((("const " + p_.name_) + "_a = ") + ff_compiler_JsEmitter.escapeKeyword
3022
2000
  })), "\n");
3023
2001
  const body_ = (await ff_compiler_JsEmitter.JsEmitter_emitTailCall$(self_, (async ($task) => {
3024
2002
  const casesString_ = ff_core_List.List_join((await ff_core_List.List_map$(cases_, (async (_w1, $task) => {
3025
- return (("{\n" + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, escapedArguments_, _w1, true, true, async_, $task))) + "\n}")
2003
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, escapedArguments_, _w1, [], [], true, true, async_, $task))
3026
2004
  }), $task)), "\n");
3027
- return (((("{\n" + shadowingWorkaround_) + "\n") + casesString_) + "\n}")
2005
+ return ((shadowingWorkaround_ + "\n") + casesString_)
3028
2006
  }), $task));
3029
2007
  return (((signature_ + " {\n") + body_) + "\n}")
3030
- return
3031
2008
  }
3032
2009
  }
3033
2010
  return
3034
2011
  }
3035
2012
  }
3036
2013
  }
3037
- }
3038
2014
 
3039
2015
  export async function JsEmitter_emitTailCall$(self_, body_, $task) {
3040
2016
  const outerTailCallUsed_ = self_.tailCallUsed_;
@@ -3105,93 +2081,55 @@ return (((((((((("export function " + definition_.name_) + "(") + fields_) + ")
3105
2081
  export async function JsEmitter_emitTerm$(self_, term_, async_, $task) {
3106
2082
  {
3107
2083
  const _1 = term_;
3108
- {
3109
2084
  if(_1.EString) {
3110
2085
  const at_ = _1.at_;
3111
2086
  const value_ = _1.value_;
3112
- const _guard1 = ff_core_String.String_startsWith(value_, "\"\"\"", 0);
3113
- if(_guard1) {
2087
+ if(ff_core_String.String_startsWith(value_, "\"\"\"", 0)) {
3114
2088
  return (("`" + ff_core_String.String_replace(ff_core_String.String_dropLast(ff_core_String.String_dropFirst(value_, 3), 3), "`", "\\`")) + "`")
3115
- return
3116
2089
  }
3117
2090
  }
3118
- }
3119
- {
3120
2091
  if(_1.EString) {
3121
2092
  const at_ = _1.at_;
3122
2093
  const value_ = _1.value_;
3123
2094
  return value_
3124
- return
3125
- }
3126
2095
  }
3127
- {
3128
2096
  if(_1.EChar) {
3129
2097
  const at_ = _1.at_;
3130
2098
  const value_ = _1.value_;
3131
2099
  return ff_compiler_JsEmitter.charLiteralToNumber_(value_)
3132
- return
3133
2100
  }
3134
- }
3135
- {
3136
2101
  if(_1.EInt) {
3137
2102
  const at_ = _1.at_;
3138
2103
  const value_ = _1.value_;
3139
2104
  return value_
3140
- return
3141
- }
3142
2105
  }
3143
- {
3144
2106
  if(_1.EFloat) {
3145
2107
  const at_ = _1.at_;
3146
2108
  const value_ = _1.value_;
3147
2109
  return value_
3148
- return
3149
2110
  }
3150
- }
3151
- {
3152
2111
  if(_1.EVariable) {
3153
2112
  const at_ = _1.at_;
3154
2113
  const name_ = _1.name_;
3155
2114
  return ff_compiler_JsEmitter.escapeResolved_(name_)
3156
- return
3157
- }
3158
2115
  }
3159
- {
3160
2116
  if(_1.EList) {
3161
2117
  const at_ = _1.at_;
3162
2118
  const items_ = _1.items_;
3163
2119
  return (await ff_compiler_JsEmitter.JsEmitter_emitList$(self_, items_, async_, $task))
3164
- return
3165
2120
  }
3166
- }
3167
- {
3168
- if(_1.EVariant) {
2121
+ if(_1.EVariant && _1.name_ === "ff:core/Bool.False") {
3169
2122
  const at_ = _1.at_;
3170
- if(_1.name_ === "ff:core/Bool.False") {
3171
2123
  return "false"
3172
- return
3173
- }
3174
- }
3175
2124
  }
3176
- {
3177
- if(_1.EVariant) {
2125
+ if(_1.EVariant && _1.name_ === "ff:core/Bool.True") {
3178
2126
  const at_ = _1.at_;
3179
- if(_1.name_ === "ff:core/Bool.True") {
3180
2127
  return "true"
3181
- return
3182
- }
3183
2128
  }
3184
- }
3185
- {
3186
- if(_1.EVariant) {
2129
+ if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
3187
2130
  const at_ = _1.at_;
3188
- if(_1.name_ === "ff:core/Unit.Unit") {
3189
2131
  return "(void 0)"
3190
- return
3191
2132
  }
3192
- }
3193
- }
3194
- {
3195
2133
  if(_1.EVariant) {
3196
2134
  const at_ = _1.at_;
3197
2135
  const name_ = _1.name_;
@@ -3207,35 +2145,18 @@ return (((ff_compiler_JsEmitter.escapeResolved_(name_) + "(") + argumentsString_
3207
2145
  }
3208
2146
  return
3209
2147
  }
3210
- }
3211
- {
3212
- if(_1.EVariantIs) {
2148
+ if(_1.EVariantIs && _1.name_ === "ff:core/Bool.False") {
3213
2149
  const at_ = _1.at_;
3214
- if(_1.name_ === "ff:core/Bool.False") {
3215
2150
  return "function(_v) { return !_v ? ff_core_Option.Some(_v) : ff_core_Option.None(); }"
3216
- return
3217
- }
3218
2151
  }
3219
- }
3220
- {
3221
- if(_1.EVariantIs) {
2152
+ if(_1.EVariantIs && _1.name_ === "ff:core/Bool.True") {
3222
2153
  const at_ = _1.at_;
3223
- if(_1.name_ === "ff:core/Bool.True") {
3224
2154
  return "function(_v) { return _v ? ff_core_Option.Some(_v) : ff_core_Option.None(); }"
3225
- return
3226
2155
  }
3227
- }
3228
- }
3229
- {
3230
- if(_1.EVariantIs) {
2156
+ if(_1.EVariantIs && _1.name_ === "ff:core/Unit.Unit") {
3231
2157
  const at_ = _1.at_;
3232
- if(_1.name_ === "ff:core/Unit.Unit") {
3233
2158
  return "function(_v) { return ff_core_Option.Some(_v); }"
3234
- return
3235
- }
3236
2159
  }
3237
- }
3238
- {
3239
2160
  if(_1.EVariantIs) {
3240
2161
  const at_ = _1.at_;
3241
2162
  const name_ = _1.name_;
@@ -3243,10 +2164,7 @@ const n_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core
3243
2164
  return (_w1 !== 46)
3244
2165
  })));
3245
2166
  return (((("(function(_v) { " + "return _v.") + ff_compiler_JsEmitter.escapeResolved_(n_)) + " ? ff_core_Option.Some(_v) : ff_core_Option.None();") + "})")
3246
- return
3247
- }
3248
2167
  }
3249
- {
3250
2168
  if(_1.ECopy) {
3251
2169
  const at_ = _1.at_;
3252
2170
  const name_ = _1.name_;
@@ -3256,10 +2174,7 @@ const fieldCode_ = ff_core_List.List_join((await ff_core_List.List_map$(fields_,
3256
2174
  return ((ff_compiler_JsEmitter.escapeKeyword_(f_.name_) + " = ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, f_.value_, async_, $task)))
3257
2175
  }), $task)), ", ");
3258
2176
  return (((("{..." + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, record_, async_, $task))) + ", ") + fieldCode_) + "}")
3259
- return
3260
2177
  }
3261
- }
3262
- {
3263
2178
  if(_1.EField) {
3264
2179
  const at_ = _1.at_;
3265
2180
  const newtype_ = _1.newtype_;
@@ -3272,32 +2187,21 @@ return (((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, record_, async_
3272
2187
  }
3273
2188
  return
3274
2189
  }
3275
- }
3276
- {
3277
- if(_1.ELambda) {
2190
+ if(_1.ELambda && _1.lambda_.cases_.length === 1 && _1.lambda_.cases_[0].guards_.length === 0) {
3278
2191
  const at_ = _1.at_;
3279
2192
  const effect_ = _1.lambda_.effect_;
3280
- if(_1.lambda_.cases_.length > 0) {
3281
2193
  const patterns_ = _1.lambda_.cases_[0].patterns_;
3282
- if(_1.lambda_.cases_[0].guards_.length === 0) {
3283
2194
  const body_ = _1.lambda_.cases_[0].body_;
3284
- if(_1.lambda_.cases_.length === 1) {
3285
- const _guard1 = ff_core_List.List_all(patterns_, ((_1) => {
3286
- {
2195
+ if(ff_core_List.List_all(patterns_, ((_1) => {
3287
2196
  if(_1.PVariable) {
3288
2197
  return true
3289
- return
3290
- }
3291
2198
  }
3292
2199
  {
3293
2200
  return false
3294
- return
3295
2201
  }
3296
- }));
3297
- if(_guard1) {
2202
+ }))) {
3298
2203
  const newAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(effect_));
3299
2204
  const patternParameters_ = ff_core_List.List_map(patterns_, ((_1) => {
3300
- {
3301
2205
  if(_1.PVariable) {
3302
2206
  const p_ = _1;
3303
2207
  return ff_core_Option.Option_else(ff_core_Option.Option_map(p_.name_, ((word_) => {
@@ -3307,10 +2211,8 @@ return "_"
3307
2211
  }))
3308
2212
  return
3309
2213
  }
3310
- }
3311
2214
  {
3312
2215
  return ff_core_Core.panic_("!")
3313
- return
3314
2216
  }
3315
2217
  }));
3316
2218
  const controller_ = (newAsync_
@@ -3321,14 +2223,8 @@ const prefix_ = (newAsync_
3321
2223
  ? "async "
3322
2224
  : "");
3323
2225
  return (((((("(" + prefix_) + "(") + parameters_) + ") => {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, true, newAsync_, $task))) + "\n})")
3324
- return
3325
- }
3326
- }
3327
2226
  }
3328
2227
  }
3329
- }
3330
- }
3331
- {
3332
2228
  if(_1.ELambda) {
3333
2229
  const at_ = _1.at_;
3334
2230
  const effect_ = _1.lambda_.effect_;
@@ -3345,16 +2241,13 @@ const escapedArguments_ = ff_core_List.List_map(arguments_, ((word_) => {
3345
2241
  return ff_compiler_JsEmitter.escapeKeyword_(word_)
3346
2242
  }));
3347
2243
  const caseStrings_ = (await ff_core_List.List_map$(cases_, (async (_w1, $task) => {
3348
- return (("{\n" + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, escapedArguments_, _w1, true, true, newAsync_, $task))) + "\n}")
2244
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, escapedArguments_, _w1, [], [], true, true, newAsync_, $task))
3349
2245
  }), $task));
3350
2246
  const prefix_ = (newAsync_
3351
2247
  ? "async "
3352
2248
  : "");
3353
2249
  return ((((((("(" + prefix_) + "(") + ff_core_List.List_join([...escapedArguments_, ...controller_], ", ")) + ") => ") + "{\n") + ff_core_List.List_join(caseStrings_, "\n")) + "\n})")
3354
- return
3355
2250
  }
3356
- }
3357
- {
3358
2251
  if(_1.EPipe) {
3359
2252
  const at_ = _1.at_;
3360
2253
  const value_ = _1.value_;
@@ -3372,76 +2265,43 @@ return call_
3372
2265
  }
3373
2266
  return
3374
2267
  }
3375
- }
3376
- {
3377
- if(_1.ECall) {
2268
+ if(_1.ECall && _1.target_.StaticCall && _1.typeArguments_.length === 0 && _1.arguments_.length === 1) {
3378
2269
  const at_ = _1.at_;
3379
- if(_1.target_.StaticCall) {
3380
2270
  const operator_ = _1.target_.name_;
3381
- if(_1.typeArguments_.length === 0) {
3382
- if(_1.arguments_.length > 0) {
3383
2271
  const value_ = _1.arguments_[0];
3384
- if(_1.arguments_.length === 1) {
3385
- const _guard1 = (!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)));
3386
- if(_guard1) {
2272
+ if((!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)))) {
3387
2273
  return ((("(" + operator_) + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, value_, async_, $task))) + ")")
3388
- return
3389
- }
3390
- }
3391
- }
3392
2274
  }
3393
2275
  }
3394
- }
3395
- }
3396
- {
3397
- if(_1.ECall) {
2276
+ if(_1.ECall && _1.target_.StaticCall && _1.typeArguments_.length === 0 && _1.arguments_.length === 2) {
3398
2277
  const at_ = _1.at_;
3399
- if(_1.target_.StaticCall) {
3400
2278
  const operator_ = _1.target_.name_;
3401
- if(_1.typeArguments_.length === 0) {
3402
- if(_1.arguments_.length > 0) {
3403
2279
  const left_ = _1.arguments_[0];
3404
- if(_1.arguments_.length > 1) {
3405
2280
  const right_ = _1.arguments_[1];
3406
- if(_1.arguments_.length === 2) {
3407
- const _guard1 = (!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)));
3408
- if(_guard1) {
2281
+ if((!ff_core_Char.Char_isAsciiLetter(ff_core_String.String_grabFirst(operator_)))) {
3409
2282
  return (((((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " ") + operator_) + " ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3410
- return
3411
- }
3412
- }
3413
- }
3414
- }
3415
2283
  }
3416
2284
  }
2285
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_grab" && _1.arguments_.length === 2 && _1.arguments_[0].value_.EVariable && _1.arguments_[1].value_.EVariable) {
2286
+ const at_ = _1.at_;
2287
+ const x1_ = _1.arguments_[0].value_.name_;
2288
+ const x2_ = _1.arguments_[1].value_.name_;
2289
+ return ((((((((("(" + ff_compiler_JsEmitter.escapeResolved_(x1_)) + "[") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "] ?? ") + "ff_core_List.internalGrab_(") + ff_compiler_JsEmitter.escapeResolved_(x1_)) + ", ") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "))")
3417
2290
  }
2291
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Array.Array_grab" && _1.arguments_.length === 2 && _1.arguments_[0].value_.EVariable && _1.arguments_[1].value_.EVariable) {
2292
+ const at_ = _1.at_;
2293
+ const x1_ = _1.arguments_[0].value_.name_;
2294
+ const x2_ = _1.arguments_[1].value_.name_;
2295
+ return ((((((((("(" + ff_compiler_JsEmitter.escapeResolved_(x1_)) + ".array[") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "] ?? ") + "ff_core_Array.internalGrab_(") + ff_compiler_JsEmitter.escapeResolved_(x1_)) + ", ") + ff_compiler_JsEmitter.escapeResolved_(x2_)) + "))")
3418
2296
  }
3419
- {
3420
- if(_1.ECall) {
2297
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.import" && _1.arguments_.length === 1 && _1.arguments_[0].value_.EString) {
3421
2298
  const at_ = _1.at_;
3422
- if(_1.target_.StaticCall) {
3423
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.import") {
3424
- if(_1.arguments_.length > 0) {
3425
- if(_1.arguments_[0].value_.EString) {
3426
2299
  const url_ = _1.arguments_[0].value_.value_;
3427
- if(_1.arguments_.length === 1) {
3428
2300
  return ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", ""))
3429
- return
3430
2301
  }
3431
- }
3432
- }
3433
- }
3434
- }
3435
- }
3436
- }
3437
- {
3438
- if(_1.ECall) {
2302
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.await" && _1.arguments_.length === 1) {
3439
2303
  const at_ = _1.at_;
3440
- if(_1.target_.StaticCall) {
3441
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.await") {
3442
- if(_1.arguments_.length > 0) {
3443
2304
  const body_ = _1.arguments_[0].value_;
3444
- if(_1.arguments_.length === 1) {
3445
2305
  const emittedBody_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task));
3446
2306
  if(async_) {
3447
2307
  return (("(await " + emittedBody_) + "($task))")
@@ -3450,17 +2310,8 @@ return (("(" + emittedBody_) + "())")
3450
2310
  }
3451
2311
  return
3452
2312
  }
3453
- }
3454
- }
3455
- }
3456
- }
3457
- }
3458
- {
3459
- if(_1.ECall) {
2313
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.cancelled" && _1.arguments_.length === 0) {
3460
2314
  const at_ = _1.at_;
3461
- if(_1.target_.StaticCall) {
3462
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.cancelled") {
3463
- if(_1.arguments_.length === 0) {
3464
2315
  if(async_) {
3465
2316
  return "$task.controller.signal.aborted"
3466
2317
  } else {
@@ -3468,16 +2319,8 @@ return "false"
3468
2319
  }
3469
2320
  return
3470
2321
  }
3471
- }
3472
- }
3473
- }
3474
- }
3475
- {
3476
- if(_1.ECall) {
2322
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
3477
2323
  const at_ = _1.at_;
3478
- if(_1.target_.StaticCall) {
3479
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled") {
3480
- if(_1.arguments_.length === 0) {
3481
2324
  if(async_) {
3482
2325
  return "((() => ff_core_Task.Task_throwIfAborted($task))())"
3483
2326
  } else {
@@ -3485,207 +2328,69 @@ return ""
3485
2328
  }
3486
2329
  return
3487
2330
  }
3488
- }
3489
- }
3490
- }
3491
- }
3492
- {
3493
- if(_1.ECall) {
2331
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Equal.equals" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
3494
2332
  const at_ = _1.at_;
3495
- if(_1.target_.StaticCall) {
3496
- if(_1.target_.name_ === "ff:core/Equal.equals") {
3497
- if(_1.arguments_.length > 0) {
3498
2333
  const left_ = _1.arguments_[0];
3499
- if(_1.arguments_.length > 1) {
3500
2334
  const right_ = _1.arguments_[1];
3501
- if(_1.arguments_.length === 2) {
3502
- if(_1.dictionaries_.length > 0) {
3503
2335
  const typeName_ = _1.dictionaries_[0].typeName_;
3504
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
3505
- if(_1.dictionaries_.length === 1) {
3506
- const _guard1 = (ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"));
3507
- if(_guard1) {
2336
+ if((ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"))) {
3508
2337
  return (((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " === ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3509
- return
3510
2338
  }
3511
2339
  }
3512
- }
3513
- }
3514
- }
3515
- }
3516
- }
3517
- }
3518
- }
3519
- }
3520
- }
3521
- {
3522
- if(_1.ECall) {
2340
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Equal.notEquals" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
3523
2341
  const at_ = _1.at_;
3524
- if(_1.target_.StaticCall) {
3525
- if(_1.target_.name_ === "ff:core/Equal.notEquals") {
3526
- if(_1.arguments_.length > 0) {
3527
2342
  const left_ = _1.arguments_[0];
3528
- if(_1.arguments_.length > 1) {
3529
2343
  const right_ = _1.arguments_[1];
3530
- if(_1.arguments_.length === 2) {
3531
- if(_1.dictionaries_.length > 0) {
3532
2344
  const typeName_ = _1.dictionaries_[0].typeName_;
3533
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
3534
- if(_1.dictionaries_.length === 1) {
3535
- const _guard1 = (ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"));
3536
- if(_guard1) {
2345
+ if((ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String) || (typeName_ === "ff:core/Ordering.Ordering"))) {
3537
2346
  return (((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " !== ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3538
- return
3539
- }
3540
- }
3541
- }
3542
- }
3543
- }
3544
2347
  }
3545
2348
  }
3546
- }
3547
- }
3548
- }
3549
- }
3550
- {
3551
- if(_1.ECall) {
2349
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.before" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
3552
2350
  const at_ = _1.at_;
3553
- if(_1.target_.StaticCall) {
3554
- if(_1.target_.name_ === "ff:core/Ordering.before") {
3555
- if(_1.arguments_.length > 0) {
3556
2351
  const left_ = _1.arguments_[0];
3557
- if(_1.arguments_.length > 1) {
3558
2352
  const right_ = _1.arguments_[1];
3559
- if(_1.arguments_.length === 2) {
3560
- if(_1.dictionaries_.length > 0) {
3561
2353
  const typeName_ = _1.dictionaries_[0].typeName_;
3562
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
3563
- if(_1.dictionaries_.length === 1) {
3564
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
3565
- if(_guard1) {
2354
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
3566
2355
  return (((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " < ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3567
- return
3568
- }
3569
- }
3570
2356
  }
3571
2357
  }
3572
- }
3573
- }
3574
- }
3575
- }
3576
- }
3577
- }
3578
- }
3579
- {
3580
- if(_1.ECall) {
2358
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.notBefore" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
3581
2359
  const at_ = _1.at_;
3582
- if(_1.target_.StaticCall) {
3583
- if(_1.target_.name_ === "ff:core/Ordering.notBefore") {
3584
- if(_1.arguments_.length > 0) {
3585
2360
  const left_ = _1.arguments_[0];
3586
- if(_1.arguments_.length > 1) {
3587
2361
  const right_ = _1.arguments_[1];
3588
- if(_1.arguments_.length === 2) {
3589
- if(_1.dictionaries_.length > 0) {
3590
2362
  const typeName_ = _1.dictionaries_[0].typeName_;
3591
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
3592
- if(_1.dictionaries_.length === 1) {
3593
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
3594
- if(_guard1) {
2363
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
3595
2364
  return (((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " >= ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3596
- return
3597
- }
3598
- }
3599
- }
3600
- }
3601
- }
3602
- }
3603
- }
3604
2365
  }
3605
2366
  }
3606
- }
3607
- }
3608
- {
3609
- if(_1.ECall) {
2367
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.after" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
3610
2368
  const at_ = _1.at_;
3611
- if(_1.target_.StaticCall) {
3612
- if(_1.target_.name_ === "ff:core/Ordering.after") {
3613
- if(_1.arguments_.length > 0) {
3614
2369
  const left_ = _1.arguments_[0];
3615
- if(_1.arguments_.length > 1) {
3616
2370
  const right_ = _1.arguments_[1];
3617
- if(_1.arguments_.length === 2) {
3618
- if(_1.dictionaries_.length > 0) {
3619
2371
  const typeName_ = _1.dictionaries_[0].typeName_;
3620
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
3621
- if(_1.dictionaries_.length === 1) {
3622
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
3623
- if(_guard1) {
2372
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
3624
2373
  return (((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " > ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3625
- return
3626
- }
3627
- }
3628
- }
3629
- }
3630
2374
  }
3631
2375
  }
3632
- }
3633
- }
3634
- }
3635
- }
3636
- }
3637
- {
3638
- if(_1.ECall) {
2376
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Ordering.notAfter" && _1.arguments_.length === 2 && _1.dictionaries_.length === 1 && _1.dictionaries_[0].dictionaries_.length === 0) {
3639
2377
  const at_ = _1.at_;
3640
- if(_1.target_.StaticCall) {
3641
- if(_1.target_.name_ === "ff:core/Ordering.notAfter") {
3642
- if(_1.arguments_.length > 0) {
3643
2378
  const left_ = _1.arguments_[0];
3644
- if(_1.arguments_.length > 1) {
3645
2379
  const right_ = _1.arguments_[1];
3646
- if(_1.arguments_.length === 2) {
3647
- if(_1.dictionaries_.length > 0) {
3648
2380
  const typeName_ = _1.dictionaries_[0].typeName_;
3649
- if(_1.dictionaries_[0].dictionaries_.length === 0) {
3650
- if(_1.dictionaries_.length === 1) {
3651
- const _guard1 = ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
3652
- if(_guard1) {
2381
+ if(ff_core_Set.Set_contains(ff_compiler_JsEmitter.primitiveTypes_, typeName_, ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String)) {
3653
2382
  return (((("(" + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, left_, async_, $task))) + " <= ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, right_, async_, $task))) + ")")
3654
- return
3655
- }
3656
- }
3657
- }
3658
- }
3659
- }
3660
- }
3661
- }
3662
- }
3663
- }
3664
2383
  }
3665
2384
  }
3666
- {
3667
- if(_1.ECall) {
3668
- if(_1.target_.StaticCall) {
3669
- if(_1.target_.name_ === "ff:core/List.fillBy") {
2385
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.fillBy" && _1.arguments_.length === 2 && _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) {
3670
2386
  const effect_ = _1.effect_;
3671
- if(_1.arguments_.length > 0) {
3672
2387
  const size_ = _1.arguments_[0];
3673
- if(_1.arguments_.length > 1) {
3674
- if(_1.arguments_[1].value_.ELambda) {
3675
2388
  const at_ = _1.arguments_[1].value_.at_;
3676
2389
  const l_ = _1.arguments_[1].value_.lambda_;
3677
- if(_1.arguments_[1].value_.lambda_.cases_.length > 0) {
3678
2390
  const c_ = _1.arguments_[1].value_.lambda_.cases_[0];
3679
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length > 0) {
3680
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].PVariable) {
3681
2391
  const name_ = _1.arguments_[1].value_.lambda_.cases_[0].patterns_[0].name_;
3682
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 1) {
3683
- if(_1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
3684
2392
  const body_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
3685
- if(_1.arguments_[1].value_.lambda_.cases_.length === 1) {
3686
- if(_1.arguments_.length === 2) {
3687
- const _guard1 = (!ff_compiler_JsEmitter.effectTypeIsAsync_(effect_));
3688
- if(_guard1) {
2393
+ if((!ff_compiler_JsEmitter.effectTypeIsAsync_(effect_))) {
3689
2394
  const n_ = ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
3690
2395
  return ff_compiler_JsEmitter.escapeResolved_(_w1)
3691
2396
  })), (() => {
@@ -3696,28 +2401,11 @@ const await_ = (newAsync_
3696
2401
  ? "await "
3697
2402
  : "");
3698
2403
  return ((((((((((((((((((await_ + "((() => {\n") + "const size = ") + (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, size_, async_, $task))) + ";\n") + "const result = [];\n") + "for(let ") + n_) + " = 0; ") + n_) + " < size; ") + n_) + "++) {\n") + "result.push(") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, newAsync_, $task))) + ");\n") + "}\n") + "return result;\n") + "})())")
3699
- return
3700
- }
3701
- }
3702
- }
3703
- }
3704
- }
3705
- }
3706
2404
  }
3707
2405
  }
3708
- }
3709
- }
3710
- }
3711
- }
3712
- }
3713
- }
3714
- }
3715
- {
3716
- if(_1.ECall) {
2406
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.instanceCall_) {
3717
2407
  const at_ = _1.at_;
3718
- if(_1.target_.StaticCall) {
3719
2408
  const name_ = _1.target_.name_;
3720
- if(_1.target_.instanceCall_) {
3721
2409
  const effect_ = _1.effect_;
3722
2410
  const typeArguments_ = _1.typeArguments_;
3723
2411
  const arguments_ = _1.arguments_;
@@ -3748,13 +2436,8 @@ return call_
3748
2436
  }
3749
2437
  return
3750
2438
  }
3751
- }
3752
- }
3753
- }
3754
- {
3755
- if(_1.ECall) {
2439
+ if(_1.ECall && _1.target_.StaticCall) {
3756
2440
  const at_ = _1.at_;
3757
- if(_1.target_.StaticCall) {
3758
2441
  const name_ = _1.target_.name_;
3759
2442
  const effect_ = _1.effect_;
3760
2443
  const typeArguments_ = _1.typeArguments_;
@@ -3770,7 +2453,6 @@ throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Core.G
3770
2453
  };
3771
2454
  {
3772
2455
  const _1 = ff_compiler_JsEmitter.detectIfElse_(term_);
3773
- {
3774
2456
  if(_1.length === 0) {
3775
2457
  const await_ = (async_ && ff_compiler_JsEmitter.effectTypeIsAsync_(effect_));
3776
2458
  const ds_ = (await ff_core_List.List_map$(dictionaries_, (async (_w1, $task) => {
@@ -3793,11 +2475,7 @@ return call_
3793
2475
  }
3794
2476
  return
3795
2477
  }
3796
- }
3797
- {
3798
- if(_1.length > 0) {
3799
- if(_1[0].first_.EVariant) {
3800
- if(_1[0].first_.name_ === "ff:core/Bool.True") {
2478
+ if(_1.length >= 1 && _1[0].first_.EVariant && _1[0].first_.name_ === "ff:core/Bool.True") {
3801
2479
  const elseBody_ = _1[0].second_;
3802
2480
  const list_ = _1.slice(1);
3803
2481
  return (("(" + (await ff_core_List.List_foldLeft$(list_, (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, elseBody_, async_, $task)), (async (_1, _2, $task) => {
@@ -3806,14 +2484,10 @@ const otherwise_ = _1;
3806
2484
  const condition_ = _2.first_;
3807
2485
  const body_ = _2.second_;
3808
2486
  return (((((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_, async_, $task)) + "\n? ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task))) + "\n: ") + otherwise_)
3809
- return
3810
2487
  }
3811
2488
  }), $task))) + ")")
3812
2489
  return
3813
2490
  }
3814
- }
3815
- }
3816
- }
3817
2491
  {
3818
2492
  const list_ = _1;
3819
2493
  return (("(" + (await ff_core_List.List_foldLeft$(list_, "ff_core_Option.None()", (async (_1, _2, $task) => {
@@ -3822,7 +2496,6 @@ const otherwise_ = _1;
3822
2496
  const condition_ = _2.first_;
3823
2497
  const body_ = _2.second_;
3824
2498
  return (((((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_, async_, $task)) + "\n? ff_core_Option.Some(") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task))) + ")\n: ") + otherwise_)
3825
- return
3826
2499
  }
3827
2500
  }), $task))) + ")")
3828
2501
  return
@@ -3830,12 +2503,8 @@ return
3830
2503
  }
3831
2504
  return
3832
2505
  }
3833
- }
3834
- }
3835
- {
3836
- if(_1.ECall) {
2506
+ if(_1.ECall && _1.target_.DynamicCall) {
3837
2507
  const at_ = _1.at_;
3838
- if(_1.target_.DynamicCall) {
3839
2508
  const function_ = _1.target_.function_;
3840
2509
  const effect_ = _1.effect_;
3841
2510
  const typeArguments_ = _1.typeArguments_;
@@ -3860,9 +2529,6 @@ return call_
3860
2529
  }
3861
2530
  return
3862
2531
  }
3863
- }
3864
- }
3865
- {
3866
2532
  if(_1.ERecord) {
3867
2533
  const at_ = _1.at_;
3868
2534
  const fields_ = _1.fields_;
@@ -3876,8 +2542,6 @@ return (("{\n" + ff_core_List.List_join(list_, ",\n")) + "\n}")
3876
2542
  }
3877
2543
  return
3878
2544
  }
3879
- }
3880
- {
3881
2545
  if(_1.EWildcard) {
3882
2546
  const at_ = _1.at_;
3883
2547
  const index_ = _1.index_;
@@ -3885,19 +2549,12 @@ if((index_ === 0)) {
3885
2549
  ff_compiler_JsEmitter.fail_(at_, "Unbound wildcard")
3886
2550
  };
3887
2551
  return ("_w" + index_)
3888
- return
3889
- }
3890
2552
  }
3891
- {
3892
- const _guard1 = async_;
3893
- if(_guard1) {
2553
+ if(async_) {
3894
2554
  return (("(await (async function() {\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, term_, true, async_, $task))) + "\n})())")
3895
- return
3896
- }
3897
2555
  }
3898
2556
  {
3899
2557
  return (("(function() {\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, term_, true, async_, $task))) + "\n})()")
3900
- return
3901
2558
  }
3902
2559
  }
3903
2560
  }
@@ -3919,7 +2576,6 @@ return (await ff_compiler_JsEmitter.JsEmitter_emitDictionary$(self_, _w1, $task)
3919
2576
  export async function JsEmitter_emitStatements$(self_, term_, last_, async_, $task) {
3920
2577
  {
3921
2578
  const _1 = term_;
3922
- {
3923
2579
  if(_1.EFunctions) {
3924
2580
  const at_ = _1.at_;
3925
2581
  const functions_ = _1.functions_;
@@ -3929,10 +2585,7 @@ const newAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsy
3929
2585
  return (await ff_compiler_JsEmitter.JsEmitter_emitFunctionDefinition$(self_, f_, newAsync_, "", $task))
3930
2586
  }), $task));
3931
2587
  return ((ff_core_List.List_join(functionStrings_, "\n") + "\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task)))
3932
- return
3933
- }
3934
2588
  }
3935
- {
3936
2589
  if(_1.ELet) {
3937
2590
  const at_ = _1.at_;
3938
2591
  const mutable_ = _1.mutable_;
@@ -3941,64 +2594,32 @@ const valueType_ = _1.valueType_;
3941
2594
  const value_ = _1.value_;
3942
2595
  const body_ = _1.body_;
3943
2596
  return (((await ff_compiler_JsEmitter.JsEmitter_emitLetDefinition$(self_, ff_compiler_Syntax.DLet(at_, name_, valueType_, value_), mutable_, async_, $task)) + "\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task)))
3944
- return
3945
2597
  }
3946
- }
3947
- {
3948
- if(_1.EVariant) {
2598
+ if(_1.EVariant && _1.name_ === "ff:core/Unit.Unit") {
3949
2599
  const at_ = _1.at_;
3950
- if(_1.name_ === "ff:core/Unit.Unit") {
3951
2600
  return ""
3952
- return
3953
2601
  }
3954
- }
3955
- }
3956
- {
3957
- if(_1.ESequential) {
3958
- const at_ = _1.at_;
3959
- if(_1.before_.EVariant) {
3960
- const at_ = _1.before_.at_;
3961
- if(_1.before_.name_ === "ff:core/Unit.Unit") {
2602
+ if(_1.ESequential && _1.before_.EVariant && _1.before_.name_ === "ff:core/Unit.Unit") {
3962
2603
  const after_ = _1.after_;
3963
2604
  return (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, after_, last_, async_, $task))
3964
- return
3965
- }
3966
- }
3967
2605
  }
3968
- }
3969
- {
3970
- if(_1.ESequential) {
3971
- const at_ = _1.at_;
2606
+ if(_1.ESequential && _1.after_.EVariant && _1.after_.name_ === "ff:core/Unit.Unit") {
3972
2607
  const before_ = _1.before_;
3973
- if(_1.after_.EVariant) {
3974
- const at_ = _1.after_.at_;
3975
- if(_1.after_.name_ === "ff:core/Unit.Unit") {
3976
2608
  return (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, before_, false, async_, $task))
3977
- return
3978
- }
3979
- }
3980
- }
3981
2609
  }
3982
- {
3983
2610
  if(_1.ESequential) {
3984
2611
  const at_ = _1.at_;
3985
2612
  const before_ = _1.before_;
3986
2613
  const after_ = _1.after_;
3987
2614
  return (((await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, before_, false, async_, $task)) + ";\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, after_, last_, async_, $task)))
3988
- return
3989
2615
  }
3990
- }
3991
- {
3992
2616
  if(_1.EAssign) {
3993
2617
  const at_ = _1.at_;
3994
2618
  const operator_ = _1.operator_;
3995
2619
  const name_ = _1.variable_;
3996
2620
  const value_ = _1.value_;
3997
2621
  return ((((ff_compiler_JsEmitter.escapeKeyword_(name_) + " ") + operator_) + "= ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, value_, async_, $task)))
3998
- return
3999
- }
4000
2622
  }
4001
- {
4002
2623
  if(_1.EAssignField) {
4003
2624
  const at_ = _1.at_;
4004
2625
  const operator_ = _1.operator_;
@@ -4006,235 +2627,102 @@ const record_ = _1.record_;
4006
2627
  const field_ = _1.field_;
4007
2628
  const value_ = _1.value_;
4008
2629
  return (((((((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, record_, async_, $task)) + ".") + ff_compiler_JsEmitter.escapeKeyword_(field_)) + " ") + operator_) + "= ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, value_, async_, $task)))
4009
- return
4010
2630
  }
4011
- }
4012
- {
4013
- if(_1.ECall) {
2631
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.while" && _1.arguments_.length === 2) {
4014
2632
  const at_ = _1.at_;
4015
- if(_1.target_.StaticCall) {
4016
- if(_1.target_.name_ === "ff:core/Core.while") {
4017
- if(_1.arguments_.length > 0) {
4018
2633
  const condition_ = _1.arguments_[0];
4019
- if(_1.arguments_.length > 1) {
4020
2634
  const body_ = _1.arguments_[1];
4021
- if(_1.arguments_.length === 2) {
4022
2635
  return (((("while(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, ff_compiler_JsEmitter.invokeImmediately_(condition_.value_), async_, $task))) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_), false, async_, $task))) + "\n}")
4023
- return
4024
- }
4025
2636
  }
4026
- }
4027
- }
4028
- }
4029
- }
4030
- }
4031
- {
4032
- if(_1.ECall) {
2637
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.doWhile" && _1.arguments_.length === 1) {
4033
2638
  const at_ = _1.at_;
4034
- if(_1.target_.StaticCall) {
4035
- if(_1.target_.name_ === "ff:core/Core.doWhile") {
4036
- if(_1.arguments_.length > 0) {
4037
2639
  const doWhileBody_ = _1.arguments_[0].value_;
4038
- if(_1.arguments_.length === 1) {
4039
2640
  const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
4040
2641
  if(_guard1.ESequential) {
4041
2642
  const body_ = _guard1.before_;
4042
2643
  const condition_ = _guard1.after_;
4043
2644
  return ((((("while(true) {\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, false, async_, $task))) + "\nif(!") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_, async_, $task))) + ") break") + "\n}")
4044
- return
4045
- }
4046
2645
  }
4047
2646
  }
4048
- }
4049
- }
4050
- }
4051
- }
4052
- {
4053
- if(_1.ECall) {
2647
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.doWhile" && _1.arguments_.length === 1) {
4054
2648
  const at_ = _1.at_;
4055
- if(_1.target_.StaticCall) {
4056
- if(_1.target_.name_ === "ff:core/Core.doWhile") {
4057
- if(_1.arguments_.length > 0) {
4058
2649
  const doWhileBody_ = _1.arguments_[0].value_;
4059
- if(_1.arguments_.length === 1) {
4060
2650
  const _guard1 = ff_compiler_JsEmitter.invokeImmediately_(doWhileBody_);
2651
+ {
4061
2652
  const body_ = _guard1;
4062
2653
  return (("while(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task))) + ") {}")
4063
- return
4064
- }
4065
2654
  }
4066
2655
  }
4067
- }
4068
- }
4069
- }
4070
- {
4071
- if(_1.ECall) {
2656
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.if" && _1.arguments_.length === 2) {
4072
2657
  const at_ = _1.at_;
4073
- if(_1.target_.StaticCall) {
4074
- if(_1.target_.name_ === "ff:core/Core.if") {
4075
- if(_1.arguments_.length > 0) {
4076
2658
  const condition_ = _1.arguments_[0];
4077
- if(_1.arguments_.length > 1) {
4078
2659
  const body_ = _1.arguments_[1];
4079
- if(_1.arguments_.length === 2) {
4080
2660
  return ((("if(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_.value_, async_, $task))) + ") {\n") + (last_
4081
2661
  ? (("return ff_core_Option.Some(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_), async_, $task))) + ")\n} else return ff_core_Option.None()")
4082
2662
  : ((await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, ff_compiler_JsEmitter.invokeImmediately_(body_.value_), false, async_, $task)) + "\n}")))
4083
2663
  return
4084
2664
  }
4085
- }
4086
- }
4087
- }
4088
- }
4089
- }
4090
- }
4091
- {
4092
- if(_1.ECall) {
2665
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.throw" && _1.arguments_.length === 1 && _1.dictionaries_.length === 1) {
4093
2666
  const at_ = _1.at_;
4094
- if(_1.target_.StaticCall) {
4095
- if(_1.target_.name_ === "ff:core/Core.throw") {
4096
- if(_1.arguments_.length > 0) {
4097
2667
  const argument_ = _1.arguments_[0];
4098
- if(_1.arguments_.length === 1) {
4099
- if(_1.dictionaries_.length > 0) {
4100
2668
  const dictionary_ = _1.dictionaries_[0];
4101
- if(_1.dictionaries_.length === 1) {
4102
2669
  const d_ = (await ff_compiler_JsEmitter.JsEmitter_emitDictionary$(self_, dictionary_, $task));
4103
2670
  const a_ = (await ff_compiler_JsEmitter.JsEmitter_emitArgument$(self_, at_, argument_, async_, $task));
4104
2671
  return (((("throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(" + a_) + ", ") + d_) + ")})")
4105
- return
4106
- }
4107
- }
4108
- }
4109
- }
4110
2672
  }
4111
- }
4112
- }
4113
- }
4114
- {
4115
- if(_1.ECall) {
2673
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Core.try") {
4116
2674
  const at_ = _1.at_;
4117
- if(_1.target_.StaticCall) {
4118
- if(_1.target_.name_ === "ff:core/Core.try") {
4119
- const _guard1 = (!last_);
4120
- if(_guard1) {
2675
+ if((!last_)) {
4121
2676
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a try without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4122
- return
4123
- }
4124
- }
4125
- }
4126
2677
  }
4127
2678
  }
4128
- {
4129
- if(_1.ECall) {
2679
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_map") {
4130
2680
  const at_ = _1.at_;
4131
- if(_1.target_.StaticCall) {
4132
- if(_1.target_.name_ === "ff:core/Try.Try_map") {
4133
- const _guard1 = (!last_);
4134
- if(_guard1) {
2681
+ if((!last_)) {
4135
2682
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a map without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4136
- return
4137
- }
4138
- }
4139
2683
  }
4140
2684
  }
4141
- }
4142
- {
4143
- if(_1.ECall) {
2685
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_flatMap") {
4144
2686
  const at_ = _1.at_;
4145
- if(_1.target_.StaticCall) {
4146
- if(_1.target_.name_ === "ff:core/Try.Try_flatMap") {
4147
- const _guard1 = (!last_);
4148
- if(_guard1) {
2687
+ if((!last_)) {
4149
2688
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a flatMap without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4150
- return
4151
- }
4152
2689
  }
4153
2690
  }
4154
- }
4155
- }
4156
- {
4157
- if(_1.ECall) {
2691
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_flatten") {
4158
2692
  const at_ = _1.at_;
4159
- if(_1.target_.StaticCall) {
4160
- if(_1.target_.name_ === "ff:core/Try.Try_flatten") {
4161
- const _guard1 = (!last_);
4162
- if(_guard1) {
2693
+ if((!last_)) {
4163
2694
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a flatten without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4164
- return
4165
2695
  }
4166
2696
  }
4167
- }
4168
- }
4169
- }
4170
- {
4171
- if(_1.ECall) {
2697
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catch") {
4172
2698
  const at_ = _1.at_;
4173
- if(_1.target_.StaticCall) {
4174
- if(_1.target_.name_ === "ff:core/Try.Try_catch") {
4175
- const _guard1 = (!last_);
4176
- if(_guard1) {
2699
+ if((!last_)) {
4177
2700
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a catch without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4178
- return
4179
- }
4180
- }
4181
- }
4182
2701
  }
4183
2702
  }
4184
- {
4185
- if(_1.ECall) {
2703
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_catchAny") {
4186
2704
  const at_ = _1.at_;
4187
- if(_1.target_.StaticCall) {
4188
- if(_1.target_.name_ === "ff:core/Try.Try_catchAny") {
4189
- const _guard1 = (!last_);
4190
- if(_guard1) {
2705
+ if((!last_)) {
4191
2706
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a catchAny without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4192
- return
4193
- }
4194
- }
4195
2707
  }
4196
2708
  }
4197
- }
4198
- {
4199
- if(_1.ECall) {
2709
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_finally") {
4200
2710
  const at_ = _1.at_;
4201
- if(_1.target_.StaticCall) {
4202
- if(_1.target_.name_ === "ff:core/Try.Try_finally") {
4203
- const _guard1 = (!last_);
4204
- if(_guard1) {
2711
+ if((!last_)) {
4205
2712
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(at_, "Statements can't be a finally without a grab"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
4206
- return
4207
- }
4208
2713
  }
4209
2714
  }
4210
- }
4211
- }
4212
- {
4213
- if(_1.ECall) {
2715
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/Try.Try_grab" && _1.arguments_.length === 1) {
4214
2716
  const at_ = _1.at_;
4215
- if(_1.target_.StaticCall) {
4216
- if(_1.target_.name_ === "ff:core/Try.Try_grab") {
4217
- if(_1.arguments_.length > 0) {
4218
2717
  const argument_ = _1.arguments_[0];
4219
- if(_1.arguments_.length === 1) {
4220
2718
  const _guard1 = (await ff_compiler_JsEmitter.JsEmitter_emitTryCatchFinally$(self_, argument_.value_, last_, async_, $task));
4221
2719
  if(_guard1.Some) {
4222
2720
  const code_ = _guard1.value_;
4223
2721
  return code_
4224
- return
4225
2722
  }
4226
2723
  }
4227
- }
4228
- }
4229
- }
4230
- }
4231
- }
4232
- {
4233
- if(_1.ECall) {
2724
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
4234
2725
  const at_ = _1.at_;
4235
- if(_1.target_.StaticCall) {
4236
- if(_1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled") {
4237
- if(_1.arguments_.length === 0) {
4238
2726
  if(async_) {
4239
2727
  return "ff_core_Task.Task_throwIfAborted($task)"
4240
2728
  } else {
@@ -4242,16 +2730,9 @@ return ""
4242
2730
  }
4243
2731
  return
4244
2732
  }
4245
- }
4246
- }
4247
- }
4248
- }
4249
- {
4250
- if(_1.ECall) {
2733
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.tailCall_) {
4251
2734
  const at_ = _1.at_;
4252
- if(_1.target_.StaticCall) {
4253
2735
  const name_ = _1.target_.name_;
4254
- if(_1.target_.tailCall_) {
4255
2736
  const instanceCall_ = _1.target_.instanceCall_;
4256
2737
  const effect_ = _1.effect_;
4257
2738
  const arguments_ = _1.arguments_;
@@ -4265,33 +2746,24 @@ return ff_core_Option.Some(ff_core_Pair.Pair((((("const " + ff_compiler_JsEmitte
4265
2746
  return _w1
4266
2747
  })));
4267
2748
  return (((("{\n" + ff_core_List.List_join(pair_.first_, "\n")) + "\n") + ff_core_List.List_join(pair_.second_, "\n")) + "\ncontinue _tailcall\n}")
4268
- return
4269
2749
  }
4270
- }
4271
- }
4272
- }
4273
- {
4274
- if(_1.EPipe) {
2750
+ if(_1.EPipe && _1.function_.ELambda) {
4275
2751
  const at_ = _1.at_;
4276
2752
  const value_ = _1.value_;
4277
- if(_1.function_.ELambda) {
4278
2753
  const cases_ = _1.function_.lambda_.cases_;
4279
2754
  ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
4280
2755
  return ((((((((!last_)
4281
2756
  ? "do "
4282
2757
  : "") + "{\nconst _1 = ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, value_, async_, $task))) + ";\n") + ff_core_List.List_join((await ff_core_List.List_map$(cases_, (async (_w1, $task) => {
4283
- return (("{\n" + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, ["_1"], _w1, true, last_, async_, $task))) + "\n}")
2758
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, ["_1"], _w1, [], [], true, last_, async_, $task))
4284
2759
  }), $task)), "\n")) + "\n}") + ((!last_)
4285
2760
  ? " while(false)"
4286
2761
  : ""))
4287
2762
  return
4288
2763
  }
4289
- }
4290
- }
4291
2764
  {
4292
2765
  {
4293
2766
  const _1 = ff_compiler_JsEmitter.detectIfElse_(term_);
4294
- {
4295
2767
  if(_1.length === 0) {
4296
2768
  if(last_) {
4297
2769
  return ("return " + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, term_, async_, $task)))
@@ -4300,11 +2772,7 @@ return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, term_, async_, $t
4300
2772
  }
4301
2773
  return
4302
2774
  }
4303
- }
4304
- {
4305
- if(_1.length > 0) {
4306
- if(_1[0].first_.EVariant) {
4307
- if(_1[0].first_.name_ === "ff:core/Bool.True") {
2775
+ if(_1.length >= 1 && _1[0].first_.EVariant && _1[0].first_.name_ === "ff:core/Bool.True") {
4308
2776
  const elseBody_ = _1[0].second_;
4309
2777
  const list_ = _1.slice(1);
4310
2778
  const initial_ = (("{\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, elseBody_, last_, async_, $task))) + "\n}");
@@ -4314,25 +2782,19 @@ const otherwise_ = _1;
4314
2782
  const condition_ = _2.first_;
4315
2783
  const body_ = _2.second_;
4316
2784
  return ((((("if(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_, async_, $task))) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + "\n} else ") + otherwise_)
4317
- return
4318
2785
  }
4319
2786
  }), $task))
4320
2787
  return
4321
2788
  }
4322
- }
4323
- }
4324
- }
4325
2789
  {
4326
2790
  const list_ = _1;
4327
- const _guard1 = (!last_);
4328
- if(_guard1) {
2791
+ if((!last_)) {
4329
2792
  return (await ff_core_List.List_foldLeft$(list_, "{}", (async (_1, _2, $task) => {
4330
2793
  {
4331
2794
  const otherwise_ = _1;
4332
2795
  const condition_ = _2.first_;
4333
2796
  const body_ = _2.second_;
4334
2797
  return ((((("if(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_, async_, $task))) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + "\n} else ") + otherwise_)
4335
- return
4336
2798
  }
4337
2799
  }), $task))
4338
2800
  return
@@ -4346,7 +2808,6 @@ const otherwise_ = _1;
4346
2808
  const condition_ = _2.first_;
4347
2809
  const body_ = _2.second_;
4348
2810
  return (((((("if(" + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, condition_, async_, $task))) + ") {\n") + "return ff_core_Option.Some(") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task))) + ")\n} else ") + otherwise_)
4349
- return
4350
2811
  }
4351
2812
  }), $task))
4352
2813
  return
@@ -4364,19 +2825,14 @@ ff_compiler_Patterns.convertAndCheck_(self_.otherModules_, cases_);
4364
2825
  const arguments_ = ["_exception.value_", "_error"];
4365
2826
  {
4366
2827
  const _1 = cases_;
4367
- {
4368
- if(_1.length > 0) {
4369
- const case_ = _1[0];
4370
2828
  if(_1.length === 1) {
4371
- return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, case_, false, last_, catchAsync_, $task))
4372
- return
4373
- }
4374
- }
2829
+ const case_ = _1[0];
2830
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, case_, [], [], false, last_, catchAsync_, $task))
4375
2831
  }
4376
2832
  {
4377
2833
  const cs_ = _1;
4378
2834
  const caseStrings_ = (await ff_core_List.List_map$(cases_, (async (_w1, $task) => {
4379
- return (("{\n" + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, _w1, true, last_, catchAsync_, $task))) + "\n}")
2835
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, _w1, [], [], true, last_, catchAsync_, $task))
4380
2836
  }), $task));
4381
2837
  if(last_) {
4382
2838
  return ff_core_List.List_join(caseStrings_, "\n")
@@ -4389,344 +2845,181 @@ return
4389
2845
  }
4390
2846
  {
4391
2847
  const _1 = term_;
4392
- {
4393
- if(_1.ECall) {
4394
- const at_ = _1.at_;
4395
- if(_1.target_.StaticCall) {
4396
- if(_1.target_.name_ === "ff:core/Try.Try_finally") {
4397
- if(_1.arguments_.length > 0) {
4398
- if(_1.arguments_[0].value_.ECall) {
4399
- const at_ = _1.arguments_[0].value_.at_;
4400
- if(_1.arguments_[0].value_.target_.StaticCall) {
4401
- if(_1.arguments_[0].value_.target_.name_ === "ff:core/Core.try") {
4402
- if(_1.arguments_[0].value_.arguments_.length > 0) {
4403
- if(_1.arguments_[0].value_.arguments_[0].value_.ELambda) {
2848
+ 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/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 === 0 && _1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
4404
2849
  const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
4405
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length > 0) {
4406
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0) {
4407
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0) {
4408
2850
  const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
4409
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1) {
4410
- if(_1.arguments_[0].value_.arguments_.length === 1) {
4411
- if(_1.arguments_.length > 1) {
4412
- if(_1.arguments_[1].value_.ELambda) {
4413
2851
  const finallyEffect_ = _1.arguments_[1].value_.lambda_.effect_;
4414
- if(_1.arguments_[1].value_.lambda_.cases_.length > 0) {
4415
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 0) {
4416
- if(_1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
4417
2852
  const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
4418
- if(_1.arguments_[1].value_.lambda_.cases_.length === 1) {
4419
- if(_1.arguments_.length === 2) {
4420
2853
  const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
4421
2854
  const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
4422
2855
  return ff_core_Option.Some((((("try {\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, tryBody_, last_, tryAsync_, $task))) + "\n} finally {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, finallyBody_, last_, finallyAsync_, $task))) + "\n}"))
4423
- return
4424
- }
4425
- }
4426
- }
4427
- }
4428
- }
4429
- }
4430
- }
4431
- }
4432
- }
4433
- }
4434
- }
4435
- }
4436
- }
4437
- }
4438
- }
4439
- }
4440
- }
4441
- }
4442
- }
4443
2856
  }
4444
- }
4445
- }
4446
- {
4447
- if(_1.ECall) {
4448
- const at_ = _1.at_;
4449
- if(_1.target_.StaticCall) {
4450
- if(_1.target_.name_ === "ff:core/Try.Try_catch") {
4451
- if(_1.arguments_.length > 0) {
4452
- if(_1.arguments_[0].value_.ECall) {
4453
- const at_ = _1.arguments_[0].value_.at_;
4454
- if(_1.arguments_[0].value_.target_.StaticCall) {
4455
- if(_1.arguments_[0].value_.target_.name_ === "ff:core/Core.try") {
4456
- if(_1.arguments_[0].value_.arguments_.length > 0) {
4457
- if(_1.arguments_[0].value_.arguments_[0].value_.ELambda) {
2857
+ 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) {
4458
2858
  const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
4459
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length > 0) {
4460
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0) {
4461
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0) {
4462
2859
  const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
4463
- if(_1.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1) {
4464
- if(_1.arguments_[0].value_.arguments_.length === 1) {
4465
- if(_1.arguments_.length > 1) {
4466
- if(_1.arguments_[1].value_.ELambda) {
4467
2860
  const catchEffect_ = _1.arguments_[1].value_.lambda_.effect_;
4468
2861
  const cases_ = _1.arguments_[1].value_.lambda_.cases_;
4469
- if(_1.arguments_.length === 2) {
4470
- if(_1.dictionaries_.length > 0) {
4471
2862
  const dictionary_ = _1.dictionaries_[0];
4472
- if(_1.dictionaries_.length === 1) {
4473
2863
  const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
4474
2864
  const d_ = (await ff_compiler_JsEmitter.JsEmitter_emitDictionary$(self_, dictionary_, $task));
4475
2865
  return ff_core_Option.Some(((((((((("try {\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, tryBody_, last_, tryAsync_, $task))) + "\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") + (await emitCatch_$(catchEffect_, cases_, $task))) + "\n}"))
4476
- return
4477
- }
4478
- }
4479
- }
4480
- }
4481
- }
4482
- }
4483
- }
4484
- }
4485
- }
4486
- }
4487
- }
4488
2866
  }
4489
- }
4490
- }
4491
- }
4492
- }
4493
- }
4494
- }
4495
- }
4496
- }
4497
- {
4498
- if(_1.ECall) {
4499
- const at_ = _1.at_;
4500
- if(_1.target_.StaticCall) {
4501
- if(_1.target_.name_ === "ff:core/Try.Try_finally") {
4502
- if(_1.arguments_.length > 0) {
4503
- if(_1.arguments_[0].value_.ECall) {
4504
- const at_ = _1.arguments_[0].value_.at_;
4505
- if(_1.arguments_[0].value_.target_.StaticCall) {
4506
- if(_1.arguments_[0].value_.target_.name_ === "ff:core/Try.Try_catch") {
4507
- if(_1.arguments_[0].value_.arguments_.length > 0) {
4508
- if(_1.arguments_[0].value_.arguments_[0].value_.ECall) {
4509
- const at_ = _1.arguments_[0].value_.arguments_[0].value_.at_;
4510
- if(_1.arguments_[0].value_.arguments_[0].value_.target_.StaticCall) {
4511
- if(_1.arguments_[0].value_.arguments_[0].value_.target_.name_ === "ff:core/Core.try") {
4512
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_.length > 0) {
4513
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.ELambda) {
2867
+ 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) {
4514
2868
  const tryEffect_ = _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.effect_;
4515
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length > 0) {
4516
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].patterns_.length === 0) {
4517
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].guards_.length === 0) {
4518
2869
  const tryBody_ = _1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_[0].body_;
4519
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_[0].value_.lambda_.cases_.length === 1) {
4520
- if(_1.arguments_[0].value_.arguments_[0].value_.arguments_.length === 1) {
4521
- if(_1.arguments_[0].value_.arguments_.length > 1) {
4522
- if(_1.arguments_[0].value_.arguments_[1].value_.ELambda) {
4523
2870
  const catchEffect_ = _1.arguments_[0].value_.arguments_[1].value_.lambda_.effect_;
4524
2871
  const cases_ = _1.arguments_[0].value_.arguments_[1].value_.lambda_.cases_;
4525
- if(_1.arguments_[0].value_.arguments_.length === 2) {
4526
- if(_1.arguments_[0].value_.dictionaries_.length > 0) {
4527
2872
  const dictionary_ = _1.arguments_[0].value_.dictionaries_[0];
4528
- if(_1.arguments_[0].value_.dictionaries_.length === 1) {
4529
- if(_1.arguments_.length > 1) {
4530
- if(_1.arguments_[1].value_.ELambda) {
4531
2873
  const finallyEffect_ = _1.arguments_[1].value_.lambda_.effect_;
4532
- if(_1.arguments_[1].value_.lambda_.cases_.length > 0) {
4533
- if(_1.arguments_[1].value_.lambda_.cases_[0].patterns_.length === 0) {
4534
- if(_1.arguments_[1].value_.lambda_.cases_[0].guards_.length === 0) {
4535
2874
  const finallyBody_ = _1.arguments_[1].value_.lambda_.cases_[0].body_;
4536
- if(_1.arguments_[1].value_.lambda_.cases_.length === 1) {
4537
- if(_1.arguments_.length === 2) {
4538
2875
  const tryAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(tryEffect_));
4539
2876
  const finallyAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(finallyEffect_));
4540
2877
  const d_ = (await ff_compiler_JsEmitter.JsEmitter_emitDictionary$(self_, dictionary_, $task));
4541
2878
  return ff_core_Option.Some(((((((((((("try {\n" + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, tryBody_, last_, tryAsync_, $task))) + "\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") + (await emitCatch_$(catchEffect_, cases_, $task))) + "\n} finally {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, finallyBody_, last_, finallyAsync_, $task))) + "\n}"))
4542
- return
4543
- }
4544
- }
4545
- }
4546
- }
4547
- }
4548
- }
4549
- }
4550
- }
4551
- }
4552
- }
4553
- }
4554
- }
4555
- }
4556
- }
4557
- }
4558
- }
4559
- }
4560
- }
4561
- }
4562
- }
4563
- }
4564
- }
4565
- }
4566
- }
4567
- }
4568
- }
4569
- }
4570
- }
4571
- }
4572
- }
4573
2879
  }
4574
2880
  {
4575
2881
  return ff_core_Option.None()
4576
- return
4577
2882
  }
4578
2883
  }
4579
2884
  }
4580
2885
 
4581
- export async function JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task) {
2886
+ export async function JsEmitter_emitCase$(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_, $task) {
2887
+ function emitWrapper_(code_) {
2888
+ return ((((ff_core_List.List_isEmpty(conditions_)
2889
+ ? "{\n"
2890
+ : (("if(" + ff_core_List.List_join(conditions_, " && ")) + ") {\n")) + ff_core_List.List_join(variables_, "")) + code_) + "\n}")
2891
+ }
4582
2892
  {
4583
2893
  const _1 = ff_core_Pair.Pair(matchCase_.patterns_, matchCase_.guards_);
4584
- {
4585
- if(_1.first_.length > 0) {
2894
+ if(_1.first_.length >= 1) {
4586
2895
  const p_ = _1.first_[0];
4587
2896
  const ps_ = _1.first_.slice(1);
4588
2897
  return (await ff_compiler_JsEmitter.JsEmitter_emitPattern$(self_, ff_core_List.List_grab(arguments_, 0), p_, ff_core_List.List_dropFirst(arguments_, 1), (((_c) => {
4589
2898
  return ff_compiler_Syntax.MatchCase(_c.at_, ps_, _c.guards_, _c.body_)
4590
- }))(matchCase_), jump_, last_, async_, $task))
2899
+ }))(matchCase_), conditions_, variables_, jump_, last_, async_, $task))
4591
2900
  return
4592
2901
  }
2902
+ if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
2903
+ const e_ = _1.second_[0].term_;
2904
+ if(ff_core_List.List_isEmpty(variables_)) {
2905
+ const newCase_ = (((_c) => {
2906
+ return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
2907
+ }))(matchCase_);
2908
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, [], newCase_, [...conditions_, (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e_, async_, $task))], [], jump_, last_, async_, $task))
2909
+ }
2910
+ }
2911
+ if(_1.first_.length === 0 && _1.second_.length === 1 && _1.second_[0].pattern_.PVariant && _1.second_[0].pattern_.name_ === "ff:core/Bool.True") {
2912
+ const e_ = _1.second_[0].term_;
2913
+ const newCase_ = (((_c) => {
2914
+ return ff_compiler_Syntax.MatchCase(_c.at_, [], [], _c.body_)
2915
+ }))(matchCase_);
2916
+ const code_ = (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, [], newCase_, [(await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e_, async_, $task))], [], jump_, last_, async_, $task));
2917
+ return emitWrapper_(code_)
4593
2918
  }
4594
- {
4595
- if(_1.first_.length === 0) {
4596
- if(_1.second_.length > 0) {
2919
+ if(_1.first_.length === 0 && _1.second_.length >= 1) {
4597
2920
  const guard_ = _1.second_[0];
4598
2921
  const guards_ = _1.second_.slice(1);
4599
2922
  const guardName_ = ("_guard" + (ff_core_List.List_size(guards_) + 1));
4600
2923
  const newCase_ = (((_c) => {
4601
2924
  return ff_compiler_Syntax.MatchCase(_c.at_, [guard_.pattern_], guards_, _c.body_)
4602
2925
  }))(matchCase_);
4603
- return ((((("const " + guardName_) + " = ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, guard_.term_, async_, $task))) + ";\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, [guardName_], newCase_, jump_, last_, async_, $task)))
4604
- return
2926
+ const code_ = ((((("const " + guardName_) + " = ") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, guard_.term_, async_, $task))) + ";\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, [guardName_], newCase_, [], [], jump_, last_, async_, $task)));
2927
+ return emitWrapper_(code_)
4605
2928
  }
4606
- }
4607
- }
4608
- {
4609
- if(_1.first_.length === 0) {
4610
- if(_1.second_.length === 0) {
4611
- return ((await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, matchCase_.body_, last_, async_, $task)) + ((jump_ && last_)
2929
+ if(_1.first_.length === 0 && _1.second_.length === 0) {
2930
+ const statementsCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, matchCase_.body_, last_, async_, $task));
2931
+ const lastLine_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(statementsCode_), ((_w1) => {
2932
+ return (_w1 !== 10)
2933
+ })));
2934
+ 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));
2935
+ const code_ = (statementsCode_ + (((jump_ && last_) && (!returns_))
4612
2936
  ? "\nreturn"
4613
- : jump_
2937
+ : (jump_ && (!returns_))
4614
2938
  ? "\nbreak"
4615
- : ""))
4616
- return
4617
- }
4618
- }
2939
+ : ""));
2940
+ return emitWrapper_(code_)
4619
2941
  }
4620
2942
  }
4621
2943
  }
4622
2944
 
4623
- export async function JsEmitter_emitPattern$(self_, argument_, pattern_, arguments_, matchCase_, jump_, last_, async_, $task) {
2945
+ export async function JsEmitter_emitPattern$(self_, argument_, pattern_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_, $task) {
4624
2946
  {
4625
2947
  const _1 = pattern_;
4626
- {
4627
2948
  if(_1.PString) {
4628
2949
  const value_ = _1.value_;
4629
- return (((((("if(" + argument_) + " === ") + value_) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + "\n}")
4630
- return
4631
- }
2950
+ const newConditions_ = [...conditions_, ((argument_ + " === ") + value_)];
2951
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_, $task))
4632
2952
  }
4633
- {
4634
2953
  if(_1.PInt) {
4635
2954
  const value_ = _1.value_;
4636
- return (((((("if(" + argument_) + " === ") + value_) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + "\n}")
4637
- return
2955
+ const newConditions_ = [...conditions_, ((argument_ + " === ") + value_)];
2956
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_, $task))
4638
2957
  }
4639
- }
4640
- {
4641
2958
  if(_1.PChar) {
4642
2959
  const value_ = _1.value_;
4643
- return (((((("if(" + argument_) + " === ") + ff_compiler_JsEmitter.charLiteralToNumber_(value_)) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + "\n}")
4644
- return
4645
- }
4646
- }
4647
- {
4648
- if(_1.PVariable) {
4649
- if(_1.name_.None) {
4650
- return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))
4651
- return
2960
+ const newConditions_ = [...conditions_, ((argument_ + " === ") + ff_compiler_JsEmitter.charLiteralToNumber_(value_))];
2961
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, newConditions_, variables_, jump_, last_, async_, $task))
4652
2962
  }
2963
+ if(_1.PVariable && _1.name_.None) {
2964
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, conditions_, variables_, jump_, last_, async_, $task))
4653
2965
  }
4654
- }
4655
- {
4656
- if(_1.PVariable) {
4657
- if(_1.name_.Some) {
2966
+ if(_1.PVariable && _1.name_.Some) {
4658
2967
  const name_ = _1.name_.value_;
4659
2968
  const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(name_);
4660
- return (((escaped_ !== argument_)
4661
- ? (((("const " + escaped_) + " = ") + argument_) + ";\n")
4662
- : "") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task)))
4663
- return
2969
+ const newVariables_ = ((escaped_ !== argument_)
2970
+ ? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
2971
+ : variables_);
2972
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_, $task))
4664
2973
  }
2974
+ if(_1.PVariant && _1.name_ === "ff:core/Bool.False" && _1.patterns_.length === 0) {
2975
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, [...conditions_, ("!" + argument_)], variables_, jump_, last_, async_, $task))
4665
2976
  }
2977
+ if(_1.PVariant && _1.name_ === "ff:core/Bool.True" && _1.patterns_.length === 0) {
2978
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, [...conditions_, argument_], variables_, jump_, last_, async_, $task))
4666
2979
  }
4667
- {
4668
2980
  if(_1.PVariant) {
4669
- if(_1.name_ === "ff:core/Bool.False") {
4670
- if(_1.patterns_.length === 0) {
4671
- return (((("if(!" + argument_) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + "\n}")
4672
- return
4673
- }
4674
- }
2981
+ const emptyOrLink_ = _1.name_;
2982
+ if(((emptyOrLink_ === "List$Empty") || (emptyOrLink_ === "List$Link"))) {
2983
+ let restPattern_ = ff_core_Option.None();
2984
+ function listPatterns_(matchPattern_) {
2985
+ const matchPattern_a = matchPattern_;
2986
+ if(matchPattern_a.PVariant && matchPattern_a.name_ === "List$Empty" && matchPattern_a.patterns_.length === 0) {
2987
+ return []
4675
2988
  }
2989
+ if(matchPattern_a.PVariant && matchPattern_a.name_ === "List$Link" && matchPattern_a.patterns_.length === 2) {
2990
+ const head_ = matchPattern_a.patterns_[0];
2991
+ const tail_ = matchPattern_a.patterns_[1];
2992
+ return [head_, ...listPatterns_(tail_)]
4676
2993
  }
4677
2994
  {
4678
- if(_1.PVariant) {
4679
- if(_1.name_ === "ff:core/Bool.True") {
4680
- if(_1.patterns_.length === 0) {
4681
- return (((("if(" + argument_) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + "\n}")
4682
- return
4683
- }
4684
- }
2995
+ const p_ = matchPattern_a;
2996
+ restPattern_ = ff_core_Option.Some(p_);
2997
+ return []
4685
2998
  }
4686
2999
  }
3000
+ const patterns_ = listPatterns_(pattern_);
3001
+ const itemArguments_ = ff_core_List.List_map(ff_core_List.List_pairs(patterns_), ((_1) => {
4687
3002
  {
4688
- if(_1.PVariant) {
4689
- if(_1.name_ === "List$Empty") {
4690
- if(_1.patterns_.length === 0) {
4691
- let shortArgument_ = argument_;
4692
- let shortCount_ = 0;
4693
- while(ff_core_String.String_endsWith(shortArgument_, ".slice(1)")) {
4694
- shortArgument_ = ff_core_String.String_dropLast(shortArgument_, ff_core_String.String_size(".slice(1)"));
4695
- shortCount_ += 1
4696
- };
4697
- return (((((("if(" + shortArgument_) + ".length === ") + shortCount_) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + "\n}")
4698
- return
4699
- }
3003
+ const i_ = _1.first_;
3004
+ return (((argument_ + "[") + i_) + "]")
4700
3005
  }
4701
- }
4702
- }
4703
- {
4704
- if(_1.PVariant) {
4705
- if(_1.name_ === "List$Link") {
4706
- if(_1.patterns_.length > 0) {
4707
- const head_ = _1.patterns_[0];
4708
- if(_1.patterns_.length > 1) {
4709
- const tail_ = _1.patterns_[1];
4710
- if(_1.patterns_.length === 2) {
4711
- let shortArgument_ = argument_;
4712
- let shortCount_ = 0;
4713
- while(ff_core_String.String_endsWith(shortArgument_, ".slice(1)")) {
4714
- shortArgument_ = ff_core_String.String_dropLast(shortArgument_, ff_core_String.String_size(".slice(1)"));
4715
- shortCount_ += 1
4716
- };
4717
- const newArguments_ = [(((shortArgument_ + "[") + shortCount_) + "]"), (argument_ + ".slice(1)"), ...arguments_];
3006
+ }));
3007
+ const restArgument_ = ff_core_Option.Option_map(restPattern_, ((_) => {
3008
+ return (((argument_ + ".slice(") + ff_core_List.List_size(patterns_)) + ")")
3009
+ }));
3010
+ const newArguments_ = [...itemArguments_, ...ff_core_Option.Option_toList(restArgument_), ...arguments_];
4718
3011
  const newMatchCase_ = (((_c) => {
4719
- return ff_compiler_Syntax.MatchCase(_c.at_, [head_, tail_, ...matchCase_.patterns_], _c.guards_, _c.body_)
3012
+ return ff_compiler_Syntax.MatchCase(_c.at_, [...patterns_, ...ff_core_Option.Option_toList(restPattern_), ...matchCase_.patterns_], _c.guards_, _c.body_)
4720
3013
  }))(matchCase_);
4721
- return (((((("if(" + shortArgument_) + ".length > ") + shortCount_) + ") {\n") + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, newArguments_, newMatchCase_, jump_, last_, async_, $task))) + "\n}")
4722
- return
4723
- }
4724
- }
4725
- }
4726
- }
3014
+ const operator_ = ff_core_Option.Option_else(ff_core_Option.Option_map(restPattern_, ((_) => {
3015
+ return ">="
3016
+ })), (() => {
3017
+ return "==="
3018
+ }));
3019
+ const newConditions_ = [...conditions_, ((((argument_ + ".length ") + operator_) + " ") + ff_core_List.List_size(patterns_))];
3020
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_, $task))
4727
3021
  }
4728
3022
  }
4729
- {
4730
3023
  if(_1.PVariant) {
4731
3024
  const name_ = _1.name_;
4732
3025
  const patterns_ = _1.patterns_;
@@ -4734,77 +3027,58 @@ const processed_ = (await ff_compiler_JsEmitter.JsEmitter_processVariantCase$(se
4734
3027
  const newMatchCase_ = (((_c) => {
4735
3028
  return ff_compiler_Syntax.MatchCase(_c.at_, [...patterns_, ...matchCase_.patterns_], _c.guards_, _c.body_)
4736
3029
  }))(matchCase_);
4737
- return (((processed_.loneVariant_
4738
- ? ""
4739
- : (((("if(" + argument_) + ".") + processed_.variantName_) + ") {\n")) + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, [...processed_.arguments_, ...arguments_], newMatchCase_, jump_, last_, async_, $task))) + (processed_.loneVariant_
4740
- ? ""
4741
- : "\n}"))
4742
- return
3030
+ const newConditions_ = (processed_.loneVariant_
3031
+ ? conditions_
3032
+ : [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
3033
+ const newArguments_ = [...processed_.arguments_, ...arguments_];
3034
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, newArguments_, newMatchCase_, newConditions_, variables_, jump_, last_, async_, $task))
4743
3035
  }
4744
- }
4745
- {
4746
3036
  if(_1.PVariantAs) {
4747
3037
  const at_ = _1.at_;
4748
3038
  const name_ = _1.name_;
4749
3039
  const variableAt_ = _1.variableAt_;
4750
3040
  const variable_ = _1.variable_;
4751
3041
  const processed_ = (await ff_compiler_JsEmitter.JsEmitter_processVariantCase$(self_, name_, argument_, $task));
4752
- return ((((processed_.loneVariant_
4753
- ? ""
4754
- : (((("if(" + argument_) + ".") + processed_.variantName_) + ") {\n")) + ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(ff_core_Option.Option_map(variable_, ((word_) => {
3042
+ const newConditions_ = (processed_.loneVariant_
3043
+ ? conditions_
3044
+ : [...conditions_, ((argument_ + ".") + processed_.variantName_)]);
3045
+ const newVariables_ = ff_core_Option.Option_else(ff_core_Option.Option_map(ff_core_Option.Option_filter(ff_core_Option.Option_map(variable_, ((word_) => {
4755
3046
  return ff_compiler_JsEmitter.escapeKeyword_(word_)
4756
3047
  })), ((_w1) => {
4757
3048
  return (_w1 !== argument_)
4758
3049
  })), ((_w1) => {
4759
- return (((("const " + _w1) + " = ") + argument_) + ";\n")
3050
+ return [...variables_, (((("const " + _w1) + " = ") + argument_) + ";\n")]
4760
3051
  })), (() => {
4761
- return ""
4762
- }))) + (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, jump_, last_, async_, $task))) + (processed_.loneVariant_
4763
- ? ""
4764
- : "\n}"))
4765
- return
4766
- }
3052
+ return []
3053
+ }));
3054
+ return (await ff_compiler_JsEmitter.JsEmitter_emitCase$(self_, arguments_, matchCase_, newConditions_, newVariables_, jump_, last_, async_, $task))
4767
3055
  }
4768
- {
4769
3056
  if(_1.PAlias) {
4770
3057
  const pattern_ = _1.pattern_;
4771
3058
  const variable_ = _1.variable_;
4772
3059
  const escaped_ = ff_compiler_JsEmitter.escapeKeyword_(variable_);
4773
- return (((escaped_ !== argument_)
4774
- ? (((("const " + escaped_) + " = ") + argument_) + ";\n")
4775
- : "") + (await ff_compiler_JsEmitter.JsEmitter_emitPattern$(self_, argument_, pattern_, arguments_, matchCase_, jump_, last_, async_, $task)))
4776
- return
4777
- }
3060
+ const newVariables_ = ((escaped_ !== argument_)
3061
+ ? [...variables_, (((("const " + escaped_) + " = ") + argument_) + ";\n")]
3062
+ : variables_);
3063
+ return (await ff_compiler_JsEmitter.JsEmitter_emitPattern$(self_, argument_, pattern_, arguments_, matchCase_, conditions_, newVariables_, jump_, last_, async_, $task))
4778
3064
  }
4779
3065
  }
4780
3066
  }
4781
3067
 
4782
3068
  export async function JsEmitter_emitList$(self_, items_, async_, $task) {
4783
3069
  return (("[" + ff_core_List.List_join((await ff_core_List.List_map$(items_, (async (_1, $task) => {
4784
- {
4785
- const item_ = _1.first_;
4786
3070
  if(!_1.second_) {
3071
+ const item_ = _1.first_;
4787
3072
  return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, item_, async_, $task))
4788
- return
4789
3073
  }
4790
- }
4791
- {
4792
- const item_ = _1.first_;
4793
3074
  if(_1.second_) {
3075
+ const item_ = _1.first_;
4794
3076
  return ("..." + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, item_, async_, $task)))
4795
- return
4796
- }
4797
3077
  }
4798
3078
  }), $task)), ", ")) + "]")
4799
3079
  }
4800
3080
 
4801
3081
  export async function JsEmitter_processVariantCase$(self_, name_, argument_, $task) {
4802
- if((name_ === "List$Empty")) {
4803
- return ff_compiler_JsEmitter.ProcessedVariantCase(name_, false, false, [])
4804
- } else {
4805
- if((name_ === "List$Link")) {
4806
- return ff_compiler_JsEmitter.ProcessedVariantCase(name_, false, false, [(argument_ + "[0]"), (argument_ + ".slice(1)")])
4807
- } else {
4808
3082
  const variantNameUnqualified_ = ff_core_String.String_reverse(ff_core_String.String_takeWhile(ff_core_String.String_reverse(name_), ((_w1) => {
4809
3083
  return (_w1 !== 46)
4810
3084
  })));
@@ -4834,8 +3108,6 @@ return ((argument_ + ".") + ff_compiler_JsEmitter.escapeKeyword_(field_))
4834
3108
  }));
4835
3109
  return ff_compiler_JsEmitter.ProcessedVariantCase(variantName_, newtype_, loneVariant_, newArguments_)
4836
3110
  }
4837
- }
4838
- }
4839
3111
 
4840
3112
  export async function JsEmitter_processVariant$(self_, name_, $task) {
4841
3113
  if(ff_core_String.String_startsWith(name_, "List$", 0)) {
@@ -4862,20 +3134,12 @@ return newtype_
4862
3134
  export async function JsEmitter_emitArgument$(self_, callAt_, argument_, async_, $task) {
4863
3135
  {
4864
3136
  const _1 = argument_.value_;
4865
- {
4866
- if(_1.ECall) {
4867
- if(_1.target_.StaticCall) {
4868
- if(_1.target_.name_ === "ff:core/SourceLocation.callSite") {
3137
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/SourceLocation.callSite") {
4869
3138
  return (((((((((("\"" + self_.moduleName_) + ":") + callAt_.line_) + ":") + callAt_.column_) + ",") + self_.packagePair_.group_) + ",") + self_.packagePair_.name_) + "\"")
4870
- return
4871
- }
4872
- }
4873
- }
4874
3139
  }
4875
3140
  {
4876
3141
  const value_ = _1;
4877
3142
  return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, value_, async_, $task))
4878
- return
4879
3143
  }
4880
3144
  }
4881
3145
  }
@@ -4900,276 +3164,167 @@ return ff_core_Any.internalAnyTag_((("ff:compiler/JsEmitter.ProcessedVariantCase
4900
3164
 
4901
3165
  export const ff_core_Show_Show$ff_compiler_JsEmitter_EmitTarget = {
4902
3166
  show_(value_) {
4903
- {
4904
3167
  const value_a = value_;
4905
- {
4906
3168
  if(value_a.EmitNode) {
4907
3169
  const z_ = value_a;
4908
3170
  return "EmitNode"
4909
- return
4910
- }
4911
3171
  }
4912
- {
4913
3172
  if(value_a.EmitBrowser) {
4914
3173
  const z_ = value_a;
4915
3174
  return "EmitBrowser"
4916
- return
4917
3175
  }
4918
- }
4919
- {
4920
3176
  if(value_a.EmitBuild) {
4921
3177
  const z_ = value_a;
4922
3178
  return "EmitBuild"
4923
- return
4924
- }
4925
3179
  }
4926
- {
4927
3180
  if(value_a.EmitExecutable) {
4928
3181
  const z_ = value_a;
4929
3182
  return "EmitExecutable"
4930
- return
4931
- }
4932
- }
4933
3183
  }
4934
3184
  },
4935
3185
  async show_$(value_, $task) {
4936
- {
4937
3186
  const value_a = value_;
4938
- {
4939
3187
  if(value_a.EmitNode) {
4940
3188
  const z_ = value_a;
4941
3189
  return "EmitNode"
4942
- return
4943
- }
4944
3190
  }
4945
- {
4946
3191
  if(value_a.EmitBrowser) {
4947
3192
  const z_ = value_a;
4948
3193
  return "EmitBrowser"
4949
- return
4950
3194
  }
4951
- }
4952
- {
4953
3195
  if(value_a.EmitBuild) {
4954
3196
  const z_ = value_a;
4955
3197
  return "EmitBuild"
4956
- return
4957
- }
4958
3198
  }
4959
- {
4960
3199
  if(value_a.EmitExecutable) {
4961
3200
  const z_ = value_a;
4962
3201
  return "EmitExecutable"
4963
- return
4964
- }
4965
- }
4966
3202
  }
4967
3203
  }
4968
3204
  };
4969
3205
 
4970
3206
  export const ff_core_Show_Show$ff_compiler_JsEmitter_ProcessedVariantCase = {
4971
3207
  show_(value_) {
4972
- {
4973
3208
  const value_a = value_;
4974
3209
  {
4975
3210
  const z_ = value_a;
4976
3211
  return ((((((((("ProcessedVariantCase" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.variantName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_Bool_Bool.show_(z_.newtype_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_Bool_Bool.show_(z_.loneVariant_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.arguments_)) + ")")
4977
- return
4978
- }
4979
3212
  }
4980
3213
  },
4981
3214
  async show_$(value_, $task) {
4982
- {
4983
3215
  const value_a = value_;
4984
3216
  {
4985
3217
  const z_ = value_a;
4986
3218
  return ((((((((("ProcessedVariantCase" + "(") + ff_core_Show.ff_core_Show_Show$ff_core_String_String.show_(z_.variantName_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_Bool_Bool.show_(z_.newtype_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_Bool_Bool.show_(z_.loneVariant_)) + ", ") + ff_core_Show.ff_core_Show_Show$ff_core_List_List(ff_core_Show.ff_core_Show_Show$ff_core_String_String).show_(z_.arguments_)) + ")")
4987
- return
4988
- }
4989
3219
  }
4990
3220
  }
4991
3221
  };
4992
3222
 
4993
3223
  export const ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget = {
4994
3224
  equals_(x_, y_) {
4995
- {
4996
3225
  const x_a = x_;
4997
3226
  const y_a = y_;
4998
- {
4999
- const _guard1 = (x_ === y_);
5000
- if(_guard1) {
3227
+ if((x_ === y_)) {
5001
3228
  return true
5002
- return
5003
- }
5004
3229
  }
5005
3230
  {
5006
3231
  return false
5007
- return
5008
- }
5009
3232
  }
5010
3233
  },
5011
3234
  async equals_$(x_, y_, $task) {
5012
- {
5013
3235
  const x_a = x_;
5014
3236
  const y_a = y_;
5015
- {
5016
- const _guard1 = (x_ === y_);
5017
- if(_guard1) {
3237
+ if((x_ === y_)) {
5018
3238
  return true
5019
- return
5020
- }
5021
3239
  }
5022
3240
  {
5023
3241
  return false
5024
- return
5025
- }
5026
3242
  }
5027
3243
  }
5028
3244
  };
5029
3245
 
5030
3246
  export const ff_core_Equal_Equal$ff_compiler_JsEmitter_ProcessedVariantCase = {
5031
3247
  equals_(x_, y_) {
5032
- {
5033
3248
  const x_a = x_;
5034
3249
  const y_a = y_;
5035
- {
5036
- const _guard1 = (x_ === y_);
5037
- if(_guard1) {
3250
+ if((x_ === y_)) {
5038
3251
  return true
5039
- return
5040
- }
5041
3252
  }
5042
3253
  {
5043
3254
  return ((x_.variantName_ === y_.variantName_) && ((x_.newtype_ === y_.newtype_) && ((x_.loneVariant_ === y_.loneVariant_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.arguments_, y_.arguments_))))
5044
- return
5045
- }
5046
3255
  }
5047
3256
  },
5048
3257
  async equals_$(x_, y_, $task) {
5049
- {
5050
3258
  const x_a = x_;
5051
3259
  const y_a = y_;
5052
- {
5053
- const _guard1 = (x_ === y_);
5054
- if(_guard1) {
3260
+ if((x_ === y_)) {
5055
3261
  return true
5056
- return
5057
- }
5058
3262
  }
5059
3263
  {
5060
3264
  return ((x_.variantName_ === y_.variantName_) && ((x_.newtype_ === y_.newtype_) && ((x_.loneVariant_ === y_.loneVariant_) && ff_core_List.ff_core_Equal_Equal$ff_core_List_List(ff_core_Equal.ff_core_Equal_Equal$ff_core_String_String).equals_(x_.arguments_, y_.arguments_))))
5061
- return
5062
- }
5063
3265
  }
5064
3266
  }
5065
3267
  };
5066
3268
 
5067
3269
  export const ff_core_Ordering_Order$ff_compiler_JsEmitter_EmitTarget = {
5068
3270
  compare_(x_, y_) {
5069
- {
5070
3271
  const x_a = x_;
5071
3272
  const y_a = y_;
5072
- {
5073
- const _guard1 = (x_ === y_);
5074
- if(_guard1) {
3273
+ if((x_ === y_)) {
5075
3274
  return ff_core_Ordering.OrderingSame()
5076
- return
5077
- }
5078
3275
  }
5079
3276
  {
5080
3277
  function number_(z_) {
5081
- {
5082
3278
  const z_a = z_;
5083
- {
5084
3279
  if(z_a.EmitNode) {
5085
3280
  return 0
5086
- return
5087
- }
5088
3281
  }
5089
- {
5090
3282
  if(z_a.EmitBrowser) {
5091
3283
  return 1
5092
- return
5093
3284
  }
5094
- }
5095
- {
5096
3285
  if(z_a.EmitBuild) {
5097
3286
  return 2
5098
- return
5099
- }
5100
3287
  }
5101
- {
5102
3288
  if(z_a.EmitExecutable) {
5103
3289
  return 3
5104
- return
5105
- }
5106
- }
5107
3290
  }
5108
3291
  }
5109
3292
  return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(number_(x_), number_(y_))
5110
- return
5111
- }
5112
3293
  }
5113
3294
  },
5114
3295
  async compare_$(x_, y_, $task) {
5115
- {
5116
3296
  const x_a = x_;
5117
3297
  const y_a = y_;
5118
- {
5119
- const _guard1 = (x_ === y_);
5120
- if(_guard1) {
3298
+ if((x_ === y_)) {
5121
3299
  return ff_core_Ordering.OrderingSame()
5122
- return
5123
- }
5124
3300
  }
5125
3301
  {
5126
3302
  function number_(z_) {
5127
- {
5128
3303
  const z_a = z_;
5129
- {
5130
3304
  if(z_a.EmitNode) {
5131
3305
  return 0
5132
- return
5133
- }
5134
3306
  }
5135
- {
5136
3307
  if(z_a.EmitBrowser) {
5137
3308
  return 1
5138
- return
5139
3309
  }
5140
- }
5141
- {
5142
3310
  if(z_a.EmitBuild) {
5143
3311
  return 2
5144
- return
5145
- }
5146
3312
  }
5147
- {
5148
3313
  if(z_a.EmitExecutable) {
5149
3314
  return 3
5150
- return
5151
- }
5152
- }
5153
3315
  }
5154
3316
  }
5155
3317
  return ff_core_Ordering.ff_core_Ordering_Order$ff_core_Int_Int.compare_(number_(x_), number_(y_))
5156
- return
5157
- }
5158
3318
  }
5159
3319
  }
5160
3320
  };
5161
3321
 
5162
3322
  export const ff_core_Ordering_Order$ff_compiler_JsEmitter_ProcessedVariantCase = {
5163
3323
  compare_(x_, y_) {
5164
- {
5165
3324
  const x_a = x_;
5166
3325
  const y_a = y_;
5167
- {
5168
- const _guard1 = (x_ === y_);
5169
- if(_guard1) {
3326
+ if((x_ === y_)) {
5170
3327
  return ff_core_Ordering.OrderingSame()
5171
- return
5172
- }
5173
3328
  }
5174
3329
  {
5175
3330
  const variantNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.variantName_, y_.variantName_);
@@ -5195,18 +3350,12 @@ return ff_core_Ordering.OrderingSame()
5195
3350
  }
5196
3351
  return
5197
3352
  }
5198
- }
5199
3353
  },
5200
3354
  async compare_$(x_, y_, $task) {
5201
- {
5202
3355
  const x_a = x_;
5203
3356
  const y_a = y_;
5204
- {
5205
- const _guard1 = (x_ === y_);
5206
- if(_guard1) {
3357
+ if((x_ === y_)) {
5207
3358
  return ff_core_Ordering.OrderingSame()
5208
- return
5209
- }
5210
3359
  }
5211
3360
  {
5212
3361
  const variantNameOrdering_ = ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String.compare_(x_.variantName_, y_.variantName_);
@@ -5233,15 +3382,12 @@ return ff_core_Ordering.OrderingSame()
5233
3382
  return
5234
3383
  }
5235
3384
  }
5236
- }
5237
3385
  };
5238
3386
 
5239
3387
  export const ff_core_Serializable_Serializable$ff_compiler_JsEmitter_EmitTarget = {
5240
3388
  serializeUsing_(serialization_, value_) {
5241
- {
5242
3389
  const serialization_a = serialization_;
5243
3390
  const value_a = value_;
5244
- {
5245
3391
  if(value_a.EmitNode) {
5246
3392
  const v_ = value_a;
5247
3393
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 30), 0);
@@ -5250,8 +3396,6 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0
5250
3396
  serialization_.offset_ += 1
5251
3397
  return
5252
3398
  }
5253
- }
5254
- {
5255
3399
  if(value_a.EmitBrowser) {
5256
3400
  const v_ = value_a;
5257
3401
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 33), 0);
@@ -5260,8 +3404,6 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 1
5260
3404
  serialization_.offset_ += 1
5261
3405
  return
5262
3406
  }
5263
- }
5264
- {
5265
3407
  if(value_a.EmitBuild) {
5266
3408
  const v_ = value_a;
5267
3409
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
@@ -5270,8 +3412,6 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 2
5270
3412
  serialization_.offset_ += 1
5271
3413
  return
5272
3414
  }
5273
- }
5274
- {
5275
3415
  if(value_a.EmitExecutable) {
5276
3416
  const v_ = value_a;
5277
3417
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 36), 0);
@@ -5280,53 +3420,36 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 3
5280
3420
  serialization_.offset_ += 1
5281
3421
  return
5282
3422
  }
5283
- }
5284
- }
5285
3423
  },
5286
3424
  deserializeUsing_(serialization_) {
5287
3425
  const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
5288
3426
  serialization_.offset_ += 1;
5289
3427
  {
5290
3428
  const _1 = variantIndex_;
5291
- {
5292
3429
  if(_1 === 0) {
5293
3430
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 30), 0);
5294
3431
  return ff_compiler_JsEmitter.EmitNode()
5295
- return
5296
3432
  }
5297
- }
5298
- {
5299
3433
  if(_1 === 1) {
5300
3434
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 33), 0);
5301
3435
  return ff_compiler_JsEmitter.EmitBrowser()
5302
- return
5303
- }
5304
3436
  }
5305
- {
5306
3437
  if(_1 === 2) {
5307
3438
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
5308
3439
  return ff_compiler_JsEmitter.EmitBuild()
5309
- return
5310
3440
  }
5311
- }
5312
- {
5313
3441
  if(_1 === 3) {
5314
3442
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 36), 0);
5315
3443
  return ff_compiler_JsEmitter.EmitExecutable()
5316
- return
5317
- }
5318
3444
  }
5319
3445
  {
5320
3446
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
5321
- return
5322
3447
  }
5323
3448
  }
5324
3449
  },
5325
3450
  async serializeUsing_$(serialization_, value_, $task) {
5326
- {
5327
3451
  const serialization_a = serialization_;
5328
3452
  const value_a = value_;
5329
- {
5330
3453
  if(value_a.EmitNode) {
5331
3454
  const v_ = value_a;
5332
3455
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 30), 0);
@@ -5335,8 +3458,6 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 0
5335
3458
  serialization_.offset_ += 1
5336
3459
  return
5337
3460
  }
5338
- }
5339
- {
5340
3461
  if(value_a.EmitBrowser) {
5341
3462
  const v_ = value_a;
5342
3463
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 33), 0);
@@ -5345,8 +3466,6 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 1
5345
3466
  serialization_.offset_ += 1
5346
3467
  return
5347
3468
  }
5348
- }
5349
- {
5350
3469
  if(value_a.EmitBuild) {
5351
3470
  const v_ = value_a;
5352
3471
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
@@ -5355,8 +3474,6 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 2
5355
3474
  serialization_.offset_ += 1
5356
3475
  return
5357
3476
  }
5358
- }
5359
- {
5360
3477
  if(value_a.EmitExecutable) {
5361
3478
  const v_ = value_a;
5362
3479
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 36), 0);
@@ -5365,45 +3482,30 @@ ff_core_Buffer.Buffer_setUint8(serialization_.buffer_, serialization_.offset_, 3
5365
3482
  serialization_.offset_ += 1
5366
3483
  return
5367
3484
  }
5368
- }
5369
- }
5370
3485
  },
5371
3486
  async deserializeUsing_$(serialization_, $task) {
5372
3487
  const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
5373
3488
  serialization_.offset_ += 1;
5374
3489
  {
5375
3490
  const _1 = variantIndex_;
5376
- {
5377
3491
  if(_1 === 0) {
5378
3492
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 30), 0);
5379
3493
  return ff_compiler_JsEmitter.EmitNode()
5380
- return
5381
- }
5382
3494
  }
5383
- {
5384
3495
  if(_1 === 1) {
5385
3496
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 33), 0);
5386
3497
  return ff_compiler_JsEmitter.EmitBrowser()
5387
- return
5388
3498
  }
5389
- }
5390
- {
5391
3499
  if(_1 === 2) {
5392
3500
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 31), 0);
5393
3501
  return ff_compiler_JsEmitter.EmitBuild()
5394
- return
5395
- }
5396
3502
  }
5397
- {
5398
3503
  if(_1 === 3) {
5399
3504
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 36), 0);
5400
3505
  return ff_compiler_JsEmitter.EmitExecutable()
5401
- return
5402
- }
5403
3506
  }
5404
3507
  {
5405
3508
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
5406
- return
5407
3509
  }
5408
3510
  }
5409
3511
  }
@@ -5411,7 +3513,6 @@ return
5411
3513
 
5412
3514
  export const ff_core_Serializable_Serializable$ff_compiler_JsEmitter_ProcessedVariantCase = {
5413
3515
  serializeUsing_(serialization_, value_) {
5414
- {
5415
3516
  const serialization_a = serialization_;
5416
3517
  const value_a = value_;
5417
3518
  {
@@ -5426,28 +3527,22 @@ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Bool_Bool.seriali
5426
3527
  ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.arguments_)
5427
3528
  return
5428
3529
  }
5429
- }
5430
3530
  },
5431
3531
  deserializeUsing_(serialization_) {
5432
3532
  const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
5433
3533
  serialization_.offset_ += 1;
5434
3534
  {
5435
3535
  const _1 = variantIndex_;
5436
- {
5437
3536
  if(_1 === 0) {
5438
3537
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
5439
3538
  return ff_compiler_JsEmitter.ProcessedVariantCase(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Bool_Bool.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Bool_Bool.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_))
5440
- return
5441
- }
5442
3539
  }
5443
3540
  {
5444
3541
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
5445
- return
5446
3542
  }
5447
3543
  }
5448
3544
  },
5449
3545
  async serializeUsing_$(serialization_, value_, $task) {
5450
- {
5451
3546
  const serialization_a = serialization_;
5452
3547
  const value_a = value_;
5453
3548
  {
@@ -5462,23 +3557,18 @@ ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Bool_Bool.seriali
5462
3557
  ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).serializeUsing_(serialization_, v_.arguments_)
5463
3558
  return
5464
3559
  }
5465
- }
5466
3560
  },
5467
3561
  async deserializeUsing_$(serialization_, $task) {
5468
3562
  const variantIndex_ = ff_core_Buffer.Buffer_grabUint8(serialization_.buffer_, serialization_.offset_);
5469
3563
  serialization_.offset_ += 1;
5470
3564
  {
5471
3565
  const _1 = variantIndex_;
5472
- {
5473
3566
  if(_1 === 0) {
5474
3567
  serialization_.checksum_ = ff_core_Int.Int_bitOr(((31 * serialization_.checksum_) + 42), 0);
5475
3568
  return ff_compiler_JsEmitter.ProcessedVariantCase(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Bool_Bool.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_Bool_Bool.deserializeUsing_(serialization_), ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_List_List(ff_core_Serializable.ff_core_Serializable_Serializable$ff_core_String_String).deserializeUsing_(serialization_))
5476
- return
5477
- }
5478
3569
  }
5479
3570
  {
5480
3571
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_core_Serializable.DeserializationChecksumException(), ff_core_Serializable.ff_core_Any_HasAnyTag$ff_core_Serializable_DeserializationChecksumException)})
5481
- return
5482
3572
  }
5483
3573
  }
5484
3574
  }