@magnusopera/fscript 0.75.0
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/README.md +5 -0
- package/dist/FScript.Language/Ast.js +234 -0
- package/dist/FScript.Language/BuiltinFunctions.js +2039 -0
- package/dist/FScript.Language/BuiltinSignatures.js +24 -0
- package/dist/FScript.Language/BuiltinTypes.js +13 -0
- package/dist/FScript.Language/Error.js +74 -0
- package/dist/FScript.Language/Eval.js +2404 -0
- package/dist/FScript.Language/IncludeResolver.js +806 -0
- package/dist/FScript.Language/Lexer.js +1067 -0
- package/dist/FScript.Language/Library.js +28 -0
- package/dist/FScript.Language/Parser.js +2368 -0
- package/dist/FScript.Language/Pretty.js +115 -0
- package/dist/FScript.Language/Span.js +33 -0
- package/dist/FScript.Language/Token.js +32 -0
- package/dist/FScript.Language/TypeInfer.js +2561 -0
- package/dist/FScript.Language/Types.js +205 -0
- package/dist/FScript.Language/Value.js +91 -0
- package/dist/Library.js +732 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Array.js +1347 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Async.js +134 -0
- package/dist/fable_modules/fable-library-js.5.2.0/AsyncBuilder.js +183 -0
- package/dist/fable_modules/fable-library-js.5.2.0/BigInt.js +306 -0
- package/dist/fable_modules/fable-library-js.5.2.0/BitConverter.js +138 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Boolean.js +22 -0
- package/dist/fable_modules/fable-library-js.5.2.0/CHANGELOG.md +234 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Char.js +202 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Choice.js +184 -0
- package/dist/fable_modules/fable-library-js.5.2.0/CollectionUtil.js +182 -0
- package/dist/fable_modules/fable-library-js.5.2.0/ConditionalWeakTable.js +21 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Date.js +841 -0
- package/dist/fable_modules/fable-library-js.5.2.0/DateOffset.js +261 -0
- package/dist/fable_modules/fable-library-js.5.2.0/DateOnly.js +124 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Decimal.js +238 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Double.js +47 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Encoding.js +185 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Event.js +93 -0
- package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Collections.js +45 -0
- package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.CompilerServices.js +27 -0
- package/dist/fable_modules/fable-library-js.5.2.0/FSharp.Core.js +156 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Global.js +29 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Guid.js +161 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Int32.js +135 -0
- package/dist/fable_modules/fable-library-js.5.2.0/List.js +1323 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Long.js +47 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MailboxProcessor.js +94 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Map.js +1396 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MapUtil.js +130 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MutableMap.js +339 -0
- package/dist/fable_modules/fable-library-js.5.2.0/MutableSet.js +233 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Native.js +14 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Numeric.js +75 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Observable.js +113 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Option.js +104 -0
- package/dist/fable_modules/fable-library-js.5.2.0/README.md +3 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Random.js +172 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Range.js +45 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Reflection.js +479 -0
- package/dist/fable_modules/fable-library-js.5.2.0/RegExp.js +141 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Result.js +165 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Seq.js +1417 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Seq2.js +111 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Set.js +1816 -0
- package/dist/fable_modules/fable-library-js.5.2.0/String.js +674 -0
- package/dist/fable_modules/fable-library-js.5.2.0/System.Collections.Generic.js +333 -0
- package/dist/fable_modules/fable-library-js.5.2.0/System.Text.js +200 -0
- package/dist/fable_modules/fable-library-js.5.2.0/System.js +283 -0
- package/dist/fable_modules/fable-library-js.5.2.0/TimeOnly.js +122 -0
- package/dist/fable_modules/fable-library-js.5.2.0/TimeSpan.js +180 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Timer.js +67 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Types.js +198 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Unicode.13.0.0.js +4 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Uri.js +165 -0
- package/dist/fable_modules/fable-library-js.5.2.0/Util.js +795 -0
- package/dist/fable_modules/fable-library-js.5.2.0/big.d.ts +338 -0
- package/dist/fable_modules/fable-library-js.5.2.0/lib/big.js +825 -0
- package/dist/fable_modules/fable-library-js.5.2.0/package.json +24 -0
- package/dist/fable_modules/fable-library-js.5.2.0/quotation.js +618 -0
- package/dist/fable_modules/project_cracked.json +1 -0
- package/package.json +36 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { Exception } from "./Util.js";
|
|
2
|
+
export const NumberStyles = {
|
|
3
|
+
// None: 0x00000000,
|
|
4
|
+
// AllowLeadingWhite: 0x00000001,
|
|
5
|
+
// AllowTrailingWhite: 0x00000002,
|
|
6
|
+
// AllowLeadingSign: 0x00000004,
|
|
7
|
+
// AllowTrailingSign: 0x00000008,
|
|
8
|
+
// AllowParentheses: 0x00000010,
|
|
9
|
+
// AllowDecimalPoint: 0x00000020,
|
|
10
|
+
// AllowThousands: 0x00000040,
|
|
11
|
+
// AllowExponent: 0x00000080,
|
|
12
|
+
// AllowCurrencySymbol: 0x00000100,
|
|
13
|
+
AllowHexSpecifier: 0x00000200,
|
|
14
|
+
// Integer = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign,
|
|
15
|
+
// HexNumber = AllowLeadingWhite | AllowTrailingWhite | AllowHexSpecifier,
|
|
16
|
+
// Number = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign |
|
|
17
|
+
// AllowTrailingSign | AllowDecimalPoint | AllowThousands,
|
|
18
|
+
// Float = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign |
|
|
19
|
+
// AllowDecimalPoint | AllowExponent,
|
|
20
|
+
// Currency = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
|
|
21
|
+
// AllowParentheses | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol,
|
|
22
|
+
// Any = AllowLeadingWhite | AllowTrailingWhite | AllowLeadingSign | AllowTrailingSign |
|
|
23
|
+
// AllowParentheses | AllowDecimalPoint | AllowThousands | AllowCurrencySymbol | AllowExponent,
|
|
24
|
+
};
|
|
25
|
+
function validResponse(regexMatch, radix) {
|
|
26
|
+
const [/*all*/ , sign, prefix, digits] = regexMatch;
|
|
27
|
+
return {
|
|
28
|
+
sign: sign || "",
|
|
29
|
+
prefix: prefix || "",
|
|
30
|
+
digits,
|
|
31
|
+
radix,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function getRange(unsigned, bitsize) {
|
|
35
|
+
switch (bitsize) {
|
|
36
|
+
case 8: return unsigned ? [0, 255] : [-128, 127];
|
|
37
|
+
case 16: return unsigned ? [0, 65535] : [-32768, 32767];
|
|
38
|
+
case 32: return unsigned ? [0, 4294967295] : [-2147483648, 2147483647];
|
|
39
|
+
default: throw new Exception("Invalid bit size.");
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function getInvalidDigits(radix) {
|
|
43
|
+
switch (radix) {
|
|
44
|
+
case 2: return /[^0-1]/;
|
|
45
|
+
case 8: return /[^0-7]/;
|
|
46
|
+
case 10: return /[^0-9]/;
|
|
47
|
+
case 16: return /[^0-9a-fA-F]/;
|
|
48
|
+
default:
|
|
49
|
+
throw new Exception("Invalid Base.");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function getPrefix(radix) {
|
|
53
|
+
switch (radix) {
|
|
54
|
+
case 2: return "0b";
|
|
55
|
+
case 8: return "0o";
|
|
56
|
+
case 10: return "";
|
|
57
|
+
case 16: return "0x";
|
|
58
|
+
default: return "";
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
export function getRadix(prefix, style) {
|
|
62
|
+
if (style & NumberStyles.AllowHexSpecifier) {
|
|
63
|
+
return 16;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
switch (prefix) {
|
|
67
|
+
case "0b":
|
|
68
|
+
case "0B": return 2;
|
|
69
|
+
case "0o":
|
|
70
|
+
case "0O": return 8;
|
|
71
|
+
case "0x":
|
|
72
|
+
case "0X": return 16;
|
|
73
|
+
default: return 10;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function isValid(str, style, radix) {
|
|
78
|
+
const integerRegex = /^\s*([\+\-])?(0[xXoObB])?([0-9a-fA-F]+)\s*$/;
|
|
79
|
+
const res = integerRegex.exec(str.replace(/_/g, ""));
|
|
80
|
+
if (res != null) {
|
|
81
|
+
const [/*all*/ , /*sign*/ , prefix, digits] = res;
|
|
82
|
+
radix = radix || getRadix(prefix, style);
|
|
83
|
+
const invalidDigits = getInvalidDigits(radix);
|
|
84
|
+
if (!invalidDigits.test(digits)) {
|
|
85
|
+
return validResponse(res, radix);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
export function parse(str, style, unsigned, bitsize, radix) {
|
|
91
|
+
const res = isValid(str, style, radix);
|
|
92
|
+
if (res != null) {
|
|
93
|
+
let v = Number.parseInt(res.sign + res.digits, res.radix);
|
|
94
|
+
if (!Number.isNaN(v)) {
|
|
95
|
+
const [umin, umax] = getRange(true, bitsize);
|
|
96
|
+
if (!unsigned && res.radix !== 10 && v >= umin && v <= umax) {
|
|
97
|
+
v = v << (32 - bitsize) >> (32 - bitsize);
|
|
98
|
+
}
|
|
99
|
+
const [min, max] = getRange(unsigned, bitsize);
|
|
100
|
+
if (v >= min && v <= max) {
|
|
101
|
+
return v;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
106
|
+
}
|
|
107
|
+
export function tryParse(str, style, unsigned, bitsize, defValue) {
|
|
108
|
+
try {
|
|
109
|
+
defValue.contents = parse(str, style, unsigned, bitsize);
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
catch {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
export function op_UnaryNegation_Int8(x) {
|
|
117
|
+
return x === -128 ? x : -x;
|
|
118
|
+
}
|
|
119
|
+
export function op_UnaryNegation_Int16(x) {
|
|
120
|
+
return x === -32768 ? x : -x;
|
|
121
|
+
}
|
|
122
|
+
export function op_UnaryNegation_Int32(x) {
|
|
123
|
+
return x === -2147483648 ? x : -x;
|
|
124
|
+
}
|
|
125
|
+
export function divRem(x, y, out) {
|
|
126
|
+
const div = ~~(x / y);
|
|
127
|
+
const rem = x % y;
|
|
128
|
+
if (out === void 0) {
|
|
129
|
+
return [div, rem];
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
out.contents = rem;
|
|
133
|
+
return div;
|
|
134
|
+
}
|
|
135
|
+
}
|