firefly-compiler 0.5.8 → 0.5.10
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 +89 -1
- 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 +276 -2
- 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
|
@@ -710,7 +710,7 @@ const mutability_ = (mutable_
|
|
|
710
710
|
? "let"
|
|
711
711
|
: "const");
|
|
712
712
|
const valueCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, definition_.value_, async_);
|
|
713
|
-
const assignmentCode_ = ((valueCode_ !== "(void 0)")
|
|
713
|
+
const assignmentCode_ = (((!mutable_) || (valueCode_ !== "(void 0)"))
|
|
714
714
|
? (" = " + valueCode_)
|
|
715
715
|
: "");
|
|
716
716
|
return ((((mutability_ + " ") + ff_compiler_JsEmitter.escapeKeyword_(definition_.name_)) + assignmentCode_) + ";")
|
|
@@ -1915,6 +1915,143 @@ 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
|
+
let start_ = "0";
|
|
1948
|
+
let end_ = "for_a.length";
|
|
1949
|
+
const listCode_ = (((_1) => {
|
|
1950
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
1951
|
+
const a1_ = _1.arguments_[0];
|
|
1952
|
+
const a2_ = _1.arguments_[1];
|
|
1953
|
+
start_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
1954
|
+
if((!ff_core_String.String_all(start_, ((_w1) => {
|
|
1955
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
1956
|
+
})))) {
|
|
1957
|
+
start_ = (("Math.max(" + start_) + ", 0)")
|
|
1958
|
+
};
|
|
1959
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
1960
|
+
}
|
|
1961
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropLast" && _1.arguments_.length === 2) {
|
|
1962
|
+
const a1_ = _1.arguments_[0];
|
|
1963
|
+
const a2_ = _1.arguments_[1];
|
|
1964
|
+
const count_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
1965
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
1966
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
1967
|
+
})))) {
|
|
1968
|
+
end_ = (((end_ + " - Math.max(") + count_) + ", 0)")
|
|
1969
|
+
} else {
|
|
1970
|
+
end_ = ((end_ + " - ") + count_)
|
|
1971
|
+
};
|
|
1972
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
1973
|
+
}
|
|
1974
|
+
{
|
|
1975
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_)
|
|
1976
|
+
}
|
|
1977
|
+
}))(list_);
|
|
1978
|
+
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) => {
|
|
1979
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
1980
|
+
})), (() => {
|
|
1981
|
+
return ""
|
|
1982
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + "\n}"))
|
|
1983
|
+
return
|
|
1984
|
+
}
|
|
1985
|
+
}
|
|
1986
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
1987
|
+
const _guard1 = arguments_;
|
|
1988
|
+
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) {
|
|
1989
|
+
const list_ = _guard1[0];
|
|
1990
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
1991
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_.before_;
|
|
1992
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_.after_;
|
|
1993
|
+
let start_ = "0";
|
|
1994
|
+
let end_ = "for_a.length";
|
|
1995
|
+
const listCode_ = (((_1) => {
|
|
1996
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
1997
|
+
const a1_ = _1.arguments_[0];
|
|
1998
|
+
const a2_ = _1.arguments_[1];
|
|
1999
|
+
start_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
2000
|
+
if((!ff_core_String.String_all(start_, ((_w1) => {
|
|
2001
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2002
|
+
})))) {
|
|
2003
|
+
start_ = (("Math.max(" + start_) + ", 0)")
|
|
2004
|
+
};
|
|
2005
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2006
|
+
}
|
|
2007
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropLast" && _1.arguments_.length === 2) {
|
|
2008
|
+
const a1_ = _1.arguments_[0];
|
|
2009
|
+
const a2_ = _1.arguments_[1];
|
|
2010
|
+
const count_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a2_.value_, async_);
|
|
2011
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
2012
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
2013
|
+
})))) {
|
|
2014
|
+
end_ = (((end_ + " - Math.max(") + count_) + ", 0)")
|
|
2015
|
+
} else {
|
|
2016
|
+
end_ = ((end_ + " - ") + count_)
|
|
2017
|
+
};
|
|
2018
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, a1_.value_, async_)
|
|
2019
|
+
}
|
|
2020
|
+
{
|
|
2021
|
+
return ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_)
|
|
2022
|
+
}
|
|
2023
|
+
}))(list_);
|
|
2024
|
+
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) => {
|
|
2025
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
2026
|
+
})), (() => {
|
|
2027
|
+
return ""
|
|
2028
|
+
}))) + ff_compiler_JsEmitter.JsEmitter_emitStatements(self_, body_, last_, async_)) + ";\n") + "if(!") + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") break") + "\n}"))
|
|
2029
|
+
return
|
|
2030
|
+
}
|
|
2031
|
+
}
|
|
2032
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
2033
|
+
const _guard1 = arguments_;
|
|
2034
|
+
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) {
|
|
2035
|
+
const list_ = _guard1[0];
|
|
2036
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
2037
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_;
|
|
2038
|
+
const listCode_ = ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, list_, async_);
|
|
2039
|
+
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) => {
|
|
2040
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
2041
|
+
})), (() => {
|
|
2042
|
+
return ""
|
|
2043
|
+
}))) + "if(!") + ff_compiler_JsEmitter.JsEmitter_emitComma(self_, condition_, async_)) + ") break") + "\n}"))
|
|
2044
|
+
return
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
if(_1 === "ff:core/Array.Array_push") {
|
|
2048
|
+
const _guard1 = arguments_;
|
|
2049
|
+
if(_guard1.length === 2) {
|
|
2050
|
+
const array_ = _guard1[0];
|
|
2051
|
+
const value_ = _guard1[1];
|
|
2052
|
+
return ff_core_Option.Some((((ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, array_, async_) + ".array.push(") + ff_compiler_JsEmitter.JsEmitter_emitTerm(self_, value_, async_)) + ")"))
|
|
2053
|
+
}
|
|
2054
|
+
}
|
|
1918
2055
|
if(_1 === "ff:core/Core.if") {
|
|
1919
2056
|
const _guard1 = arguments_;
|
|
1920
2057
|
if(_guard1.length === 2) {
|
|
@@ -2511,7 +2648,7 @@ const mutability_ = (mutable_
|
|
|
2511
2648
|
? "let"
|
|
2512
2649
|
: "const");
|
|
2513
2650
|
const valueCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, definition_.value_, async_, $task));
|
|
2514
|
-
const assignmentCode_ = ((valueCode_ !== "(void 0)")
|
|
2651
|
+
const assignmentCode_ = (((!mutable_) || (valueCode_ !== "(void 0)"))
|
|
2515
2652
|
? (" = " + valueCode_)
|
|
2516
2653
|
: "");
|
|
2517
2654
|
return ((((mutability_ + " ") + ff_compiler_JsEmitter.escapeKeyword_(definition_.name_)) + assignmentCode_) + ";")
|
|
@@ -3716,6 +3853,143 @@ return ff_core_Option.Some((("while(" + (await ff_compiler_JsEmitter.JsEmitter_e
|
|
|
3716
3853
|
}
|
|
3717
3854
|
}
|
|
3718
3855
|
}
|
|
3856
|
+
if(_1 === "ff:core/List.List_each") {
|
|
3857
|
+
const _guard2 = arguments_;
|
|
3858
|
+
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) {
|
|
3859
|
+
const r_ = _guard2[0].target_.name_;
|
|
3860
|
+
const start_ = _guard2[0].arguments_[0];
|
|
3861
|
+
const end_ = _guard2[0].arguments_[1];
|
|
3862
|
+
const name_ = _guard2[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3863
|
+
const body_ = _guard2[1].lambda_.cases_[0].body_;
|
|
3864
|
+
if(((r_ === "ff:core/Int.Int_until") || (r_ === "ff:core/Int.Int_to"))) {
|
|
3865
|
+
const startCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, start_.value_, async_, $task));
|
|
3866
|
+
const endCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, end_.value_, async_, $task));
|
|
3867
|
+
const op_ = ((r_ === "ff:core/Int.Int_until")
|
|
3868
|
+
? "<"
|
|
3869
|
+
: "<=");
|
|
3870
|
+
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) => {
|
|
3871
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_i;\n")
|
|
3872
|
+
})), (() => {
|
|
3873
|
+
return ""
|
|
3874
|
+
}))) + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + "\n}"))
|
|
3875
|
+
return
|
|
3876
|
+
}
|
|
3877
|
+
}
|
|
3878
|
+
}
|
|
3879
|
+
if(_1 === "ff:core/List.List_each") {
|
|
3880
|
+
const _guard1 = arguments_;
|
|
3881
|
+
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) {
|
|
3882
|
+
const list_ = _guard1[0];
|
|
3883
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3884
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_;
|
|
3885
|
+
let start_ = "0";
|
|
3886
|
+
let end_ = "for_a.length";
|
|
3887
|
+
const listCode_ = (await ((async (_1, $task) => {
|
|
3888
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
3889
|
+
const a1_ = _1.arguments_[0];
|
|
3890
|
+
const a2_ = _1.arguments_[1];
|
|
3891
|
+
start_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
3892
|
+
if((!ff_core_String.String_all(start_, ((_w1) => {
|
|
3893
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
3894
|
+
})))) {
|
|
3895
|
+
start_ = (("Math.max(" + start_) + ", 0)")
|
|
3896
|
+
};
|
|
3897
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
3898
|
+
}
|
|
3899
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropLast" && _1.arguments_.length === 2) {
|
|
3900
|
+
const a1_ = _1.arguments_[0];
|
|
3901
|
+
const a2_ = _1.arguments_[1];
|
|
3902
|
+
const count_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
3903
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
3904
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
3905
|
+
})))) {
|
|
3906
|
+
end_ = (((end_ + " - Math.max(") + count_) + ", 0)")
|
|
3907
|
+
} else {
|
|
3908
|
+
end_ = ((end_ + " - ") + count_)
|
|
3909
|
+
};
|
|
3910
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
3911
|
+
}
|
|
3912
|
+
{
|
|
3913
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, list_, async_, $task))
|
|
3914
|
+
}
|
|
3915
|
+
}))(list_, $task));
|
|
3916
|
+
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) => {
|
|
3917
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
3918
|
+
})), (() => {
|
|
3919
|
+
return ""
|
|
3920
|
+
}))) + (await ff_compiler_JsEmitter.JsEmitter_emitStatements$(self_, body_, last_, async_, $task))) + "\n}"))
|
|
3921
|
+
return
|
|
3922
|
+
}
|
|
3923
|
+
}
|
|
3924
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
3925
|
+
const _guard1 = arguments_;
|
|
3926
|
+
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) {
|
|
3927
|
+
const list_ = _guard1[0];
|
|
3928
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3929
|
+
const body_ = _guard1[1].lambda_.cases_[0].body_.before_;
|
|
3930
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_.after_;
|
|
3931
|
+
let start_ = "0";
|
|
3932
|
+
let end_ = "for_a.length";
|
|
3933
|
+
const listCode_ = (await ((async (_1, $task) => {
|
|
3934
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropFirst" && _1.arguments_.length === 2) {
|
|
3935
|
+
const a1_ = _1.arguments_[0];
|
|
3936
|
+
const a2_ = _1.arguments_[1];
|
|
3937
|
+
start_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
3938
|
+
if((!ff_core_String.String_all(start_, ((_w1) => {
|
|
3939
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
3940
|
+
})))) {
|
|
3941
|
+
start_ = (("Math.max(" + start_) + ", 0)")
|
|
3942
|
+
};
|
|
3943
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
3944
|
+
}
|
|
3945
|
+
if(_1.ECall && _1.target_.StaticCall && _1.target_.name_ === "ff:core/List.List_dropLast" && _1.arguments_.length === 2) {
|
|
3946
|
+
const a1_ = _1.arguments_[0];
|
|
3947
|
+
const a2_ = _1.arguments_[1];
|
|
3948
|
+
const count_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a2_.value_, async_, $task));
|
|
3949
|
+
if((!ff_core_String.String_all(count_, ((_w1) => {
|
|
3950
|
+
return ff_core_Char.Char_isAsciiDigit(_w1)
|
|
3951
|
+
})))) {
|
|
3952
|
+
end_ = (((end_ + " - Math.max(") + count_) + ", 0)")
|
|
3953
|
+
} else {
|
|
3954
|
+
end_ = ((end_ + " - ") + count_)
|
|
3955
|
+
};
|
|
3956
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, a1_.value_, async_, $task))
|
|
3957
|
+
}
|
|
3958
|
+
{
|
|
3959
|
+
return (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, list_, async_, $task))
|
|
3960
|
+
}
|
|
3961
|
+
}))(list_, $task));
|
|
3962
|
+
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) => {
|
|
3963
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
3964
|
+
})), (() => {
|
|
3965
|
+
return ""
|
|
3966
|
+
}))) + (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}"))
|
|
3967
|
+
return
|
|
3968
|
+
}
|
|
3969
|
+
}
|
|
3970
|
+
if(_1 === "ff:core/List.List_eachWhile") {
|
|
3971
|
+
const _guard1 = arguments_;
|
|
3972
|
+
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) {
|
|
3973
|
+
const list_ = _guard1[0];
|
|
3974
|
+
const name_ = _guard1[1].lambda_.cases_[0].patterns_[0].name_;
|
|
3975
|
+
const condition_ = _guard1[1].lambda_.cases_[0].body_;
|
|
3976
|
+
const listCode_ = (await ff_compiler_JsEmitter.JsEmitter_emitTerm$(self_, list_, async_, $task));
|
|
3977
|
+
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) => {
|
|
3978
|
+
return (("const " + ff_compiler_JsEmitter.escapeKeyword_(_w1)) + " = for_a[for_i];\n")
|
|
3979
|
+
})), (() => {
|
|
3980
|
+
return ""
|
|
3981
|
+
}))) + "if(!") + (await ff_compiler_JsEmitter.JsEmitter_emitComma$(self_, condition_, async_, $task))) + ") break") + "\n}"))
|
|
3982
|
+
return
|
|
3983
|
+
}
|
|
3984
|
+
}
|
|
3985
|
+
if(_1 === "ff:core/Array.Array_push") {
|
|
3986
|
+
const _guard1 = arguments_;
|
|
3987
|
+
if(_guard1.length === 2) {
|
|
3988
|
+
const array_ = _guard1[0];
|
|
3989
|
+
const value_ = _guard1[1];
|
|
3990
|
+
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))) + ")"))
|
|
3991
|
+
}
|
|
3992
|
+
}
|
|
3719
3993
|
if(_1 === "ff:core/Core.if") {
|
|
3720
3994
|
const _guard1 = arguments_;
|
|
3721
3995
|
if(_guard1.length === 2) {
|
|
@@ -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) {
|