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.
- package/compiler/Builder.ff +1 -1
- package/compiler/Compiler.ff +6 -5
- package/compiler/Inference.ff +31 -19
- package/compiler/JsEmitter.ff +98 -71
- package/compiler/JsImporter.ff +1 -1
- package/compiler/LspHook.ff +17 -5
- package/compiler/Main.ff +6 -6
- package/compiler/Parser.ff +50 -52
- package/compiler/Patterns.ff +2 -0
- package/compiler/Syntax.ff +1 -1
- package/compiler/Tokenizer.ff +2 -2
- package/compiler/Workspace.ff +2 -2
- package/core/Array.ff +135 -294
- package/core/Buffer.ff +3 -3
- package/core/BuildSystem.ff +1 -1
- package/core/Equal.ff +36 -52
- package/core/HttpClient.ff +1 -1
- package/core/IntMap.ff +14 -18
- package/core/JsSystem.ff +1 -1
- package/core/JsValue.ff +6 -12
- package/core/Json.ff +21 -30
- package/core/List.ff +281 -312
- package/core/Map.ff +4 -8
- package/core/NodeSystem.ff +2 -2
- package/core/Option.ff +0 -4
- package/core/Ordering.ff +10 -6
- package/core/Pair.ff +0 -4
- package/core/Random.ff +12 -26
- package/core/RbMap.ff +216 -216
- package/core/Serializable.ff +9 -18
- package/core/Set.ff +0 -1
- package/core/SourceLocation.ff +1 -1
- package/core/Stream.ff +10 -14
- package/core/String.ff +24 -6
- package/core/StringMap.ff +15 -19
- package/guide/Main.ff +20 -2
- package/lsp/CompletionHandler.ff +18 -18
- package/lsp/Handler.ff +45 -34
- package/lsp/HoverHandler.ff +2 -2
- package/lsp/LanguageServer.ff +2 -2
- package/lsp/SignatureHelpHandler.ff +1 -1
- package/lsp/SymbolHandler.ff +19 -5
- package/lux/Lux.ff +3 -3
- package/output/js/ff/compiler/Builder.mjs +19 -21
- package/output/js/ff/compiler/Compiler.mjs +18 -20
- package/output/js/ff/compiler/Dependencies.mjs +8 -10
- package/output/js/ff/compiler/Deriver.mjs +234 -236
- package/output/js/ff/compiler/Dictionaries.mjs +6 -8
- package/output/js/ff/compiler/Environment.mjs +42 -44
- package/output/js/ff/compiler/Inference.mjs +346 -304
- package/output/js/ff/compiler/JsEmitter.mjs +907 -833
- package/output/js/ff/compiler/JsImporter.mjs +0 -2
- package/output/js/ff/compiler/LspHook.mjs +872 -51
- package/output/js/ff/compiler/Main.mjs +109 -111
- package/output/js/ff/compiler/Parser.mjs +427 -441
- package/output/js/ff/compiler/Patterns.mjs +64 -50
- package/output/js/ff/compiler/Resolver.mjs +36 -38
- package/output/js/ff/compiler/Substitution.mjs +4 -6
- package/output/js/ff/compiler/Syntax.mjs +160 -162
- package/output/js/ff/compiler/Token.mjs +52 -54
- package/output/js/ff/compiler/Tokenizer.mjs +16 -18
- package/output/js/ff/compiler/Unification.mjs +24 -26
- package/output/js/ff/compiler/Wildcards.mjs +0 -2
- package/output/js/ff/compiler/Workspace.mjs +18 -20
- package/output/js/ff/core/Any.mjs +0 -2
- package/output/js/ff/core/Array.mjs +216 -613
- package/output/js/ff/core/AssetSystem.mjs +2 -4
- package/output/js/ff/core/Atomic.mjs +0 -2
- package/output/js/ff/core/Bool.mjs +0 -2
- package/output/js/ff/core/Box.mjs +0 -2
- package/output/js/ff/core/BrowserSystem.mjs +0 -2
- package/output/js/ff/core/Buffer.mjs +0 -2
- package/output/js/ff/core/BuildSystem.mjs +12 -14
- package/output/js/ff/core/Channel.mjs +0 -2
- package/output/js/ff/core/Char.mjs +0 -2
- package/output/js/ff/core/Core.mjs +0 -2
- package/output/js/ff/core/Duration.mjs +0 -2
- package/output/js/ff/core/Equal.mjs +0 -22
- package/output/js/ff/core/Error.mjs +0 -2
- package/output/js/ff/core/FileHandle.mjs +0 -2
- package/output/js/ff/core/Float.mjs +0 -2
- package/output/js/ff/core/HttpClient.mjs +2 -4
- package/output/js/ff/core/Instant.mjs +0 -2
- package/output/js/ff/core/Int.mjs +8 -10
- package/output/js/ff/core/IntMap.mjs +32 -42
- package/output/js/ff/core/JsSystem.mjs +1 -3
- package/output/js/ff/core/JsValue.mjs +5 -12
- package/output/js/ff/core/Json.mjs +25 -58
- package/output/js/ff/core/List.mjs +648 -1989
- package/output/js/ff/core/Lock.mjs +0 -2
- package/output/js/ff/core/Log.mjs +0 -2
- package/output/js/ff/core/Map.mjs +10 -20
- package/output/js/ff/core/NodeSystem.mjs +6 -8
- package/output/js/ff/core/Nothing.mjs +0 -2
- package/output/js/ff/core/Option.mjs +8 -18
- package/output/js/ff/core/Ordering.mjs +20 -98
- package/output/js/ff/core/Pair.mjs +6 -16
- package/output/js/ff/core/Path.mjs +12 -14
- package/output/js/ff/core/Random.mjs +24 -54
- package/output/js/ff/core/RbMap.mjs +54 -56
- package/output/js/ff/core/Serializable.mjs +19 -36
- package/output/js/ff/core/Set.mjs +0 -14
- package/output/js/ff/core/Show.mjs +0 -2
- package/output/js/ff/core/SourceLocation.mjs +0 -2
- package/output/js/ff/core/Stream.mjs +34 -44
- package/output/js/ff/core/String.mjs +31 -5
- package/output/js/ff/core/StringMap.mjs +32 -42
- package/output/js/ff/core/Task.mjs +0 -2
- package/output/js/ff/core/Try.mjs +0 -2
- package/output/js/ff/core/Unit.mjs +0 -2
- package/package.json +1 -1
- package/vscode/client/src/extension.ts +30 -2
- package/vscode/package.json +17 -1
- package/webserver/WebServer.ff +8 -8
- package/core/Stack.ff +0 -263
- 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
|
-
}
|