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
|
@@ -1915,6 +1915,89 @@ return ff_core_Option.Some((("while(" + ff_compiler_JsEmitter.JsEmitter_emitComm
|
|
|
1915
1915
|
}
|
|
1916
1916
|
}
|
|
1917
1917
|
}
|
|
1918
|
+
if(_1 === "ff:core/List.List_each") {
|
|
1919
|
+
const _guard2 = arguments_;
|
|
1920
|
+
if(_guard2.length === 2 && _guard2[0].ECall && _guard2[0].target_.StaticCall && _guard2[0].arguments_.length === 2 && _guard2[1].ELambda && _guard2[1].lambda_.cases_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_[0].PVariable && _guard2[1].lambda_.cases_[0].guards_.length === 0) {
|
|
1921
|
+
const r_ = _guard2[0].target_.name_;
|
|
1922
|
+
const start_ = _guard2[0].arguments_[0];
|
|
1923
|
+
const end_ = _guard2[0].arguments_[1];
|
|
1924
|
+
const name_ = _guard2[1].lambda_.cases_[0].patterns_[0].name_;
|
|
1925
|
+
const body_ = _guard2[1].lambda_.cases_[0].body_;
|
|
1926
|
+
if(((r_ === "ff:core/Int.Int_until") || (r_ === "ff:core/Int.Int_to"))) {
|
|
1927
|
+
const startCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, start_.value_, async_);
|
|
1928
|
+
const endCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, end_.value_, async_);
|
|
1929
|
+
const op_ = ((r_ === "ff:core/Int.Int_until")
|
|
1930
|
+
? "<"
|
|
1931
|
+
: "<=");
|
|
1932
|
+
return ff_core_Option.Some((((((((((("for(let " + "for_i = ") + startCode_) + ", for_e = ") + endCode_) + "; for_i ") + op_) + " for_e; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
1933
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
1934
|
+
})), (() => {
|
|
1935
|
+
return ""
|
|
1936
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n}"))
|
|
1937
|
+
return
|
|
1938
|
+
}
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
if(_1 === "ff:core/List.List_each") {
|
|
1942
|
+
const _guard1 = arguments_;
|
|
1943
|
+
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
1944
|
+
const list_ = _guard1[0];
|
|
1945
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
1946
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
1947
|
+
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, list_, async_);
|
|
1948
|
+
const start_ = fusion_.second_.first_;
|
|
1949
|
+
const end_ = fusion_.second_.second_;
|
|
1950
|
+
const listCode_ = fusion_.first_;
|
|
1951
|
+
return ff_core_Option.Some(((((((((("for(let for_i = " + start_) + ", for_a = ") + listCode_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
1952
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
1953
|
+
})), (() => {
|
|
1954
|
+
return ""
|
|
1955
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n}"))
|
|
1956
|
+
return
|
|
1957
|
+
}
|
|
1958
|
+
}
|
|
1959
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
1960
|
+
const _guard1 = arguments_;
|
|
1961
|
+
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0 && _guard1[1].lambda_.cases_[0].body_.ESequential) {
|
|
1962
|
+
const list_ = _guard1[0];
|
|
1963
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
1964
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_.before_;
|
|
1965
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_.after_;
|
|
1966
|
+
const fusion_ = ff_compiler_JsEmitter.JsEmitter_emitLightFusion(self_, list_, async_);
|
|
1967
|
+
const start_ = fusion_.second_.first_;
|
|
1968
|
+
const end_ = fusion_.second_.second_;
|
|
1969
|
+
const listCode_ = fusion_.first_;
|
|
1970
|
+
return ff_core_Option.Some(((((((((((((("for(let for_i = " + start_) + ", for_a = ") + listCode_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
1971
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
1972
|
+
})), (() => {
|
|
1973
|
+
return ""
|
|
1974
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + ";\n") + "if(!") + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") break") + "\n}"))
|
|
1975
|
+
return
|
|
1976
|
+
}
|
|
1977
|
+
}
|
|
1978
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
1979
|
+
const _guard1 = arguments_;
|
|
1980
|
+
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
1981
|
+
const list_ = _guard1[0];
|
|
1982
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
1983
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_;
|
|
1984
|
+
const listCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_);
|
|
1985
|
+
return ff_core_Option.Some(((((((((("for(let " + "for_i = 0, for_a = ") + listCode_) + ", for_l = for_a.length") + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
1986
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
1987
|
+
})), (() => {
|
|
1988
|
+
return ""
|
|
1989
|
+
}))) + "if(!") + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") break") + "\n}"))
|
|
1990
|
+
return
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
if(_1 === "ff:core/Array.Array_push") {
|
|
1994
|
+
const _guard1 = arguments_;
|
|
1995
|
+
if(_guard1.length === 2) {
|
|
1996
|
+
const array_ = _guard1[0];
|
|
1997
|
+
const value_ = _guard1[1];
|
|
1998
|
+
return ff_core_Option.Some((((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, array_, async_) + ".array.push(") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ")"))
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
1918
2001
|
if(_1 === "ff:core/Core.if") {
|
|
1919
2002
|
const _guard1 = arguments_;
|
|
1920
2003
|
if(_guard1.length === 2) {
|
|
@@ -2051,6 +2134,66 @@ return ff_core_Option.None()
|
|
|
2051
2134
|
}
|
|
2052
2135
|
}
|
|
2053
2136
|
|
|
2137
|
+
export function JsEmitter_emitLightFusion(self_, list_, async_) {
|
|
2138
|
+
let start_ = "0";
|
|
2139
|
+
let end_ = "for_a.length";
|
|
2140
|
+
const listCode_ = (((_1) => {
|
|
2141
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
2142
|
+
const a1_ = _1.arguments_[0];
|
|
2143
|
+
const a2_ = _1.arguments_[1];
|
|
2144
|
+
start_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
2145
|
+
if((!ff_core_String.String_all(start_, ((_w1) => {
|
|
2146
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2147
|
+
})))) {
|
|
2148
|
+
start_ = (("Math.max(" + start_) + ", 0)")
|
|
2149
|
+
};
|
|
2150
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2151
|
+
}
|
|
2152
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropLast" && _1.arguments_.length === 2) {
|
|
2153
|
+
const a1_ = _1.arguments_[0];
|
|
2154
|
+
const a2_ = _1.arguments_[1];
|
|
2155
|
+
const count_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
2156
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
2157
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2158
|
+
})))) {
|
|
2159
|
+
end_ = (((end_ + " - Math.max(") + count_) + ", 0)")
|
|
2160
|
+
} else {
|
|
2161
|
+
end_ = ((end_ + " - ") + count_)
|
|
2162
|
+
};
|
|
2163
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2164
|
+
}
|
|
2165
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_takeFirst" && _1.arguments_.length === 2) {
|
|
2166
|
+
const a1_ = _1.arguments_[0];
|
|
2167
|
+
const a2_ = _1.arguments_[1];
|
|
2168
|
+
end_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
2169
|
+
if((!ff_core_String.String_all(end_, ((_w1) => {
|
|
2170
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2171
|
+
})))) {
|
|
2172
|
+
end_ = (("Math.max(" + end_) + ", 0)")
|
|
2173
|
+
};
|
|
2174
|
+
end_ = (("Math.min(" + end_) + ", for_a.length)");
|
|
2175
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2176
|
+
}
|
|
2177
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_takeLast" && _1.arguments_.length === 2) {
|
|
2178
|
+
const a1_ = _1.arguments_[0];
|
|
2179
|
+
const a2_ = _1.arguments_[1];
|
|
2180
|
+
const count_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
2181
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
2182
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2183
|
+
})))) {
|
|
2184
|
+
start_ = (("Math.max(for_a.length - Math.max(" + count_) + ", 0), 0)")
|
|
2185
|
+
} else {
|
|
2186
|
+
start_ = (("Math.max(for_a.length - " + count_) + ", 0)")
|
|
2187
|
+
};
|
|
2188
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2189
|
+
}
|
|
2190
|
+
{
|
|
2191
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_)
|
|
2192
|
+
}
|
|
2193
|
+
}))(list_);
|
|
2194
|
+
return ff_core_Pair.Pair(listCode_, ff_core_Pair.Pair(start_, end_))
|
|
2195
|
+
}
|
|
2196
|
+
|
|
2054
2197
|
export function JsEmitter_emitTryCatchFinally(self_, term_, last_, async_) {
|
|
2055
2198
|
function emitCatch_(catchEffect_, cases_) {
|
|
2056
2199
|
const catchAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(catchEffect_));
|
|
@@ -3716,6 +3859,89 @@ return ff_core_Option.Some((("while(" + (await ff_compiler_JsEmitter.JsEmitter_e
|
|
|
3716
3859
|
}
|
|
3717
3860
|
}
|
|
3718
3861
|
}
|
|
3862
|
+
if(_1 === "ff:core/List.List_each") {
|
|
3863
|
+
const _guard2 = arguments_;
|
|
3864
|
+
if(_guard2.length === 2 && _guard2[0].ECall && _guard2[0].target_.StaticCall && _guard2[0].arguments_.length === 2 && _guard2[1].ELambda && _guard2[1].lambda_.cases_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_.length === 1 && _guard2[1].lambda_.cases_[0].patterns_[0].PVariable && _guard2[1].lambda_.cases_[0].guards_.length === 0) {
|
|
3865
|
+
const r_ = _guard2[0].target_.name_;
|
|
3866
|
+
const start_ = _guard2[0].arguments_[0];
|
|
3867
|
+
const end_ = _guard2[0].arguments_[1];
|
|
3868
|
+
const name_ = _guard2[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3869
|
+
const body_ = _guard2[1].lambda_.cases_[0].body_;
|
|
3870
|
+
if(((r_ === "ff:core/Int.Int_until") || (r_ === "ff:core/Int.Int_to"))) {
|
|
3871
|
+
const startCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, start_.value_, async_, $task));
|
|
3872
|
+
const endCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, end_.value_, async_, $task));
|
|
3873
|
+
const op_ = ((r_ === "ff:core/Int.Int_until")
|
|
3874
|
+
? "<"
|
|
3875
|
+
: "<=");
|
|
3876
|
+
return ff_core_Option.Some((((((((((("for(let " + "for_i = ") + startCode_) + ", for_e = ") + endCode_) + "; for_i ") + op_) + " for_e; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
3877
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
3878
|
+
})), (() => {
|
|
3879
|
+
return ""
|
|
3880
|
+
}))) + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + "\n}"))
|
|
3881
|
+
return
|
|
3882
|
+
}
|
|
3883
|
+
}
|
|
3884
|
+
}
|
|
3885
|
+
if(_1 === "ff:core/List.List_each") {
|
|
3886
|
+
const _guard1 = arguments_;
|
|
3887
|
+
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
3888
|
+
const list_ = _guard1[0];
|
|
3889
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3890
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
3891
|
+
const fusion_ = (await ff_compiler_JsEmitter.JsEmitter_emitLightFusion$(self_, list_, async_, $task));
|
|
3892
|
+
const start_ = fusion_.second_.first_;
|
|
3893
|
+
const end_ = fusion_.second_.second_;
|
|
3894
|
+
const listCode_ = fusion_.first_;
|
|
3895
|
+
return ff_core_Option.Some(((((((((("for(let for_i = " + start_) + ", for_a = ") + listCode_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
3896
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
3897
|
+
})), (() => {
|
|
3898
|
+
return ""
|
|
3899
|
+
}))) + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + "\n}"))
|
|
3900
|
+
return
|
|
3901
|
+
}
|
|
3902
|
+
}
|
|
3903
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
3904
|
+
const _guard1 = arguments_;
|
|
3905
|
+
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0 && _guard1[1].lambda_.cases_[0].body_.ESequential) {
|
|
3906
|
+
const list_ = _guard1[0];
|
|
3907
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3908
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_.before_;
|
|
3909
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_.after_;
|
|
3910
|
+
const fusion_ = (await ff_compiler_JsEmitter.JsEmitter_emitLightFusion$(self_, list_, async_, $task));
|
|
3911
|
+
const start_ = fusion_.second_.first_;
|
|
3912
|
+
const end_ = fusion_.second_.second_;
|
|
3913
|
+
const listCode_ = fusion_.first_;
|
|
3914
|
+
return ff_core_Option.Some(((((((((((((("for(let for_i = " + start_) + ", for_a = ") + listCode_) + ", for_l = ") + end_) + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
3915
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
3916
|
+
})), (() => {
|
|
3917
|
+
return ""
|
|
3918
|
+
}))) + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + ";\n") + "if(!") + (await ff_compiler_JsEmitter.JsEmitter_emitComma$(self_, condition_, async_, $task))) + ") break") + "\n}"))
|
|
3919
|
+
return
|
|
3920
|
+
}
|
|
3921
|
+
}
|
|
3922
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
3923
|
+
const _guard1 = arguments_;
|
|
3924
|
+
if(_guard1.length === 2 && _guard1[1].ELambda && _guard1[1].lambda_.cases_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_.length === 1 && _guard1[1].lambda_.cases_[0].patterns_[0].PVariable && _guard1[1].lambda_.cases_[0].guards_.length === 0) {
|
|
3925
|
+
const list_ = _guard1[0];
|
|
3926
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3927
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_;
|
|
3928
|
+
const listCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, list_, async_, $task));
|
|
3929
|
+
return ff_core_Option.Some(((((((((("for(let " + "for_i = 0, for_a = ") + listCode_) + ", for_l = for_a.length") + "; for_i < for_l; for_i++) {\n") + ff_core_Option.Option_else(ff_core_Option.Option_map(name_, ((_w1) => {
|
|
3930
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
3931
|
+
})), (() => {
|
|
3932
|
+
return ""
|
|
3933
|
+
}))) + "if(!") + (await ff_compiler_JsEmitter.JsEmitter_emitComma$(self_, condition_, async_, $task))) + ") break") + "\n}"))
|
|
3934
|
+
return
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
if(_1 === "ff:core/Array.Array_push") {
|
|
3938
|
+
const _guard1 = arguments_;
|
|
3939
|
+
if(_guard1.length === 2) {
|
|
3940
|
+
const array_ = _guard1[0];
|
|
3941
|
+
const value_ = _guard1[1];
|
|
3942
|
+
return ff_core_Option.Some(((((await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, array_, async_, $task)) + ".array.push(") + (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, value_, async_, $task))) + ")"))
|
|
3943
|
+
}
|
|
3944
|
+
}
|
|
3719
3945
|
if(_1 === "ff:core/Core.if") {
|
|
3720
3946
|
const _guard1 = arguments_;
|
|
3721
3947
|
if(_guard1.length === 2) {
|
|
@@ -3852,6 +4078,66 @@ return ff_core_Option.None()
|
|
|
3852
4078
|
}
|
|
3853
4079
|
}
|
|
3854
4080
|
|
|
4081
|
+
export async function JsEmitter_emitLightFusion$(self_, list_, async_, $task) {
|
|
4082
|
+
let start_ = "0";
|
|
4083
|
+
let end_ = "for_a.length";
|
|
4084
|
+
const listCode_ = (await ((async (_1, $task) => {
|
|
4085
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
4086
|
+
const a1_ = _1.arguments_[0];
|
|
4087
|
+
const a2_ = _1.arguments_[1];
|
|
4088
|
+
start_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
4089
|
+
if((!ff_core_String.String_all(start_, ((_w1) => {
|
|
4090
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4091
|
+
})))) {
|
|
4092
|
+
start_ = (("Math.max(" + start_) + ", 0)")
|
|
4093
|
+
};
|
|
4094
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
4095
|
+
}
|
|
4096
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropLast" && _1.arguments_.length === 2) {
|
|
4097
|
+
const a1_ = _1.arguments_[0];
|
|
4098
|
+
const a2_ = _1.arguments_[1];
|
|
4099
|
+
const count_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
4100
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
4101
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4102
|
+
})))) {
|
|
4103
|
+
end_ = (((end_ + " - Math.max(") + count_) + ", 0)")
|
|
4104
|
+
} else {
|
|
4105
|
+
end_ = ((end_ + " - ") + count_)
|
|
4106
|
+
};
|
|
4107
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
4108
|
+
}
|
|
4109
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_takeFirst" && _1.arguments_.length === 2) {
|
|
4110
|
+
const a1_ = _1.arguments_[0];
|
|
4111
|
+
const a2_ = _1.arguments_[1];
|
|
4112
|
+
end_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
4113
|
+
if((!ff_core_String.String_all(end_, ((_w1) => {
|
|
4114
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4115
|
+
})))) {
|
|
4116
|
+
end_ = (("Math.max(" + end_) + ", 0)")
|
|
4117
|
+
};
|
|
4118
|
+
end_ = (("Math.min(" + end_) + ", for_a.length)");
|
|
4119
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
4120
|
+
}
|
|
4121
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_takeLast" && _1.arguments_.length === 2) {
|
|
4122
|
+
const a1_ = _1.arguments_[0];
|
|
4123
|
+
const a2_ = _1.arguments_[1];
|
|
4124
|
+
const count_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
4125
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
4126
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
4127
|
+
})))) {
|
|
4128
|
+
start_ = (("Math.max(for_a.length - Math.max(" + count_) + ", 0), 0)")
|
|
4129
|
+
} else {
|
|
4130
|
+
start_ = (("Math.max(for_a.length - " + count_) + ", 0)")
|
|
4131
|
+
};
|
|
4132
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
4133
|
+
}
|
|
4134
|
+
{
|
|
4135
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, list_, async_, $task))
|
|
4136
|
+
}
|
|
4137
|
+
}))(list_, $task));
|
|
4138
|
+
return ff_core_Pair.Pair(listCode_, ff_core_Pair.Pair(start_, end_))
|
|
4139
|
+
}
|
|
4140
|
+
|
|
3855
4141
|
export async function JsEmitter_emitTryCatchFinally$(self_, term_, last_, async_, $task) {
|
|
3856
4142
|
async function emitCatch_$(catchEffect_, cases_, $task) {
|
|
3857
4143
|
const catchAsync_ = (self_.emittingAsync_ && ff_compiler_JsEmitter.effectTypeIsAsync_(catchEffect_));
|
|
@@ -492,7 +492,7 @@ return (((self_.definedAt_.line_ === at_.line_) && (self_.definedAt_.column_ ===
|
|
|
492
492
|
}
|
|
493
493
|
|
|
494
494
|
export function LspHook_emit(self_, result_) {
|
|
495
|
-
|
|
495
|
+
self_.arrayOfResults_.array.push(result_)
|
|
496
496
|
}
|
|
497
497
|
|
|
498
498
|
export function LspHook_results(self_) {
|
|
@@ -512,7 +512,7 @@ return (((self_.definedAt_.line_ === at_.line_) && (self_.definedAt_.column_ ===
|
|
|
512
512
|
}
|
|
513
513
|
|
|
514
514
|
export async function LspHook_emit$(self_, result_, $task) {
|
|
515
|
-
|
|
515
|
+
self_.arrayOfResults_.array.push(result_)
|
|
516
516
|
}
|
|
517
517
|
|
|
518
518
|
export async function LspHook_results$(self_, $task) {
|