@ibyar/expressions 0.5.4 → 0.5.6

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 (99) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -0
  3. package/api/abstract.d.ts +3 -3
  4. package/api/abstract.js +2 -2
  5. package/api/abstract.js.map +1 -1
  6. package/api/class/class.d.ts +18 -12
  7. package/api/class/class.js +122 -81
  8. package/api/class/class.js.map +1 -1
  9. package/api/computing/debugger.d.ts +15 -0
  10. package/api/computing/debugger.js +35 -0
  11. package/api/computing/debugger.js.map +1 -0
  12. package/api/computing/rest.d.ts +4 -4
  13. package/api/computing/rest.js.map +1 -1
  14. package/api/definition/array.d.ts +7 -6
  15. package/api/definition/array.js +20 -14
  16. package/api/definition/array.js.map +1 -1
  17. package/api/definition/function.d.ts +35 -46
  18. package/api/definition/function.js +281 -299
  19. package/api/definition/function.js.map +1 -1
  20. package/api/definition/object.d.ts +9 -6
  21. package/api/definition/object.js +34 -4
  22. package/api/definition/object.js.map +1 -1
  23. package/api/definition/statement.js +5 -1
  24. package/api/definition/statement.js.map +1 -1
  25. package/api/definition/values.d.ts +31 -47
  26. package/api/definition/values.js +59 -145
  27. package/api/definition/values.js.map +1 -1
  28. package/api/deserialize/deserialize.d.ts +2 -1
  29. package/api/deserialize/deserialize.js +4 -1
  30. package/api/deserialize/deserialize.js.map +1 -1
  31. package/api/deserialize/type-store.d.ts +2 -2
  32. package/api/deserialize/type-store.js.map +1 -1
  33. package/api/expression.d.ts +5 -7
  34. package/api/expression.js.map +1 -1
  35. package/api/index.d.ts +2 -0
  36. package/api/index.js +2 -0
  37. package/api/index.js.map +1 -1
  38. package/api/module/common.d.ts +29 -0
  39. package/api/module/common.js +71 -0
  40. package/api/module/common.js.map +1 -0
  41. package/api/module/export.d.ts +15 -9
  42. package/api/module/export.js +57 -15
  43. package/api/module/export.js.map +1 -1
  44. package/api/module/import.d.ts +3 -8
  45. package/api/module/import.js +9 -19
  46. package/api/module/import.js.map +1 -1
  47. package/api/{module/app/program.d.ts → program.d.ts} +4 -4
  48. package/api/{module/app/program.js → program.js} +3 -3
  49. package/api/program.js.map +1 -0
  50. package/api/statement/control/block.d.ts +1 -2
  51. package/api/statement/control/block.js +20 -21
  52. package/api/statement/control/block.js.map +1 -1
  53. package/api/statement/control/switch.js +8 -3
  54. package/api/statement/control/switch.js.map +1 -1
  55. package/api/statement/control/terminate.d.ts +36 -11
  56. package/api/statement/control/terminate.js +79 -18
  57. package/api/statement/control/terminate.js.map +1 -1
  58. package/api/statement/declarations/declares.d.ts +7 -7
  59. package/api/statement/declarations/declares.js +1 -1
  60. package/api/statement/declarations/declares.js.map +1 -1
  61. package/api/statement/iterations/for.js +22 -16
  62. package/api/statement/iterations/for.js.map +1 -1
  63. package/api/statement/iterations/while.js +15 -11
  64. package/api/statement/iterations/while.js.map +1 -1
  65. package/api/utils.d.ts +2 -0
  66. package/api/utils.js +3 -1
  67. package/api/utils.js.map +1 -1
  68. package/package.json +4 -4
  69. package/scope/proxy.d.ts +0 -2
  70. package/scope/proxy.js +4 -24
  71. package/scope/proxy.js.map +1 -1
  72. package/scope/stack.d.ts +2 -2
  73. package/scope/stack.js.map +1 -1
  74. package/v8/enums.d.ts +204 -0
  75. package/v8/enums.js +375 -0
  76. package/v8/enums.js.map +1 -0
  77. package/v8/index.d.ts +2 -1
  78. package/v8/index.js +2 -1
  79. package/v8/index.js.map +1 -1
  80. package/v8/inline.d.ts +177 -0
  81. package/v8/inline.js +1973 -0
  82. package/v8/inline.js.map +1 -0
  83. package/v8/nodes.d.ts +8 -7
  84. package/v8/nodes.js +37 -63
  85. package/v8/nodes.js.map +1 -1
  86. package/v8/parser.d.ts +41 -151
  87. package/v8/parser.js +507 -1579
  88. package/v8/parser.js.map +1 -1
  89. package/v8/stream.d.ts +35 -3
  90. package/v8/stream.js +616 -164
  91. package/v8/stream.js.map +1 -1
  92. package/v8/token.d.ts +15 -9
  93. package/v8/token.js +79 -46
  94. package/v8/token.js.map +1 -1
  95. package/visit/visitor.js.map +1 -1
  96. package/api/module/app/program.js.map +0 -1
  97. package/v8/app.d.ts +0 -0
  98. package/v8/app.js +0 -2
  99. package/v8/app.js.map +0 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2021 @ibyar/expressions
3
+ Copyright (c) 2020-2022 @ibyar/expressions
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -19,6 +19,7 @@
19
19
  Aurora expression, is a JavaScript expression parsing and evaluation. and template expression evaluation, with stack and scope.
20
20
 
21
21
  - this package has no dependance, can work on both (Node.js) and any Web Browsers, that support modules and class syntax
22
+ - An 100% spec compliant ES2022 JavaScript toolchain
22
23
 
23
24
  ## `Install`
24
25
 
package/api/abstract.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import type { Scope } from '../scope/scope.js';
2
2
  import type { AwaitPromiseInfo, Stack } from '../scope/stack.js';
3
- import type { NodeDeserializer, ExpressionNode, NodeExpressionClass, NodeJsonType, CanDeclareExpression, ExpressionEventMap, ExpressionEventPath, VisitNodeType } from './expression.js';
3
+ import type { NodeDeserializer, ExpressionNode, ExpressionNodConstructor, NodeJsonType, DeclarationExpression, ExpressionEventMap, ExpressionEventPath, VisitNodeType } from './expression.js';
4
4
  export declare abstract class AbstractExpressionNode implements ExpressionNode {
5
5
  static fromJSON(node: ExpressionNode, deserializer: NodeDeserializer): ExpressionNode;
6
- getClass(): NodeExpressionClass<ExpressionNode>;
6
+ getClass(): ExpressionNodConstructor<ExpressionNode>;
7
7
  toJSON(key?: string): NodeJsonType;
8
8
  events(): ExpressionEventMap;
9
9
  abstract shareVariables(scopeList: Scope<any>[]): void;
@@ -50,7 +50,7 @@ export declare class YieldDelegateValue {
50
50
  }
51
51
  export declare class AwaitPromise implements AwaitPromiseInfo {
52
52
  promise: Promise<any>;
53
- node: CanDeclareExpression;
53
+ node: DeclarationExpression;
54
54
  declareVariable: boolean;
55
55
  constructor(promise: Promise<any>);
56
56
  }
package/api/abstract.js CHANGED
@@ -21,9 +21,9 @@ export class AbstractExpressionNode {
21
21
  return this.constructor;
22
22
  }
23
23
  toJSON(key) {
24
+ const type = this.getClass().type;
24
25
  const json = this.toJson(key);
25
- json.type = Reflect.get(this.constructor, 'type');
26
- return json;
26
+ return { type, ...json };
27
27
  }
28
28
  events() {
29
29
  const dependencyNodes = this.dependency();
@@ -1 +1 @@
1
- {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../src/expressions/api/abstract.ts"],"names":[],"mappings":"AAQA,SAAS,0BAA0B,CAAC,YAAgC,EAAE,IAA2B;IAChG,IAAI,OAAO,GAAG,YAAY,CAAC;IAE3B,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAClC,IAAI,QAAQ,EAAE;YACb,OAAO,GAAG,QAAQ,CAAC;YACnB,SAAS;SACT;QAKD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,0BAA0B,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;SAClF;KACD;AACF,CAAC;AACD,MAAM,OAAgB,sBAAsB;IAC3C,MAAM,CAAC,QAAQ,CAAC,IAAoB,EAAE,YAA8B;QACnE,OAAO,YAAY,CAAC,IAAW,CAAC,CAAC;IAClC,CAAC;IACD,QAAQ;QACP,OAAO,IAAI,CAAC,WAAkD,CAAC;IAChE,CAAC;IACD,MAAM,CAAC,GAAY;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CA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O,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAED,MAAM,OAAO,YAAY;IAGxB,YAAmB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAI,CAAC;CAC7C","sourcesContent":["import type { Scope } from '../scope/scope.js';\nimport type { AwaitPromiseInfo, Stack } from '../scope/stack.js';\nimport type {\n\tNodeDeserializer, ExpressionNode, NodeExpressionClass,\n\tNodeJsonType, CanDeclareExpression, ExpressionEventMap,\n\tExpressionEventPath, VisitNodeType\n} from './expression.js';\n\nfunction initPathExpressionEventMap(rootEventMap: ExpressionEventMap, path: ExpressionEventPath[]): void {\n\tlet lastMap = rootEventMap;\n\t// let index = 0;\n\tfor (const node of path) {\n\t\tconst scopeName = node.path;\n\t\tlet eventMap = lastMap[scopeName];\n\t\tif (eventMap) {\n\t\t\tlastMap = eventMap;\n\t\t\tcontinue;\n\t\t}\n\t\t// if ((index++) === path.length - 1) {\n\t\t// \tlastMap[scopeName] = undefined;\n\t\t// \tcontinue;\n\t\t// }\n\t\tlastMap = lastMap[scopeName] = {};\n\t\tif (node.computed) {\n\t\t\tnode.computedPath.forEach(path => initPathExpressionEventMap(rootEventMap, path));\n\t\t}\n\t}\n}\nexport abstract class AbstractExpressionNode implements ExpressionNode {\n\tstatic fromJSON(node: ExpressionNode, deserializer: NodeDeserializer): ExpressionNode {\n\t\treturn deserializer(node as any);\n\t}\n\tgetClass(): NodeExpressionClass<ExpressionNode> {\n\t\treturn this.constructor as NodeExpressionClass<ExpressionNode>;\n\t}\n\ttoJSON(key?: string): NodeJsonType {\n\t\tconst json = this.toJson(key) as NodeJsonType;\n\t\tjson.type = Reflect.get(this.constructor, 'type');\n\t\treturn json;\n\t}\n\tevents(): ExpressionEventMap {\n\t\tconst dependencyNodes = this.dependency();\n\t\tconst eventMap: ExpressionEventMap = {};\n\t\tfor (const node of dependencyNodes) {\n\t\t\tconst dependencyPath = node.dependencyPath();\n\t\t\tinitPathExpressionEventMap(eventMap, dependencyPath);\n\t\t}\n\t\treturn eventMap;\n\t}\n\tabstract shareVariables(scopeList: Scope<any>[]): void;\n\tabstract set(stack: Stack, value: any): any;\n\tabstract get(stack: Stack, thisContext?: any): any;\n\tabstract dependency(computed?: true): ExpressionNode[];\n\tabstract dependencyPath(computed?: true): ExpressionEventPath[];\n\tabstract toString(): string;\n\tabstract toJson(key?: string): { [key: string]: any };\n}\nexport abstract class InfixExpressionNode<T> extends AbstractExpressionNode {\n\tstatic visit(node: InfixExpressionNode<any>, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.getLeft());\n\t\tvisitNode(node.getRight())\n\t}\n\tconstructor(protected operator: T, protected left: ExpressionNode, protected right: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetOperator() {\n\t\treturn this.operator;\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.left.shareVariables(scopeList);\n\t\tthis.right.shareVariables(scopeList);\n\t}\n\tset(context: object, value: any) {\n\t\tthrow new Error(`${this.constructor.name}#set() of operator: '${this.operator}' has no implementation.`);\n\t}\n\tabstract get(stack: Stack): any;\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.left.dependency(computed).concat(this.right.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.left.dependencyPath(computed).concat(this.right.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `${this.left.toString()} ${this.operator} ${this.right.toString()}`;\n\t}\n\ttoJson(key: string): object {\n\t\treturn {\n\t\t\toperator: this.operator,\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON()\n\t\t};\n\t}\n}\n\nexport class ReturnValue {\n\tconstructor(public value: any) { }\n\tgetValue() {\n\t\treturn this.value;\n\t}\n}\n\nexport class YieldValue {\n\tconstructor(public value: any) { }\n\tgetValue() {\n\t\treturn this.value;\n\t}\n}\n\nexport class YieldDelegateValue {\n\tconstructor(public value: any) { }\n\tgetValue() {\n\t\treturn this.value;\n\t}\n}\n\nexport class AwaitPromise implements AwaitPromiseInfo {\n\tnode: CanDeclareExpression;\n\tdeclareVariable: boolean;\n\tconstructor(public promise: Promise<any>) { }\n}\n"]}
1
+ {"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../src/expressions/api/abstract.ts"],"names":[],"mappings":"AAQA,SAAS,0BAA0B,CAAC,YAAgC,EAAE,IAA2B;IAChG,IAAI,OAAO,GAAG,YAAY,CAAC;IAE3B,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;QAClC,IAAI,QAAQ,EAAE;YACb,OAAO,GAAG,QAAQ,CAAC;YACnB,SAAS;SACT;QAKD,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,0BAA0B,CAAC,YAAY,EAAE,IAAI,CAAC,CAAC,CAAC;SAClF;KACD;AACF,CAAC;AACD,MAAM,OAAgB,sBAAsB;IAC3C,MAAM,CAAC,QAAQ,CAAC,IAAoB,EAAE,YAA8B;QACnE,OAAO,YAAY,CAAC,IAAW,CAAC,CAAC;IAClC,CAAC;IACD,QAAQ;QACP,OAAO,IAAI,CAAC,WAAuD,CAAC;IACrE,CAAC;IACD,MAAM,CAAC,GAAY;QAClB,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC;QAClC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;IAC1B,CAAC;IACD,MAAM;QACL,MAAM,eAAe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nimport type { AwaitPromiseInfo, Stack } from '../scope/stack.js';\nimport type {\n\tNodeDeserializer, ExpressionNode, ExpressionNodConstructor,\n\tNodeJsonType, DeclarationExpression, ExpressionEventMap,\n\tExpressionEventPath, VisitNodeType\n} from './expression.js';\n\nfunction initPathExpressionEventMap(rootEventMap: ExpressionEventMap, path: ExpressionEventPath[]): void {\n\tlet lastMap = rootEventMap;\n\t// let index = 0;\n\tfor (const node of path) {\n\t\tconst scopeName = node.path;\n\t\tlet eventMap = lastMap[scopeName];\n\t\tif (eventMap) {\n\t\t\tlastMap = eventMap;\n\t\t\tcontinue;\n\t\t}\n\t\t// if ((index++) === path.length - 1) {\n\t\t// \tlastMap[scopeName] = undefined;\n\t\t// \tcontinue;\n\t\t// }\n\t\tlastMap = lastMap[scopeName] = {};\n\t\tif (node.computed) {\n\t\t\tnode.computedPath.forEach(path => initPathExpressionEventMap(rootEventMap, path));\n\t\t}\n\t}\n}\nexport abstract class AbstractExpressionNode implements ExpressionNode {\n\tstatic fromJSON(node: ExpressionNode, deserializer: NodeDeserializer): ExpressionNode {\n\t\treturn deserializer(node as any);\n\t}\n\tgetClass(): ExpressionNodConstructor<ExpressionNode> {\n\t\treturn this.constructor as ExpressionNodConstructor<ExpressionNode>;\n\t}\n\ttoJSON(key?: string): NodeJsonType {\n\t\tconst type = this.getClass().type;\n\t\tconst json = this.toJson(key);\n\t\treturn { type, ...json };\n\t}\n\tevents(): ExpressionEventMap {\n\t\tconst dependencyNodes = this.dependency();\n\t\tconst eventMap: ExpressionEventMap = {};\n\t\tfor (const node of dependencyNodes) {\n\t\t\tconst dependencyPath = node.dependencyPath();\n\t\t\tinitPathExpressionEventMap(eventMap, dependencyPath);\n\t\t}\n\t\treturn eventMap;\n\t}\n\tabstract shareVariables(scopeList: Scope<any>[]): void;\n\tabstract set(stack: Stack, value: any): any;\n\tabstract get(stack: Stack, thisContext?: any): any;\n\tabstract dependency(computed?: true): ExpressionNode[];\n\tabstract dependencyPath(computed?: true): ExpressionEventPath[];\n\tabstract toString(): string;\n\tabstract toJson(key?: string): { [key: string]: any };\n}\nexport abstract class InfixExpressionNode<T> extends AbstractExpressionNode {\n\tstatic visit(node: InfixExpressionNode<any>, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.getLeft());\n\t\tvisitNode(node.getRight())\n\t}\n\tconstructor(protected operator: T, protected left: ExpressionNode, protected right: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetOperator() {\n\t\treturn this.operator;\n\t}\n\tgetLeft() {\n\t\treturn this.left;\n\t}\n\tgetRight() {\n\t\treturn this.right;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.left.shareVariables(scopeList);\n\t\tthis.right.shareVariables(scopeList);\n\t}\n\tset(context: object, value: any) {\n\t\tthrow new Error(`${this.constructor.name}#set() of operator: '${this.operator}' has no implementation.`);\n\t}\n\tabstract get(stack: Stack): any;\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.left.dependency(computed).concat(this.right.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.left.dependencyPath(computed).concat(this.right.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `${this.left.toString()} ${this.operator} ${this.right.toString()}`;\n\t}\n\ttoJson(key: string): object {\n\t\treturn {\n\t\t\toperator: this.operator,\n\t\t\tleft: this.left.toJSON(),\n\t\t\tright: this.right.toJSON()\n\t\t};\n\t}\n}\n\nexport class ReturnValue {\n\tconstructor(public value: any) { }\n\tgetValue() {\n\t\treturn this.value;\n\t}\n}\n\nexport class YieldValue {\n\tconstructor(public value: any) { }\n\tgetValue() {\n\t\treturn this.value;\n\t}\n}\n\nexport class YieldDelegateValue {\n\tconstructor(public value: any) { }\n\tgetValue() {\n\t\treturn this.value;\n\t}\n}\n\nexport class AwaitPromise implements AwaitPromiseInfo {\n\tnode: DeclarationExpression;\n\tdeclareVariable: boolean;\n\tconstructor(public promise: Promise<any>) { }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { CanDeclareExpression, ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';
1
+ import type { DeclarationExpression, ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';
2
2
  import type { Scope } from '../../scope/scope.js';
3
3
  import { Stack } from '../../scope/stack.js';
4
4
  import { AbstractExpressionNode } from '../abstract.js';
@@ -11,26 +11,23 @@ declare const STACK: unique symbol;
11
11
  declare const GET_PARAMETERS: unique symbol;
12
12
  declare const CONSTRUCTOR: unique symbol;
13
13
  declare const PRIVATE_SYMBOL: unique symbol;
14
- declare const INIT_PRIVATE_SYMBOL: unique symbol;
14
+ declare const INSTANCE_PRIVATE_SYMBOL: unique symbol;
15
15
  declare const STATIC_INITIALIZATION_BLOCK: unique symbol;
16
16
  interface ClassConstructor {
17
17
  readonly prototype: ClassInstance;
18
18
  [GET_PARAMETERS](args: any[]): any[];
19
19
  [STATIC_INITIALIZATION_BLOCK]: Function[];
20
- [INIT_PRIVATE_SYMBOL]: {
20
+ [PRIVATE_SYMBOL]: {
21
21
  [key: PropertyKey]: any;
22
22
  };
23
- [PRIVATE_SYMBOL]: {
23
+ [INSTANCE_PRIVATE_SYMBOL]: {
24
24
  [key: PropertyKey]: any;
25
25
  };
26
+ [CONSTRUCTOR]: Function;
26
27
  [key: string]: any;
27
28
  }
28
29
  declare var ClassInstance: ClassConstructor;
29
30
  interface ClassInstance {
30
- [CONSTRUCTOR]: Function;
31
- [INIT_PRIVATE_SYMBOL]: {
32
- [key: PropertyKey]: any;
33
- };
34
31
  [PRIVATE_SYMBOL]: {
35
32
  [key: PropertyKey]: any;
36
33
  };
@@ -73,7 +70,7 @@ export declare class PrivateIdentifier extends AbstractExpressionNode {
73
70
  constructor(name: string);
74
71
  getName(): string;
75
72
  set(stack: Stack, value: any): void;
76
- get(stack: Stack, thisContext?: any): any;
73
+ get(stack: Stack, thisContext?: ClassInstance | ClassConstructor): any;
77
74
  dependency(computed?: true): ExpressionNode[];
78
75
  dependencyPath(computed?: true): ExpressionEventPath[];
79
76
  shareVariables(scopeList: Scope<any>[]): void;
@@ -84,9 +81,10 @@ export declare class PrivateIdentifier extends AbstractExpressionNode {
84
81
  }
85
82
  export declare class StaticBlock extends BlockStatement {
86
83
  static fromJSON(node: StaticBlock, deserializer: NodeDeserializer<any>): StaticBlock;
87
- constructor(body: ExpressionNode[], isStatement: boolean);
84
+ constructor(body: ExpressionNode[]);
88
85
  get(stack: Stack, classConstructor?: ClassConstructor): void;
89
86
  toString(): string;
87
+ toJson(): object;
90
88
  }
91
89
  export declare abstract class AbstractDefinition extends AbstractExpressionNode {
92
90
  protected key: ExpressionNode | PrivateIdentifier;
@@ -104,6 +102,12 @@ export declare abstract class AbstractDefinition extends AbstractExpressionNode
104
102
  set(stack: Stack, value: any): void;
105
103
  dependency(computed?: true): ExpressionNode[];
106
104
  dependencyPath(computed?: true): ExpressionEventPath[];
105
+ getTarget(classConstructor: ClassConstructor): {
106
+ [key: string]: any;
107
+ [key: number]: any;
108
+ [key: symbol]: any;
109
+ };
110
+ getKeyName(stack: Stack): any;
107
111
  abstract get(stack: Stack, classConstructor: ClassConstructor): void;
108
112
  abstract toString(): string;
109
113
  abstract toJson(): {
@@ -182,12 +186,14 @@ export declare class Class extends AbstractExpressionNode {
182
186
  toString(): string;
183
187
  toJson(): object;
184
188
  }
185
- export declare class ClassDeclaration extends Class implements CanDeclareExpression {
189
+ export declare class ClassDeclaration extends Class implements DeclarationExpression {
186
190
  static fromJSON(node: ClassDeclaration, deserializer: NodeDeserializer<any>): ClassDeclaration;
187
191
  static visit(node: ClassDeclaration, visitNode: VisitNodeType): void;
188
- protected id?: Identifier;
192
+ protected id: Identifier;
193
+ constructor(body: ClassBody, decorators: Decorator[], id: Identifier, superClass?: ExpressionNode);
189
194
  declareVariable(stack: Stack, propertyValue?: any): void;
190
195
  getDeclarationName(): string;
196
+ get(stack: Stack): ClassConstructor;
191
197
  }
192
198
  export declare class ClassExpression extends Class {
193
199
  static fromJSON(node: ClassExpression, deserializer: NodeDeserializer<any>): ClassExpression;
@@ -8,18 +8,18 @@ import { MemberExpression } from '../definition/member.js';
8
8
  import { FunctionExpression } from '../definition/function.js';
9
9
  import { BlockStatement } from '../statement/control/block.js';
10
10
  import { CallExpression } from '../computing/call.js';
11
- const TEMP_CLASS_NAME = Symbol('temp_class_name');
12
- const SUPER = Symbol('super');
13
- const NEW_TARGET = Symbol('new.target');
14
- const IMPORT_META = Symbol('import.meta');
15
- const STACK = Symbol('stack');
16
- const GET_PARAMETERS = Symbol('getParameters');
17
- const GET_SUPER_PROPERTY = Symbol('getSuperProperty');
18
- const CALL_SUPER_Method = Symbol('callSuperMethod');
19
- const CONSTRUCTOR = Symbol('constructor');
20
- const PRIVATE_SYMBOL = Symbol('#private');
21
- const INIT_PRIVATE_SYMBOL = Symbol('#init_private');
22
- const STATIC_INITIALIZATION_BLOCK = Symbol('static_block');
11
+ const TEMP_CLASS_NAME = Symbol('TempClassName');
12
+ const SUPER = Symbol('Super');
13
+ const NEW_TARGET = Symbol('NewTarget');
14
+ const IMPORT_META = Symbol('ImportMeta');
15
+ const STACK = Symbol('Stack');
16
+ const GET_PARAMETERS = Symbol('GetParameters');
17
+ const GET_SUPER_PROPERTY = Symbol('GetSuperProperty');
18
+ const CALL_SUPER_Method = Symbol('CallSuperMethod');
19
+ const CONSTRUCTOR = Symbol('Constructor');
20
+ const PRIVATE_SYMBOL = Symbol('Private');
21
+ const INSTANCE_PRIVATE_SYMBOL = Symbol('InstancePrivate');
22
+ const STATIC_INITIALIZATION_BLOCK = Symbol('StaticBlock');
23
23
  let Super = Super_1 = class Super extends AbstractExpressionNode {
24
24
  constructor() {
25
25
  super();
@@ -121,7 +121,14 @@ let PrivateIdentifier = PrivateIdentifier_1 = class PrivateIdentifier extends Ab
121
121
  privateScope.getScope(PRIVATE_SYMBOL)?.set(this.name, value);
122
122
  }
123
123
  get(stack, thisContext) {
124
- const privateObj = stack.get(PRIVATE_SYMBOL);
124
+ if (thisContext) {
125
+ return thisContext[PRIVATE_SYMBOL][this.name];
126
+ }
127
+ let privateObj = stack.get('this');
128
+ if (privateObj) {
129
+ return privateObj[PRIVATE_SYMBOL][this.name];
130
+ }
131
+ privateObj = stack.get(PRIVATE_SYMBOL);
125
132
  return privateObj[this.name];
126
133
  }
127
134
  dependency(computed) {
@@ -147,10 +154,10 @@ PrivateIdentifier = PrivateIdentifier_1 = __decorate_1([
147
154
  export { PrivateIdentifier };
148
155
  let StaticBlock = StaticBlock_1 = class StaticBlock extends BlockStatement {
149
156
  static fromJSON(node, deserializer) {
150
- return new StaticBlock_1(deserializer(node.body), node.isStatement);
157
+ return new StaticBlock_1(deserializer(node.body));
151
158
  }
152
- constructor(body, isStatement) {
153
- super(body, isStatement);
159
+ constructor(body) {
160
+ super(body);
154
161
  }
155
162
  get(stack, classConstructor) {
156
163
  const constructor = classConstructor;
@@ -159,10 +166,15 @@ let StaticBlock = StaticBlock_1 = class StaticBlock extends BlockStatement {
159
166
  toString() {
160
167
  return `static ${super.toString()}`;
161
168
  }
169
+ toJson() {
170
+ return {
171
+ body: this.body.map(node => node.toJSON())
172
+ };
173
+ }
162
174
  };
163
175
  StaticBlock = StaticBlock_1 = __decorate_1([
164
176
  Deserializer('StaticBlock'),
165
- __metadata("design:paramtypes", [Array, Boolean])
177
+ __metadata("design:paramtypes", [Array])
166
178
  ], StaticBlock);
167
179
  export { StaticBlock };
168
180
  export class AbstractDefinition extends AbstractExpressionNode {
@@ -199,6 +211,19 @@ export class AbstractDefinition extends AbstractExpressionNode {
199
211
  dependencyPath(computed) {
200
212
  return [];
201
213
  }
214
+ getTarget(classConstructor) {
215
+ return this.static
216
+ ? (this.key instanceof PrivateIdentifier ? classConstructor[PRIVATE_SYMBOL] : classConstructor)
217
+ : (this.key instanceof PrivateIdentifier ? classConstructor[INSTANCE_PRIVATE_SYMBOL] : classConstructor.prototype);
218
+ }
219
+ getKeyName(stack) {
220
+ switch (true) {
221
+ case this.computed: return this.key.get(stack);
222
+ case this.key instanceof Identifier:
223
+ case this.key instanceof PrivateIdentifier: return this.key.getName();
224
+ default: return this.key.toString();
225
+ }
226
+ }
202
227
  }
203
228
  let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends AbstractDefinition {
204
229
  constructor(kind, key, value, decorators, computed, isStatic) {
@@ -224,23 +249,22 @@ let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends Abstr
224
249
  this.initConstructor(stack, classConstructor);
225
250
  return;
226
251
  }
227
- const target = this.static ? classConstructor : classConstructor.prototype;
252
+ const target = this.getTarget(classConstructor);
253
+ const name = this.getKeyName(stack);
228
254
  const value = this.value?.get(stack);
229
- const name = this.computed ? this.key.get(stack) : this.key.getName();
230
- const ref = this.key instanceof PrivateIdentifier ? target[INIT_PRIVATE_SYMBOL] : target;
231
255
  switch (this.kind) {
232
256
  case 'method':
233
- ref[name] = value;
257
+ target[name] = value;
234
258
  break;
235
259
  case 'set':
236
- Object.defineProperty(ref, name, {
260
+ Object.defineProperty(target, name, {
237
261
  configurable: true,
238
262
  enumerable: false,
239
263
  set: value,
240
264
  });
241
265
  break;
242
266
  case 'get':
243
- Object.defineProperty(ref, name, {
267
+ Object.defineProperty(target, name, {
244
268
  configurable: true,
245
269
  enumerable: false,
246
270
  get: value,
@@ -250,17 +274,18 @@ let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends Abstr
250
274
  break;
251
275
  }
252
276
  const decorators = this.decorators.map(decorator => decorator.get(stack));
253
- __decorate(decorators, target, name, null);
277
+ decorators.length && __decorate(decorators, target, name, null);
254
278
  }
255
279
  initConstructor(stack, classConstructor) {
256
- let superIndex = this.value.getBody()
280
+ const body = this.value.getBody().getBody();
281
+ let superIndex = body
257
282
  .findIndex(call => call instanceof CallExpression && Super.INSTANCE === call.getCallee());
258
283
  if (superIndex === -1) {
259
- superIndex = this.value.getBody().length;
284
+ superIndex = body.length;
260
285
  }
261
- const superCall = this.value.getBody()[superIndex];
262
- const blockBeforeSuper = new BlockStatement(this.value.getBody().slice(0, superIndex), false);
263
- const blockAfterSuper = new BlockStatement(this.value.getBody().slice(superIndex + 1), false);
286
+ const superCall = body[superIndex];
287
+ const blockBeforeSuper = new BlockStatement(body.slice(0, superIndex));
288
+ const blockAfterSuper = new BlockStatement(body.slice(superIndex + 1));
264
289
  if (superCall) {
265
290
  classConstructor[GET_PARAMETERS] = function (params) {
266
291
  const scope = stack.pushBlockScope();
@@ -271,7 +296,7 @@ let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends Abstr
271
296
  return parameters;
272
297
  };
273
298
  }
274
- classConstructor.prototype[CONSTRUCTOR] = function (params) {
299
+ classConstructor[CONSTRUCTOR] = function (params) {
275
300
  const scope = this[STACK].pushBlockScope();
276
301
  blockAfterSuper.get(this[STACK]);
277
302
  stack.clearTo(scope);
@@ -282,22 +307,36 @@ let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends Abstr
282
307
  if (str.length) {
283
308
  str += ' ';
284
309
  }
285
- let name = this.computed ? `[${this.key.toString()}]` : this.key.toString();
310
+ if (this.static) {
311
+ str += 'static ';
312
+ }
313
+ const methodName = this.key.toString();
286
314
  switch (this.kind) {
287
- case 'constructor':
288
- str += 'constructor ';
289
- break;
290
315
  case 'get':
291
- str += `get ${name} `;
316
+ str += 'get ' + methodName;
292
317
  break;
293
318
  case 'set':
294
- str += `set ${name} `;
319
+ str += 'set ' + methodName;
320
+ break;
321
+ case 'method':
322
+ if (this.value.getAsync() && this.value.getGenerator()) {
323
+ str += 'async *';
324
+ }
325
+ else if (this.value.getAsync()) {
326
+ str += 'async ';
327
+ }
328
+ else if (this.value.getGenerator()) {
329
+ str += '*';
330
+ }
331
+ str += methodName;
332
+ break;
333
+ case 'constructor':
334
+ str += 'constructor';
295
335
  break;
296
336
  default:
297
- str = `${name} `;
298
337
  break;
299
338
  }
300
- str += this.value.toString();
339
+ str += this.value.paramsAndBodyToString();
301
340
  return str;
302
341
  }
303
342
  toJson() {
@@ -328,21 +367,17 @@ let PropertyDefinition = PropertyDefinition_1 = class PropertyDefinition extends
328
367
  super(key, decorators, computed, isStatic, value);
329
368
  }
330
369
  get(stack, classConstructor) {
331
- const target = this.static ? classConstructor : classConstructor.prototype;
370
+ const target = this.getTarget(classConstructor);
371
+ const name = this.getKeyName(stack);
332
372
  const value = this.value?.get(stack);
333
- const name = this.computed ? this.key.get(stack) : this.key.getName();
334
- const ref = this.key instanceof PrivateIdentifier ? target[INIT_PRIVATE_SYMBOL] : target;
335
- ref[name] = value;
373
+ target[name] = value;
336
374
  const decorators = this.decorators.map(decorator => decorator.get(stack));
337
- __decorate(decorators, target, name, null);
375
+ decorators.length && __decorate(decorators, target, name, null);
338
376
  }
339
377
  toString() {
340
378
  const decorators = this.decorators.map(decorator => decorator.toString()).join('\n');
341
379
  const name = this.computed ? `[${this.key.toString()}]` : this.key.toString();
342
- if (this.value) {
343
- return `${name} = ${this.value.toString()};`;
344
- }
345
- return `${decorators.length ? decorators + ' ' : ''}${name};`;
380
+ return `${decorators.length ? decorators + ' ' : ''}${this.static ? 'static ' : ''}${name}${this.value ? ` = ${this.value.toString()}` : ''};`;
346
381
  }
347
382
  toJson() {
348
383
  return {
@@ -372,18 +407,19 @@ let AccessorProperty = AccessorProperty_1 = class AccessorProperty extends Abstr
372
407
  super(key, decorators, computed, isStatic, value);
373
408
  }
374
409
  get(stack, classConstructor) {
375
- const target = this.static ? classConstructor : classConstructor.prototype;
410
+ const target = this.getTarget(classConstructor);
411
+ const name = this.getKeyName(stack);
376
412
  const value = this.value?.get(stack);
377
- const name = this.computed ? this.key.get(stack) : this.key.getName();
378
- target[INIT_PRIVATE_SYMBOL][name] = value;
379
- Object.defineProperty(target, name, {
413
+ target[name] = value;
414
+ const ref = this.static ? classConstructor : classConstructor.prototype;
415
+ Object.defineProperty(ref, name, {
380
416
  configurable: true,
381
417
  enumerable: false,
382
418
  set: function (setValue) {
383
419
  this[PRIVATE_SYMBOL][name] = setValue;
384
420
  },
385
421
  });
386
- Object.defineProperty(target, name, {
422
+ Object.defineProperty(ref, name, {
387
423
  configurable: true,
388
424
  enumerable: false,
389
425
  get: function () {
@@ -391,15 +427,12 @@ let AccessorProperty = AccessorProperty_1 = class AccessorProperty extends Abstr
391
427
  },
392
428
  });
393
429
  const decorators = this.decorators.map(decorator => decorator.get(stack));
394
- __decorate(decorators, target, name, null);
430
+ decorators.length && __decorate(decorators, ref, name, null);
395
431
  }
396
432
  toString() {
397
433
  const decorators = this.decorators.map(decorator => decorator.toString()).join('\n');
398
434
  const name = this.computed ? `[${this.key.toString()}]` : this.key.toString();
399
- if (this.value) {
400
- return `${name} = ${this.value.toString()};`;
401
- }
402
- return `${decorators.length ? decorators + ' ' : ''}accessor ${name};`;
435
+ return `${decorators.length ? decorators.concat(' ') : ''}${this.static ? 'static ' : ''}accessor ${name}${this.value ? ` = ${this.value.toString()}` : ''};`;
403
436
  }
404
437
  toJson() {
405
438
  return {
@@ -444,7 +477,7 @@ let ClassBody = ClassBody_1 = class ClassBody extends AbstractExpressionNode {
444
477
  throw new Error('Method not implemented.');
445
478
  }
446
479
  toString() {
447
- return this.body.map(definition => definition.toString()).join('\n');
480
+ return this.body.map(definition => `\t${definition.toString()}`).join('\n');
448
481
  }
449
482
  toJson() {
450
483
  return {
@@ -489,22 +522,21 @@ export class Class extends AbstractExpressionNode {
489
522
  };
490
523
  let classConstructor = this.createClass(stack, parentClass, className);
491
524
  this.body.get(stack, classConstructor);
492
- classConstructor[PRIVATE_SYMBOL] = Object.assign(classConstructor[PRIVATE_SYMBOL], classConstructor[INIT_PRIVATE_SYMBOL]);
493
- Reflect.deleteProperty(classConstructor, INIT_PRIVATE_SYMBOL);
494
525
  const decorators = this.decorators.map(decorator => decorator.get(stack));
495
526
  classConstructor = __decorate(decorators, classConstructor);
527
+ classConstructor[STATIC_INITIALIZATION_BLOCK].forEach(block => block());
528
+ Reflect.deleteProperty(classConstructor, STATIC_INITIALIZATION_BLOCK);
496
529
  return classConstructor;
497
530
  }
498
531
  createClass(stack, parentClass, className = TEMP_CLASS_NAME) {
499
- var _a, _b, _c, _d, _e, _f;
532
+ var _a, _b, _c, _d, _e;
500
533
  const TEMP = {
501
- [className]: (_a = class extends parentClass {
534
+ [className]: (_e = class extends parentClass {
502
535
  constructor(...params) {
503
536
  const parameters = TEMP[className][GET_PARAMETERS](params);
504
537
  super(...parameters);
505
- this[_e] = {};
506
- this[_f] = {};
507
- this[PRIVATE_SYMBOL] = Object.assign(this[PRIVATE_SYMBOL], this[INIT_PRIVATE_SYMBOL]);
538
+ this[_d] = {};
539
+ this[PRIVATE_SYMBOL] = Object.assign(this[PRIVATE_SYMBOL], TEMP[className][INSTANCE_PRIVATE_SYMBOL]);
508
540
  this[STACK] = stack.copyStack();
509
541
  const instanceStack = this[STACK];
510
542
  instanceStack.pushBlockScope();
@@ -514,20 +546,18 @@ export class Class extends AbstractExpressionNode {
514
546
  instanceStack.declareVariable(CALL_SUPER_Method, (name) => super[name]());
515
547
  instanceStack.declareVariable(GET_SUPER_PROPERTY, (name) => super[name]);
516
548
  instanceStack.pushReactiveScope();
517
- this[CONSTRUCTOR]();
549
+ TEMP[className][CONSTRUCTOR]();
518
550
  }
519
551
  static [GET_PARAMETERS](args) {
520
- return [];
552
+ return args;
521
553
  }
522
- [(_b = STATIC_INITIALIZATION_BLOCK, _c = INIT_PRIVATE_SYMBOL, _d = PRIVATE_SYMBOL, _e = PRIVATE_SYMBOL, _f = INIT_PRIVATE_SYMBOL, CONSTRUCTOR)]() { }
554
+ static [(_a = STATIC_INITIALIZATION_BLOCK, _b = PRIVATE_SYMBOL, _c = INSTANCE_PRIVATE_SYMBOL, CONSTRUCTOR)]() { }
523
555
  },
524
- _a[_b] = [],
525
- _a[_c] = {},
526
- _a[_d] = {},
527
- (() => {
528
- _a[STATIC_INITIALIZATION_BLOCK].forEach(block => block());
529
- })(),
530
- _a)
556
+ _d = PRIVATE_SYMBOL,
557
+ _e[_a] = [],
558
+ _e[_b] = {},
559
+ _e[_c] = {},
560
+ _e)
531
561
  };
532
562
  return TEMP[className];
533
563
  }
@@ -546,7 +576,7 @@ export class Class extends AbstractExpressionNode {
546
576
  if (this.superClass) {
547
577
  classDeclaration += ' extends ' + this.superClass.toString();
548
578
  }
549
- return `${decorators}${classDeclaration} {${this.body.toString()}\n`;
579
+ return `${decorators}${classDeclaration} {\n${this.body.toString()}\n}`;
550
580
  }
551
581
  toJson() {
552
582
  return {
@@ -563,26 +593,37 @@ let ClassDeclaration = ClassDeclaration_1 = class ClassDeclaration extends Class
563
593
  }
564
594
  static visit(node, visitNode) {
565
595
  visitNode(node.body);
566
- node.id && visitNode(node.id);
596
+ node.decorators.forEach(visitNode);
597
+ visitNode(node.id);
567
598
  node.superClass && visitNode(node.superClass);
568
599
  }
600
+ constructor(body, decorators, id, superClass) {
601
+ super(body, decorators, id, superClass);
602
+ }
569
603
  declareVariable(stack, propertyValue) {
570
- this.id && stack.declareVariable(this.id.getName(), propertyValue);
604
+ stack.declareVariable(this.id.getName(), propertyValue);
571
605
  }
572
606
  getDeclarationName() {
573
- return this.id?.getDeclarationName();
607
+ return this.id.getDeclarationName();
608
+ }
609
+ get(stack) {
610
+ const classConstructor = super.get(stack);
611
+ this.id.declareVariable(stack, classConstructor);
612
+ return classConstructor;
574
613
  }
575
614
  };
576
615
  ClassDeclaration = ClassDeclaration_1 = __decorate_1([
577
- Deserializer('ClassDeclaration')
616
+ Deserializer('ClassDeclaration'),
617
+ __metadata("design:paramtypes", [ClassBody, Array, Identifier, Object])
578
618
  ], ClassDeclaration);
579
619
  export { ClassDeclaration };
580
620
  let ClassExpression = ClassExpression_1 = class ClassExpression extends Class {
581
621
  static fromJSON(node, deserializer) {
582
- return new ClassExpression_1(deserializer(node.body), node.id && deserializer(node.id), node.superClass && deserializer(node.superClass));
622
+ return new ClassExpression_1(deserializer(node.body), node.superClass && deserializer(node.superClass));
583
623
  }
584
624
  static visit(node, visitNode) {
585
625
  visitNode(node.body);
626
+ node.decorators.forEach(visitNode);
586
627
  node.id && visitNode(node.id);
587
628
  node.superClass && visitNode(node.superClass);
588
629
  }