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/Array.ff
CHANGED
|
@@ -1,201 +1,150 @@
|
|
|
1
|
-
|
|
1
|
+
class Array[T] {}
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
target js sync ""
|
|
5
|
-
return [];
|
|
6
|
-
"""
|
|
3
|
+
make[T](): Array[T]
|
|
4
|
+
target js sync "return {array: []}"
|
|
7
5
|
|
|
8
|
-
fill[T](size: Int, value: T):
|
|
6
|
+
fill[T](size: Int, value: T): List[T]
|
|
9
7
|
target js sync """
|
|
10
|
-
return new Array(size_).fill(value_);
|
|
8
|
+
return {array: new Array(size_).fill(value_)};
|
|
11
9
|
"""
|
|
12
10
|
|
|
13
|
-
fillBy[T](size: Int, body: Int => T):
|
|
11
|
+
fillBy[T](size: Int, body: Int => T): List[T]
|
|
14
12
|
target js sync """
|
|
15
|
-
return Array.from({length: size_}, (_, i) => body_(i));
|
|
16
|
-
"""
|
|
17
|
-
target js async """
|
|
18
|
-
const array = new Array(size_);
|
|
19
|
-
for(let i = 0; i < size_; i++) {
|
|
20
|
-
array[i] = await(body_(_i));
|
|
21
|
-
}
|
|
22
|
-
return array;
|
|
13
|
+
return {array: Array.from({length: size_}, (_, i) => body_(i))};
|
|
23
14
|
"""
|
|
24
15
|
|
|
25
|
-
range(size: Int):
|
|
16
|
+
range(size: Int): List[Int]
|
|
26
17
|
target js sync """
|
|
27
|
-
return Array.from({length: size_}, (_, i) => i);
|
|
18
|
+
return {array: Array.from({length: size_}, (_, i) => i)};
|
|
28
19
|
"""
|
|
29
20
|
|
|
30
21
|
extend self[T]: Array[T] {
|
|
31
22
|
|
|
32
|
-
addAll(that: Array[T]): Array[T]
|
|
33
|
-
target js sync "return self_.concat(that_)"
|
|
34
|
-
|
|
35
23
|
isEmpty(): Bool
|
|
36
|
-
target js sync "return self_.length === 0"
|
|
24
|
+
target js sync "return self_.array.length === 0"
|
|
37
25
|
|
|
38
26
|
size(): Int
|
|
39
|
-
target js sync "return self_.length"
|
|
27
|
+
target js sync "return self_.array.length"
|
|
40
28
|
|
|
41
29
|
get(index: Int): Option[T]
|
|
42
30
|
target js sync """
|
|
43
|
-
return index_ >= 0 && index_ < self_.length
|
|
44
|
-
? ff_core_Option.Some(self_[index_])
|
|
31
|
+
return index_ >= 0 && index_ < self_.array.length
|
|
32
|
+
? ff_core_Option.Some(self_.array[index_])
|
|
45
33
|
: ff_core_Option.None()
|
|
46
34
|
"""
|
|
47
35
|
|
|
48
36
|
grab(index: Int): T
|
|
49
37
|
target js sync """
|
|
50
|
-
if(index_ < 0 || index_ >= self_.length) {
|
|
38
|
+
if(index_ < 0 || index_ >= self_.array.length) {
|
|
51
39
|
ff_core_Try.internalThrowGrabException_()
|
|
52
40
|
}
|
|
53
|
-
return self_[index_]
|
|
41
|
+
return self_.array[index_]
|
|
54
42
|
"""
|
|
55
43
|
|
|
56
|
-
first(): Option[T] {self.get(0)}
|
|
57
|
-
|
|
58
|
-
last(): Option[T] {self.get(self.size() - 1)}
|
|
59
|
-
|
|
60
44
|
grabFirst(): T {self.grab(0)}
|
|
61
45
|
|
|
62
46
|
grabLast(): T {self.grab(self.size() - 1)}
|
|
63
47
|
|
|
64
|
-
|
|
65
|
-
target js sync "
|
|
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
|
+
"""
|
|
66
54
|
|
|
67
|
-
|
|
68
|
-
target js sync "
|
|
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
|
+
"""
|
|
69
61
|
|
|
70
|
-
|
|
71
|
-
target js sync "
|
|
62
|
+
push(value: T): Unit
|
|
63
|
+
target js sync "self_.array.push(value_)"
|
|
72
64
|
|
|
73
|
-
|
|
74
|
-
target js sync "
|
|
65
|
+
pushArray(value: Array[T]): Unit
|
|
66
|
+
target js sync "self_.array.push(...value_.array)"
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
self.map {x =>
|
|
79
|
-
let r = Pair(i, x)
|
|
80
|
-
i += 1
|
|
81
|
-
r
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
slice(from: Int, until: Int): Array[T] {
|
|
86
|
-
self.dropFirst(from).takeFirst(until - from)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
foldLeft[R](initial: R, body: (R, T) => R): R {
|
|
90
|
-
mutable result = initial
|
|
91
|
-
self.each {x =>
|
|
92
|
-
result = body(result, x)
|
|
93
|
-
}
|
|
94
|
-
result
|
|
95
|
-
}
|
|
68
|
+
pushList(value: List[T]): Unit
|
|
69
|
+
target js sync "self_.array.push(...value_)"
|
|
96
70
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
102
79
|
target js sync """
|
|
103
|
-
if(index_ < 0 || index_
|
|
80
|
+
if(index_ < 0 || index_ > self_.array.length) {
|
|
104
81
|
ff_core_Try.internalThrowGrabException_()
|
|
105
82
|
}
|
|
106
|
-
|
|
107
|
-
result[index_] = body_(result[index_]);
|
|
108
|
-
return result;
|
|
83
|
+
self_.array[index_] = value_
|
|
109
84
|
"""
|
|
110
|
-
|
|
111
|
-
|
|
85
|
+
|
|
86
|
+
modify(index: Int, body: T => T): Unit
|
|
87
|
+
target js sync """
|
|
88
|
+
if(index_ < 0 || index_ >= self_.array.length) {
|
|
112
89
|
ff_core_Try.internalThrowGrabException_()
|
|
113
90
|
}
|
|
114
|
-
|
|
115
|
-
result[index_] = await body_(result[index_], $task);
|
|
116
|
-
return result;
|
|
91
|
+
self_.array[index_] = body_(self_.array[index_])
|
|
117
92
|
"""
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
mutable i = -1
|
|
122
|
-
self.map {x =>
|
|
123
|
-
i += 1
|
|
124
|
-
Pair(x, that.grab(i))
|
|
125
|
-
}
|
|
126
|
-
} else {
|
|
127
|
-
mutable i = -1
|
|
128
|
-
that.map {y =>
|
|
129
|
-
i += 1
|
|
130
|
-
Pair(self.grab(i), y)
|
|
93
|
+
target js async """
|
|
94
|
+
if(index_ < 0 || index_ >= self_.array.length) {
|
|
95
|
+
ff_core_Try.internalThrowGrabException_()
|
|
131
96
|
}
|
|
132
|
-
|
|
133
|
-
|
|
97
|
+
self_.array[index_] = await body_(self_.array[index_], $task)
|
|
98
|
+
"""
|
|
134
99
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
self.each {item =>
|
|
140
|
-
if(added < chunkSize) {
|
|
141
|
-
added += 1
|
|
142
|
-
} else {
|
|
143
|
-
results.push(result.drain())
|
|
144
|
-
added = 1
|
|
145
|
-
}
|
|
146
|
-
result.push(item)
|
|
147
|
-
}
|
|
148
|
-
if(added != 0) {
|
|
149
|
-
results.push(result.drain())
|
|
150
|
-
}
|
|
151
|
-
results.drain()
|
|
152
|
-
}
|
|
100
|
+
fill(value: T, start: Int = 0, end: Int = 9007199254740991): Unit
|
|
101
|
+
target js sync """
|
|
102
|
+
self_.array.fill(value_, start_, end_);
|
|
103
|
+
"""
|
|
153
104
|
|
|
154
|
-
|
|
105
|
+
copy(target: Int, start: Int, end: Int): Unit
|
|
155
106
|
target js sync """
|
|
156
|
-
|
|
157
|
-
for(let i = self_.length - 1; i >= 0; i--) {
|
|
158
|
-
result = ff_core_List.Link(self_[i], result);
|
|
159
|
-
}
|
|
160
|
-
return result;
|
|
107
|
+
self_.array.copyWithin(target_, start_, end_);
|
|
161
108
|
"""
|
|
162
109
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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
|
+
insertArray(start: Int, value: Array[T], deleteCount: Int = 0): Unit
|
|
121
|
+
target js sync """
|
|
122
|
+
self_.array.splice(start_, deleteCount_, ...value_.array);
|
|
123
|
+
"""
|
|
177
124
|
|
|
178
|
-
|
|
179
|
-
target js sync "
|
|
125
|
+
insertList(start: Int, value: List[T], deleteCount: Int = 0): Unit
|
|
126
|
+
target js sync """
|
|
127
|
+
self_.array.splice(start_, deleteCount_, ...value_);
|
|
128
|
+
"""
|
|
180
129
|
|
|
181
130
|
each(body: T => Unit): Unit
|
|
182
131
|
target js sync """
|
|
183
|
-
return self_.forEach(body_);
|
|
132
|
+
return self_.array.forEach(body_);
|
|
184
133
|
"""
|
|
185
134
|
target js async """
|
|
186
|
-
for(let i = 0; i < self_.length; i++) {
|
|
187
|
-
await body_(self_[i], $task)
|
|
135
|
+
for(let i = 0; i < self_.array.length; i++) {
|
|
136
|
+
await body_(self_.array[i], $task)
|
|
188
137
|
}
|
|
189
138
|
"""
|
|
190
139
|
|
|
191
140
|
eachWhile(body: T => Bool): Unit
|
|
192
|
-
target js sync "for(const value of self_) if(!body_(value)) break"
|
|
193
|
-
target js async "for(const value of self_) if(!await body_(value, $task)) break"
|
|
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"
|
|
194
143
|
|
|
195
144
|
all(body: T => Bool): Bool {
|
|
196
145
|
mutable result = True
|
|
197
146
|
self.eachWhile {x =>
|
|
198
|
-
result =
|
|
147
|
+
result = body(x)
|
|
199
148
|
result
|
|
200
149
|
}
|
|
201
150
|
result
|
|
@@ -204,7 +153,7 @@ extend self[T]: Array[T] {
|
|
|
204
153
|
any(body: T => Bool): Bool {
|
|
205
154
|
mutable result = False
|
|
206
155
|
self.eachWhile {x =>
|
|
207
|
-
result =
|
|
156
|
+
result = body(x)
|
|
208
157
|
(!result)
|
|
209
158
|
}
|
|
210
159
|
result
|
|
@@ -223,200 +172,92 @@ extend self[T]: Array[T] {
|
|
|
223
172
|
result
|
|
224
173
|
}
|
|
225
174
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
175
|
+
indexWhere(body: T => Bool): Option[Int] {
|
|
176
|
+
mutable i = -1
|
|
177
|
+
mutable result = False
|
|
178
|
+
self.eachWhile {x =>
|
|
179
|
+
i += 1
|
|
180
|
+
result = body(x)
|
|
181
|
+
(!result)
|
|
232
182
|
}
|
|
233
|
-
result
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
partition(body: T => Bool): Pair[Array[T], Array[T]] {
|
|
237
|
-
Pair(self.filter(body), self.filter {!body(_)})
|
|
183
|
+
if(result) {i}
|
|
238
184
|
}
|
|
239
185
|
|
|
240
|
-
|
|
241
|
-
target js sync ""
|
|
242
|
-
return self_.map(body_)
|
|
243
|
-
"""
|
|
244
|
-
target js async """
|
|
245
|
-
let result = [];
|
|
246
|
-
for(let i = self_.length - 1; i >= 0; i--) {
|
|
247
|
-
result.push(await body_(self_[i], $task));
|
|
248
|
-
}
|
|
249
|
-
return result;
|
|
250
|
-
"""
|
|
251
|
-
|
|
252
|
-
flatMap[S](body: T => Array[S]): Array[S] {
|
|
253
|
-
let results = Stack.make()
|
|
254
|
-
self.each {x =>
|
|
255
|
-
results.pushArray(body(x))
|
|
256
|
-
}
|
|
257
|
-
results.drain()
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
collect[R](body: T => Option[R]): Array[R] {
|
|
261
|
-
mutable result = Stack.make()
|
|
262
|
-
self.each {x =>
|
|
263
|
-
body(x).each {result.push(_)}
|
|
264
|
-
}
|
|
265
|
-
result.drain()
|
|
266
|
-
}
|
|
186
|
+
drain(): List[T]
|
|
187
|
+
target js sync "const result = self_.array; self_.array = []; return result"
|
|
267
188
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
True
|
|
274
|
-
| o =>
|
|
275
|
-
result = o
|
|
276
|
-
False
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
result
|
|
189
|
+
toList(start: Int = 0, end: Int = 9007199254740991): List[T]
|
|
190
|
+
target js sync """return self_.array.slice(start_, end_)"""
|
|
191
|
+
|
|
192
|
+
toStream(start: Int = 0, end: Int = 9007199254740991): Stream[T] {
|
|
193
|
+
self.toList(start, end).toStream()
|
|
280
194
|
}
|
|
281
195
|
|
|
282
|
-
|
|
196
|
+
reverse(): Unit
|
|
197
|
+
target js sync "self_.array.reverse()"
|
|
198
|
+
|
|
199
|
+
sortBy[S: Order](body: T => S): Unit {
|
|
283
200
|
self.sortWith {Ordering.compare(body(_), body(_))}
|
|
284
201
|
}
|
|
285
202
|
|
|
286
|
-
sortWith(ordering: (T, T) => Ordering):
|
|
287
|
-
|
|
288
|
-
stack.sortWith(ordering)
|
|
289
|
-
stack.drain()
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
reverse(): Array[T] {
|
|
293
|
-
1.to(self.size()).toArray().map {i =>
|
|
294
|
-
self.grab(self.size() - i)
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
separate(separator: Array[T]): Array[T] {
|
|
299
|
-
let stack = Stack.make()
|
|
300
|
-
self.pairs().each {| Pair(i, x) =>
|
|
301
|
-
if(i != 0) {
|
|
302
|
-
stack.pushArray(separator)
|
|
303
|
-
}
|
|
304
|
-
stack.push(x)
|
|
305
|
-
}
|
|
306
|
-
stack.drain()
|
|
203
|
+
sortWith(ordering: (T, T) => Ordering): Unit {
|
|
204
|
+
sortRange(self, ordering, 0, self.size())
|
|
307
205
|
}
|
|
206
|
+
target js sync "self_.array.sort((x, y) => ff_core_Ordering.Ordering_toInt(ordering_(x, y)))"
|
|
308
207
|
|
|
309
208
|
}
|
|
310
209
|
|
|
311
210
|
extend self[T: Order]: Array[T] {
|
|
312
211
|
|
|
313
|
-
sort():
|
|
212
|
+
sort(): Unit {
|
|
314
213
|
self.sortWith(Ordering.compare)
|
|
315
214
|
}
|
|
316
215
|
|
|
317
|
-
toSet(): Set[T] {
|
|
318
|
-
self.toList().toSet()
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
distinct(): Array[T] {
|
|
322
|
-
mutable seen = [].toSet()
|
|
323
|
-
self.filter {
|
|
324
|
-
| item {!seen.contains(item)} =>
|
|
325
|
-
seen = seen.add(item)
|
|
326
|
-
True
|
|
327
|
-
| _ =>
|
|
328
|
-
False
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
extend self[T]: Array[Array[T]] {
|
|
335
|
-
|
|
336
|
-
flatten(): Array[T] {
|
|
337
|
-
let result = Stack.make()
|
|
338
|
-
self.each {xs =>
|
|
339
|
-
result.pushArray(xs)
|
|
340
|
-
}
|
|
341
|
-
result.drain()
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
extend self[K: Order, V]: Array[Pair[K, V]] {
|
|
347
|
-
|
|
348
|
-
toMap(): Map[K, V] {
|
|
349
|
-
self.toList().toMap()
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
group(): Map[K, Array[V]] {
|
|
353
|
-
mutable map = Map.empty[K, Stack[V]]()
|
|
354
|
-
self.each {| Pair(k, v) => map = map.push(k, v)}
|
|
355
|
-
map.mapValues {_, v => v.drain()}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
extend self[K, V]: Array[Pair[K, V]] {
|
|
361
|
-
|
|
362
|
-
unzip(): Pair[Array[K], Array[V]] {
|
|
363
|
-
let first = Stack.make()
|
|
364
|
-
let second = Stack.make()
|
|
365
|
-
self.each {| Pair(x, y) =>
|
|
366
|
-
first.push(x)
|
|
367
|
-
second.push(y)
|
|
368
|
-
}
|
|
369
|
-
Pair(first.drain(), second.drain())
|
|
370
|
-
}
|
|
371
|
-
|
|
372
216
|
}
|
|
373
217
|
|
|
374
218
|
extend self: Array[String] {
|
|
375
219
|
|
|
376
220
|
join(separator: String = ""): String
|
|
377
|
-
target js sync "return self_.join(separator_)"
|
|
221
|
+
target js sync "return self_.array.join(separator_)"
|
|
378
222
|
|
|
379
223
|
}
|
|
380
224
|
|
|
381
225
|
instance Array[T: Show]: Show {
|
|
382
226
|
show(value: Array[T]): String {
|
|
383
|
-
let
|
|
384
|
-
|
|
227
|
+
let array = Array.make()
|
|
228
|
+
array.push("[")
|
|
385
229
|
value.each {x =>
|
|
386
|
-
if(
|
|
387
|
-
|
|
230
|
+
if(array.size() > 1) {array.push(", ")}
|
|
231
|
+
array.push(Show.show(x))
|
|
388
232
|
}
|
|
389
|
-
|
|
390
|
-
|
|
233
|
+
array.push("].toArray()")
|
|
234
|
+
array.join()
|
|
391
235
|
}
|
|
392
236
|
}
|
|
393
237
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
if(internalSame(x, y)) {True} else:
|
|
397
|
-
if(x.size() != y.size()) {False} else:
|
|
398
|
-
mutable i = -1
|
|
399
|
-
x.all {l =>
|
|
400
|
-
i += 1
|
|
401
|
-
l == y.grab(i)
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
}
|
|
238
|
+
sortRange[T](array: Array[T], compare: (T, T) => Ordering, start: Int, end: Int): Unit {
|
|
239
|
+
if(end - start < 2) {} else:
|
|
405
240
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
241
|
+
mutable middle = start + ((end - start) / 2)
|
|
242
|
+
sortRange(array, compare, start, middle)
|
|
243
|
+
sortRange(array, compare, middle, end)
|
|
244
|
+
|
|
245
|
+
mutable i = start
|
|
246
|
+
mutable j = middle
|
|
247
|
+
while {i < middle && j < end} {
|
|
248
|
+
if(compare(array.grab(i), array.grab(j)) != OrderingAfter) {
|
|
414
249
|
i += 1
|
|
250
|
+
} else {
|
|
251
|
+
let value = array.grab(j)
|
|
252
|
+
mutable k = j
|
|
253
|
+
while {k > i} {
|
|
254
|
+
array.set(k, array.grab(k - 1))
|
|
255
|
+
k -= 1
|
|
256
|
+
}
|
|
257
|
+
array.set(i, value)
|
|
258
|
+
i += 1
|
|
259
|
+
middle += 1
|
|
260
|
+
j += 1
|
|
415
261
|
}
|
|
416
|
-
if(ordering != OrderingSame) {ordering} else:
|
|
417
|
-
Ordering.compare(x.size(), y.size())
|
|
418
262
|
}
|
|
419
263
|
}
|
|
420
|
-
|
|
421
|
-
internalSame[T](left: Array[T], right: Array[T]): Bool
|
|
422
|
-
target js sync "return left_ === right_"
|
package/core/Buffer.ff
CHANGED
|
@@ -123,7 +123,7 @@ extend self: Buffer {
|
|
|
123
123
|
return new TextDecoder().decode(self_)
|
|
124
124
|
"""
|
|
125
125
|
|
|
126
|
-
toByteArray():
|
|
126
|
+
toByteArray(): List[Int]
|
|
127
127
|
target js sync "return [...new Uint8Array(self_.buffer, self_.byteOffset, self_.byteLength)]"
|
|
128
128
|
|
|
129
129
|
toHex(): String
|
|
@@ -143,10 +143,10 @@ extend self: Buffer {
|
|
|
143
143
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
-
fromByteArray(array:
|
|
146
|
+
fromByteArray(array: List[Int]): Buffer
|
|
147
147
|
target js sync "return new DataView(new Uint8Array(array_).buffer)"
|
|
148
148
|
|
|
149
|
-
fromBufferArray(array:
|
|
149
|
+
fromBufferArray(array: List[Buffer]): Buffer
|
|
150
150
|
target js sync """
|
|
151
151
|
let length = 0
|
|
152
152
|
for(let b of array_) length += b.byteLength
|
package/core/BuildSystem.ff
CHANGED
package/core/Equal.ff
CHANGED
|
@@ -1,52 +1,36 @@
|
|
|
1
|
-
trait T: Equal {
|
|
2
|
-
equals(x: T, y: T): Bool
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
notEquals[T: Equal](x: T, y: T): Bool {
|
|
6
|
-
!equals(x, y)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
instance Nothing: Equal {
|
|
10
|
-
equals(x: Nothing, y: Nothing): Bool {True}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
instance Bool: Equal {
|
|
14
|
-
equals(x: Bool, y: Bool): Bool
|
|
15
|
-
target js sync """return x_ === y_"""
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
instance Char: Equal {
|
|
19
|
-
equals(x: Char, y: Char): Bool
|
|
20
|
-
target js sync """return x_ === y_"""
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
instance Int: Equal {
|
|
24
|
-
equals(x: Int, y: Int): Bool
|
|
25
|
-
target js sync """return x_ === y_"""
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
instance Float: Equal {
|
|
29
|
-
equals(x: Float, y: Float): Bool
|
|
30
|
-
target js sync """return x_ === y_"""
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
instance String: Equal {
|
|
34
|
-
equals(x: String, y: String): Bool
|
|
35
|
-
target js sync """return x_ === y_"""
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
instance List[T]: Equal {
|
|
39
|
-
equals(x: List[T], y: List[T]): Bool
|
|
40
|
-
target js sync """
|
|
41
|
-
let a = x_
|
|
42
|
-
let b = y_
|
|
43
|
-
if(a === b) return true
|
|
44
|
-
while(a.Link && b.Link) {
|
|
45
|
-
if(a === b) return true
|
|
46
|
-
if(!ff_core_Equal_Equal$T.equals_(a.head_, b.head_)) return false
|
|
47
|
-
a = a.tail_
|
|
48
|
-
b = b.tail_
|
|
49
|
-
}
|
|
50
|
-
return a.Empty && b.Empty
|
|
51
|
-
"""
|
|
52
|
-
}
|
|
1
|
+
trait T: Equal {
|
|
2
|
+
equals(x: T, y: T): Bool
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
notEquals[T: Equal](x: T, y: T): Bool {
|
|
6
|
+
!equals(x, y)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
instance Nothing: Equal {
|
|
10
|
+
equals(x: Nothing, y: Nothing): Bool {True}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
instance Bool: Equal {
|
|
14
|
+
equals(x: Bool, y: Bool): Bool
|
|
15
|
+
target js sync """return x_ === y_"""
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
instance Char: Equal {
|
|
19
|
+
equals(x: Char, y: Char): Bool
|
|
20
|
+
target js sync """return x_ === y_"""
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
instance Int: Equal {
|
|
24
|
+
equals(x: Int, y: Int): Bool
|
|
25
|
+
target js sync """return x_ === y_"""
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
instance Float: Equal {
|
|
29
|
+
equals(x: Float, y: Float): Bool
|
|
30
|
+
target js sync """return x_ === y_"""
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
instance String: Equal {
|
|
34
|
+
equals(x: String, y: String): Bool
|
|
35
|
+
target js sync """return x_ === y_"""
|
|
36
|
+
}
|
package/core/HttpClient.ff
CHANGED
|
@@ -27,7 +27,7 @@ extend self: HttpClient {
|
|
|
27
27
|
try {
|
|
28
28
|
const options = {headers: {}, signal: $task.controller.signal}
|
|
29
29
|
options.method = method_
|
|
30
|
-
|
|
30
|
+
headers_.forEach(pair => {options.headers[pair.first_] = pair.second_})
|
|
31
31
|
if(body_.value_) options.body = body_.value_
|
|
32
32
|
if(redirect_.RedirectError) options.redirect = "error"
|
|
33
33
|
else if(redirect_.RedirectManual) options.redirect = "manual"
|