firefly-compiler 0.5.9 → 0.5.11
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/JsEmitter.ff +95 -0
- package/output/js/ff/compiler/Builder.mjs +22 -16
- package/output/js/ff/compiler/Compiler.mjs +2 -2
- package/output/js/ff/compiler/Inference.mjs +32 -22
- package/output/js/ff/compiler/JsEmitter.mjs +286 -0
- package/output/js/ff/compiler/LspHook.mjs +2 -2
- package/output/js/ff/compiler/Parser.mjs +84 -82
- package/output/js/ff/compiler/Resolver.mjs +38 -28
- package/output/js/ff/compiler/Tokenizer.mjs +10 -10
- package/output/js/ff/compiler/Unification.mjs +10 -8
- package/output/js/ff/core/Array.mjs +8 -8
- package/output/js/ff/core/Int.mjs +4 -4
- package/output/js/ff/core/IntMap.mjs +8 -8
- package/output/js/ff/core/Json.mjs +12 -10
- package/output/js/ff/core/List.mjs +130 -104
- package/output/js/ff/core/Map.mjs +8 -6
- package/output/js/ff/core/Random.mjs +18 -12
- package/output/js/ff/core/RbMap.mjs +2 -2
- package/output/js/ff/core/Serializable.mjs +6 -4
- package/output/js/ff/core/Set.mjs +6 -4
- package/output/js/ff/core/Stream.mjs +8 -8
- package/output/js/ff/core/StringMap.mjs +8 -8
- package/output/js/ff/core/Task.mjs +6 -4
- package/package.json +1 -1
- package/vscode/package.json +1 -1
package/compiler/JsEmitter.ff
CHANGED
|
@@ -680,6 +680,62 @@ extend self: JsEmitter {
|
|
|
680
680
|
invokeImmediately(doWhileBody) | body
|
|
681
681
|
} =>
|
|
682
682
|
Some("while(" + self.emitComma(body, async) + ") {}")
|
|
683
|
+
| "ff:core/List.List_each" {arguments | [
|
|
684
|
+
ECall(_, StaticCall(r, _, _), _, _, [start, end], _)
|
|
685
|
+
ELambda(_, Lambda(_, _, [MatchCase(_, [PVariable(_, name)], [], body)]))
|
|
686
|
+
]} {r == "ff:core/Int.Int_until" || r == "ff:core/Int.Int_to"} =>
|
|
687
|
+
let startCode = self.emitTerm(start.value, async)
|
|
688
|
+
let endCode = self.emitTerm(end.value, async)
|
|
689
|
+
let op = if(r == "ff:core/Int.Int_until") {"<"} else {"<="}
|
|
690
|
+
Some(
|
|
691
|
+
"for(let " +
|
|
692
|
+
"for_i = " + startCode + ", for_e = " + endCode + "; for_i " + op + " for_e; for_i++) {\n" +
|
|
693
|
+
name.map {"const " + escapeKeyword(_) + " = for_i;\n"}.else {""} +
|
|
694
|
+
self.emitStatements(body, last, async) +
|
|
695
|
+
"\n}"
|
|
696
|
+
)
|
|
697
|
+
| "ff:core/List.List_each" {arguments | [list, ELambda(_, Lambda(_, _, [
|
|
698
|
+
MatchCase(_, [PVariable(_, name)], [], body)
|
|
699
|
+
]))]} =>
|
|
700
|
+
let fusion = self.emitLightFusion(list, async)
|
|
701
|
+
let start = fusion.second.first
|
|
702
|
+
let end = fusion.second.second
|
|
703
|
+
let listCode = fusion.first
|
|
704
|
+
Some(
|
|
705
|
+
"for(let for_i = " + start + ", for_a = " + listCode + ", for_l = " + end +
|
|
706
|
+
"; for_i < for_l; for_i++) {\n" +
|
|
707
|
+
name.map {"const " + escapeKeyword(_) + " = for_a[for_i];\n"}.else {""} +
|
|
708
|
+
self.emitStatements(body, last, async) +
|
|
709
|
+
"\n}"
|
|
710
|
+
)
|
|
711
|
+
| "ff:core/List.List_eachWhile" {arguments | [list, ELambda(_, Lambda(_, _, [
|
|
712
|
+
MatchCase(_, [PVariable(_, name)], [], ESequential(_, body, condition))
|
|
713
|
+
]))]} =>
|
|
714
|
+
let fusion = self.emitLightFusion(list, async)
|
|
715
|
+
let start = fusion.second.first
|
|
716
|
+
let end = fusion.second.second
|
|
717
|
+
let listCode = fusion.first
|
|
718
|
+
Some(
|
|
719
|
+
"for(let for_i = " + start + ", for_a = " + listCode + ", for_l = " + end +
|
|
720
|
+
"; for_i < for_l; for_i++) {\n" +
|
|
721
|
+
name.map {"const " + escapeKeyword(_) + " = for_a[for_i];\n"}.else {""} +
|
|
722
|
+
self.emitStatements(body, last, async) + ";\n" +
|
|
723
|
+
"if(!" + self.emitComma(condition, async) + ") break" +
|
|
724
|
+
"\n}"
|
|
725
|
+
)
|
|
726
|
+
| "ff:core/List.List_eachWhile" {arguments | [list, ELambda(_, Lambda(_, _, [
|
|
727
|
+
MatchCase(_, [PVariable(_, name)], [], condition)
|
|
728
|
+
]))]} =>
|
|
729
|
+
let listCode = self.emitTerm(list, async)
|
|
730
|
+
Some(
|
|
731
|
+
"for(let " +
|
|
732
|
+
"for_i = 0, for_a = " + listCode + ", for_l = for_a.length" + "; for_i < for_l; for_i++) {\n" +
|
|
733
|
+
name.map {"const " + escapeKeyword(_) + " = for_a[for_i];\n"}.else {""} +
|
|
734
|
+
"if(!" + self.emitComma(condition, async) + ") break" +
|
|
735
|
+
"\n}"
|
|
736
|
+
)
|
|
737
|
+
| "ff:core/Array.Array_push" {arguments | [array, value]} =>
|
|
738
|
+
Some(self.emitTerm(array, async) + ".array.push(" + self.emitTerm(value, async) + ")")
|
|
683
739
|
| "ff:core/Core.if" {arguments | [condition, body]} =>
|
|
684
740
|
Some(
|
|
685
741
|
"if(" + self.emitComma(condition, async) + ") {\n" +
|
|
@@ -718,6 +774,45 @@ extend self: JsEmitter {
|
|
|
718
774
|
None
|
|
719
775
|
}
|
|
720
776
|
}
|
|
777
|
+
|
|
778
|
+
emitLightFusion(list: Term, async: Bool): Pair[String, Pair[String, String]] {
|
|
779
|
+
mutable start = "0"
|
|
780
|
+
mutable end = "for_a.length"
|
|
781
|
+
let listCode = list.{
|
|
782
|
+
| ECall(_, StaticCall("ff:core/List.List_dropFirst", _, _), _, _, [a1, a2], _) =>
|
|
783
|
+
start = self.emitTerm(a2.value, async)
|
|
784
|
+
if(!start.all {_.isAsciiDigit()}) {
|
|
785
|
+
start = "Math.max(" + start + ", 0)"
|
|
786
|
+
}
|
|
787
|
+
self.emitTerm(a1.value, async)
|
|
788
|
+
| ECall(_, StaticCall("ff:core/List.List_dropLast", _, _), _, _, [a1, a2], _) =>
|
|
789
|
+
let count = self.emitTerm(a2.value, async)
|
|
790
|
+
if(!count.all {_.isAsciiDigit()}) {
|
|
791
|
+
end = end + " - Math.max(" + count + ", 0)"
|
|
792
|
+
} else {
|
|
793
|
+
end = end + " - " + count
|
|
794
|
+
}
|
|
795
|
+
self.emitTerm(a1.value, async)
|
|
796
|
+
| ECall(_, StaticCall("ff:core/List.List_takeFirst", _, _), _, _, [a1, a2], _) =>
|
|
797
|
+
end = self.emitTerm(a2.value, async)
|
|
798
|
+
if(!end.all {_.isAsciiDigit()}) {
|
|
799
|
+
end = "Math.max(" + end + ", 0)"
|
|
800
|
+
}
|
|
801
|
+
end = "Math.min(" + end + ", for_a.length)"
|
|
802
|
+
self.emitTerm(a1.value, async)
|
|
803
|
+
| ECall(_, StaticCall("ff:core/List.List_takeLast", _, _), _, _, [a1, a2], _) =>
|
|
804
|
+
let count = self.emitTerm(a2.value, async)
|
|
805
|
+
if(!count.all {_.isAsciiDigit()}) {
|
|
806
|
+
start = "Math.max(for_a.length - Math.max(" + count + ", 0), 0)"
|
|
807
|
+
} else {
|
|
808
|
+
start = "Math.max(for_a.length - " + count + ", 0)"
|
|
809
|
+
}
|
|
810
|
+
self.emitTerm(a1.value, async)
|
|
811
|
+
| _ =>
|
|
812
|
+
self.emitTerm(list, async)
|
|
813
|
+
}
|
|
814
|
+
Pair(listCode, Pair(start, end))
|
|
815
|
+
}
|
|
721
816
|
|
|
722
817
|
emitTryCatchFinally(term: Term, last: Bool, async: Bool): Option[String] {
|
|
723
818
|
function emitCatch(catchEffect: Type, cases: List[MatchCase]): String {
|
|
@@ -152,11 +152,12 @@ ff_core_Path.Path_renameTo(jsPathFile_, jsOutputPath_)
|
|
|
152
152
|
}
|
|
153
153
|
|
|
154
154
|
export function processIncludes_(jsPathFile_, packagePath_, info_) {
|
|
155
|
-
|
|
155
|
+
for(let for_i = 0, for_a = info_.includes_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
156
|
+
const include_ = for_a[for_i];
|
|
156
157
|
const fromPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(ff_core_Path.Path_slash(packagePath_, ".firefly"), "include"), include_.path_);
|
|
157
158
|
const toPath_ = ff_core_Path.Path_slash(ff_core_Path.Path_slash(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/")), include_.path_);
|
|
158
159
|
ff_core_Path.Path_copyTo(fromPath_, toPath_, 0, 100)
|
|
159
|
-
}
|
|
160
|
+
}
|
|
160
161
|
}
|
|
161
162
|
|
|
162
163
|
export function buildViaBuildSystem_(system_, fireflyPath_, mainFile_, target_) {
|
|
@@ -185,9 +186,10 @@ return [ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab(ff_core_Path
|
|
|
185
186
|
}
|
|
186
187
|
}))(ff_core_Path.Path_isDirectory(path_));
|
|
187
188
|
const errors_ = ff_core_Array.new_();
|
|
188
|
-
|
|
189
|
+
for(let for_i = 0, for_a = ff_core_List.List_filter(packages_, ((_w1) => {
|
|
189
190
|
return (!ff_core_List.List_isEmpty(_w1.files_))
|
|
190
|
-
})),
|
|
191
|
+
})), for_l = for_a.length; for_i < for_l; for_i++) {
|
|
192
|
+
const package_ = for_a[for_i];
|
|
191
193
|
const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
|
|
192
194
|
const resolvedDependencies_ = ff_compiler_Dependencies.process_(ff_core_NodeSystem.NodeSystem_httpClient(system_), dependencyLock_, firstFile_);
|
|
193
195
|
const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
@@ -203,7 +205,8 @@ const files_ = (checkDependencies_
|
|
|
203
205
|
: ff_core_List.List_filter(package_.files_, ((_w1) => {
|
|
204
206
|
return (!ff_core_Path.Path_contains(_w1, [".firefly", "dependencies"]))
|
|
205
207
|
})));
|
|
206
|
-
|
|
208
|
+
for(let for_i = 0, for_a = files_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
209
|
+
const file_ = for_a[for_i];
|
|
207
210
|
const localFile_ = ff_core_Path.Path_base(file_);
|
|
208
211
|
ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch(ff_core_Core.try_((() => {
|
|
209
212
|
if(infer_) {
|
|
@@ -215,7 +218,7 @@ ff_compiler_Compiler.Compiler_resolve(compiler_, resolvedDependencies_.mainPacka
|
|
|
215
218
|
{
|
|
216
219
|
const c_ = _1;
|
|
217
220
|
const error_ = _2;
|
|
218
|
-
|
|
221
|
+
errors_.array.push(c_)
|
|
219
222
|
return
|
|
220
223
|
}
|
|
221
224
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
@@ -226,9 +229,9 @@ ff_core_Array.Array_pushList(errors_, compileErrors_)
|
|
|
226
229
|
return
|
|
227
230
|
}
|
|
228
231
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
|
|
229
|
-
}
|
|
232
|
+
};
|
|
230
233
|
ff_compiler_ModuleCache.ModuleCache_mergeVersions(cache_, compiler_.cache_)
|
|
231
|
-
}
|
|
234
|
+
};
|
|
232
235
|
return ff_core_Array.Array_drain(errors_)
|
|
233
236
|
}
|
|
234
237
|
|
|
@@ -346,11 +349,12 @@ if((await ff_core_Path.Path_exists$(jsOutputPath_, false, false, false, $task)))
|
|
|
346
349
|
}
|
|
347
350
|
|
|
348
351
|
export async function processIncludes_$(jsPathFile_, packagePath_, info_, $task) {
|
|
349
|
-
(
|
|
352
|
+
for(let for_i = 0, for_a = info_.includes_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
353
|
+
const include_ = for_a[for_i];
|
|
350
354
|
const fromPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(packagePath_, ".firefly", $task)), "include", $task)), include_.path_, $task));
|
|
351
355
|
const toPath_ = (await ff_core_Path.Path_slash$((await ff_core_Path.Path_slash$(jsPathFile_, ff_compiler_Syntax.PackagePair_groupName(info_.package_.packagePair_, "/"), $task)), include_.path_, $task));
|
|
352
356
|
(await ff_core_Path.Path_copyTo$(fromPath_, toPath_, 0, 100, $task))
|
|
353
|
-
}
|
|
357
|
+
}
|
|
354
358
|
}
|
|
355
359
|
|
|
356
360
|
export async function buildViaBuildSystem_$(system_, fireflyPath_, mainFile_, target_, $task) {
|
|
@@ -379,9 +383,10 @@ return [ff_compiler_Builder.PackageFiles(ff_core_Option.Option_grab((await ff_co
|
|
|
379
383
|
}
|
|
380
384
|
}))((await ff_core_Path.Path_isDirectory$(path_, $task)), $task));
|
|
381
385
|
const errors_ = ff_core_Array.new_();
|
|
382
|
-
(
|
|
386
|
+
for(let for_i = 0, for_a = ff_core_List.List_filter(packages_, ((_w1) => {
|
|
383
387
|
return (!ff_core_List.List_isEmpty(_w1.files_))
|
|
384
|
-
})),
|
|
388
|
+
})), for_l = for_a.length; for_i < for_l; for_i++) {
|
|
389
|
+
const package_ = for_a[for_i];
|
|
385
390
|
const firstFile_ = ff_core_List.List_grabFirst(package_.files_);
|
|
386
391
|
const resolvedDependencies_ = (await ff_compiler_Dependencies.process_$((await ff_core_NodeSystem.NodeSystem_httpClient$(system_, $task)), dependencyLock_, firstFile_, $task));
|
|
387
392
|
const fixedPackagePaths_ = (ff_core_Map.Map_contains(resolvedDependencies_.packagePaths_, ff_compiler_Syntax.PackagePair("ff", "core"), ff_compiler_Syntax.ff_core_Ordering_Order$ff_compiler_Syntax_PackagePair)
|
|
@@ -397,7 +402,8 @@ const files_ = (checkDependencies_
|
|
|
397
402
|
: (await ff_core_List.List_filter$(package_.files_, (async (_w1, $task) => {
|
|
398
403
|
return (!(await ff_core_Path.Path_contains$(_w1, [".firefly", "dependencies"], $task)))
|
|
399
404
|
}), $task)));
|
|
400
|
-
(
|
|
405
|
+
for(let for_i = 0, for_a = files_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
406
|
+
const file_ = for_a[for_i];
|
|
401
407
|
const localFile_ = (await ff_core_Path.Path_base$(file_, $task));
|
|
402
408
|
ff_core_Try.Try_catch(ff_core_Try.Try_tryCatch((await ff_core_Core.try_$((async ($task) => {
|
|
403
409
|
if(infer_) {
|
|
@@ -409,7 +415,7 @@ if(infer_) {
|
|
|
409
415
|
{
|
|
410
416
|
const c_ = _1;
|
|
411
417
|
const error_ = _2;
|
|
412
|
-
|
|
418
|
+
errors_.array.push(c_)
|
|
413
419
|
return
|
|
414
420
|
}
|
|
415
421
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError), ((_1, _2) => {
|
|
@@ -420,9 +426,9 @@ ff_core_Array.Array_pushList(errors_, compileErrors_)
|
|
|
420
426
|
return
|
|
421
427
|
}
|
|
422
428
|
}), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileErrors)
|
|
423
|
-
}
|
|
429
|
+
};
|
|
424
430
|
ff_compiler_ModuleCache.ModuleCache_mergeVersions(cache_, compiler_.cache_)
|
|
425
|
-
}
|
|
431
|
+
};
|
|
426
432
|
return ff_core_Array.Array_drain(errors_)
|
|
427
433
|
}
|
|
428
434
|
|
|
@@ -148,7 +148,7 @@ const stop_ = (ff_core_Task.Task_elapsed(self_.task_) - self_.phaseDurationDelta
|
|
|
148
148
|
const duration_ = (stop_ - start_);
|
|
149
149
|
self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
|
|
150
150
|
const text_ = ((((phase_ + " ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")) + "/") + moduleName_);
|
|
151
|
-
|
|
151
|
+
self_.phaseDurations_.array.push(ff_core_Pair.Pair(text_, duration_));
|
|
152
152
|
return result_
|
|
153
153
|
}
|
|
154
154
|
|
|
@@ -279,7 +279,7 @@ const stop_ = ((await ff_core_Task.Task_elapsed$(self_.task_, $task)) - self_.ph
|
|
|
279
279
|
const duration_ = (stop_ - start_);
|
|
280
280
|
self_.phaseDurationDelta_ = (self_.phaseDurationDelta_ + duration_);
|
|
281
281
|
const text_ = ((((phase_ + " ") + ff_compiler_Syntax.PackagePair_groupName(packagePair_, ":")) + "/") + moduleName_);
|
|
282
|
-
|
|
282
|
+
self_.phaseDurations_.array.push(ff_core_Pair.Pair(text_, duration_));
|
|
283
283
|
return result_
|
|
284
284
|
}
|
|
285
285
|
|
|
@@ -217,17 +217,19 @@ if((ff_core_List.List_size(traitDefinition_.generics_) !== ff_core_List.List_siz
|
|
|
217
217
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (ff_core_List.List_size(traitDefinition_.generics_) - 1)) + ", got ") + (ff_core_List.List_size(definition_.typeArguments_) - 1))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
218
218
|
};
|
|
219
219
|
const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(traitDefinition_.generics_, definition_.typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
220
|
-
|
|
220
|
+
for(let for_i = 0, for_a = traitDefinition_.methods_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
221
|
+
const traitMethod_ = for_a[for_i];
|
|
221
222
|
const found_ = ff_core_List.List_filter(definition_.methods_, ((_w1) => {
|
|
222
223
|
return (_w1.signature_.name_ === traitMethod_.name_)
|
|
223
224
|
}));
|
|
224
225
|
if(ff_core_List.List_isEmpty(found_)) {
|
|
225
226
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("Missing instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
226
227
|
};
|
|
227
|
-
|
|
228
|
+
for(let for_i = 1, for_a = found_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
229
|
+
const duplicateMethod_ = for_a[for_i];
|
|
228
230
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(duplicateMethod_.at_, ("Duplicated instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
+
}
|
|
232
|
+
};
|
|
231
233
|
{
|
|
232
234
|
const _1 = definition_;
|
|
233
235
|
{
|
|
@@ -250,12 +252,14 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
250
252
|
}
|
|
251
253
|
}));
|
|
252
254
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, traitMethodScheme_.signature_.returnType_);
|
|
253
|
-
|
|
255
|
+
for(let for_i = Math.max(ff_core_List.List_size(parameters_), 0), for_a = instanceFunction_.signature_.parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
256
|
+
const instanceParameter_ = for_a[for_i];
|
|
254
257
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceParameter_.at_, ("Unexpected parameter: " + instanceParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
255
|
-
}
|
|
256
|
-
|
|
258
|
+
};
|
|
259
|
+
for(let for_i = Math.max(ff_core_List.List_size(instanceFunction_.signature_.parameters_), 0), for_a = parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
260
|
+
const traitParameter_ = for_a[for_i];
|
|
257
261
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceFunction_.at_, ("Missing parameter: " + traitParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
258
|
-
}
|
|
262
|
+
};
|
|
259
263
|
ff_core_List.List_each(ff_core_List.List_zip(parameters_, instanceFunction_.signature_.parameters_), ((_1) => {
|
|
260
264
|
{
|
|
261
265
|
const traitParameter_ = _1.first_;
|
|
@@ -459,7 +463,7 @@ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing"
|
|
|
459
463
|
return ff_compiler_Environment.Scheme(true, false, false, false, ff_compiler_Syntax.Signature(at_, name_, false, [], [], [], type_, noEffect_))
|
|
460
464
|
}
|
|
461
465
|
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
462
|
-
|
|
466
|
+
guards_.array.push((((_c) => {
|
|
463
467
|
return ff_compiler_Syntax.MatchGuard(_c.at_, guardTerm_, _c.pattern_)
|
|
464
468
|
}))(g_));
|
|
465
469
|
{
|
|
@@ -1979,12 +1983,13 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
1979
1983
|
}));
|
|
1980
1984
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.returnType_);
|
|
1981
1985
|
const effect_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.effect_);
|
|
1982
|
-
|
|
1986
|
+
for(let for_i = 0, for_a = scheme_.signature_.constraints_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
1987
|
+
const c_ = for_a[for_i];
|
|
1983
1988
|
const generics_ = ff_core_List.List_map(c_.generics_, ((_w1) => {
|
|
1984
1989
|
return ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, _w1)
|
|
1985
1990
|
}));
|
|
1986
1991
|
ff_compiler_Unification.Unification_constrain(self_.unification_, at_, ff_core_List.List_grabFirst(generics_), c_.name_, ff_core_List.List_dropFirst(generics_, 1))
|
|
1987
|
-
}
|
|
1992
|
+
};
|
|
1988
1993
|
const signature_ = (((_c) => {
|
|
1989
1994
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, [], [], parameters_, returnType_, effect_)
|
|
1990
1995
|
}))(scheme_.signature_);
|
|
@@ -2064,17 +2069,19 @@ if((ff_core_List.List_size(traitDefinition_.generics_) !== ff_core_List.List_siz
|
|
|
2064
2069
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ((((("Wrong number of type arguments for " + traitName_) + ", expected ") + (ff_core_List.List_size(traitDefinition_.generics_) - 1)) + ", got ") + (ff_core_List.List_size(definition_.typeArguments_) - 1))), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2065
2070
|
};
|
|
2066
2071
|
const instantiationMap_ = ff_core_List.List_toMap(ff_core_List.List_zip(traitDefinition_.generics_, definition_.typeArguments_), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2067
|
-
|
|
2072
|
+
for(let for_i = 0, for_a = traitDefinition_.methods_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2073
|
+
const traitMethod_ = for_a[for_i];
|
|
2068
2074
|
const found_ = ff_core_List.List_filter(definition_.methods_, ((_w1) => {
|
|
2069
2075
|
return (_w1.signature_.name_ === traitMethod_.name_)
|
|
2070
2076
|
}));
|
|
2071
2077
|
if(ff_core_List.List_isEmpty(found_)) {
|
|
2072
2078
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(definition_.at_, ("Missing instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2073
2079
|
};
|
|
2074
|
-
|
|
2080
|
+
for(let for_i = 1, for_a = found_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2081
|
+
const duplicateMethod_ = for_a[for_i];
|
|
2075
2082
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(duplicateMethod_.at_, ("Duplicated instance method: " + traitMethod_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2076
|
-
}
|
|
2077
|
-
}
|
|
2083
|
+
}
|
|
2084
|
+
};
|
|
2078
2085
|
{
|
|
2079
2086
|
const _1 = definition_;
|
|
2080
2087
|
{
|
|
@@ -2097,12 +2104,14 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
2097
2104
|
}
|
|
2098
2105
|
}));
|
|
2099
2106
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, traitMethodScheme_.signature_.returnType_);
|
|
2100
|
-
|
|
2107
|
+
for(let for_i = Math.max(ff_core_List.List_size(parameters_), 0), for_a = instanceFunction_.signature_.parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2108
|
+
const instanceParameter_ = for_a[for_i];
|
|
2101
2109
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceParameter_.at_, ("Unexpected parameter: " + instanceParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2102
|
-
}
|
|
2103
|
-
|
|
2110
|
+
};
|
|
2111
|
+
for(let for_i = Math.max(ff_core_List.List_size(instanceFunction_.signature_.parameters_), 0), for_a = parameters_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
2112
|
+
const traitParameter_ = for_a[for_i];
|
|
2104
2113
|
throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(instanceFunction_.at_, ("Missing parameter: " + traitParameter_.name_)), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
|
|
2105
|
-
}
|
|
2114
|
+
};
|
|
2106
2115
|
ff_core_List.List_each(ff_core_List.List_zip(parameters_, instanceFunction_.signature_.parameters_), ((_1) => {
|
|
2107
2116
|
{
|
|
2108
2117
|
const traitParameter_ = _1.first_;
|
|
@@ -2306,7 +2315,7 @@ const noEffect_ = ff_compiler_Syntax.TConstructor(at_, "ff:core/Nothing.Nothing"
|
|
|
2306
2315
|
return ff_compiler_Environment.Scheme(true, false, false, false, ff_compiler_Syntax.Signature(at_, name_, false, [], [], [], type_, noEffect_))
|
|
2307
2316
|
}
|
|
2308
2317
|
}), ff_core_Ordering.ff_core_Ordering_Order$ff_core_String_String);
|
|
2309
|
-
|
|
2318
|
+
guards_.array.push((((_c) => {
|
|
2310
2319
|
return ff_compiler_Syntax.MatchGuard(_c.at_, guardTerm_, _c.pattern_)
|
|
2311
2320
|
}))(g_));
|
|
2312
2321
|
{
|
|
@@ -3826,12 +3835,13 @@ return ff_compiler_Syntax.Parameter(_c.at_, _c.mutable_, _c.name_, ff_compiler_U
|
|
|
3826
3835
|
}));
|
|
3827
3836
|
const returnType_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.returnType_);
|
|
3828
3837
|
const effect_ = ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, scheme_.signature_.effect_);
|
|
3829
|
-
|
|
3838
|
+
for(let for_i = 0, for_a = scheme_.signature_.constraints_, for_l = for_a.length; for_i < for_l; for_i++) {
|
|
3839
|
+
const c_ = for_a[for_i];
|
|
3830
3840
|
const generics_ = ff_core_List.List_map(c_.generics_, ((_w1) => {
|
|
3831
3841
|
return ff_compiler_Unification.Unification_instantiate(self_.unification_, instantiationMap_, _w1)
|
|
3832
3842
|
}));
|
|
3833
3843
|
ff_compiler_Unification.Unification_constrain(self_.unification_, at_, ff_core_List.List_grabFirst(generics_), c_.name_, ff_core_List.List_dropFirst(generics_, 1))
|
|
3834
|
-
}
|
|
3844
|
+
};
|
|
3835
3845
|
const signature_ = (((_c) => {
|
|
3836
3846
|
return ff_compiler_Syntax.Signature(_c.at_, _c.name_, _c.member_, [], [], parameters_, returnType_, effect_)
|
|
3837
3847
|
}))(scheme_.signature_);
|