firefly-compiler 0.4.18 → 0.4.19
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 +4 -4
- package/compiler/Main.ff +6 -6
- package/compiler/Parser.ff +39 -39
- 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 +19 -28
- 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/Stack.ff +32 -45
- 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 +4 -4
- package/lsp/Handler.ff +44 -33
- package/lsp/HoverHandler.ff +2 -2
- package/lsp/LanguageServer.ff +2 -2
- package/lsp/SignatureHelpHandler.ff +1 -1
- package/lsp/SymbolHandler.ff +1 -1
- 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 +10 -12
- package/output/js/ff/compiler/Main.mjs +109 -111
- package/output/js/ff/compiler/Parser.mjs +405 -407
- 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 +23 -56
- 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/package.json +1 -1
- package/webserver/WebServer.ff +8 -8
- package/output/js/ff/core/Stack.mjs +0 -603
package/core/IntMap.ff
CHANGED
|
@@ -40,18 +40,14 @@ extend self[V]: IntMap[V] {
|
|
|
40
40
|
target js sync "for(const [k, v] of self_) if(!body_(k, v)) break"
|
|
41
41
|
target js async "for(const [k, v] of self_) if(!await body_(k, v)) break"
|
|
42
42
|
|
|
43
|
-
toStack(): Stack[Pair[Int, V]] {
|
|
44
|
-
let stack = Stack.make()
|
|
45
|
-
self.each {k, v => stack.push(Pair(k, v))}
|
|
46
|
-
stack
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
toArray(): Array[Pair[Int, V]] {
|
|
50
|
-
|
|
44
|
+
let array = Array.make()
|
|
45
|
+
self.each {k, v => array.push(Pair(k, v))}
|
|
46
|
+
array
|
|
51
47
|
}
|
|
52
48
|
|
|
53
49
|
toList(): List[Pair[Int, V]] {
|
|
54
|
-
self.toArray().
|
|
50
|
+
self.toArray().drain()
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
toStream(): Stream[Pair[Int, V]] {
|
|
@@ -59,19 +55,19 @@ extend self[V]: IntMap[V] {
|
|
|
59
55
|
}
|
|
60
56
|
|
|
61
57
|
toMap(): Map[Int, V] {
|
|
62
|
-
self.
|
|
58
|
+
self.toList().toMap()
|
|
63
59
|
}
|
|
64
60
|
|
|
65
61
|
keys(): List[Int] {
|
|
66
|
-
let
|
|
67
|
-
self.each {k, v =>
|
|
68
|
-
|
|
62
|
+
let array = Array.make()
|
|
63
|
+
self.each {k, v => array.push(k)}
|
|
64
|
+
array.toList()
|
|
69
65
|
}
|
|
70
66
|
|
|
71
67
|
values(): List[V] {
|
|
72
|
-
let
|
|
73
|
-
self.each {k, v =>
|
|
74
|
-
|
|
68
|
+
let array = Array.make()
|
|
69
|
+
self.each {k, v => array.push(v)}
|
|
70
|
+
array.toList()
|
|
75
71
|
}
|
|
76
72
|
|
|
77
73
|
copy(): IntMap[V]
|
|
@@ -84,12 +80,12 @@ extend self[V]: IntMap[V] {
|
|
|
84
80
|
|
|
85
81
|
}
|
|
86
82
|
|
|
87
|
-
extend self[V]: IntMap[
|
|
83
|
+
extend self[V]: IntMap[Array[V]] {
|
|
88
84
|
|
|
89
85
|
push(key: Int, value: V) {
|
|
90
86
|
self.get(key).{
|
|
91
|
-
| None => self.set(key, [value].
|
|
92
|
-
| Some(
|
|
87
|
+
| None => self.set(key, [value].toArray())
|
|
88
|
+
| Some(array) => array.push(value)
|
|
93
89
|
}
|
|
94
90
|
}
|
|
95
91
|
|
package/core/JsSystem.ff
CHANGED
|
@@ -21,7 +21,7 @@ extend self: JsSystem {
|
|
|
21
21
|
target js sync "return {}"
|
|
22
22
|
|
|
23
23
|
array(values: List[JsValue]): JsValue
|
|
24
|
-
target js sync "return
|
|
24
|
+
target js sync "return values_.slice()"
|
|
25
25
|
|
|
26
26
|
json(value: Json): JsValue
|
|
27
27
|
target js sync "return value_"
|
package/core/JsValue.ff
CHANGED
|
@@ -17,7 +17,7 @@ extend self: JsValue {
|
|
|
17
17
|
grabBool(): Bool
|
|
18
18
|
target js sync "return self_"
|
|
19
19
|
|
|
20
|
-
grabArray():
|
|
20
|
+
grabArray(): List[JsValue]
|
|
21
21
|
target js sync "return self_"
|
|
22
22
|
|
|
23
23
|
grabBuffer(): Buffer
|
|
@@ -112,7 +112,7 @@ extend self: JsValue {
|
|
|
112
112
|
|
|
113
113
|
|
|
114
114
|
call(name: String, arguments: List[JsValue]): JsValue
|
|
115
|
-
target js sync "return self_[name_].apply(this_,
|
|
115
|
+
target js sync "return self_[name_].apply(this_, arguments_)"
|
|
116
116
|
|
|
117
117
|
call0(name: String): JsValue
|
|
118
118
|
target js sync "return self_[name_].call(self_)"
|
|
@@ -146,7 +146,7 @@ extend self: JsValue {
|
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
callValue(this: JsValue, arguments: List[JsValue]): JsValue
|
|
149
|
-
target js sync "return self_.apply(this_,
|
|
149
|
+
target js sync "return self_.apply(this_, arguments_)"
|
|
150
150
|
|
|
151
151
|
callValue0(): JsValue
|
|
152
152
|
target js sync "return self_.call(self_)"
|
|
@@ -180,7 +180,7 @@ extend self: JsValue {
|
|
|
180
180
|
|
|
181
181
|
|
|
182
182
|
new(this: JsValue, arguments: List[JsValue]): JsValue
|
|
183
|
-
target js sync "return new (Function.prototype.bind.apply(self_,
|
|
183
|
+
target js sync "return new (Function.prototype.bind.apply(self_, arguments_))"
|
|
184
184
|
|
|
185
185
|
new0(): JsValue
|
|
186
186
|
target js sync "return new self_()"
|
|
@@ -216,12 +216,7 @@ extend self: JsValue {
|
|
|
216
216
|
grabPairs(): List[Pair[String, JsValue]]
|
|
217
217
|
target js sync """
|
|
218
218
|
if(!(self_ instanceof Object)) throw new Error('Expected object, got '+ typeof self_);;
|
|
219
|
-
|
|
220
|
-
Object.getOwnPropertyNames(self_).forEach((name, i) => {
|
|
221
|
-
let pair = ff_core_Pair.Pair(name, self_[name]);
|
|
222
|
-
result = ff_core_List.Link(pair, result);
|
|
223
|
-
})
|
|
224
|
-
return result;
|
|
219
|
+
return Object.getOwnPropertyNames(self_).map((name, i) => ff_core_Pair.Pair(name, self_[name]));
|
|
225
220
|
"""
|
|
226
221
|
|
|
227
222
|
grabMap(): Map[String, JsValue] {
|
|
@@ -240,7 +235,6 @@ extend self: JsValue {
|
|
|
240
235
|
return self_
|
|
241
236
|
"""
|
|
242
237
|
|
|
243
|
-
//toArray(): Array[JsValue] // TODO
|
|
244
238
|
//toList(): List[JsValue] // TODO
|
|
245
239
|
// TODO: JS operators
|
|
246
240
|
|
|
@@ -253,7 +247,7 @@ instance Char: IsJsValue {}
|
|
|
253
247
|
instance Int: IsJsValue {}
|
|
254
248
|
instance Float: IsJsValue {}
|
|
255
249
|
instance Bool: IsJsValue {}
|
|
256
|
-
instance
|
|
250
|
+
instance List[T: IsJsValue]: IsJsValue {}
|
|
257
251
|
instance IntMap[T: IsJsValue]: IsJsValue {}
|
|
258
252
|
instance StringMap[T: IsJsValue]: IsJsValue {}
|
|
259
253
|
instance Error: IsJsValue {}
|
package/core/Json.ff
CHANGED
|
@@ -34,15 +34,11 @@ null(): Json
|
|
|
34
34
|
return null;
|
|
35
35
|
"""
|
|
36
36
|
|
|
37
|
-
array(json:
|
|
37
|
+
array(json: List[Json]): Json
|
|
38
38
|
target js sync """
|
|
39
39
|
return json_;
|
|
40
40
|
"""
|
|
41
41
|
|
|
42
|
-
list(json: List[Json]): Json {
|
|
43
|
-
array(json.toArray())
|
|
44
|
-
}
|
|
45
|
-
|
|
46
42
|
object(): Json
|
|
47
43
|
target js sync """
|
|
48
44
|
return {};
|
|
@@ -107,7 +103,7 @@ extend self: Json {
|
|
|
107
103
|
throw new Error('Not a bool: ' + JSON.stringify(self_));
|
|
108
104
|
"""
|
|
109
105
|
|
|
110
|
-
grabArray():
|
|
106
|
+
grabArray(): List[Json]
|
|
111
107
|
target js sync """
|
|
112
108
|
if(!Array.isArray(self_)) throw new Error('Not an array: ' + JSON.stringify(self_));
|
|
113
109
|
return self_;
|
|
@@ -137,7 +133,7 @@ extend self: Json {
|
|
|
137
133
|
if(self.isBool()) {self.grabBool()}
|
|
138
134
|
}
|
|
139
135
|
|
|
140
|
-
getArray(): Option[
|
|
136
|
+
getArray(): Option[List[Json]] {
|
|
141
137
|
if(self.isArray()) {self.grabArray()}
|
|
142
138
|
}
|
|
143
139
|
|
|
@@ -207,7 +203,7 @@ extend self: Json {
|
|
|
207
203
|
return typeof self_ === 'array' ? ff_core_Option.Some(self_[key_] ?? null) : ff_core_Option.None();
|
|
208
204
|
"""
|
|
209
205
|
|
|
210
|
-
getFields(): Option[
|
|
206
|
+
getFields(): Option[List[String]]
|
|
211
207
|
target js sync """
|
|
212
208
|
return typeof self_ === 'object' && self_ !== null && !Array.isArray(self_)
|
|
213
209
|
? ff_core_Option.Some(Object.keys(self_)) : ff_core_Option.None();
|
|
@@ -225,22 +221,22 @@ extend self: Json {
|
|
|
225
221
|
}
|
|
226
222
|
}
|
|
227
223
|
|
|
228
|
-
grabFields():
|
|
224
|
+
grabFields(): List[String] {
|
|
229
225
|
self.getFields().else {
|
|
230
226
|
throw(GrabException())
|
|
231
227
|
}
|
|
232
228
|
}
|
|
233
229
|
|
|
234
|
-
map[T](body: (String, Json) => T):
|
|
235
|
-
let
|
|
236
|
-
self.each {field, value =>
|
|
237
|
-
|
|
230
|
+
map[T](body: (String, Json) => T): List[T] {
|
|
231
|
+
let array = Array.make()
|
|
232
|
+
self.each {field, value => array.push(body(field, value))}
|
|
233
|
+
array.drain()
|
|
238
234
|
}
|
|
239
235
|
|
|
240
|
-
flatMap[T](body: (String, Json) =>
|
|
241
|
-
let
|
|
242
|
-
self.each {field, value =>
|
|
243
|
-
|
|
236
|
+
flatMap[T](body: (String, Json) => List[T]): List[T] {
|
|
237
|
+
let array = Array.make()
|
|
238
|
+
self.each {field, value => array.pushList(body(field, value))}
|
|
239
|
+
array.drain()
|
|
244
240
|
}
|
|
245
241
|
|
|
246
242
|
each(body: (String, Json) => Unit) {
|
|
@@ -301,29 +297,24 @@ instance Bool: JsonLike {
|
|
|
301
297
|
fromJson(json: Json): Option[Bool] {_.getBool()}
|
|
302
298
|
}
|
|
303
299
|
|
|
304
|
-
instance
|
|
305
|
-
toJson(value:
|
|
306
|
-
fromJson(json: Json): Option[
|
|
300
|
+
instance List[T: JsonLike]: JsonLike {
|
|
301
|
+
toJson(value: List[T]): Json {array(value.map(toJson))}
|
|
302
|
+
fromJson(json: Json): Option[List[T]] {
|
|
307
303
|
json.getArray().flatMap {array =>
|
|
308
304
|
mutable convertible = True
|
|
309
|
-
let
|
|
305
|
+
let result = Array.make()
|
|
310
306
|
array.eachWhile {item =>
|
|
311
307
|
fromJson(item).{
|
|
312
308
|
| None => convertible = False
|
|
313
|
-
| Some(value) =>
|
|
309
|
+
| Some(value) => result.push(value)
|
|
314
310
|
}
|
|
315
311
|
convertible
|
|
316
312
|
}
|
|
317
|
-
if(convertible) {
|
|
313
|
+
if(convertible) {result.drain()}
|
|
318
314
|
}
|
|
319
315
|
}
|
|
320
316
|
}
|
|
321
317
|
|
|
322
|
-
instance List[T: JsonLike]: JsonLike {
|
|
323
|
-
toJson(value: List[T]): Json {list(value.map(toJson))}
|
|
324
|
-
fromJson(json: Json): Option[List[T]] {fromJson[Array[T]](json).map {_.toList()}}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
318
|
instance StringMap[T: JsonLike]: JsonLike {
|
|
328
319
|
toJson(value: StringMap[T]): Json {
|
|
329
320
|
Json.fields {setField =>
|