firefly-compiler 0.5.3 → 0.5.5

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 (87) hide show
  1. package/bin/Release.ff +0 -1
  2. package/compiler/Compiler.ff +1 -0
  3. package/compiler/JsEmitter.ff +22 -7
  4. package/compiler/Parser.ff +9 -1
  5. package/compiler/Tokenizer.ff +8 -0
  6. package/{unsafejs → core}/UnsafeJs.ff +20 -0
  7. package/fireflysite/Guide.ff +2 -1
  8. package/fireflysite/Test.ff +10 -0
  9. package/fireflysite/assets/markdown/reference/FunctionsAndMethods.md +37 -9
  10. package/fireflysite/assets/markdown/reference/JavascriptInterop.md +23 -7
  11. package/output/js/ff/compiler/Builder.mjs +2 -0
  12. package/output/js/ff/compiler/Compiler.mjs +3 -1
  13. package/output/js/ff/compiler/Dependencies.mjs +2 -0
  14. package/output/js/ff/compiler/DependencyLock.mjs +2 -0
  15. package/output/js/ff/compiler/Deriver.mjs +2 -0
  16. package/output/js/ff/compiler/Dictionaries.mjs +2 -0
  17. package/output/js/ff/compiler/Environment.mjs +2 -0
  18. package/output/js/ff/compiler/Inference.mjs +2 -0
  19. package/output/js/ff/compiler/JsEmitter.mjs +108 -16
  20. package/output/js/ff/compiler/JsImporter.mjs +2 -0
  21. package/output/js/ff/compiler/LspHook.mjs +2 -0
  22. package/output/js/ff/compiler/Main.mjs +2 -0
  23. package/output/js/ff/compiler/ModuleCache.mjs +2 -0
  24. package/output/js/ff/compiler/Parser.mjs +20 -2
  25. package/output/js/ff/compiler/Patterns.mjs +2 -0
  26. package/output/js/ff/compiler/Resolver.mjs +2 -0
  27. package/output/js/ff/compiler/Substitution.mjs +2 -0
  28. package/output/js/ff/compiler/Syntax.mjs +2 -0
  29. package/output/js/ff/compiler/Token.mjs +2 -0
  30. package/output/js/ff/compiler/Tokenizer.mjs +8 -0
  31. package/output/js/ff/compiler/Unification.mjs +2 -0
  32. package/output/js/ff/compiler/Wildcards.mjs +2 -0
  33. package/output/js/ff/compiler/Workspace.mjs +2 -0
  34. package/output/js/ff/core/Any.mjs +2 -0
  35. package/output/js/ff/core/Array.mjs +2 -0
  36. package/output/js/ff/core/AssetSystem.mjs +2 -0
  37. package/output/js/ff/core/Atomic.mjs +2 -0
  38. package/output/js/ff/core/Bool.mjs +2 -0
  39. package/output/js/ff/core/BrowserSystem.mjs +2 -0
  40. package/output/js/ff/core/Buffer.mjs +2 -0
  41. package/output/js/ff/core/BuildSystem.mjs +2 -0
  42. package/output/js/ff/core/Channel.mjs +2 -0
  43. package/output/js/ff/core/Char.mjs +2 -0
  44. package/output/js/ff/core/Core.mjs +2 -0
  45. package/output/js/ff/core/Crypto.mjs +2 -0
  46. package/output/js/ff/core/Duration.mjs +2 -0
  47. package/output/js/ff/core/Equal.mjs +2 -0
  48. package/output/js/ff/core/Error.mjs +2 -0
  49. package/output/js/ff/core/FileHandle.mjs +2 -0
  50. package/output/js/ff/core/Float.mjs +2 -0
  51. package/output/js/ff/core/HttpClient.mjs +2 -0
  52. package/output/js/ff/core/Instant.mjs +2 -0
  53. package/output/js/ff/core/Int.mjs +2 -0
  54. package/output/js/ff/core/IntMap.mjs +2 -0
  55. package/output/js/ff/core/JsSystem.mjs +2 -0
  56. package/output/js/ff/core/JsValue.mjs +2 -0
  57. package/output/js/ff/core/Json.mjs +2 -0
  58. package/output/js/ff/core/List.mjs +2 -0
  59. package/output/js/ff/core/Lock.mjs +2 -0
  60. package/output/js/ff/core/Log.mjs +2 -0
  61. package/output/js/ff/core/Map.mjs +2 -0
  62. package/output/js/ff/core/NodeSystem.mjs +2 -0
  63. package/output/js/ff/core/Nothing.mjs +2 -0
  64. package/output/js/ff/core/Option.mjs +2 -0
  65. package/output/js/ff/core/Ordering.mjs +2 -0
  66. package/output/js/ff/core/Pair.mjs +2 -0
  67. package/output/js/ff/core/Path.mjs +2 -0
  68. package/output/js/ff/core/Random.mjs +2 -0
  69. package/output/js/ff/core/RbMap.mjs +2 -0
  70. package/output/js/ff/core/Serializable.mjs +2 -0
  71. package/output/js/ff/core/Set.mjs +2 -0
  72. package/output/js/ff/core/Show.mjs +2 -0
  73. package/output/js/ff/core/SourceLocation.mjs +2 -0
  74. package/output/js/ff/core/Stream.mjs +2 -0
  75. package/output/js/ff/core/String.mjs +2 -0
  76. package/output/js/ff/core/StringMap.mjs +2 -0
  77. package/output/js/ff/core/Task.mjs +2 -0
  78. package/output/js/ff/core/Try.mjs +2 -0
  79. package/output/js/ff/core/Unit.mjs +2 -0
  80. package/output/js/ff/core/UnsafeJs.mjs +191 -0
  81. package/package.json +1 -1
  82. package/postgresql/.firefly/package.ff +0 -1
  83. package/postgresql/Pg.ff +0 -2
  84. package/vscode/package.json +1 -1
  85. package/compression/.firefly/package.ff +0 -1
  86. package/compression/Compression.ff +0 -55
  87. package/unsafejs/.firefly/package.ff +0 -1
package/bin/Release.ff CHANGED
@@ -35,7 +35,6 @@ release(
35
35
  releaseFireflyPackage(system, accessKeyId, secretAccessKey, "postgresql")
36
36
  releaseFireflyPackage(system, accessKeyId, secretAccessKey, "rpc")
37
37
  releaseFireflyPackage(system, accessKeyId, secretAccessKey, "s3")
38
- releaseFireflyPackage(system, accessKeyId, secretAccessKey, "unsafejs")
39
38
  releaseFireflyPackage(system, accessKeyId, secretAccessKey, "webserver")
40
39
  runSuccessful(system, "git", ["commit", "-a", "-m", "Autorelease " + version], system.path(".."))
41
40
  runSuccessful(system, "git", ["push"], system.path(".."))
@@ -100,6 +100,7 @@ coreImports: List[DImport] =
100
100
  "Task"
101
101
  "Try"
102
102
  "Unit"
103
+ "UnsafeJs"
103
104
  ].map {moduleName =>
104
105
  DImport(
105
106
  at = Location("<prelude>", 1, 1)
@@ -362,15 +362,30 @@ extend self: JsEmitter {
362
362
  | ECall(at, StaticCall("ff:core/Array.Array_grab", _, _), _, _, [Argument(_, _, EVariable(_, x1)), Argument(_, _, EVariable(_, x2))], _) =>
363
363
  "(" + escapeResolved(x1) + ".array[" + escapeResolved(x2) + "] ?? " +
364
364
  "ff_core_Array.internalGrab_(" + escapeResolved(x1) + ", " + escapeResolved(x2) + "))"
365
- | ECall(at, StaticCall("ff:unsafejs/UnsafeJs.import", _, _), _, _, [Argument(_, _, EString(_, url))], _) =>
365
+ | ECall(at, StaticCall("ff:core/UnsafeJs.import", _, _), _, _, [Argument(_, _, EString(_, url))], _) =>
366
366
  self.jsImporter.add(url.replace("\"", ""))
367
- | ECall(at, StaticCall("ff:unsafejs/UnsafeJs.await", _, _), _, _, [Argument(_, _, body)], _) =>
368
- let emittedBody = self.emitTerm(body, async)
369
- if(async) {"(await " + emittedBody + "($task))"} else {"(" + emittedBody + "())"}
370
- | ECall(at, StaticCall("ff:unsafejs/UnsafeJs.cancelled", _, _), _, _, [], _) =>
367
+ | ECall(at, StaticCall("ff:core/UnsafeJs.await", _, _), _, _, [Argument(_, _, body)], _) =>
368
+ if(async) {
369
+ "(await " + self.emitTerm(body, async) + "($task))"
370
+ } else {
371
+ self.emitTerm(invokeImmediately(body), async)
372
+ }
373
+ | ECall(at, StaticCall("ff:core/UnsafeJs.cancelled", _, _), _, _, [], _) =>
371
374
  if(async) {"$task.controller.signal.aborted"} else {"false"}
372
- | ECall(at, StaticCall("ff:unsafejs/UnsafeJs.throwIfCancelled", _, _), _, _, [], _) =>
375
+ | ECall(at, StaticCall("ff:core/UnsafeJs.throwIfCancelled", _, _), _, _, [], _) =>
373
376
  if(async) {"((() => ff_core_Task.Task_throwIfAborted($task))())"} else {""}
377
+ | ECall(at, StaticCall("ff:core/UnsafeJs.inAsync", _, _), _, _, [], _) =>
378
+ if(self.emittingAsync) {"true"} else {"false"}
379
+ | ECall(at, StaticCall("ff:core/UnsafeJs.inBrowser", _, _), _, _, [], _) =>
380
+ if(self.emitTarget == EmitBrowser) {"true"} else {"false"}
381
+ | ECall(at, StaticCall("ff:core/UnsafeJs.inNode", _, _), _, _, [], _) =>
382
+ if(self.emitTarget == EmitNode) {"true"} else {"false"}
383
+ | ECall(at, StaticCall("ff:core/UnsafeJs.inBuild", _, _), _, _, [], _) =>
384
+ if(self.emitTarget == EmitBuild) {"true"} else {"false"}
385
+ | ECall(at, StaticCall("ff:core/UnsafeJs.value", _, _), _, _, [Argument(_, _, e)], _) =>
386
+ self.emitTerm(e, async)
387
+ | ECall(at, StaticCall("ff:core/UnsafeJs.fromValue", _, _), _, _, [Argument(_, _, e)], _) =>
388
+ self.emitTerm(e, async)
374
389
  | ECall(at, StaticCall("ff:core/Equal.equals", _, _), _, _, [left, right], [Dictionary(_, _, _, typeName, [])]) {
375
390
  primitiveTypes.contains(typeName) || typeName == "ff:core/Ordering.Ordering"
376
391
  } =>
@@ -545,7 +560,7 @@ extend self: JsEmitter {
545
560
  self.emitTryCatchFinally(term, last, async) | Some(code)
546
561
  } =>
547
562
  code
548
- | ECall(at, StaticCall("ff:unsafejs/UnsafeJs.throwIfCancelled", _, _), _, _, [], _) =>
563
+ | ECall(at, StaticCall("ff:core/UnsafeJs.throwIfCancelled", _, _), _, _, [], _) =>
549
564
  if(async) {"ff_core_Task.Task_throwIfAborted($task)"} else {""}
550
565
  | ECall(at, StaticCall(name, True, instanceCall), effect, _, arguments, _) =>
551
566
  if(instanceCall) {throw(CompileError(at, "Not yet implemented: Tail calls on trait methods."))}
@@ -1152,7 +1152,7 @@ extend self: Parser {
1152
1152
  True
1153
1153
  } else {False}
1154
1154
  mutable result = self.parseAtom()
1155
- while {self.current().is4(LBracketLeft, LColon, LDot, LArrowThin)} {
1155
+ while {self.current().is4(LBracketLeft, LColon, LDot, LArrowThin) || self.current().rawIs2("!", "?")} {
1156
1156
  if(self.current().is(LDot)) {
1157
1157
  self.skip(LDot)
1158
1158
  if(self.current().rawIs("{")) {
@@ -1167,6 +1167,14 @@ extend self: Parser {
1167
1167
  }
1168
1168
  } elseIf {self.current().is(LArrowThin)} {
1169
1169
  result = self.parseDynamicMember(result)
1170
+ } elseIf {self.current().rawIs2("!", "?")} {
1171
+ let token = self.skip(LOperator)
1172
+ let method = if(token.rawIs("!")) {"ff:core/UnsafeJs.value"} else {"ff:core/UnsafeJs.fromValue"}
1173
+ let target = DynamicCall(EVariable(token.at(), method), False)
1174
+ let effect = self.freshUnificationVariable(token.at())
1175
+ result = self.parseDynamicMember(ECall(token.at(), target, effect, [], [
1176
+ Argument(result.at, None, result)
1177
+ ], []))
1170
1178
  } else {
1171
1179
  let at = self.current().at()
1172
1180
  let typeArguments = if(!self.current().rawIs("[")) {[]} else {self.parseTypeArguments()}
@@ -204,6 +204,14 @@ tokenize(file: String, code: String, completionAt: Option[Location], attemptFixe
204
204
  i += 1
205
205
  emitToken(LComma, start, i)
206
206
 
207
+ } elseIf {
208
+ (code.grab(i) == '!' || code.grab(i) == '?') && i + 1 < code.size() &&
209
+ (code.grab(i + 1) == '.' || code.grab(i + 1) == '-')
210
+ } {
211
+
212
+ i += 1
213
+ emitToken(LOperator, start, i)
214
+
207
215
  } elseIf {operatorCharacters.contains(code.grab(i))} {
208
216
 
209
217
  i += 1
@@ -18,5 +18,25 @@ cancelled(): Bool
18
18
  // Replaced by the compiler
19
19
  target js sync "return false"
20
20
 
21
+ inAsync(): Bool
22
+ // Replaced by the compiler
23
+ target js sync "return false"
24
+
25
+ inBrowser(): Bool
26
+ // Replaced by the compiler
27
+ target js sync "return false"
28
+
29
+ inNode(): Bool
30
+ // Replaced by the compiler
31
+ target js sync "return false"
32
+
33
+ inBuild(): Bool
34
+ // Replaced by the compiler
35
+ target js sync "return false"
36
+
21
37
  value[T](value: T): JsValue
22
38
  target js sync "return value_"
39
+
40
+ fromValue[T](value: JsValue): T
41
+ target js sync "return value_"
42
+
@@ -411,8 +411,9 @@ renderHighlightedCode(lux: Lux, code: String) {
411
411
  | LKeyword => Styles.codeKeywordCss
412
412
  | LNamespace => Styles.codeTypeCss
413
413
  | LString => Styles.codeStringCss
414
- | LUpper => Styles.codeTypeCss
415
414
  | LWildcard => Styles.codeVariableCss
415
+ | LUpper {tokens.get(index - 1).any {_.kind == LArrowThin}} => Styles.codeStringCss
416
+ | LUpper => Styles.codeTypeCss
416
417
  | LLower {tokens.get(index - 1).any {_.kind == LArrowThin}} => Styles.codeStringCss
417
418
  | LLower {tokens.get(index - 1).any {t =>
418
419
  t.kind == LBracketRight || t.kind == LDot
@@ -27,6 +27,12 @@ nodeMain(system: NodeSystem) {
27
27
  let foo = {{_ + 1}(_)}
28
28
  Log.show(foo(1))
29
29
 
30
+ let x1 = work(initial = 3) {i =>
31
+ i + 1
32
+ } {s =>
33
+ "*" + s + "*"
34
+ }
35
+ //let x2 = work(initial = 3, {i => i + 1}, {s => s + "*"})
30
36
  }
31
37
 
32
38
  factorial(n: Int): Int {
@@ -43,4 +49,8 @@ factorialTail(n: Int, acc: Int = 1): Int {
43
49
  } else {
44
50
  tailcall factorialTail(n - 1, n * acc)
45
51
  }
52
+ }
53
+
54
+ work(f: Int => Int, g: String => String, initial: Int = 0): String {
55
+ g("" + f(initial))
46
56
  }
@@ -240,27 +240,55 @@ let f: Int => Int = {{_ + 1}(_)}
240
240
  In this code, there is an outer and an inner anonymous function, both taking one argument. The first underscore belongs to the inner function, which is called immediately by the outer function with the outer function's anonymous parameter as the argument.
241
241
 
242
242
 
243
- # Local functions
243
+ # Trailing lambda calls
244
244
 
245
- Local functions are declared exactly like top-level functions but with the `function` keyword in front of the signature, like this:
245
+ Firefly has special syntax for passing an anonymous function as the last argument in a function call. Consider the `if` function from the standard library, with this signature:
246
246
 
247
+ ```firefly
248
+ if[T](condition: Bool, body: () => T): Option[T]
249
+ ```
250
+
251
+ The `if` function takes two parameters, where the last is a function. Calling `if` with the standard syntax looks like this:
247
252
 
248
253
  ```firefly
249
- function square(n: Int): Int {
250
- n * n
251
- }
254
+ if(x == 0, {"Zero"})
252
255
  ```
253
256
 
254
- The above local function definition is a statement, similar to local variables declared with `let`. The function name `square` will be in scope for the rest of the code block.
257
+ Using the special syntax for trailing lambda calls, it looks like this:
255
258
 
256
- Furthermore, local functions declared in sequence are in scope within each other's bodies, allowing them to be mutually recursive.
259
+ ```firefly
260
+ if(x == 0) {"Zero"}
261
+ ```
257
262
 
258
- # Trailing lambda calls
263
+ With this trailing lambda call syntax, the anonymous function is written after the call parentheses. This syntax is available for multiple trailing function arguments in sequence.
264
+
265
+ The function below takes three parameters. Two functions and one `Int` with a default value:
266
+
267
+ ```firefly
268
+ work(f: Int => Int, g: String => String, initial: Int = 0): String {
269
+ g("" + f(initial))
270
+ }
271
+ ```
272
+
273
+ This function may be called with two trailling lambda arguments, like this:
259
274
 
260
275
  ```firefly
261
- if(x == 1) {"One"}
276
+ work(initial = 3) {i =>
277
+ i + 1
278
+ } {s =>
279
+ "*" + s + "*"
280
+ }
262
281
  ```
263
282
 
283
+
284
+ # Local functions
285
+
286
+ Local functions are declared exactly like top-level functions but with the `function` keyword in front of the signature, like this:
287
+
288
+ The above local function definition is a statement, similar to local variables declared with `let`. The function name `square` will be in scope for the rest of the code block.
289
+
290
+ Furthermore, local functions declared in sequence are in scope within each other's bodies, allowing them to be mutually recursive.
291
+
264
292
  # Methods
265
293
 
266
294
  Firefly has methods, which are called like this:
@@ -27,24 +27,25 @@ browserMain(system: BrowserSystem): Unit {
27
27
  This is equivalent to the following JavaScript:
28
28
 
29
29
  ```js
30
- document.onclick = {() =>
31
- Notification.requestPermission().then({() =>
30
+ document.onclick = () =>
31
+ Notification.requestPermission().then(() =>
32
32
  new Notification(
33
33
  "Hi!",
34
34
  {body: "From the Firefly JS FFI"}
35
35
  )
36
- })
37
- }
36
+ )
38
37
  ```
39
38
 
40
39
  The `->` is shorthand for calling the methods `get`, `set`, `increment`, `decrement`, `object`, `call1`, `new1` and `function1` (substitute 0 to 9 for 1).
41
40
 
42
41
  The `js` variable is of the type `JsSystem` and the rest of the expressions return `JsValue`, which represents an arbitrary JavaScript value.
43
42
 
43
+ In addition, the `!` and `?` postfix operators can be used as shorthand for `UnsafeJs.value(...)` and `UnsafeJs.fromValue(...)`.
44
44
 
45
- # The ff:unsafejs package
46
45
 
47
- This package provides access to unsafe JavaScript features:
46
+ # The UnsafeJs module
47
+
48
+ This module provides access to unsafe JavaScript features:
48
49
 
49
50
  ```firefly
50
51
  // Obtains the JsSystem without a capability
@@ -62,11 +63,26 @@ throwIfCancelled(): Unit
62
63
  // Returns true if the current task has been aborted
63
64
  cancelled(): Bool
64
65
 
66
+ // Returns true if the current target is async
67
+ inAsync(): Bool
68
+
69
+ // Returns true if the current target is browser
70
+ inBrowser(): Bool
71
+
72
+ // Returns true if the current target is node
73
+ inNode(): Bool
74
+
75
+ // Returns true if the current target is build
76
+ inBuild(): Bool
77
+
65
78
  // Casts any Firefly value to a JavaScript value without conversion
66
79
  value[T](value: T): JsValue
80
+
81
+ // Casts any JavaScript value to a Firefly value without conversion
82
+ fromValue[T](value: JsValue): T
67
83
  ```
68
84
 
69
- In the future, it may be possible to provide a whitelist of dependencies that are allowed to use this package.
85
+ In the future, it may be possible to provide a whitelist of dependencies that are allowed to use this module.
70
86
 
71
87
 
72
88
  # Internal FFI
@@ -114,6 +114,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
114
114
 
115
115
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
116
116
 
117
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
118
+
117
119
  // type PackageFiles
118
120
  export function PackageFiles(root_, packageFile_, files_) {
119
121
  return {root_, packageFile_, files_};
@@ -114,12 +114,14 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
114
114
 
115
115
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
116
116
 
117
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
118
+
117
119
  // type Compiler
118
120
  export function Compiler(emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, singleFilePackages_, virtualFiles_, cache_, lspHook_, phaseDurationDelta_, phaseDurations_) {
119
121
  return {emitTarget_, task_, compilerModulePath_, jsOutputPath_, packagePaths_, singleFilePackages_, virtualFiles_, cache_, lspHook_, phaseDurationDelta_, phaseDurations_};
120
122
  }
121
123
 
122
- export const coreImports_ = ff_core_List.List_map(["Any", "Array", "AssetSystem", "Atomic", "Bool", "BrowserSystem", "Buffer", "BuildSystem", "Channel", "Char", "Core", "Crypto", "Duration", "Equal", "Error", "FileHandle", "Float", "HttpClient", "Instant", "Int", "IntMap", "Json", "JsValue", "JsSystem", "List", "Lock", "Log", "Map", "NodeSystem", "Nothing", "Option", "Ordering", "Pair", "Path", "Random", "Serializable", "Set", "Show", "SourceLocation", "Stream", "String", "StringMap", "Task", "Try", "Unit"], ((moduleName_) => {
124
+ export const coreImports_ = ff_core_List.List_map(["Any", "Array", "AssetSystem", "Atomic", "Bool", "BrowserSystem", "Buffer", "BuildSystem", "Channel", "Char", "Core", "Crypto", "Duration", "Equal", "Error", "FileHandle", "Float", "HttpClient", "Instant", "Int", "IntMap", "Json", "JsValue", "JsSystem", "List", "Lock", "Log", "Map", "NodeSystem", "Nothing", "Option", "Ordering", "Pair", "Path", "Random", "Serializable", "Set", "Show", "SourceLocation", "Stream", "String", "StringMap", "Task", "Try", "Unit", "UnsafeJs"], ((moduleName_) => {
123
125
  return ff_compiler_Syntax.DImport(ff_compiler_Syntax.Location("<prelude>", 1, 1), moduleName_, ff_compiler_Syntax.PackagePair("ff", "core"), [], moduleName_)
124
126
  }));
125
127
 
@@ -104,6 +104,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
104
104
 
105
105
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
106
106
 
107
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
108
+
107
109
  // type Dependencies
108
110
  export function Dependencies(workspace_, packages_, packagePaths_, singleFilePackages_) {
109
111
  return {workspace_, packages_, packagePaths_, singleFilePackages_};
@@ -92,6 +92,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
92
92
 
93
93
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
94
94
 
95
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
96
+
95
97
  // type DependencyLock
96
98
  export function DependencyLock(doneLocks_, task_) {
97
99
  return {doneLocks_, task_};
@@ -94,6 +94,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
94
94
 
95
95
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
96
 
97
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
98
+
97
99
  // type Deriver
98
100
  const Deriver$ = {Deriver: true};
99
101
  export function Deriver() {
@@ -98,6 +98,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
98
98
 
99
99
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
100
100
 
101
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
102
+
101
103
  // type Dictionaries
102
104
  export function Dictionaries(instances_) {
103
105
  return {instances_};
@@ -94,6 +94,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
94
94
 
95
95
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
96
 
97
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
98
+
97
99
  // type Environment
98
100
  export function Environment(modulePrefix_, symbols_, traits_, imports_, effect_, selfVariable_) {
99
101
  return {modulePrefix_, symbols_, traits_, imports_, effect_, selfVariable_};
@@ -102,6 +102,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
102
102
 
103
103
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
104
104
 
105
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
106
+
105
107
  // type Inference
106
108
  export function Inference(unification_, missing_, lspHook_) {
107
109
  return {unification_, missing_, lspHook_};
@@ -98,6 +98,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
98
98
 
99
99
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
100
100
 
101
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
102
+
101
103
  // type JsEmitter
102
104
  export function JsEmitter(otherModules_, jsImporter_, emitTarget_, isMainModule_, compilerModulePath_, packagePair_, moduleName_, emittingAsync_, tailCallUsed_) {
103
105
  return {otherModules_, jsImporter_, emitTarget_, isMainModule_, compilerModulePath_, packagePair_, moduleName_, emittingAsync_, tailCallUsed_};
@@ -931,23 +933,22 @@ const x1_ = _1.arguments_[0].value_.name_;
931
933
  const x2_ = _1.arguments_[1].value_.name_;
932
934
  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_)) + "))")
933
935
  }
934
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.import" && _1.arguments_.length === 1 && _1.arguments_[0].value_.EString) {
936
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.import" && _1.arguments_.length === 1 && _1.arguments_[0].value_.EString) {
935
937
  const at_ = _1.at_;
936
938
  const url_ = _1.arguments_[0].value_.value_;
937
939
  return ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", ""))
938
940
  }
939
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.await" && _1.arguments_.length === 1) {
941
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.await" && _1.arguments_.length === 1) {
940
942
  const at_ = _1.at_;
941
943
  const body_ = _1.arguments_[0].value_;
942
- const emittedBody_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_);
943
944
  if(async_) {
944
- return (("(await " + emittedBody_) + "($task))")
945
+ return (("(await " + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, body_, async_)) + "($task))")
945
946
  } else {
946
- return (("(" + emittedBody_) + "())")
947
+ return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), async_)
947
948
  }
948
949
  return
949
950
  }
950
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.cancelled" && _1.arguments_.length === 0) {
951
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.cancelled" && _1.arguments_.length === 0) {
951
952
  const at_ = _1.at_;
952
953
  if(async_) {
953
954
  return "$task.controller.signal.aborted"
@@ -956,7 +957,7 @@ return "false"
956
957
  }
957
958
  return
958
959
  }
959
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
960
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
960
961
  const at_ = _1.at_;
961
962
  if(async_) {
962
963
  return "((() => ff_core_Task.Task_throwIfAborted($task))())"
@@ -965,6 +966,52 @@ return ""
965
966
  }
966
967
  return
967
968
  }
969
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inAsync" && _1.arguments_.length === 0) {
970
+ const at_ = _1.at_;
971
+ if(self_.emittingAsync_) {
972
+ return "true"
973
+ } else {
974
+ return "false"
975
+ }
976
+ return
977
+ }
978
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inBrowser" && _1.arguments_.length === 0) {
979
+ const at_ = _1.at_;
980
+ if(ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser())) {
981
+ return "true"
982
+ } else {
983
+ return "false"
984
+ }
985
+ return
986
+ }
987
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inNode" && _1.arguments_.length === 0) {
988
+ const at_ = _1.at_;
989
+ if(ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitNode())) {
990
+ return "true"
991
+ } else {
992
+ return "false"
993
+ }
994
+ return
995
+ }
996
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inBuild" && _1.arguments_.length === 0) {
997
+ const at_ = _1.at_;
998
+ if(ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBuild())) {
999
+ return "true"
1000
+ } else {
1001
+ return "false"
1002
+ }
1003
+ return
1004
+ }
1005
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.value" && _1.arguments_.length === 1) {
1006
+ const at_ = _1.at_;
1007
+ const e_ = _1.arguments_[0].value_;
1008
+ return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)
1009
+ }
1010
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.fromValue" && _1.arguments_.length === 1) {
1011
+ const at_ = _1.at_;
1012
+ const e_ = _1.arguments_[0].value_;
1013
+ return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, e_, async_)
1014
+ }
968
1015
  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) {
969
1016
  const at_ = _1.at_;
970
1017
  const left_ = _1.arguments_[0];
@@ -1331,7 +1378,7 @@ const code_ = _guard1.value_;
1331
1378
  return code_
1332
1379
  }
1333
1380
  }
1334
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
1381
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
1335
1382
  const at_ = _1.at_;
1336
1383
  if(async_) {
1337
1384
  return "ff_core_Task.Task_throwIfAborted($task)"
@@ -2269,23 +2316,22 @@ const x1_ = _1.arguments_[0].value_.name_;
2269
2316
  const x2_ = _1.arguments_[1].value_.name_;
2270
2317
  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_)) + "))")
2271
2318
  }
2272
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.import" && _1.arguments_.length === 1 && _1.arguments_[0].value_.EString) {
2319
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.import" && _1.arguments_.length === 1 && _1.arguments_[0].value_.EString) {
2273
2320
  const at_ = _1.at_;
2274
2321
  const url_ = _1.arguments_[0].value_.value_;
2275
2322
  return ff_compiler_JsImporter.JsImporter_add(self_.jsImporter_, ff_core_String.String_replace(url_, "\"", ""))
2276
2323
  }
2277
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.await" && _1.arguments_.length === 1) {
2324
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.await" && _1.arguments_.length === 1) {
2278
2325
  const at_ = _1.at_;
2279
2326
  const body_ = _1.arguments_[0].value_;
2280
- const emittedBody_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task));
2281
2327
  if(async_) {
2282
- return (("(await " + emittedBody_) + "($task))")
2328
+ return (("(await " + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, body_, async_, $task))) + "($task))")
2283
2329
  } else {
2284
- return (("(" + emittedBody_) + "())")
2330
+ return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, ff_compiler_JsEmitter.invokeImmediately_(body_), async_, $task))
2285
2331
  }
2286
2332
  return
2287
2333
  }
2288
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.cancelled" && _1.arguments_.length === 0) {
2334
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.cancelled" && _1.arguments_.length === 0) {
2289
2335
  const at_ = _1.at_;
2290
2336
  if(async_) {
2291
2337
  return "$task.controller.signal.aborted"
@@ -2294,7 +2340,7 @@ return "false"
2294
2340
  }
2295
2341
  return
2296
2342
  }
2297
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
2343
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
2298
2344
  const at_ = _1.at_;
2299
2345
  if(async_) {
2300
2346
  return "((() => ff_core_Task.Task_throwIfAborted($task))())"
@@ -2303,6 +2349,52 @@ return ""
2303
2349
  }
2304
2350
  return
2305
2351
  }
2352
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inAsync" && _1.arguments_.length === 0) {
2353
+ const at_ = _1.at_;
2354
+ if(self_.emittingAsync_) {
2355
+ return "true"
2356
+ } else {
2357
+ return "false"
2358
+ }
2359
+ return
2360
+ }
2361
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inBrowser" && _1.arguments_.length === 0) {
2362
+ const at_ = _1.at_;
2363
+ if(ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBrowser())) {
2364
+ return "true"
2365
+ } else {
2366
+ return "false"
2367
+ }
2368
+ return
2369
+ }
2370
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inNode" && _1.arguments_.length === 0) {
2371
+ const at_ = _1.at_;
2372
+ if(ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitNode())) {
2373
+ return "true"
2374
+ } else {
2375
+ return "false"
2376
+ }
2377
+ return
2378
+ }
2379
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.inBuild" && _1.arguments_.length === 0) {
2380
+ const at_ = _1.at_;
2381
+ if(ff_compiler_JsEmitter.ff_core_Equal_Equal$ff_compiler_JsEmitter_EmitTarget.equals_(self_.emitTarget_, ff_compiler_JsEmitter.EmitBuild())) {
2382
+ return "true"
2383
+ } else {
2384
+ return "false"
2385
+ }
2386
+ return
2387
+ }
2388
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.value" && _1.arguments_.length === 1) {
2389
+ const at_ = _1.at_;
2390
+ const e_ = _1.arguments_[0].value_;
2391
+ return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e_, async_, $task))
2392
+ }
2393
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.fromValue" && _1.arguments_.length === 1) {
2394
+ const at_ = _1.at_;
2395
+ const e_ = _1.arguments_[0].value_;
2396
+ return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, e_, async_, $task))
2397
+ }
2306
2398
  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) {
2307
2399
  const at_ = _1.at_;
2308
2400
  const left_ = _1.arguments_[0];
@@ -2669,7 +2761,7 @@ const code_ = _guard1.value_;
2669
2761
  return code_
2670
2762
  }
2671
2763
  }
2672
- if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:unsafejs/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
2764
+ if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/UnsafeJs.throwIfCancelled" && _1.arguments_.length === 0) {
2673
2765
  const at_ = _1.at_;
2674
2766
  if(async_) {
2675
2767
  return "ff_core_Task.Task_throwIfAborted($task)"
@@ -94,6 +94,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
94
94
 
95
95
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
96
 
97
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
98
+
97
99
  // type JsImporter
98
100
  export function JsImporter(imports_) {
99
101
  return {imports_};
@@ -98,6 +98,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
98
98
 
99
99
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
100
100
 
101
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
102
+
101
103
  // type LspHook
102
104
  export function LspHook(at_, definedAt_, insertIdentifier_, trackSymbols_, arrayOfResults_) {
103
105
  return {at_, definedAt_, insertIdentifier_, trackSymbols_, arrayOfResults_};
@@ -118,6 +118,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
118
118
 
119
119
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
120
120
 
121
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
122
+
121
123
  // type MainCommand
122
124
  const BootstrapCommand$ = {BootstrapCommand: true};
123
125
  export function BootstrapCommand() {
@@ -94,6 +94,8 @@ import * as ff_core_Try from "../../ff/core/Try.mjs"
94
94
 
95
95
  import * as ff_core_Unit from "../../ff/core/Unit.mjs"
96
96
 
97
+ import * as ff_core_UnsafeJs from "../../ff/core/UnsafeJs.mjs"
98
+
97
99
  // type ModuleCache
98
100
  export function ModuleCache(version_, parsedModules_, resolvedModules_, derivedModules_, inferredModules_, emittedModules_) {
99
101
  return {version_, parsedModules_, resolvedModules_, derivedModules_, inferredModules_, emittedModules_};