@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,47 @@
|
|
|
1
|
+
import { getPrefix, isValid } from "./Int32.js";
|
|
2
|
+
import { fromString } from "./BigInt.js";
|
|
3
|
+
import { Exception } from "./Util.js";
|
|
4
|
+
function getMaxValue(unsigned, radix, isNegative) {
|
|
5
|
+
switch (radix) {
|
|
6
|
+
case 2: return unsigned ?
|
|
7
|
+
"1111111111111111111111111111111111111111111111111111111111111111" :
|
|
8
|
+
(isNegative ? "1000000000000000000000000000000000000000000000000000000000000000"
|
|
9
|
+
: "111111111111111111111111111111111111111111111111111111111111111");
|
|
10
|
+
case 8: return unsigned ?
|
|
11
|
+
"1777777777777777777777" :
|
|
12
|
+
(isNegative ? "1000000000000000000000" : "777777777777777777777");
|
|
13
|
+
case 10: return unsigned ?
|
|
14
|
+
"18446744073709551615" :
|
|
15
|
+
(isNegative ? "9223372036854775808" : "9223372036854775807");
|
|
16
|
+
case 16: return unsigned ?
|
|
17
|
+
"FFFFFFFFFFFFFFFF" :
|
|
18
|
+
(isNegative ? "8000000000000000" : "7FFFFFFFFFFFFFFF");
|
|
19
|
+
default: throw new Exception("Invalid radix.");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export function parse(str, style, unsigned, _bitsize, radix) {
|
|
23
|
+
const res = isValid(str, style, radix);
|
|
24
|
+
if (res != null) {
|
|
25
|
+
const lessOrEqual = (x, y) => {
|
|
26
|
+
const len = Math.max(x.length, y.length);
|
|
27
|
+
return x.padStart(len, "0") <= y.padStart(len, "0");
|
|
28
|
+
};
|
|
29
|
+
const isNegative = res.sign === "-";
|
|
30
|
+
const maxValue = getMaxValue(unsigned || res.radix !== 10, res.radix, isNegative);
|
|
31
|
+
if (lessOrEqual(res.digits.toUpperCase(), maxValue)) {
|
|
32
|
+
str = getPrefix(res.radix) + res.digits;
|
|
33
|
+
str = isNegative ? res.sign + str : str;
|
|
34
|
+
return fromString(str);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
throw new Exception(`The input string ${str} was not in a correct format.`);
|
|
38
|
+
}
|
|
39
|
+
export function tryParse(str, style, unsigned, bitsize, defValue) {
|
|
40
|
+
try {
|
|
41
|
+
defValue.contents = parse(str, style, unsigned, bitsize);
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { defaultCancellationToken } from "./Async.js";
|
|
2
|
+
import { fromContinuations } from "./Async.js";
|
|
3
|
+
import { startImmediate } from "./Async.js";
|
|
4
|
+
import { Exception } from "./Util.js";
|
|
5
|
+
class QueueCell {
|
|
6
|
+
constructor(message) {
|
|
7
|
+
this.value = message;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
class MailboxQueue {
|
|
11
|
+
add(message) {
|
|
12
|
+
const itCell = new QueueCell(message);
|
|
13
|
+
if (this.firstAndLast) {
|
|
14
|
+
this.firstAndLast[1].next = itCell;
|
|
15
|
+
this.firstAndLast = [this.firstAndLast[0], itCell];
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
this.firstAndLast = [itCell, itCell];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
tryGet() {
|
|
22
|
+
if (this.firstAndLast) {
|
|
23
|
+
const value = this.firstAndLast[0].value;
|
|
24
|
+
if (this.firstAndLast[0].next) {
|
|
25
|
+
this.firstAndLast = [this.firstAndLast[0].next, this.firstAndLast[1]];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
delete this.firstAndLast;
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
return void 0;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
export class MailboxProcessor {
|
|
36
|
+
constructor(body, cancellationToken) {
|
|
37
|
+
this.body = body;
|
|
38
|
+
this.cancellationToken = cancellationToken || defaultCancellationToken;
|
|
39
|
+
this.messages = new MailboxQueue();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
function __processEvents($this) {
|
|
43
|
+
if ($this.continuation) {
|
|
44
|
+
const value = $this.messages.tryGet();
|
|
45
|
+
if (value) {
|
|
46
|
+
const cont = $this.continuation;
|
|
47
|
+
delete $this.continuation;
|
|
48
|
+
cont(value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export function startInstance($this) {
|
|
53
|
+
startImmediate($this.body($this), $this.cancellationToken);
|
|
54
|
+
}
|
|
55
|
+
export function receive($this) {
|
|
56
|
+
return fromContinuations((conts) => {
|
|
57
|
+
if ($this.continuation) {
|
|
58
|
+
throw new Exception("Receive can only be called once!");
|
|
59
|
+
}
|
|
60
|
+
$this.continuation = conts[0];
|
|
61
|
+
__processEvents($this);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function post($this, message) {
|
|
65
|
+
$this.messages.add(message);
|
|
66
|
+
__processEvents($this);
|
|
67
|
+
}
|
|
68
|
+
export function postAndAsyncReply($this, buildMessage) {
|
|
69
|
+
let result;
|
|
70
|
+
let continuation;
|
|
71
|
+
function checkCompletion() {
|
|
72
|
+
if (result !== void 0 && continuation !== void 0) {
|
|
73
|
+
continuation(result);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const reply = {
|
|
77
|
+
reply: (res) => {
|
|
78
|
+
result = res;
|
|
79
|
+
checkCompletion();
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
$this.messages.add(buildMessage(reply));
|
|
83
|
+
__processEvents($this);
|
|
84
|
+
return fromContinuations((conts) => {
|
|
85
|
+
continuation = conts[0];
|
|
86
|
+
checkCompletion();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
export function start(body, cancellationToken) {
|
|
90
|
+
const mbox = new MailboxProcessor(body, cancellationToken);
|
|
91
|
+
startInstance(mbox);
|
|
92
|
+
return mbox;
|
|
93
|
+
}
|
|
94
|
+
export default MailboxProcessor;
|