affinirum 1.3.0 → 1.4.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.
Files changed (76) hide show
  1. package/README.md +156 -126
  2. package/dst/Affinirum.d.ts +1 -1
  3. package/dst/Affinirum.js +49 -53
  4. package/dst/Constants.js +10 -10
  5. package/dst/Functions.js +10 -10
  6. package/dst/ParserState.js +8 -8
  7. package/dst/atom/ArrayAtom.d.ts +3 -3
  8. package/dst/atom/ArrayAtom.js +14 -13
  9. package/dst/atom/FunctionAtom.d.ts +1 -1
  10. package/dst/atom/FunctionAtom.js +10 -8
  11. package/dst/atom/ObjectAtom.d.ts +3 -3
  12. package/dst/atom/ObjectAtom.js +14 -18
  13. package/dst/atom/PrimitiveAtom.js +3 -3
  14. package/dst/cjs/Affinirum.js +49 -53
  15. package/dst/cjs/Constants.js +10 -10
  16. package/dst/cjs/Functions.js +10 -10
  17. package/dst/cjs/ParserState.js +8 -8
  18. package/dst/cjs/atom/ArrayAtom.js +14 -13
  19. package/dst/cjs/atom/FunctionAtom.js +10 -8
  20. package/dst/cjs/atom/ObjectAtom.js +14 -18
  21. package/dst/cjs/atom/PrimitiveAtom.js +3 -3
  22. package/dst/cjs/node/ArrayNode.js +7 -3
  23. package/dst/cjs/node/{FunctionNode.js → CallNode.js} +5 -4
  24. package/dst/cjs/node/ObjectNode.js +4 -2
  25. package/dst/node/ArrayNode.d.ts +2 -1
  26. package/dst/node/ArrayNode.js +7 -3
  27. package/dst/node/{FunctionNode.d.ts → CallNode.d.ts} +1 -1
  28. package/dst/node/{FunctionNode.js → CallNode.js} +3 -2
  29. package/dst/node/ObjectNode.d.ts +1 -1
  30. package/dst/node/ObjectNode.js +4 -2
  31. package/package.json +1 -1
  32. /package/dst/cjs/{constant → native}/Aggregable.js +0 -0
  33. /package/dst/cjs/{constant → native}/Array.js +0 -0
  34. /package/dst/cjs/{constant → native}/Boolean.js +0 -0
  35. /package/dst/cjs/{constant → native}/Buffer.js +0 -0
  36. /package/dst/cjs/{constant → native}/Enumerable.js +0 -0
  37. /package/dst/cjs/{constant → native}/Float.js +0 -0
  38. /package/dst/cjs/{constant → native}/Integer.js +0 -0
  39. /package/dst/cjs/{constant → native}/Iterable.js +0 -0
  40. /package/dst/cjs/{constant → native}/Number.js +0 -0
  41. /package/dst/cjs/{constant → native}/Object.js +0 -0
  42. /package/dst/cjs/{constant → native}/String.js +0 -0
  43. /package/dst/cjs/{constant → native}/Timestamp.js +0 -0
  44. /package/dst/cjs/{constant → native}/Unknown.js +0 -0
  45. /package/dst/cjs/{constant → native}/notation/AN.js +0 -0
  46. /package/dst/cjs/{constant → native}/notation/JSON.js +0 -0
  47. /package/dst/{constant → native}/Aggregable.d.ts +0 -0
  48. /package/dst/{constant → native}/Aggregable.js +0 -0
  49. /package/dst/{constant → native}/Array.d.ts +0 -0
  50. /package/dst/{constant → native}/Array.js +0 -0
  51. /package/dst/{constant → native}/Boolean.d.ts +0 -0
  52. /package/dst/{constant → native}/Boolean.js +0 -0
  53. /package/dst/{constant → native}/Buffer.d.ts +0 -0
  54. /package/dst/{constant → native}/Buffer.js +0 -0
  55. /package/dst/{constant → native}/Enumerable.d.ts +0 -0
  56. /package/dst/{constant → native}/Enumerable.js +0 -0
  57. /package/dst/{constant → native}/Float.d.ts +0 -0
  58. /package/dst/{constant → native}/Float.js +0 -0
  59. /package/dst/{constant → native}/Integer.d.ts +0 -0
  60. /package/dst/{constant → native}/Integer.js +0 -0
  61. /package/dst/{constant → native}/Iterable.d.ts +0 -0
  62. /package/dst/{constant → native}/Iterable.js +0 -0
  63. /package/dst/{constant → native}/Number.d.ts +0 -0
  64. /package/dst/{constant → native}/Number.js +0 -0
  65. /package/dst/{constant → native}/Object.d.ts +0 -0
  66. /package/dst/{constant → native}/Object.js +0 -0
  67. /package/dst/{constant → native}/String.d.ts +0 -0
  68. /package/dst/{constant → native}/String.js +0 -0
  69. /package/dst/{constant → native}/Timestamp.d.ts +0 -0
  70. /package/dst/{constant → native}/Timestamp.js +0 -0
  71. /package/dst/{constant → native}/Unknown.d.ts +0 -0
  72. /package/dst/{constant → native}/Unknown.js +0 -0
  73. /package/dst/{constant → native}/notation/AN.d.ts +0 -0
  74. /package/dst/{constant → native}/notation/AN.js +0 -0
  75. /package/dst/{constant → native}/notation/JSON.d.ts +0 -0
  76. /package/dst/{constant → native}/notation/JSON.js +0 -0
@@ -8,10 +8,12 @@ const Type_js_1 = require("../Type.js");
8
8
  class ObjectNode extends Node_js_1.Node {
9
9
  _subnodes;
10
10
  _type;
11
- constructor(frame, _subnodes) {
11
+ constructor(frame, _subnodes, generic = false) {
12
12
  super(frame);
13
13
  this._subnodes = _subnodes;
14
- this._type = Type_js_1.Type.Object;
14
+ this._type = generic
15
+ ? Type_js_1.Type.Object
16
+ : Type_js_1.Type.objectType(Object.fromEntries(_subnodes.filter(([i]) => i instanceof ConstantNode_js_1.ConstantNode && i.constant).map(([k, v]) => [k.evaluate(), v.type])));
15
17
  }
16
18
  get type() {
17
19
  return this._type;
@@ -4,7 +4,8 @@ import { Value } from "../Value.js";
4
4
  import { Type } from "../Type.js";
5
5
  export declare class ArrayNode extends Node {
6
6
  protected _subnodes: Node[];
7
- constructor(frame: ParserFrame, _subnodes: Node[]);
7
+ protected _type: Type;
8
+ constructor(frame: ParserFrame, _subnodes: Node[], generic?: boolean);
8
9
  get type(): Type;
9
10
  compile(type: Type): Node;
10
11
  evaluate(): Value;
@@ -4,15 +4,19 @@ import { ConstantNode } from "./ConstantNode.js";
4
4
  import { Type } from "../Type.js";
5
5
  export class ArrayNode extends Node {
6
6
  _subnodes;
7
- constructor(frame, _subnodes) {
7
+ _type;
8
+ constructor(frame, _subnodes, generic = false) {
8
9
  super(frame);
9
10
  this._subnodes = _subnodes;
11
+ this._type = generic
12
+ ? Type.Array
13
+ : Type.arrayType(_subnodes.map((i) => i.type));
10
14
  }
11
15
  get type() {
12
- return Type.Array;
16
+ return this._type;
13
17
  }
14
18
  compile(type) {
15
- this.reduceType(type);
19
+ this._type = this.reduceType(type);
16
20
  let constant = true;
17
21
  for (let i = 0; i < this._subnodes.length; ++i) {
18
22
  this._subnodes[i] = this._subnodes[i].compile(Type.Unknown);
@@ -2,7 +2,7 @@ import { Node } from "../Node.js";
2
2
  import { ParserFrame } from "../ParserFrame.js";
3
3
  import { Value } from "../Value.js";
4
4
  import { Type } from "../Type.js";
5
- export declare class FunctionNode extends Node {
5
+ export declare class CallNode extends Node {
6
6
  protected _fnode: Node;
7
7
  protected _subnodes: Node[];
8
8
  protected _type: Type;
@@ -4,7 +4,7 @@ import { ConstantNode } from "./ConstantNode.js";
4
4
  import { ArrayNode } from "./ArrayNode.js";
5
5
  import { Type } from "../Type.js";
6
6
  import { JumpException } from "../JumpException.js";
7
- export class FunctionNode extends Node {
7
+ export class CallNode extends Node {
8
8
  _fnode;
9
9
  _subnodes;
10
10
  _type;
@@ -31,7 +31,8 @@ export class FunctionNode extends Node {
31
31
  if (this._fnode.constant) {
32
32
  let constant = true;
33
33
  for (let i = 0; i < this._subnodes.length; ++i) {
34
- const argType = Type.union(...functionAtoms.map((a) => a.argType(i)));
34
+ const argTypes = functionAtoms.map((a) => a.argType(i));
35
+ const argType = Type.union(...argTypes.filter((t) => t != null));
35
36
  this._subnodes[i] = this._subnodes[i].compile(argType);
36
37
  constant &&= this._subnodes[i].constant;
37
38
  }
@@ -5,7 +5,7 @@ import { Type } from "../Type.js";
5
5
  export declare class ObjectNode extends Node {
6
6
  protected _subnodes: [Node, Node][];
7
7
  protected _type: Type;
8
- constructor(frame: ParserFrame, _subnodes: [Node, Node][]);
8
+ constructor(frame: ParserFrame, _subnodes: [Node, Node][], generic?: boolean);
9
9
  get type(): Type;
10
10
  compile(type: Type): Node;
11
11
  evaluate(): Value;
@@ -5,10 +5,12 @@ import { Type } from "../Type.js";
5
5
  export class ObjectNode extends Node {
6
6
  _subnodes;
7
7
  _type;
8
- constructor(frame, _subnodes) {
8
+ constructor(frame, _subnodes, generic = false) {
9
9
  super(frame);
10
10
  this._subnodes = _subnodes;
11
- this._type = Type.Object;
11
+ this._type = generic
12
+ ? Type.Object
13
+ : Type.objectType(Object.fromEntries(_subnodes.filter(([i]) => i instanceof ConstantNode && i.constant).map(([k, v]) => [k.evaluate(), v.type])));
12
14
  }
13
15
  get type() {
14
16
  return this._type;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "affinirum",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Affinirum Scripting Language",
5
5
  "main": "dst/cjs/index.js",
6
6
  "module": "dst/index.js",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes