affinirum 1.4.2 → 1.5.1

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.
Files changed (89) hide show
  1. package/README.md +226 -154
  2. package/dst/Affinirum.js +24 -15
  3. package/dst/Atom.d.ts +3 -1
  4. package/dst/Constant.js +1 -1
  5. package/dst/Functions.js +7 -4
  6. package/dst/Keywords.js +4 -4
  7. package/dst/ParserState.d.ts +2 -1
  8. package/dst/ParserState.js +43 -82
  9. package/dst/Type.d.ts +11 -7
  10. package/dst/Type.js +113 -38
  11. package/dst/Value.d.ts +1 -0
  12. package/dst/Value.js +19 -1
  13. package/dst/atom/ArrayAtom.d.ts +7 -3
  14. package/dst/atom/ArrayAtom.js +53 -8
  15. package/dst/atom/FunctionAtom.d.ts +4 -1
  16. package/dst/atom/FunctionAtom.js +65 -15
  17. package/dst/atom/ObjectAtom.d.ts +7 -5
  18. package/dst/atom/ObjectAtom.js +35 -13
  19. package/dst/atom/PrimitiveAtom.d.ts +3 -1
  20. package/dst/atom/PrimitiveAtom.js +10 -1
  21. package/dst/cjs/Affinirum.js +24 -15
  22. package/dst/cjs/Constant.js +1 -1
  23. package/dst/cjs/Functions.js +6 -3
  24. package/dst/cjs/Keywords.js +4 -4
  25. package/dst/cjs/ParserState.js +42 -81
  26. package/dst/cjs/Type.js +113 -38
  27. package/dst/cjs/Value.js +21 -0
  28. package/dst/cjs/atom/ArrayAtom.js +53 -8
  29. package/dst/cjs/atom/FunctionAtom.js +65 -15
  30. package/dst/cjs/atom/ObjectAtom.js +35 -13
  31. package/dst/cjs/atom/PrimitiveAtom.js +10 -1
  32. package/dst/cjs/native/Aggregable.js +3 -2
  33. package/dst/cjs/native/Array.js +10 -8
  34. package/dst/cjs/native/Boolean.js +8 -5
  35. package/dst/cjs/native/Buffer.js +32 -3
  36. package/dst/cjs/native/Enumerable.js +7 -4
  37. package/dst/cjs/native/Float.js +26 -13
  38. package/dst/cjs/native/Integer.js +64 -28
  39. package/dst/cjs/native/Iterable.js +8 -5
  40. package/dst/cjs/native/Number.js +62 -33
  41. package/dst/cjs/native/Object.js +2 -1
  42. package/dst/cjs/native/String.js +71 -24
  43. package/dst/cjs/native/Timestamp.js +76 -18
  44. package/dst/cjs/native/Unknown.js +1 -1
  45. package/dst/cjs/native/notation/AN.js +152 -11
  46. package/dst/cjs/native/notation/IP.js +4 -3
  47. package/dst/cjs/native/notation/JSON.js +1 -1
  48. package/dst/cjs/node/ArrayNode.js +6 -6
  49. package/dst/cjs/node/BlockNode.js +5 -4
  50. package/dst/cjs/node/CallNode.js +28 -22
  51. package/dst/cjs/node/CastNode.js +42 -0
  52. package/dst/cjs/node/ObjectNode.js +2 -4
  53. package/dst/cjs/node/SwitchNode.js +10 -10
  54. package/dst/cjs/node/VariableNode.js +3 -1
  55. package/dst/native/Aggregable.js +3 -2
  56. package/dst/native/Array.js +10 -8
  57. package/dst/native/Boolean.d.ts +1 -0
  58. package/dst/native/Boolean.js +7 -4
  59. package/dst/native/Buffer.d.ts +2 -0
  60. package/dst/native/Buffer.js +29 -2
  61. package/dst/native/Enumerable.js +7 -4
  62. package/dst/native/Float.d.ts +2 -0
  63. package/dst/native/Float.js +25 -12
  64. package/dst/native/Integer.d.ts +5 -1
  65. package/dst/native/Integer.js +61 -27
  66. package/dst/native/Iterable.js +8 -5
  67. package/dst/native/Number.d.ts +4 -3
  68. package/dst/native/Number.js +57 -32
  69. package/dst/native/Object.js +2 -1
  70. package/dst/native/String.d.ts +2 -7
  71. package/dst/native/String.js +68 -16
  72. package/dst/native/Timestamp.d.ts +4 -2
  73. package/dst/native/Timestamp.js +73 -17
  74. package/dst/native/Unknown.js +1 -1
  75. package/dst/native/notation/AN.d.ts +1 -0
  76. package/dst/native/notation/AN.js +152 -12
  77. package/dst/native/notation/IP.js +4 -3
  78. package/dst/native/notation/JSON.js +1 -1
  79. package/dst/node/ArrayNode.d.ts +1 -1
  80. package/dst/node/ArrayNode.js +6 -6
  81. package/dst/node/BlockNode.js +5 -4
  82. package/dst/node/CallNode.js +28 -22
  83. package/dst/node/CastNode.d.ts +15 -0
  84. package/dst/node/CastNode.js +38 -0
  85. package/dst/node/ObjectNode.d.ts +1 -1
  86. package/dst/node/ObjectNode.js +2 -4
  87. package/dst/node/SwitchNode.js +10 -10
  88. package/dst/node/VariableNode.js +3 -1
  89. package/package.json +5 -4
package/dst/Value.js CHANGED
@@ -1 +1,19 @@
1
- export {};
1
+ const normalizeValue = (value, objects) => {
2
+ if (typeof value === "bigint") {
3
+ return BigInt.asIntN(64, value);
4
+ }
5
+ if (value == null || typeof value !== "object" || value instanceof Date || value instanceof ArrayBuffer || objects.has(value)) {
6
+ return value;
7
+ }
8
+ objects.add(value);
9
+ if (Array.isArray(value)) {
10
+ value.forEach((i, ix) => value[ix] = normalizeValue(i, objects));
11
+ }
12
+ else {
13
+ for (const key of Object.keys(value)) {
14
+ value[key] = normalizeValue(value[key], objects);
15
+ }
16
+ }
17
+ return value;
18
+ };
19
+ export const normalize = (value) => normalizeValue(value, new WeakSet());
@@ -4,9 +4,13 @@ export declare class ArrayAtom implements IAtom {
4
4
  protected readonly _valTypes: Type[];
5
5
  constructor(_valTypes?: Type[]);
6
6
  private get _undefined();
7
- subtypes(): Type[];
8
- valueType(index: number): Type | undefined;
9
- match(atom: IAtom): boolean;
7
+ private _intersectLength;
8
+ get isTuple(): boolean;
9
+ valTypes(): Type[];
10
+ valType(index: number): Type | undefined;
11
+ equate(atom: IAtom): boolean;
12
+ accept(atom: IAtom): boolean;
13
+ intersect(atom: IAtom): boolean;
10
14
  weight(): number;
11
15
  toString(): string;
12
16
  }
@@ -1,3 +1,4 @@
1
+ import { Type } from "../Type.js";
1
2
  export class ArrayAtom {
2
3
  _valTypes;
3
4
  constructor(_valTypes = []) {
@@ -6,29 +7,73 @@ export class ArrayAtom {
6
7
  get _undefined() {
7
8
  return this._valTypes.length === 0;
8
9
  }
9
- subtypes() {
10
+ _intersectLength(length) {
11
+ return !this.isTuple || this._valTypes.slice(length).every((type) => type.isOptional);
12
+ }
13
+ get isTuple() {
14
+ return this._valTypes.length > 1;
15
+ }
16
+ valTypes() {
10
17
  return this._valTypes;
11
18
  }
12
- valueType(index) {
19
+ valType(index) {
13
20
  return this._valTypes[index];
14
21
  }
15
- match(atom) {
22
+ equate(atom) {
23
+ return atom instanceof ArrayAtom
24
+ && this._valTypes.length === atom._valTypes.length
25
+ && this._valTypes.every((type, index) => type.equate(atom._valTypes[index]));
26
+ }
27
+ accept(atom) {
16
28
  if (atom instanceof ArrayAtom) {
17
29
  if (this._undefined || atom._undefined) {
18
30
  return true;
19
31
  }
20
- for (let i = 0; i < this._valTypes.length; ++i) {
21
- const vtype = atom.valueType(i);
22
- if (!vtype || !this._valTypes[i].match(vtype)) {
23
- return false;
32
+ if (this.isTuple) {
33
+ for (let i = 0; i < this._valTypes.length; ++i) {
34
+ const vtype = atom.isTuple
35
+ ? atom.valType(i) ?? Type.Void
36
+ : atom.valType(0);
37
+ if (!vtype || !this._valTypes[i].accept(vtype)) {
38
+ return false;
39
+ }
40
+ }
41
+ }
42
+ else {
43
+ for (let i = 0; i < atom.valTypes().length; ++i) {
44
+ const vtype = atom.valType(i);
45
+ if (!vtype || !this._valTypes[0].accept(vtype)) {
46
+ return false;
47
+ }
24
48
  }
25
49
  }
26
50
  return true;
27
51
  }
28
52
  return false;
29
53
  }
54
+ intersect(atom) {
55
+ if (!(atom instanceof ArrayAtom)) {
56
+ return false;
57
+ }
58
+ if (this._undefined || atom._undefined) {
59
+ return true;
60
+ }
61
+ const length = this.isTuple
62
+ ? atom.isTuple ? Math.min(this._valTypes.length, atom._valTypes.length) : this._valTypes.length
63
+ : atom.isTuple ? atom._valTypes.length : 1;
64
+ for (let i = 0; i < length; ++i) {
65
+ const type = this.isTuple ? this._valTypes[i] : this._valTypes[0];
66
+ const atype = atom.isTuple ? atom._valTypes[i] : atom._valTypes[0];
67
+ if (!type.intersect(atype)) {
68
+ return (this.isTuple || atom.isTuple)
69
+ && this._intersectLength(i)
70
+ && atom._intersectLength(i);
71
+ }
72
+ }
73
+ return true;
74
+ }
30
75
  weight() {
31
- return 0x10000 + this.subtypes().reduce((acc, i) => acc + i.weight(), 0);
76
+ return 0x10000 + this.valTypes().reduce((acc, i) => acc + i.weight(), 0);
32
77
  }
33
78
  toString() {
34
79
  if (this._undefined) {
@@ -13,7 +13,10 @@ export declare class FunctionAtom implements IAtom {
13
13
  get isVariadic(): boolean;
14
14
  get arity(): number;
15
15
  argType(index: number): Type | undefined;
16
- match(atom: IAtom): boolean;
16
+ paramType(index: number): Type | undefined;
17
+ equate(atom: IAtom): boolean;
18
+ accept(atom: IAtom): boolean;
19
+ intersect(atom: IAtom): boolean;
17
20
  weight(): number;
18
21
  toString(): string;
19
22
  }
@@ -43,27 +43,77 @@ export class FunctionAtom {
43
43
  argType(index) {
44
44
  return this._argTypes[index] ?? (this._isVariadic ? this._argTypes[this._argTypes.length - 1] : undefined);
45
45
  }
46
- match(atom) {
47
- if (atom instanceof FunctionAtom) {
48
- if (this._undefined || atom._undefined) {
49
- return true;
50
- }
51
- if (!this._retType.match(atom._retType) || this.minArity > atom.maxArity || this.maxArity < atom.minArity) {
46
+ paramType(index) {
47
+ if (!this._isVariadic) {
48
+ return this.argType(index);
49
+ }
50
+ if (!this._argTypes.length) {
51
+ return Type.Unknown;
52
+ }
53
+ const variadicIndex = this._argTypes.length - 1;
54
+ if (index < variadicIndex) {
55
+ return this.argType(index);
56
+ }
57
+ return this.argType(variadicIndex)
58
+ ?.arrayAtomValType(index - variadicIndex);
59
+ }
60
+ equate(atom) {
61
+ return atom instanceof FunctionAtom
62
+ && this._isVariadic === atom._isVariadic
63
+ && this._argTypes.length === atom._argTypes.length
64
+ && this._retType.equate(atom._retType)
65
+ && this._argTypes.every((type, index) => type.equate(atom._argTypes[index]));
66
+ }
67
+ accept(atom) {
68
+ if (!(atom instanceof FunctionAtom)) {
69
+ return false;
70
+ }
71
+ if (this._undefined || atom._undefined) {
72
+ return true;
73
+ }
74
+ if (this._isVariadic !== atom._isVariadic
75
+ || this._isVariadic && this.arity !== atom.arity
76
+ || !this._retType.accept(atom._retType)
77
+ || this.minArity > atom.maxArity
78
+ || this.maxArity < atom.minArity) {
79
+ return false;
80
+ }
81
+ const argc = Math.min(this.arity, atom.arity);
82
+ for (let i = 0; i < argc; ++i) {
83
+ const type = this.argType(i)?.toMandatory();
84
+ const atype = atom.argType(i);
85
+ if (type && (!atype || !atype.accept(type))) {
52
86
  return false;
53
87
  }
54
- const argc = Math.max(this.minArity, atom.minArity);
55
- for (let i = 0; i < argc; ++i) {
56
- const atype = atom.argType(i);
57
- if (!atype || !this.argType(i)?.match(atype)) {
58
- return false;
59
- }
60
- }
88
+ }
89
+ return true;
90
+ }
91
+ intersect(atom) {
92
+ if (!(atom instanceof FunctionAtom)) {
93
+ return false;
94
+ }
95
+ if (this._undefined || atom._undefined) {
61
96
  return true;
62
97
  }
63
- return false;
98
+ if (this._isVariadic !== atom._isVariadic
99
+ || this._isVariadic && this.arity !== atom.arity
100
+ || !this._retType.intersect(atom._retType)
101
+ || this.minArity > atom.maxArity
102
+ || this.maxArity < atom.minArity) {
103
+ return false;
104
+ }
105
+ const argc = Math.max(this.minArity, atom.minArity);
106
+ for (let i = 0; i < argc; ++i) {
107
+ const type = this.argType(i);
108
+ const atype = atom.argType(i);
109
+ if (!type || !atype || !type.intersect(atype)) {
110
+ return false;
111
+ }
112
+ }
113
+ return true;
64
114
  }
65
115
  weight() {
66
- return 0x1000000000000 + (this._retType ? [this._retType, ...this._argTypes] : []).reduce((acc, i) => acc + i.weight(), 0);
116
+ return 0x1000000000000 + this._argTypes.reduce((acc, i) => acc + i.weight(), this._retType.weight());
67
117
  }
68
118
  toString() {
69
119
  if (this._undefined) {
@@ -1,12 +1,14 @@
1
1
  import { IAtom } from "../Atom.js";
2
2
  import { Type } from "../Type.js";
3
3
  export declare class ObjectAtom implements IAtom {
4
- protected readonly _valTypes: Record<string, Type>;
5
- constructor(_valTypes?: Record<string, Type>);
4
+ protected readonly _valTypes: [string, Type][];
5
+ constructor(valTypes?: [string, Type][]);
6
6
  private get _undefined();
7
- subtypes(): Type[];
8
- valueType(key: string): Type | undefined;
9
- match(atom: IAtom): boolean;
7
+ valTypes(): [string, Type][];
8
+ valType(key: string): Type | undefined;
9
+ equate(atom: IAtom): boolean;
10
+ accept(atom: IAtom): boolean;
11
+ intersect(atom: IAtom): boolean;
10
12
  weight(): number;
11
13
  toString(): string;
12
14
  }
@@ -1,25 +1,32 @@
1
+ import { Type } from "../Type.js";
1
2
  export class ObjectAtom {
2
3
  _valTypes;
3
- constructor(_valTypes = Object.create(null)) {
4
- this._valTypes = _valTypes;
4
+ constructor(valTypes = []) {
5
+ this._valTypes = [...new Map(valTypes)];
5
6
  }
6
7
  get _undefined() {
7
- return Object.keys(this._valTypes).length === 0;
8
+ return this._valTypes.length === 0;
8
9
  }
9
- subtypes() {
10
- return Object.values(this._valTypes);
10
+ valTypes() {
11
+ return this._valTypes;
11
12
  }
12
- valueType(key) {
13
- return this._valTypes[key];
13
+ valType(key) {
14
+ return this._valTypes.find((i) => i[0] === key)?.[1];
14
15
  }
15
- match(atom) {
16
+ equate(atom) {
17
+ if (!(atom instanceof ObjectAtom)) {
18
+ return false;
19
+ }
20
+ return this._valTypes.length === atom._valTypes.length && this._valTypes.every(([key, type]) => type.equate(atom.valType(key)));
21
+ }
22
+ accept(atom) {
16
23
  if (atom instanceof ObjectAtom) {
17
24
  if (this._undefined || atom._undefined) {
18
25
  return true;
19
26
  }
20
- for (const key in this._valTypes) {
21
- const vtype = atom.valueType(key);
22
- if (!vtype || !this._valTypes[key].match(vtype)) {
27
+ for (const [key, type] of this._valTypes) {
28
+ const atype = atom.valType(key) ?? Type.Void;
29
+ if (!type.accept(atype)) {
23
30
  return false;
24
31
  }
25
32
  }
@@ -27,13 +34,28 @@ export class ObjectAtom {
27
34
  }
28
35
  return false;
29
36
  }
37
+ intersect(atom) {
38
+ if (!(atom instanceof ObjectAtom)) {
39
+ return false;
40
+ }
41
+ if (this._undefined || atom._undefined) {
42
+ return true;
43
+ }
44
+ for (const [key, type] of this._valTypes) {
45
+ const atype = atom.valType(key);
46
+ if (atype && !type.intersect(atype)) {
47
+ return false;
48
+ }
49
+ }
50
+ return true;
51
+ }
30
52
  weight() {
31
- return 0x100000000 + this.subtypes().reduce((acc, i) => acc + i.weight(), 0);
53
+ return 0x100000000 + this._valTypes.reduce((acc, i) => acc + i[1].weight(), 0);
32
54
  }
33
55
  toString() {
34
56
  if (this._undefined) {
35
57
  return "object";
36
58
  }
37
- return `[${Object.entries(this._valTypes).map(([k, v]) => `"${k}":${v}`).join(",")}]`;
59
+ return `[${this._valTypes.map(([k, v]) => `"${k}":${v}`).join(",")}]`;
38
60
  }
39
61
  }
@@ -4,7 +4,9 @@ export declare class PrimitiveAtom implements IAtom {
4
4
  protected readonly _primitive: Primitive;
5
5
  constructor(_primitive?: Primitive);
6
6
  get undef(): boolean;
7
- match(atom: IAtom): boolean;
7
+ equate(atom: IAtom): boolean;
8
+ accept(atom: IAtom): boolean;
9
+ intersect(atom: IAtom): boolean;
8
10
  weight(): number;
9
11
  toString(): string;
10
12
  }
@@ -6,12 +6,21 @@ export class PrimitiveAtom {
6
6
  get undef() {
7
7
  return this._primitive === "void";
8
8
  }
9
- match(atom) {
9
+ equate(atom) {
10
10
  if (atom instanceof PrimitiveAtom) {
11
11
  return atom._primitive === this._primitive;
12
12
  }
13
13
  return false;
14
14
  }
15
+ accept(atom) {
16
+ if (atom instanceof PrimitiveAtom) {
17
+ return atom._primitive === this._primitive;
18
+ }
19
+ return false;
20
+ }
21
+ intersect(atom) {
22
+ return this.equate(atom);
23
+ }
15
24
  weight() {
16
25
  switch (this._primitive) {
17
26
  case "void": return 0x1;
@@ -9,6 +9,7 @@ const Number_js_1 = require("./native/Number.js");
9
9
  const Unknown_js_1 = require("./native/Unknown.js");
10
10
  const Constant_js_1 = require("./Constant.js");
11
11
  const Variable_js_1 = require("./Variable.js");
12
+ const Value_js_1 = require("./Value.js");
12
13
  const Type_js_1 = require("./Type.js");
13
14
  const Keywords_js_1 = require("./Keywords.js");
14
15
  const Constants_js_1 = require("./Constants.js");
@@ -16,6 +17,7 @@ const Functions_js_1 = require("./Functions.js");
16
17
  const ArrayNode_js_1 = require("./node/ArrayNode.js");
17
18
  const BlockNode_js_1 = require("./node/BlockNode.js");
18
19
  const CallNode_js_1 = require("./node/CallNode.js");
20
+ const CastNode_js_1 = require("./node/CastNode.js");
19
21
  const ConstantNode_js_1 = require("./node/ConstantNode.js");
20
22
  const JumpNode_js_1 = require("./node/JumpNode.js");
21
23
  const LoopNode_js_1 = require("./node/LoopNode.js");
@@ -96,23 +98,23 @@ class Affinirum {
96
98
  evaluate(values) {
97
99
  const variables = this._scope.variables();
98
100
  for (const name in variables) {
99
- if (!Object.prototype.hasOwnProperty.call(values, name)) {
101
+ if (!values || !Object.hasOwn(values, name)) {
100
102
  this._varframes.get(name)?.throwError(`undefined variable ${name}:\n`);
101
103
  }
102
104
  const variable = variables[name];
103
- const value = values?.[name] ?? undefined;
104
- if (!variable.type.match(Type_js_1.Type.of(value))) {
105
+ const value = (0, Value_js_1.normalize)(values?.[name] ?? undefined);
106
+ if (!variable.type.acceptValue(value)) {
105
107
  this._varframes.get(name)?.throwError(`unexpected type ${Type_js_1.Type.of(value)} for variable ${name} of type ${variable.type}:\n`);
106
108
  }
107
109
  variable.value = value;
108
110
  }
109
111
  try {
110
- return this._root.evaluate();
112
+ return (0, Value_js_1.normalize)(this._root.evaluate() ?? undefined);
111
113
  }
112
114
  catch (e) {
113
115
  if (e instanceof JumpException_js_1.JumpException) {
114
116
  if (e.jump === "exit") {
115
- return e.value;
117
+ return (0, Value_js_1.normalize)(e.value ?? undefined);
116
118
  }
117
119
  else {
118
120
  throw this._root.throwError(`unexpected ${e.jump} jump`);
@@ -238,9 +240,9 @@ class Affinirum {
238
240
  return node;
239
241
  }
240
242
  _accessor(state, scope) {
243
+ const frame = state.starts();
241
244
  let node = this._term(state, scope);
242
- while (state.isDot || state.isQuestion || state.isParenthesesOpen || state.isBracketsOpen) {
243
- const frame = state.starts();
245
+ while (state.isDot || state.isQuestion || state.isParenthesesOpen || state.isBracketsOpen || state.isCast) {
244
246
  if (state.isDot || state.isQuestion) { // property access or property existance operator
245
247
  const operator = state.isDot ? Iterable_js_1.funcAt : Iterable_js_1.funcHas;
246
248
  if (state.next().isLiteral && (typeof state.literal.value === "string" || typeof state.literal.value === "bigint")) {
@@ -286,13 +288,20 @@ class Affinirum {
286
288
  break;
287
289
  }
288
290
  }
291
+ state.closeParentheses();
289
292
  node = new CallNode_js_1.CallNode(frame.ends(state), node, subnodes);
290
- state.closeParentheses().next();
293
+ state.next();
291
294
  }
292
295
  else if (state.isBracketsOpen) { // index access operator
293
- const fnode = new ConstantNode_js_1.ConstantNode(frame, Iterable_js_1.funcAt);
294
- node = new CallNode_js_1.CallNode(frame, fnode, [node, this._unit(state.next(), scope)]);
295
- state.closeBrackets().next();
296
+ const subnodes = [node, this._unit(state.next(), scope)];
297
+ state.closeBrackets();
298
+ const fnode = new ConstantNode_js_1.ConstantNode(frame.ends(state), Iterable_js_1.funcAt);
299
+ node = new CallNode_js_1.CallNode(frame, fnode, subnodes);
300
+ state.next();
301
+ }
302
+ else if (state.isCast) { // type cast operator
303
+ const type = this._type(state.next(), scope);
304
+ node = new CastNode_js_1.CastNode(frame.ends(state), node, type);
296
305
  }
297
306
  }
298
307
  return node;
@@ -465,8 +474,8 @@ class Affinirum {
465
474
  state.throwError("unexpected expression token");
466
475
  }
467
476
  _function(state, scope) {
468
- state.next().openParentheses();
469
477
  const frame = state.starts();
478
+ state.next().openParentheses();
470
479
  let variadic = false;
471
480
  const variables = new Map();
472
481
  while (!state.next().isParenthesesClose) {
@@ -504,8 +513,8 @@ class Affinirum {
504
513
  const args = Array.from(variables.values());
505
514
  const subnode = this._unit(state, scope.subscope(variables));
506
515
  const func = (...values) => {
507
- args.forEach((arg, ix) => arg.value = values[ix]);
508
- return subnode.evaluate();
516
+ args.forEach((arg, ix) => arg.value = (0, Value_js_1.normalize)(values[ix]));
517
+ return (0, Value_js_1.normalize)(subnode.evaluate());
509
518
  };
510
519
  const constant = new Constant_js_1.Constant(func, Type_js_1.Type.functionType(retType, args.map((v) => v.type), variadic));
511
520
  return new ConstantNode_js_1.ConstantNode(frame, constant, subnode);
@@ -557,7 +566,7 @@ class Affinirum {
557
566
  }
558
567
  state.closeBrackets().next();
559
568
  return colon
560
- ? Type_js_1.Type.objectType(Object.fromEntries(itemKeyTypes.map(([key, type]) => [key, type])))
569
+ ? Type_js_1.Type.objectType(itemKeyTypes.map(([key, type]) => [key, type]))
561
570
  : Type_js_1.Type.arrayType(itemKeyTypes.map(([, v]) => v));
562
571
  }
563
572
  else if (state.isTilda) { // function type
@@ -15,7 +15,7 @@ class Constant {
15
15
  return this._value;
16
16
  }
17
17
  get type() {
18
- return Type_js_1.Type.isPrimitiveType(this._value) ? Type_js_1.Type.of(this._value) : this._type;
18
+ return Type_js_1.Type.isPrimitive(this._value) ? Type_js_1.Type.of(this._value) : this._type;
19
19
  }
20
20
  set type(type) {
21
21
  this._type = type;
@@ -3,8 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Functions = void 0;
4
4
  const Aggregable_js_1 = require("./native/Aggregable.js");
5
5
  const Array_js_1 = require("./native/Array.js");
6
+ const Boolean_js_1 = require("./native/Boolean.js");
6
7
  const Buffer_js_1 = require("./native/Buffer.js");
7
8
  const Enumerable_js_1 = require("./native/Enumerable.js");
9
+ const Float_js_1 = require("./native/Float.js");
10
+ const Integer_js_1 = require("./native/Integer.js");
8
11
  const Iterable_js_1 = require("./native/Iterable.js");
9
12
  const Number_js_1 = require("./native/Number.js");
10
13
  const Object_js_1 = require("./native/Object.js");
@@ -53,9 +56,9 @@ exports.Functions = [
53
56
  ["Power", Number_js_1.funcPower],
54
57
  ["Root", Number_js_1.funcRoot],
55
58
  ["Negate", Number_js_1.funcNegate],
56
- ["Cast", Number_js_1.funcCast],
57
- ["CastToFloat", Number_js_1.funcCastToFloat],
58
- ["CastToInteger", Number_js_1.funcCastToInteger],
59
+ ["Boolean", Boolean_js_1.funcBoolean],
60
+ ["Float", Float_js_1.funcFloat],
61
+ ["Integer", Integer_js_1.funcInteger],
59
62
  // Object
60
63
  ["Entries", Object_js_1.funcEntries],
61
64
  ["Keys", Object_js_1.funcKeys],
@@ -4,10 +4,10 @@ exports.Keywords = void 0;
4
4
  exports.Keywords = [
5
5
  "true", "false",
6
6
  "null", "void",
7
- "boolean",
8
- "timestamp",
9
- "float",
10
- "integer",
7
+ "bool", "boolean",
8
+ "time", "timestamp",
9
+ "f64", "float",
10
+ "i64", "integer",
11
11
  "buffer",
12
12
  "string",
13
13
  "array",