firefly-compiler 0.4.18 → 0.4.20

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 (116) hide show
  1. package/compiler/Builder.ff +1 -1
  2. package/compiler/Compiler.ff +6 -5
  3. package/compiler/Inference.ff +31 -19
  4. package/compiler/JsEmitter.ff +98 -71
  5. package/compiler/JsImporter.ff +1 -1
  6. package/compiler/LspHook.ff +17 -5
  7. package/compiler/Main.ff +6 -6
  8. package/compiler/Parser.ff +50 -52
  9. package/compiler/Patterns.ff +2 -0
  10. package/compiler/Syntax.ff +1 -1
  11. package/compiler/Tokenizer.ff +2 -2
  12. package/compiler/Workspace.ff +2 -2
  13. package/core/Array.ff +135 -294
  14. package/core/Buffer.ff +3 -3
  15. package/core/BuildSystem.ff +1 -1
  16. package/core/Equal.ff +36 -52
  17. package/core/HttpClient.ff +1 -1
  18. package/core/IntMap.ff +14 -18
  19. package/core/JsSystem.ff +1 -1
  20. package/core/JsValue.ff +6 -12
  21. package/core/Json.ff +21 -30
  22. package/core/List.ff +281 -312
  23. package/core/Map.ff +4 -8
  24. package/core/NodeSystem.ff +2 -2
  25. package/core/Option.ff +0 -4
  26. package/core/Ordering.ff +10 -6
  27. package/core/Pair.ff +0 -4
  28. package/core/Random.ff +12 -26
  29. package/core/RbMap.ff +216 -216
  30. package/core/Serializable.ff +9 -18
  31. package/core/Set.ff +0 -1
  32. package/core/SourceLocation.ff +1 -1
  33. package/core/Stream.ff +10 -14
  34. package/core/String.ff +24 -6
  35. package/core/StringMap.ff +15 -19
  36. package/guide/Main.ff +20 -2
  37. package/lsp/CompletionHandler.ff +18 -18
  38. package/lsp/Handler.ff +45 -34
  39. package/lsp/HoverHandler.ff +2 -2
  40. package/lsp/LanguageServer.ff +2 -2
  41. package/lsp/SignatureHelpHandler.ff +1 -1
  42. package/lsp/SymbolHandler.ff +19 -5
  43. package/lux/Lux.ff +3 -3
  44. package/output/js/ff/compiler/Builder.mjs +19 -21
  45. package/output/js/ff/compiler/Compiler.mjs +18 -20
  46. package/output/js/ff/compiler/Dependencies.mjs +8 -10
  47. package/output/js/ff/compiler/Deriver.mjs +234 -236
  48. package/output/js/ff/compiler/Dictionaries.mjs +6 -8
  49. package/output/js/ff/compiler/Environment.mjs +42 -44
  50. package/output/js/ff/compiler/Inference.mjs +346 -304
  51. package/output/js/ff/compiler/JsEmitter.mjs +907 -833
  52. package/output/js/ff/compiler/JsImporter.mjs +0 -2
  53. package/output/js/ff/compiler/LspHook.mjs +872 -51
  54. package/output/js/ff/compiler/Main.mjs +109 -111
  55. package/output/js/ff/compiler/Parser.mjs +427 -441
  56. package/output/js/ff/compiler/Patterns.mjs +64 -50
  57. package/output/js/ff/compiler/Resolver.mjs +36 -38
  58. package/output/js/ff/compiler/Substitution.mjs +4 -6
  59. package/output/js/ff/compiler/Syntax.mjs +160 -162
  60. package/output/js/ff/compiler/Token.mjs +52 -54
  61. package/output/js/ff/compiler/Tokenizer.mjs +16 -18
  62. package/output/js/ff/compiler/Unification.mjs +24 -26
  63. package/output/js/ff/compiler/Wildcards.mjs +0 -2
  64. package/output/js/ff/compiler/Workspace.mjs +18 -20
  65. package/output/js/ff/core/Any.mjs +0 -2
  66. package/output/js/ff/core/Array.mjs +216 -613
  67. package/output/js/ff/core/AssetSystem.mjs +2 -4
  68. package/output/js/ff/core/Atomic.mjs +0 -2
  69. package/output/js/ff/core/Bool.mjs +0 -2
  70. package/output/js/ff/core/Box.mjs +0 -2
  71. package/output/js/ff/core/BrowserSystem.mjs +0 -2
  72. package/output/js/ff/core/Buffer.mjs +0 -2
  73. package/output/js/ff/core/BuildSystem.mjs +12 -14
  74. package/output/js/ff/core/Channel.mjs +0 -2
  75. package/output/js/ff/core/Char.mjs +0 -2
  76. package/output/js/ff/core/Core.mjs +0 -2
  77. package/output/js/ff/core/Duration.mjs +0 -2
  78. package/output/js/ff/core/Equal.mjs +0 -22
  79. package/output/js/ff/core/Error.mjs +0 -2
  80. package/output/js/ff/core/FileHandle.mjs +0 -2
  81. package/output/js/ff/core/Float.mjs +0 -2
  82. package/output/js/ff/core/HttpClient.mjs +2 -4
  83. package/output/js/ff/core/Instant.mjs +0 -2
  84. package/output/js/ff/core/Int.mjs +8 -10
  85. package/output/js/ff/core/IntMap.mjs +32 -42
  86. package/output/js/ff/core/JsSystem.mjs +1 -3
  87. package/output/js/ff/core/JsValue.mjs +5 -12
  88. package/output/js/ff/core/Json.mjs +25 -58
  89. package/output/js/ff/core/List.mjs +648 -1989
  90. package/output/js/ff/core/Lock.mjs +0 -2
  91. package/output/js/ff/core/Log.mjs +0 -2
  92. package/output/js/ff/core/Map.mjs +10 -20
  93. package/output/js/ff/core/NodeSystem.mjs +6 -8
  94. package/output/js/ff/core/Nothing.mjs +0 -2
  95. package/output/js/ff/core/Option.mjs +8 -18
  96. package/output/js/ff/core/Ordering.mjs +20 -98
  97. package/output/js/ff/core/Pair.mjs +6 -16
  98. package/output/js/ff/core/Path.mjs +12 -14
  99. package/output/js/ff/core/Random.mjs +24 -54
  100. package/output/js/ff/core/RbMap.mjs +54 -56
  101. package/output/js/ff/core/Serializable.mjs +19 -36
  102. package/output/js/ff/core/Set.mjs +0 -14
  103. package/output/js/ff/core/Show.mjs +0 -2
  104. package/output/js/ff/core/SourceLocation.mjs +0 -2
  105. package/output/js/ff/core/Stream.mjs +34 -44
  106. package/output/js/ff/core/String.mjs +31 -5
  107. package/output/js/ff/core/StringMap.mjs +32 -42
  108. package/output/js/ff/core/Task.mjs +0 -2
  109. package/output/js/ff/core/Try.mjs +0 -2
  110. package/output/js/ff/core/Unit.mjs +0 -2
  111. package/package.json +1 -1
  112. package/vscode/client/src/extension.ts +30 -2
  113. package/vscode/package.json +17 -1
  114. package/webserver/WebServer.ff +8 -8
  115. package/core/Stack.ff +0 -263
  116. package/output/js/ff/core/Stack.mjs +0 -603
package/core/Stack.ff DELETED
@@ -1,263 +0,0 @@
1
- class Stack[T] {}
2
-
3
- make[T](): Stack[T]
4
- target js sync "return {array: []}"
5
-
6
- fill[T](size: Int, value: T): Array[T]
7
- target js sync """
8
- return {array: new Array(size_).fill(value_)};
9
- """
10
-
11
- fillBy[T](size: Int, body: Int => T): Array[T]
12
- target js sync """
13
- return {array: Array.from({length: size_}, (_, i) => body_(i))};
14
- """
15
-
16
- range(size: Int): Array[Int]
17
- target js sync """
18
- return {array: Array.from({length: size_}, (_, i) => i)};
19
- """
20
-
21
- extend self[T]: Stack[T] {
22
-
23
- isEmpty(): Bool
24
- target js sync "return self_.array.length === 0"
25
-
26
- size(): Int
27
- target js sync "return self_.array.length"
28
-
29
- get(index: Int): Option[T]
30
- target js sync """
31
- return index_ >= 0 && index_ < self_.array.length
32
- ? ff_core_Option.Some(self_.array[index_])
33
- : ff_core_Option.None()
34
- """
35
-
36
- grab(index: Int): T
37
- target js sync """
38
- if(index_ < 0 || index_ >= self_.array.length) {
39
- ff_core_Try.internalThrowGrabException_()
40
- }
41
- return self_.array[index_]
42
- """
43
-
44
- grabFirst(): T { self.grab(0) }
45
-
46
- grabLast(): T { self.grab(self.size() - 1) }
47
-
48
- first(): Option[T]
49
- target js sync """
50
- return self_.array.length > 0
51
- ? ff_core_Option.Some(self_.array[0])
52
- : ff_core_Option.None()
53
- """
54
-
55
- last(): Option[T]
56
- target js sync """
57
- return self_.array.length > 0
58
- ? ff_core_Option.Some(self_.array[self_.array.length - 1])
59
- : ff_core_Option.None()
60
- """
61
-
62
- push(value: T): Unit
63
- target js sync "self_.array.push(value_)"
64
-
65
- pushAll(value: Stack[T]): Unit
66
- target js sync "self_.array.push(...value_.array)"
67
-
68
- pushArray(value: Array[T]): Unit
69
- target js sync "self_.array.push(...value_)"
70
-
71
- pop(): Option[T]
72
- target js sync """
73
- return self_.array.length > 0
74
- ? ff_core_Option.Some(self_.array.pop())
75
- : ff_core_Option.None()
76
- """
77
-
78
- set(index: Int, value: T): Unit
79
- target js sync """
80
- if(index_ < 0 || index_ > self_.array.length) {
81
- ff_core_Try.internalThrowGrabException_()
82
- }
83
- self_.array[index_] = value_
84
- """
85
-
86
- modify(index: Int, body: T => T): Unit
87
- target js sync """
88
- if(index_ < 0 || index_ >= self_.array.length) {
89
- ff_core_Try.internalThrowGrabException_()
90
- }
91
- self_.array[index_] = body_(self_.array[index_])
92
- """
93
- target js async """
94
- if(index_ < 0 || index_ >= self_.array.length) {
95
- ff_core_Try.internalThrowGrabException_()
96
- }
97
- self_.array[index_] = await body_(self_.array[index_], $task)
98
- """
99
-
100
- fill(value: T, start: Int = 0, end: Int = 9007199254740991): Unit
101
- target js sync """
102
- self_.array.fill(value_, start_, end_);
103
- """
104
-
105
- copy(target: Int, start: Int, end: Int): Unit
106
- target js sync """
107
- self_.array.copyWithin(target_, start_, end_);
108
- """
109
-
110
- delete(start: Int, deleteCount: Int): Unit
111
- target js sync """
112
- self_.array.splice(start_, deleteCount_);
113
- """
114
-
115
- insert(start: Int, value: T, deleteCount: Int = 0): Unit
116
- target js sync """
117
- self_.array.splice(start_, deleteCount_, value_);
118
- """
119
-
120
- insertAll(start: Int, value: Stack[T], deleteCount: Int = 0): Unit
121
- target js sync """
122
- self_.array.splice(start_, deleteCount_, ...value_.array);
123
- """
124
-
125
- insertArray(start: Int, value: Array[T], deleteCount: Int = 0): Unit
126
- target js sync """
127
- self_.array.splice(start_, deleteCount_, ...value_);
128
- """
129
-
130
- each(body: T => Unit): Unit
131
- target js sync """
132
- return self_.array.forEach(body_);
133
- """
134
- target js async """
135
- for(let i = 0; i < self_.array.length; i++) {
136
- await body_(self_.array[i], $task)
137
- }
138
- """
139
-
140
- eachWhile(body: T => Bool): Unit
141
- target js sync "for(const value of self_.array) if(!body_(value)) break"
142
- target js async "for(const value of self_.array) if(!await body_(value, $task)) break"
143
-
144
- all(body: T => Bool): Bool {
145
- mutable result = True
146
- self.eachWhile {x =>
147
- result = body(x)
148
- result
149
- }
150
- result
151
- }
152
-
153
- any(body: T => Bool): Bool {
154
- mutable result = False
155
- self.eachWhile {x =>
156
- result = body(x)
157
- (!result)
158
- }
159
- result
160
- }
161
-
162
- indexWhere(body: T => Bool): Option[Int] {
163
- mutable i = -1
164
- mutable result = False
165
- self.eachWhile {x =>
166
- i += 1
167
- result = body(x)
168
- (!result)
169
- }
170
- if(result) {i}
171
- }
172
-
173
- drain(): Array[T]
174
- target js sync "const result = self_.array; self_.array = []; return result"
175
-
176
- toArray(start: Int = 0, end: Int = 9007199254740991): Array[T]
177
- target js sync """return self_.array.slice(start_, end_)"""
178
-
179
- toList(start: Int = 0, end: Int = 9007199254740991): List[T]
180
- target js sync """
181
- if(start_ < 0) start_ = self_.array.length + start_
182
- if(end_ < 0) end_ = self_.array.length + start_
183
- start_ = Math.max(0, Math.min(start_, self_.array.length))
184
- end_ = Math.max(0, Math.min(end_, self_.array.length))
185
- let result = ff_core_List.Empty();
186
- for(let i = end_ - 1; i >= start_; i--) {
187
- result = ff_core_List.Link(self_.array[i], result);
188
- }
189
- return result;
190
- """
191
-
192
- toStream(start: Int = 0, end: Int = 9007199254740991): Stream[T] {
193
- self.toArray(start, end).toStream()
194
- }
195
-
196
- reverse(): Unit
197
- target js sync "self_.array.reverse()"
198
-
199
- sortBy[S: Order](body: T => S): Unit {
200
- self.sortWith {Ordering.compare(body(_), body(_))}
201
- }
202
-
203
- sortWith(ordering: (T, T) => Ordering): Unit {
204
- sortRange(self, ordering, 0, self.size())
205
- }
206
- target js sync "self_.array.sort((x, y) => ff_core_Ordering.Ordering_toInt(ordering_(x, y)))"
207
-
208
- }
209
-
210
- extend self[T: Order]: Stack[T] {
211
-
212
- sort(): Unit {
213
- self.sortWith(Ordering.compare)
214
- }
215
-
216
- }
217
-
218
- extend self: Stack[String] {
219
-
220
- join(separator: String = ""): String
221
- target js sync "return self_.array.join(separator_)"
222
-
223
- }
224
-
225
- instance Stack[T: Show]: Show {
226
- show(value: Stack[T]): String {
227
- let stack = Stack.make()
228
- stack.push("[")
229
- value.each {x =>
230
- if(stack.size() > 1) {stack.push(", ")}
231
- stack.push(Show.show(x))
232
- }
233
- stack.push("].toStack()")
234
- stack.join()
235
- }
236
- }
237
-
238
- sortRange[T](stack: Stack[T], compare: (T, T) => Ordering, start: Int, end: Int): Unit {
239
- if(end - start < 2) {} else:
240
-
241
- mutable middle = start + ((end - start) / 2)
242
- sortRange(stack, compare, start, middle)
243
- sortRange(stack, compare, middle, end)
244
-
245
- mutable i = start
246
- mutable j = middle
247
- while {i < middle && j < end} {
248
- if(compare(stack.grab(i), stack.grab(j)) != OrderingAfter) {
249
- i += 1
250
- } else {
251
- let value = stack.grab(j)
252
- mutable k = j
253
- while {k > i} {
254
- stack.set(k, stack.grab(k - 1))
255
- k -= 1
256
- }
257
- stack.set(i, value)
258
- i += 1
259
- middle += 1
260
- j += 1
261
- }
262
- }
263
- }