affinirum 1.5.4 → 2.0.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/.cache/arrow-preview-vWvB5K/affinirum-arrow-functions.patch +155 -0
- package/.cache/function-syntax-tests.log +20 -0
- package/README.md +925 -355
- package/dst/Affinirum.d.ts +29 -19
- package/dst/Affinirum.js +399 -334
- package/dst/CallFrame.d.ts +12 -3
- package/dst/CallFrame.js +49 -10
- package/dst/Constant.d.ts +1 -3
- package/dst/Constant.js +3 -8
- package/dst/LexicalScope.d.ts +11 -9
- package/dst/LexicalScope.js +10 -6
- package/dst/ParserSpan.d.ts +11 -0
- package/dst/{ScriptSpan.js → ParserSpan.js} +8 -5
- package/dst/ParserState.d.ts +28 -49
- package/dst/ParserState.js +256 -489
- package/dst/Type.d.ts +34 -17
- package/dst/Type.js +211 -115
- package/dst/TypeParser.d.ts +9 -0
- package/dst/TypeParser.js +127 -0
- package/dst/Value.d.ts +1 -1
- package/dst/Value.js +21 -10
- package/dst/Variable.d.ts +16 -5
- package/dst/Variable.js +32 -7
- package/dst/atom/ArrayAtom.d.ts +10 -10
- package/dst/atom/ArrayAtom.js +62 -55
- package/dst/atom/Atom.d.ts +7 -0
- package/dst/atom/FunctionAtom.d.ts +13 -15
- package/dst/atom/FunctionAtom.js +53 -104
- package/dst/atom/FunctionSignature.d.ts +23 -0
- package/dst/atom/FunctionSignature.js +124 -0
- package/dst/atom/ObjectAtom.d.ts +11 -9
- package/dst/atom/ObjectAtom.js +73 -33
- package/dst/atom/PrimitiveAtom.d.ts +6 -7
- package/dst/atom/PrimitiveAtom.js +7 -10
- package/dst/cjs/Affinirum.d.ts +29 -19
- package/dst/cjs/Affinirum.js +398 -333
- package/dst/cjs/CallFrame.d.ts +12 -3
- package/dst/cjs/CallFrame.js +49 -10
- package/dst/cjs/Constant.d.ts +1 -3
- package/dst/cjs/Constant.js +3 -8
- package/dst/cjs/LexicalScope.d.ts +11 -9
- package/dst/cjs/LexicalScope.js +10 -6
- package/dst/cjs/ParserSpan.d.ts +11 -0
- package/dst/cjs/{ScriptSpan.js → ParserSpan.js} +10 -7
- package/dst/cjs/ParserState.d.ts +28 -49
- package/dst/cjs/ParserState.js +255 -488
- package/dst/cjs/Type.d.ts +34 -17
- package/dst/cjs/Type.js +211 -115
- package/dst/cjs/TypeParser.d.ts +9 -0
- package/dst/cjs/TypeParser.js +131 -0
- package/dst/cjs/Value.d.ts +1 -1
- package/dst/cjs/Value.js +21 -10
- package/dst/cjs/Variable.d.ts +16 -5
- package/dst/cjs/Variable.js +36 -9
- package/dst/cjs/atom/ArrayAtom.d.ts +10 -10
- package/dst/cjs/atom/ArrayAtom.js +62 -55
- package/dst/cjs/atom/Atom.d.ts +7 -0
- package/dst/cjs/atom/FunctionAtom.d.ts +13 -15
- package/dst/cjs/atom/FunctionAtom.js +54 -105
- package/dst/cjs/atom/FunctionSignature.d.ts +23 -0
- package/dst/cjs/atom/FunctionSignature.js +128 -0
- package/dst/cjs/atom/ObjectAtom.d.ts +11 -9
- package/dst/cjs/atom/ObjectAtom.js +73 -33
- package/dst/cjs/atom/PrimitiveAtom.d.ts +6 -7
- package/dst/cjs/atom/PrimitiveAtom.js +7 -10
- package/dst/cjs/dictionary/Constants.d.ts +2 -0
- package/dst/cjs/dictionary/Constants.js +27 -0
- package/dst/cjs/dictionary/Functions.d.ts +2 -0
- package/dst/cjs/{Functions.js → dictionary/Functions.js} +27 -25
- package/dst/cjs/native/Aggregable.js +10 -2
- package/dst/cjs/native/Array.d.ts +2 -3
- package/dst/cjs/native/Array.js +38 -39
- package/dst/cjs/native/Boolean.d.ts +1 -1
- package/dst/cjs/native/Boolean.js +13 -10
- package/dst/cjs/native/Buffer.d.ts +5 -5
- package/dst/cjs/native/Buffer.js +70 -46
- package/dst/cjs/native/Composite.d.ts +5 -0
- package/dst/cjs/native/Composite.js +35 -0
- package/dst/cjs/native/Enumerable.js +20 -8
- package/dst/cjs/native/Float.d.ts +3 -1
- package/dst/cjs/native/Float.js +51 -12
- package/dst/cjs/native/Integer.d.ts +4 -2
- package/dst/cjs/native/Integer.js +60 -25
- package/dst/cjs/native/Iterable.d.ts +0 -2
- package/dst/cjs/native/Iterable.js +9 -28
- package/dst/cjs/native/Number.d.ts +0 -2
- package/dst/cjs/native/Number.js +34 -48
- package/dst/cjs/native/Object.d.ts +1 -1
- package/dst/cjs/native/Object.js +5 -6
- package/dst/cjs/native/String.d.ts +7 -6
- package/dst/cjs/native/String.js +28 -27
- package/dst/cjs/native/Timestamp.d.ts +3 -3
- package/dst/cjs/native/Timestamp.js +34 -36
- package/dst/cjs/native/Unknown.d.ts +3 -3
- package/dst/cjs/native/Unknown.js +48 -17
- package/dst/cjs/native/notation/AN.d.ts +1 -1
- package/dst/cjs/native/notation/AN.js +37 -35
- package/dst/cjs/native/notation/IP.d.ts +1 -1
- package/dst/cjs/native/notation/IP.js +11 -12
- package/dst/cjs/native/notation/JSON.d.ts +1 -1
- package/dst/cjs/native/notation/JSON.js +7 -6
- package/dst/cjs/node/AccessNode.d.ts +24 -0
- package/dst/cjs/node/AccessNode.js +193 -0
- package/dst/cjs/node/ArrayNode.d.ts +7 -4
- package/dst/cjs/node/ArrayNode.js +26 -15
- package/dst/cjs/node/AssignableNode.d.ts +16 -0
- package/dst/cjs/node/AssignableNode.js +18 -0
- package/dst/cjs/node/AssignmentNode.d.ts +20 -0
- package/dst/cjs/node/AssignmentNode.js +66 -0
- package/dst/cjs/node/BlockNode.d.ts +5 -4
- package/dst/cjs/node/BlockNode.js +18 -11
- package/dst/cjs/node/CallNode.d.ts +7 -5
- package/dst/cjs/node/CallNode.js +40 -41
- package/dst/cjs/node/CastNode.d.ts +5 -6
- package/dst/cjs/node/CastNode.js +16 -17
- package/dst/cjs/node/ConstantNode.d.ts +4 -6
- package/dst/cjs/node/ConstantNode.js +9 -17
- package/dst/cjs/node/FinalNode.d.ts +19 -0
- package/dst/cjs/node/FinalNode.js +41 -0
- package/dst/cjs/node/FunctionNode.d.ts +17 -0
- package/dst/cjs/node/FunctionNode.js +51 -0
- package/dst/cjs/node/InvocationNode.d.ts +5 -0
- package/dst/cjs/node/InvocationNode.js +34 -0
- package/dst/cjs/node/JumpNode.d.ts +7 -9
- package/dst/cjs/node/JumpNode.js +12 -19
- package/dst/cjs/node/LoopNode.d.ts +7 -5
- package/dst/cjs/node/LoopNode.js +33 -22
- package/dst/cjs/node/MatchNode.d.ts +17 -0
- package/dst/cjs/node/MatchNode.js +65 -0
- package/dst/cjs/node/Node.d.ts +14 -0
- package/dst/cjs/{Node.js → node/Node.js} +17 -11
- package/dst/cjs/node/ObjectNode.d.ts +7 -4
- package/dst/cjs/node/ObjectNode.js +42 -11
- package/dst/cjs/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
- package/dst/cjs/node/TernaryNode.js +45 -0
- package/dst/cjs/node/VariableNode.d.ts +10 -6
- package/dst/cjs/node/VariableNode.js +50 -16
- package/dst/dictionary/Constants.d.ts +2 -0
- package/dst/dictionary/Constants.js +24 -0
- package/dst/dictionary/Functions.d.ts +2 -0
- package/dst/{Functions.js → dictionary/Functions.js} +26 -24
- package/dst/native/Aggregable.js +11 -3
- package/dst/native/Array.d.ts +2 -3
- package/dst/native/Array.js +37 -38
- package/dst/native/Boolean.d.ts +1 -1
- package/dst/native/Boolean.js +12 -9
- package/dst/native/Buffer.d.ts +5 -5
- package/dst/native/Buffer.js +66 -42
- package/dst/native/Composite.d.ts +5 -0
- package/dst/native/Composite.js +32 -0
- package/dst/native/Enumerable.js +20 -8
- package/dst/native/Float.d.ts +3 -1
- package/dst/native/Float.js +48 -11
- package/dst/native/Integer.d.ts +4 -2
- package/dst/native/Integer.js +56 -23
- package/dst/native/Iterable.d.ts +0 -2
- package/dst/native/Iterable.js +8 -27
- package/dst/native/Number.d.ts +0 -2
- package/dst/native/Number.js +34 -46
- package/dst/native/Object.d.ts +1 -1
- package/dst/native/Object.js +4 -5
- package/dst/native/String.d.ts +7 -6
- package/dst/native/String.js +24 -24
- package/dst/native/Timestamp.d.ts +3 -3
- package/dst/native/Timestamp.js +31 -33
- package/dst/native/Unknown.d.ts +3 -3
- package/dst/native/Unknown.js +49 -18
- package/dst/native/notation/AN.d.ts +1 -1
- package/dst/native/notation/AN.js +37 -35
- package/dst/native/notation/IP.d.ts +1 -1
- package/dst/native/notation/IP.js +10 -11
- package/dst/native/notation/JSON.d.ts +1 -1
- package/dst/native/notation/JSON.js +6 -5
- package/dst/node/AccessNode.d.ts +24 -0
- package/dst/node/AccessNode.js +189 -0
- package/dst/node/ArrayNode.d.ts +7 -4
- package/dst/node/ArrayNode.js +26 -15
- package/dst/node/AssignableNode.d.ts +16 -0
- package/dst/node/AssignableNode.js +14 -0
- package/dst/node/AssignmentNode.d.ts +20 -0
- package/dst/node/AssignmentNode.js +62 -0
- package/dst/node/BlockNode.d.ts +5 -4
- package/dst/node/BlockNode.js +18 -11
- package/dst/node/CallNode.d.ts +7 -5
- package/dst/node/CallNode.js +40 -41
- package/dst/node/CastNode.d.ts +5 -6
- package/dst/node/CastNode.js +16 -17
- package/dst/node/ConstantNode.d.ts +4 -6
- package/dst/node/ConstantNode.js +9 -17
- package/dst/node/FinalNode.d.ts +19 -0
- package/dst/node/FinalNode.js +37 -0
- package/dst/node/FunctionNode.d.ts +17 -0
- package/dst/node/FunctionNode.js +47 -0
- package/dst/node/InvocationNode.d.ts +5 -0
- package/dst/node/InvocationNode.js +30 -0
- package/dst/node/JumpNode.d.ts +7 -9
- package/dst/node/JumpNode.js +12 -19
- package/dst/node/LoopNode.d.ts +7 -5
- package/dst/node/LoopNode.js +33 -22
- package/dst/node/MatchNode.d.ts +17 -0
- package/dst/node/MatchNode.js +61 -0
- package/dst/node/Node.d.ts +14 -0
- package/dst/node/Node.js +28 -0
- package/dst/node/ObjectNode.d.ts +7 -4
- package/dst/node/ObjectNode.js +42 -11
- package/dst/node/{SwitchNode.d.ts → TernaryNode.d.ts} +6 -6
- package/dst/node/TernaryNode.js +41 -0
- package/dst/node/VariableNode.d.ts +10 -6
- package/dst/node/VariableNode.js +50 -16
- package/package.json +4 -4
- package/dst/Atom.d.ts +0 -7
- package/dst/Constants.d.ts +0 -2
- package/dst/Constants.js +0 -24
- package/dst/Functions.d.ts +0 -2
- package/dst/Jump.d.ts +0 -1
- package/dst/Jump.js +0 -1
- package/dst/JumpException.d.ts +0 -9
- package/dst/JumpException.js +0 -14
- package/dst/Keywords.d.ts +0 -1
- package/dst/Keywords.js +0 -17
- package/dst/Node.d.ts +0 -14
- package/dst/Node.js +0 -22
- package/dst/ScriptSpan.d.ts +0 -10
- package/dst/cjs/Atom.d.ts +0 -7
- package/dst/cjs/Constants.d.ts +0 -2
- package/dst/cjs/Constants.js +0 -27
- package/dst/cjs/Functions.d.ts +0 -2
- package/dst/cjs/Jump.d.ts +0 -1
- package/dst/cjs/Jump.js +0 -2
- package/dst/cjs/JumpException.d.ts +0 -9
- package/dst/cjs/JumpException.js +0 -18
- package/dst/cjs/Keywords.d.ts +0 -1
- package/dst/cjs/Keywords.js +0 -20
- package/dst/cjs/Node.d.ts +0 -14
- package/dst/cjs/ScriptSpan.d.ts +0 -10
- package/dst/cjs/node/SwitchNode.js +0 -49
- package/dst/cjs/node/VariadicNode.d.ts +0 -4
- package/dst/cjs/node/VariadicNode.js +0 -10
- package/dst/node/SwitchNode.js +0 -45
- package/dst/node/VariadicNode.d.ts +0 -4
- package/dst/node/VariadicNode.js +0 -6
- /package/dst/{Atom.js → atom/Atom.js} +0 -0
- /package/dst/cjs/{Atom.js → atom/Atom.js} +0 -0
|
@@ -1,35 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObjectNode = void 0;
|
|
4
|
-
const Node_js_1 = require("
|
|
4
|
+
const Node_js_1 = require("./Node.js");
|
|
5
5
|
const ConstantNode_js_1 = require("./ConstantNode.js");
|
|
6
6
|
const Type_js_1 = require("../Type.js");
|
|
7
|
-
const CallFrame_js_1 = require("../CallFrame.js");
|
|
8
7
|
class ObjectNode extends Node_js_1.Node {
|
|
9
8
|
_subnodes;
|
|
9
|
+
_uniform;
|
|
10
10
|
_type;
|
|
11
|
-
constructor(span,
|
|
11
|
+
constructor(span, subnodes, uniform = false) {
|
|
12
12
|
super(span);
|
|
13
|
-
this._subnodes =
|
|
14
|
-
this.
|
|
13
|
+
this._subnodes = subnodes;
|
|
14
|
+
this._uniform = uniform;
|
|
15
|
+
const types = subnodes.flatMap(([key, value]) => key instanceof ConstantNode_js_1.ConstantNode && key.constant && key.type.isString ? [[key.value, value.type]] : []);
|
|
16
|
+
this._type = Type_js_1.Type.objectType(uniform ? Type_js_1.Type.union(...subnodes.map(([, value]) => value.type)) : types);
|
|
15
17
|
}
|
|
16
18
|
get type() {
|
|
17
19
|
return this._type;
|
|
18
20
|
}
|
|
19
|
-
|
|
20
|
-
this.
|
|
21
|
+
satisfies(type) {
|
|
22
|
+
return type.isAny || this.type.isNever || type.objectAtoms().some((atom) => this.type.intersects(atom) && Type_js_1.Type.objectType(atom.types).accepts(this.type) && this._subnodes.every(([keyNode, value]) => {
|
|
23
|
+
const key = keyNode instanceof ConstantNode_js_1.ConstantNode && keyNode.constant ? keyNode.value : undefined;
|
|
24
|
+
return value.satisfies(atom.valType(key) ?? Type_js_1.Type.Any);
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
compile(type = Type_js_1.Type.Any) {
|
|
28
|
+
let objectAtoms = type.objectAtoms().filter((atom) => this._type.intersects(atom));
|
|
29
|
+
const valTypes = new Map();
|
|
30
|
+
let never = false;
|
|
21
31
|
for (let i = 0; i < this._subnodes.length; ++i) {
|
|
22
|
-
this._subnodes[i][0] = this._subnodes[i][0].compile(Type_js_1.Type.String);
|
|
23
|
-
|
|
32
|
+
const keyNode = this._subnodes[i][0] = this._subnodes[i][0].compile(Type_js_1.Type.String);
|
|
33
|
+
const key = keyNode instanceof ConstantNode_js_1.ConstantNode && keyNode.constant ? keyNode.value : undefined;
|
|
34
|
+
if (key !== undefined && valTypes.has(key)) {
|
|
35
|
+
keyNode.throwError(`duplicate object key ${JSON.stringify(key)}`);
|
|
36
|
+
}
|
|
37
|
+
const constraints = objectAtoms.map((atom) => atom.valType(key) ?? Type_js_1.Type.Any);
|
|
38
|
+
const firstType = constraints[0];
|
|
39
|
+
const valueType = firstType && constraints.every((candidate) => firstType.equals(candidate)) ? firstType : Type_js_1.Type.Any;
|
|
40
|
+
this._subnodes[i][1] = this._subnodes[i][1].compile(valueType);
|
|
41
|
+
objectAtoms = objectAtoms.filter((_, index) => this._subnodes[i][1].satisfies(constraints[index]));
|
|
42
|
+
never ||= this._subnodes[i][0].type.isNever || this._subnodes[i][1].type.isNever;
|
|
43
|
+
if (key !== undefined) {
|
|
44
|
+
valTypes.set(key, this._subnodes[i][1].type);
|
|
45
|
+
}
|
|
24
46
|
}
|
|
25
|
-
|
|
47
|
+
this._type = never
|
|
48
|
+
? Type_js_1.Type.Never
|
|
49
|
+
: Type_js_1.Type.objectType(this._uniform ? Type_js_1.Type.union(...this._subnodes.map(([, value]) => value.type)) : [...valTypes]);
|
|
50
|
+
return super.compile(type);
|
|
26
51
|
}
|
|
27
52
|
evaluate(frame) {
|
|
28
53
|
const result = Object.create(null);
|
|
29
54
|
for (const [key, value] of this._subnodes) {
|
|
30
55
|
result[key.evaluate(frame)] = value.evaluate(frame);
|
|
31
56
|
}
|
|
32
|
-
|
|
57
|
+
if (!this._type.acceptsValue(result)) {
|
|
58
|
+
this.throwError(`object value mismatch with expected type ${this._type}`);
|
|
59
|
+
}
|
|
60
|
+
return frame.define(result, this.type);
|
|
61
|
+
}
|
|
62
|
+
get constant() {
|
|
63
|
+
return this._subnodes.every(([key, value]) => key.constant && value.constant);
|
|
33
64
|
}
|
|
34
65
|
toString(ident = 0) {
|
|
35
66
|
const subnodes = this._subnodes.map(([k, v]) => `${k.toString(ident + 1)}:\n${v.toString(ident + 1)}`).join("\n");
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Node } from "
|
|
2
|
-
import {
|
|
1
|
+
import { Node } from "./Node.js";
|
|
2
|
+
import { ParserSpan } from "../ParserSpan.js";
|
|
3
3
|
import { Value } from "../Value.js";
|
|
4
4
|
import { Type } from "../Type.js";
|
|
5
5
|
import { CallFrame } from "../CallFrame.js";
|
|
6
|
-
export declare class
|
|
6
|
+
export declare class TernaryNode extends Node {
|
|
7
7
|
protected _cnode: Node;
|
|
8
8
|
protected _subnodes: Node[];
|
|
9
|
-
|
|
10
|
-
constructor(span: ScriptSpan, _cnode: Node, _subnodes: Node[]);
|
|
9
|
+
constructor(span: ParserSpan, cnode: Node, subnodes: Node[]);
|
|
11
10
|
get type(): Type;
|
|
12
|
-
|
|
11
|
+
satisfies(type: Type): boolean;
|
|
12
|
+
compile(type?: Type): Node;
|
|
13
13
|
evaluate(frame: CallFrame): Value;
|
|
14
14
|
toString(ident?: number): string;
|
|
15
15
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TernaryNode = void 0;
|
|
4
|
+
const Node_js_1 = require("./Node.js");
|
|
5
|
+
const Type_js_1 = require("../Type.js");
|
|
6
|
+
const CallFrame_js_1 = require("../CallFrame.js");
|
|
7
|
+
class TernaryNode extends Node_js_1.Node {
|
|
8
|
+
_cnode;
|
|
9
|
+
_subnodes;
|
|
10
|
+
constructor(span, cnode, subnodes) {
|
|
11
|
+
super(span);
|
|
12
|
+
this._cnode = cnode;
|
|
13
|
+
this._subnodes = subnodes.slice(0, 2);
|
|
14
|
+
}
|
|
15
|
+
get type() {
|
|
16
|
+
return this._cnode.type.isNever ? Type_js_1.Type.Never : Type_js_1.Type.union(...this._subnodes.map((i) => i.type));
|
|
17
|
+
}
|
|
18
|
+
satisfies(type) {
|
|
19
|
+
return this._cnode.type.isNever || this._subnodes.every((node) => node.satisfies(type));
|
|
20
|
+
}
|
|
21
|
+
compile(type = Type_js_1.Type.Any) {
|
|
22
|
+
this._cnode = this._cnode.compile(Type_js_1.Type.Boolean);
|
|
23
|
+
if (this._cnode.constant) {
|
|
24
|
+
const index = this._cnode.evaluate(new CallFrame_js_1.CallFrame()) ? 0 : 1;
|
|
25
|
+
this._subnodes[1 - index] = this._subnodes[1 - index].compile();
|
|
26
|
+
return this._subnodes[index].compile(type);
|
|
27
|
+
}
|
|
28
|
+
const branchType = this._cnode.type.isNever ? Type_js_1.Type.Any : type;
|
|
29
|
+
for (let i = 0; i < this._subnodes.length; ++i) {
|
|
30
|
+
this._subnodes[i] = this._subnodes[i].compile(branchType);
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
}
|
|
34
|
+
evaluate(frame) {
|
|
35
|
+
return this._cnode.evaluate(frame)
|
|
36
|
+
? this._subnodes[0].evaluate(frame)
|
|
37
|
+
: this._subnodes[1].evaluate(frame);
|
|
38
|
+
}
|
|
39
|
+
toString(ident = 0) {
|
|
40
|
+
const subnodes = this._subnodes.map((s) => s.toString(ident + 1)).join("\n");
|
|
41
|
+
return `${super.toString(ident)} ternary node condition node:\n${this._cnode.toString(ident + 1)}\n`
|
|
42
|
+
+ `${super.toString(ident)} ternary node subnodes:\n${subnodes}`;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.TernaryNode = TernaryNode;
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { AssignableNode, AssignmentResolver } from "./AssignableNode.js";
|
|
2
|
+
import { ParserSpan } from "../ParserSpan.js";
|
|
3
3
|
import { Variable } from "../Variable.js";
|
|
4
4
|
import { Value } from "../Value.js";
|
|
5
5
|
import { Type } from "../Type.js";
|
|
6
6
|
import { CallFrame } from "../CallFrame.js";
|
|
7
|
-
export declare class VariableNode extends
|
|
7
|
+
export declare class VariableNode extends AssignableNode {
|
|
8
8
|
protected readonly _variable: Variable;
|
|
9
|
-
protected
|
|
10
|
-
|
|
9
|
+
protected readonly _initializer: boolean;
|
|
10
|
+
protected _type?: Type;
|
|
11
|
+
constructor(span: ParserSpan, variable: Variable, initializer?: boolean);
|
|
12
|
+
get assignable(): boolean;
|
|
11
13
|
get type(): Type;
|
|
12
|
-
compile(type
|
|
14
|
+
compile(type?: Type): AssignableNode;
|
|
15
|
+
compileAssignment(type: Type): AssignableNode;
|
|
13
16
|
evaluate(frame: CallFrame): Value;
|
|
17
|
+
resolver(frame: CallFrame): AssignmentResolver;
|
|
14
18
|
toString(ident?: number): string;
|
|
15
19
|
}
|
|
@@ -1,32 +1,66 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.VariableNode = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
4
|
+
const AssignableNode_js_1 = require("./AssignableNode.js");
|
|
5
|
+
const Variable_js_1 = require("../Variable.js");
|
|
6
|
+
const Type_js_1 = require("../Type.js");
|
|
7
|
+
class VariableNode extends AssignableNode_js_1.AssignableNode {
|
|
6
8
|
_variable;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
_initializer;
|
|
10
|
+
_type;
|
|
11
|
+
constructor(span, variable, initializer = false) {
|
|
9
12
|
super(span);
|
|
10
|
-
this._variable =
|
|
11
|
-
this.
|
|
13
|
+
this._variable = variable;
|
|
14
|
+
this._initializer = initializer;
|
|
15
|
+
}
|
|
16
|
+
get assignable() {
|
|
17
|
+
return this._variable instanceof Variable_js_1.LocalVariable && this._variable.assignable;
|
|
12
18
|
}
|
|
13
19
|
get type() {
|
|
14
|
-
return this._variable.
|
|
20
|
+
return this._type ?? (this._variable instanceof Variable_js_1.InputVariable && !this._variable.declared
|
|
21
|
+
? Type_js_1.Type.Any
|
|
22
|
+
: this._variable.type);
|
|
23
|
+
}
|
|
24
|
+
compile(type = Type_js_1.Type.Any) {
|
|
25
|
+
if (this._variable instanceof Variable_js_1.InputVariable && !this._variable.declared) {
|
|
26
|
+
this._type = this._variable.type;
|
|
27
|
+
if (!type.isAny && !type.isNull && !type.isNever) {
|
|
28
|
+
this._type = type === Type_js_1.Type.Function ? this._type.reduce(type) ?? type : type;
|
|
29
|
+
this._variable.declare(this._type);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
super.compile(type);
|
|
33
|
+
return this;
|
|
15
34
|
}
|
|
16
|
-
|
|
17
|
-
this.
|
|
18
|
-
|
|
35
|
+
compileAssignment(type) {
|
|
36
|
+
if (!(this._variable instanceof Variable_js_1.LocalVariable)) {
|
|
37
|
+
this.throwError("illegal re-assignment");
|
|
38
|
+
}
|
|
39
|
+
if (this._initializer) {
|
|
40
|
+
this._variable.declare(type);
|
|
41
|
+
}
|
|
42
|
+
if (!this.reduceAssignmentType(type)) {
|
|
43
|
+
this._throwTypeError(type);
|
|
44
|
+
}
|
|
19
45
|
return this;
|
|
20
46
|
}
|
|
21
47
|
evaluate(frame) {
|
|
22
|
-
return this.
|
|
23
|
-
|
|
24
|
-
|
|
48
|
+
return frame.get(this._variable);
|
|
49
|
+
}
|
|
50
|
+
resolver(frame) {
|
|
51
|
+
return {
|
|
52
|
+
set: (value) => {
|
|
53
|
+
const type = this._variable.type;
|
|
54
|
+
if (!type.acceptsValue(value)) {
|
|
55
|
+
this.throwError(`type ${Type_js_1.Type.of(value)} mismatch with expected type ${type}`);
|
|
56
|
+
}
|
|
57
|
+
return frame.set(this._variable, value);
|
|
58
|
+
},
|
|
59
|
+
get: () => frame.get(this._variable),
|
|
60
|
+
};
|
|
25
61
|
}
|
|
26
62
|
toString(ident = 0) {
|
|
27
|
-
return
|
|
28
|
-
? `${super.toString(ident)} variable node subnode:\n${this._subnode.toString(ident + 1)}`
|
|
29
|
-
: `${super.toString(ident)} variable node`;
|
|
63
|
+
return `${super.toString(ident)} variable node`;
|
|
30
64
|
}
|
|
31
65
|
}
|
|
32
66
|
exports.VariableNode = VariableNode;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { globArray } from "../native/Array.js";
|
|
2
|
+
import { globBoolean } from "../native/Boolean.js";
|
|
3
|
+
import { globBuffer } from "../native/Buffer.js";
|
|
4
|
+
import { globFloat } from "../native/Float.js";
|
|
5
|
+
import { globInteger } from "../native/Integer.js";
|
|
6
|
+
import { globObject } from "../native/Object.js";
|
|
7
|
+
import { globString } from "../native/String.js";
|
|
8
|
+
import { globTimestamp } from "../native/Timestamp.js";
|
|
9
|
+
import { globAN } from "../native/notation/AN.js";
|
|
10
|
+
import { globIP } from "../native/notation/IP.js";
|
|
11
|
+
import { globJSON } from "../native/notation/JSON.js";
|
|
12
|
+
export const constants = [
|
|
13
|
+
["Array", globArray],
|
|
14
|
+
["Boolean", globBoolean],
|
|
15
|
+
["Buffer", globBuffer],
|
|
16
|
+
["Float", globFloat],
|
|
17
|
+
["Integer", globInteger],
|
|
18
|
+
["Object", globObject],
|
|
19
|
+
["String", globString],
|
|
20
|
+
["Timestamp", globTimestamp],
|
|
21
|
+
["AN", globAN],
|
|
22
|
+
["IP", globIP],
|
|
23
|
+
["JSON", globJSON],
|
|
24
|
+
];
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { funcAdd } from "
|
|
2
|
-
import { funcFirst, funcLast, funcFirstIndex, funcLastIndex, funcEvery, funcAny, funcFlatten, funcReverse, funcDerive, funcFilter, funcReduce, funcCompose
|
|
3
|
-
import { funcBoolean } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
import { funcAdd } from "../native/Aggregable.js";
|
|
2
|
+
import { funcFirst, funcLast, funcFirstIndex, funcLastIndex, funcEvery, funcAny, funcFlatten, funcReverse, funcDerive, funcFilter, funcReduce, funcCompose } from "../native/Array.js";
|
|
3
|
+
import { funcBoolean } from "../native/Boolean.js";
|
|
4
|
+
import { funcByteAt } from "../native/Buffer.js";
|
|
5
|
+
import { funcAt, funcOptionalAt, funcHas, funcOptionalHas } from "../native/Composite.js";
|
|
6
|
+
import { funcSlice, funcSplice, funcInject } from "../native/Enumerable.js";
|
|
7
|
+
import { funcFloat } from "../native/Float.js";
|
|
8
|
+
import { funcInteger } from "../native/Integer.js";
|
|
9
|
+
import { funcLength, funcContains } from "../native/Iterable.js";
|
|
10
|
+
import { funcGreaterThan, funcLessThan, funcGreaterOrEqual, funcLessOrEqual, funcSubtract, funcMultiply, funcDivide, funcRemainder, funcModulo, funcPower, funcRoot, funcNegate } from "../native/Number.js";
|
|
11
|
+
import { funcEntries, funcKeys, funcValues } from "../native/Object.js";
|
|
12
|
+
import { funcLike, funcNotLike, funcStartsWith, funcEndsWith, funcCharAt, funcCharCodeAt, funcTrim, funcTrimStart, funcTrimEnd, funcLowerCase, funcUpperCase, funcSplit, funcReplaceWith } from "../native/String.js";
|
|
13
|
+
import { funcYear, funcMonth, funcMonthIndex, funcWeekdayIndex, funcDay, funcHour, funcMinute, funcSecond, funcMillisecond, funcEpochTime, funcDaysSince, funcHoursSince, funcMinutesSince, funcSecondsSince } from "../native/Timestamp.js";
|
|
14
|
+
import { funcCoalesce, funcEquals, funcNotEquals, funcEncode, funcFormat } from "../native/Unknown.js";
|
|
15
|
+
export const functions = [
|
|
15
16
|
// Aggregable
|
|
16
17
|
["Add", funcAdd],
|
|
17
18
|
// Array
|
|
@@ -27,10 +28,13 @@ export const Functions = [
|
|
|
27
28
|
["Filter", funcFilter],
|
|
28
29
|
["Reduce", funcReduce],
|
|
29
30
|
["Compose", funcCompose],
|
|
30
|
-
["Prepend", funcPrepend],
|
|
31
|
-
["Append", funcAppend],
|
|
32
31
|
// Buffer
|
|
33
|
-
["
|
|
32
|
+
["ByteAt", funcByteAt],
|
|
33
|
+
// Composite
|
|
34
|
+
["At", funcAt],
|
|
35
|
+
["OptionalAt", funcOptionalAt],
|
|
36
|
+
["Has", funcHas],
|
|
37
|
+
["OptionalHas", funcOptionalHas],
|
|
34
38
|
// Enumerable
|
|
35
39
|
["Slice", funcSlice],
|
|
36
40
|
["Splice", funcSplice],
|
|
@@ -38,8 +42,6 @@ export const Functions = [
|
|
|
38
42
|
// Iterable
|
|
39
43
|
["Length", funcLength],
|
|
40
44
|
["Contains", funcContains],
|
|
41
|
-
["At", funcAt],
|
|
42
|
-
["Has", funcHas],
|
|
43
45
|
// Number
|
|
44
46
|
["GreaterThan", funcGreaterThan],
|
|
45
47
|
["LessThan", funcLessThan],
|
|
@@ -62,11 +64,11 @@ export const Functions = [
|
|
|
62
64
|
["Values", funcValues],
|
|
63
65
|
// String
|
|
64
66
|
["Like", funcLike],
|
|
65
|
-
["
|
|
67
|
+
["NotLike", funcNotLike],
|
|
66
68
|
["StartsWith", funcStartsWith],
|
|
67
69
|
["EndsWith", funcEndsWith],
|
|
68
|
-
["
|
|
69
|
-
["
|
|
70
|
+
["CharAt", funcCharAt],
|
|
71
|
+
["CharCodeAt", funcCharCodeAt],
|
|
70
72
|
["Trim", funcTrim],
|
|
71
73
|
["TrimStart", funcTrimStart],
|
|
72
74
|
["TrimEnd", funcTrimEnd],
|
|
@@ -91,8 +93,8 @@ export const Functions = [
|
|
|
91
93
|
["SecondsSince", funcSecondsSince],
|
|
92
94
|
// Unknown
|
|
93
95
|
["Coalesce", funcCoalesce],
|
|
94
|
-
["
|
|
95
|
-
["
|
|
96
|
+
["Equals", funcEquals],
|
|
97
|
+
["NotEquals", funcNotEquals],
|
|
96
98
|
["Encode", funcEncode],
|
|
97
99
|
["Format", funcFormat],
|
|
98
100
|
];
|
package/dst/native/Aggregable.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
import { Type } from "../Type.js";
|
|
3
3
|
import { concatBuffers } from "./Buffer.js";
|
|
4
|
-
import {
|
|
4
|
+
import { int64 } from "./Integer.js";
|
|
5
5
|
export const aggregate = (value1, value2) => {
|
|
6
6
|
if (value1 == null || value2 == null) {
|
|
7
7
|
return undefined;
|
|
@@ -16,11 +16,19 @@ export const aggregate = (value1, value2) => {
|
|
|
16
16
|
};
|
|
17
17
|
const add = (value1, value2) => {
|
|
18
18
|
if (typeof value1 === "bigint" && typeof value2 === "bigint") {
|
|
19
|
-
return
|
|
19
|
+
return int64(value1 + value2);
|
|
20
20
|
}
|
|
21
21
|
if ((typeof value1 === "number" || typeof value1 === "bigint") && (typeof value2 === "number" || typeof value2 === "bigint")) {
|
|
22
22
|
return Number(value1) + Number(value2);
|
|
23
23
|
}
|
|
24
24
|
return aggregate(value1, value2);
|
|
25
25
|
};
|
|
26
|
-
export const funcAdd = new Constant((value1, value2) => add(value1, value2), Type.
|
|
26
|
+
export const funcAdd = new Constant((value1, value2) => add(value1, value2), Type.functionType([
|
|
27
|
+
[Type.Integer, [Type.Integer, Type.Integer]],
|
|
28
|
+
[Type.Float, [Type.Float, Type.Number]],
|
|
29
|
+
[Type.Float, [Type.Number, Type.Float]],
|
|
30
|
+
[Type.Number, [Type.Number, Type.Number]],
|
|
31
|
+
[Type.Buffer, [Type.Buffer, Type.Buffer]],
|
|
32
|
+
[Type.String, [Type.String, Type.String]],
|
|
33
|
+
[Type.Array, [Type.Array, Type.Array]],
|
|
34
|
+
]));
|
package/dst/native/Array.d.ts
CHANGED
|
@@ -11,6 +11,5 @@ export declare const funcDerive: Constant;
|
|
|
11
11
|
export declare const funcFilter: Constant;
|
|
12
12
|
export declare const funcReduce: Constant;
|
|
13
13
|
export declare const funcCompose: Constant;
|
|
14
|
-
export declare const
|
|
15
|
-
export declare const
|
|
16
|
-
export declare const constArray: any;
|
|
14
|
+
export declare const funcRange: Constant;
|
|
15
|
+
export declare const globArray: any;
|
package/dst/native/Array.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
import { Type } from "../Type.js";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const typeVariadicInsert = Type.functionType(Type.Array, [Type.Array, Type.Array], true);
|
|
10
|
-
const typeArrayOperator = Type.functionType(Type.Array, [Type.Array, Type.Array]);
|
|
3
|
+
import { equals } from "./Unknown.js";
|
|
4
|
+
const typePredicate = Type.functionType([[Type.Boolean, [Type.Any, Type.Integer, Type.Array]]]);
|
|
5
|
+
const typeItemFinder = Type.functionType([[Type.Any, [Type.Array, typePredicate]]]);
|
|
6
|
+
const typeIndexFinder = Type.functionType([[Type.OptionalInteger, [Type.Array, typePredicate]]]);
|
|
7
|
+
const typeConditionSet = Type.functionType([[Type.Boolean, [Type.Array, typePredicate]]]);
|
|
8
|
+
const typeArrayOperator = Type.functionType([[Type.Array, [Type.Array, Type.Array]]]);
|
|
11
9
|
export const funcFirst = new Constant((value, predicate) => value?.find((v, i, a) => predicate(v, BigInt(i), a)), typeItemFinder);
|
|
12
10
|
export const funcLast = new Constant((value, predicate) => {
|
|
13
11
|
if (value == null) {
|
|
@@ -25,7 +23,7 @@ export const funcFirstIndex = new Constant((value, predicate) => {
|
|
|
25
23
|
return undefined;
|
|
26
24
|
}
|
|
27
25
|
const ix = value.findIndex((v, i, a) => predicate(v, BigInt(i), a));
|
|
28
|
-
return ix < 0 ? undefined :
|
|
26
|
+
return ix < 0 ? undefined : BigInt(ix);
|
|
29
27
|
}, typeIndexFinder);
|
|
30
28
|
export const funcLastIndex = new Constant((value, predicate) => {
|
|
31
29
|
if (value == null) {
|
|
@@ -33,58 +31,59 @@ export const funcLastIndex = new Constant((value, predicate) => {
|
|
|
33
31
|
}
|
|
34
32
|
for (let i = value.length - 1; i >= 0; i--) {
|
|
35
33
|
if (predicate(value[i], BigInt(i), value)) {
|
|
36
|
-
return
|
|
34
|
+
return BigInt(i);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
37
|
return undefined;
|
|
40
38
|
}, typeIndexFinder);
|
|
41
39
|
export const funcEvery = new Constant((value, predicate) => value?.every((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
42
40
|
export const funcAny = new Constant((value, predicate) => value?.some((v, i, a) => predicate(v, BigInt(i), a)) ?? false, typeConditionSet);
|
|
43
|
-
export const funcFlatten = new Constant((values, depth = 1n) => values ? values?.flat(Number(depth)) : undefined, Type.functionType(Type.Array, [Type.Array, Type.OptionalInteger]));
|
|
44
|
-
export const funcReverse = new Constant((value) => value ? [...value].reverse() : undefined, Type.functionType(Type.Array, [Type.Array]));
|
|
45
|
-
export const funcDerive = new Constant((value, transform) => value?.map((v, i, a) => transform(v, BigInt(i), a)), Type.functionType(
|
|
46
|
-
|
|
41
|
+
export const funcFlatten = new Constant((values, depth = 1n) => values ? values?.flat(Number(depth)) : undefined, Type.functionType([[Type.Array, [Type.Array, Type.OptionalInteger]]]));
|
|
42
|
+
export const funcReverse = new Constant((value) => value ? [...value].reverse() : undefined, Type.functionType([[Type.Array, [Type.Array]]]));
|
|
43
|
+
export const funcDerive = new Constant((value, transform) => value?.map((v, i, a) => transform(v, BigInt(i), a)), Type.functionType([[Type.Array, [
|
|
44
|
+
Type.Array,
|
|
45
|
+
Type.functionType([[Type.Any, [Type.Any, Type.Integer, Type.Array]]]),
|
|
46
|
+
]]]));
|
|
47
|
+
export const funcFilter = new Constant((value, predicate) => value?.filter((v, i, a) => predicate(v, BigInt(i), a)), Type.functionType([[Type.Array, [Type.Array, typePredicate]]]));
|
|
47
48
|
export const funcReduce = new Constant((value, reducer, initial) => initial != null
|
|
48
49
|
? value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a), initial)
|
|
49
|
-
: value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a)), Type.functionType(
|
|
50
|
+
: value?.reduce((p, v, i, a) => reducer(p, v, BigInt(i), a)), Type.functionType([[Type.Any, [
|
|
51
|
+
Type.Array,
|
|
52
|
+
Type.functionType([[Type.Any, [Type.Any, Type.Any, Type.Integer, Type.Array]]]),
|
|
53
|
+
Type.Any,
|
|
54
|
+
]]]));
|
|
50
55
|
export const funcCompose = new Constant((value, callback) => {
|
|
51
56
|
if (value == null) {
|
|
52
57
|
return undefined;
|
|
53
58
|
}
|
|
54
|
-
|
|
59
|
+
let obj = Object.create(null);
|
|
55
60
|
for (let i = 0; i < value.length; ++i) {
|
|
56
61
|
const key = value[i];
|
|
57
|
-
|
|
62
|
+
const item = callback(obj, key, BigInt(i), value);
|
|
63
|
+
obj = Object.assign(Object.create(null), obj, { [key]: item });
|
|
58
64
|
}
|
|
59
65
|
return obj;
|
|
60
|
-
}, Type.functionType(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
export const
|
|
66
|
-
|
|
67
|
-
return
|
|
68
|
-
},
|
|
69
|
-
const funcJoin = new Constant((values) => values.flat(Infinity), Type.functionType(Type.Array, [Type.arrayType([Type.Array])], true));
|
|
70
|
-
const funcRange = new Constant((value1, value2) => {
|
|
71
|
-
const v1 = boundInteger(value1);
|
|
72
|
-
const v2 = boundInteger(value2);
|
|
73
|
-
const [min, max] = v1 < v2 ? [v1, v2] : [v2, v1];
|
|
74
|
-
return [...Array(Number(max - min)).keys()].map((i) => BigInt(i) + min);
|
|
75
|
-
}, Type.functionType(Type.Array, [Type.Integer, Type.Integer]));
|
|
66
|
+
}, Type.functionType([[Type.Object, [
|
|
67
|
+
Type.Array,
|
|
68
|
+
Type.functionType([[Type.Any, [Type.Object, Type.String, Type.Integer, Type.Array]]]),
|
|
69
|
+
]]]));
|
|
70
|
+
const funcJoin = new Constant((...values) => values.flat(), Type.functionType([[Type.Array, [Type.arrayType(Type.Array)], true]]));
|
|
71
|
+
export const funcRange = new Constant((value1, value2) => {
|
|
72
|
+
const [min, max] = value1 < value2 ? [value1, value2] : [value2, value1];
|
|
73
|
+
return [...Array(Number(max - min) + 1).keys()].map((i) => BigInt(i) + min);
|
|
74
|
+
}, Type.functionType([[Type.arrayType(Type.Integer), [Type.Integer, Type.Integer]]]));
|
|
76
75
|
const funcUnique = new Constant((value) => {
|
|
77
76
|
const result = [];
|
|
78
77
|
value?.forEach((i) => {
|
|
79
|
-
if (result.every((v) => !
|
|
78
|
+
if (result.every((v) => !equals(v, i))) {
|
|
80
79
|
result.push(i);
|
|
81
80
|
}
|
|
82
81
|
});
|
|
83
82
|
return result;
|
|
84
|
-
}, Type.functionType(Type.Array, [Type.Array]));
|
|
85
|
-
const funcIntersection = new Constant((value1, value2) => value1?.filter((i) => value2?.some((v) =>
|
|
86
|
-
const funcDifference = new Constant((value1, value2) => [...value1?.filter((i) => value2?.every((v) => !
|
|
87
|
-
export const
|
|
83
|
+
}, Type.functionType([[Type.Array, [Type.Array]]]));
|
|
84
|
+
const funcIntersection = new Constant((value1, value2) => value1?.filter((i) => value2?.some((v) => equals(v, i))) ?? [], typeArrayOperator);
|
|
85
|
+
const funcDifference = new Constant((value1, value2) => [...value1?.filter((i) => value2?.every((v) => !equals(v, i))) ?? [], ...value2?.filter((i) => value1?.every((v) => !equals(v, i))) ?? []], typeArrayOperator);
|
|
86
|
+
export const globArray = Object.assign(Object.create(null), {
|
|
88
87
|
Join: funcJoin,
|
|
89
88
|
Range: funcRange,
|
|
90
89
|
Unique: funcUnique,
|
package/dst/native/Boolean.d.ts
CHANGED
package/dst/native/Boolean.js
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
import { Type } from "../Type.js";
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const funcNot = new Constant((value) => !value, Type.functionType(Type.Boolean, [Type.Boolean]));
|
|
3
|
+
const typeBooleanLogic = Type.functionType([[Type.Boolean, [Type.arrayType(Type.Boolean)], true]]);
|
|
4
|
+
export const funcOr = new Constant((...values) => values.some((v) => v), typeBooleanLogic);
|
|
5
|
+
export const funcAnd = new Constant((...values) => values.every((v) => v), typeBooleanLogic);
|
|
6
|
+
export const funcNot = new Constant((value) => !value, Type.functionType([[Type.Boolean, [Type.Boolean]]]));
|
|
8
7
|
const funcDecodeBoolean = new Constant((value, byteOffset) => {
|
|
9
8
|
const offset = byteOffset == null ? 0 : Number(byteOffset);
|
|
10
9
|
return !value || offset < 0 || value.byteLength < offset + 1
|
|
11
10
|
? undefined
|
|
12
11
|
: Boolean(new Uint8Array(value)[offset]);
|
|
13
|
-
}, Type.functionType(Type.OptionalBoolean, [Type.OptionalBuffer, Type.OptionalInteger]));
|
|
12
|
+
}, Type.functionType([[Type.OptionalBoolean, [Type.OptionalBuffer, Type.OptionalInteger]]]));
|
|
14
13
|
const funcParseBoolean = new Constant((value) => {
|
|
15
14
|
if (value == null) {
|
|
16
15
|
return undefined;
|
|
17
16
|
}
|
|
18
17
|
const v = value.toLowerCase();
|
|
19
18
|
return v === "true" ? true : v === "false" ? false : undefined;
|
|
20
|
-
}, Type.functionType(Type.OptionalBoolean, [Type.OptionalString]));
|
|
21
|
-
export const funcBoolean = new Constant((value) => typeof value === "bigint" ? value !== 0n : Boolean(Number(value)), Type.
|
|
22
|
-
|
|
19
|
+
}, Type.functionType([[Type.OptionalBoolean, [Type.OptionalString]]]));
|
|
20
|
+
export const funcBoolean = new Constant((value) => typeof value === "bigint" ? value !== 0n : Boolean(Number(value)), Type.functionType([
|
|
21
|
+
[Type.Boolean, [Type.Timestamp]],
|
|
22
|
+
[Type.Boolean, [Type.Float]],
|
|
23
|
+
[Type.Boolean, [Type.Integer]],
|
|
24
|
+
]));
|
|
25
|
+
export const globBoolean = Object.assign(Object.create(null), {
|
|
23
26
|
Or: funcOr,
|
|
24
27
|
And: funcAnd,
|
|
25
28
|
Not: funcNot,
|
package/dst/native/Buffer.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Constant } from "../Constant.js";
|
|
2
2
|
export type BufferFormatting = "hex" | "base64";
|
|
3
3
|
export declare const EmptyBuffer: ArrayBuffer;
|
|
4
|
-
export declare const formatLiteralBuffer: (value: ArrayBuffer) => string;
|
|
5
|
-
export declare const parseLiteralBuffer: (value: string, offset?: number) => readonly [ArrayBuffer, number];
|
|
6
4
|
export declare const parseBoundedInteger: (input: string, base: 10 | 16, min: number, max: number) => number;
|
|
7
|
-
export declare const
|
|
5
|
+
export declare const equalsBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => boolean;
|
|
8
6
|
export declare const containsBuffer: (value: ArrayBuffer, search: ArrayBuffer, startPos?: number) => boolean;
|
|
9
7
|
export declare const concatBuffers: (value1: ArrayBuffer, value2: ArrayBuffer) => ArrayBuffer;
|
|
10
8
|
export declare const formatBuffer: (value: ArrayBuffer, formatting?: BufferFormatting) => string;
|
|
11
9
|
export declare const parseBuffer: (value?: string) => ArrayBuffer | undefined;
|
|
12
|
-
export declare const
|
|
13
|
-
export declare const
|
|
10
|
+
export declare const formatLiteralBuffer: (value: ArrayBuffer) => string;
|
|
11
|
+
export declare const parseLiteralBuffer: (value: string, offset?: number) => readonly [ArrayBuffer, number];
|
|
12
|
+
export declare const funcByteAt: Constant;
|
|
13
|
+
export declare const globBuffer: any;
|