@ibyar/expressions 0.6.1 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/api/abstract.d.ts +0 -3
- package/api/abstract.js +0 -4
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +85 -43
- package/api/class/class.js +232 -169
- package/api/class/class.js.map +1 -1
- package/api/class/decorator.d.ts +0 -2
- package/api/class/decorator.js +0 -3
- package/api/class/decorator.js.map +1 -1
- package/api/computing/call.d.ts +0 -2
- package/api/computing/call.js +0 -3
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +0 -2
- package/api/computing/debugger.js +0 -2
- package/api/computing/debugger.js.map +1 -1
- package/api/computing/new.d.ts +0 -2
- package/api/computing/new.js +0 -3
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +0 -2
- package/api/computing/rest.js +0 -3
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +0 -2
- package/api/computing/return.js +0 -3
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +0 -2
- package/api/computing/spread.js +0 -3
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +0 -4
- package/api/computing/throw.js +0 -5
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +0 -2
- package/api/computing/yield.js +0 -3
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +0 -3
- package/api/definition/array.js +0 -4
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +0 -1
- package/api/definition/bind.js +0 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/comment.d.ts +0 -2
- package/api/definition/comment.js +0 -1
- package/api/definition/comment.js.map +1 -1
- package/api/definition/function.d.ts +3 -11
- package/api/definition/function.js +33 -56
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +0 -1
- package/api/definition/member.js +1 -2
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +1 -5
- package/api/definition/object.js +2 -8
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +0 -2
- package/api/definition/statement.js +0 -3
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +6 -9
- package/api/definition/values.js +9 -20
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +0 -20
- package/api/expression.js.map +1 -1
- package/api/module/common.d.ts +1 -2
- package/api/module/common.js +3 -3
- package/api/module/common.js.map +1 -1
- package/api/module/export.d.ts +0 -5
- package/api/module/export.js +5 -9
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +2 -6
- package/api/module/import.js +4 -9
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +0 -2
- package/api/operators/await.js +0 -3
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +0 -1
- package/api/operators/chaining.js +0 -1
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +0 -2
- package/api/operators/comma.js +0 -3
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +0 -2
- package/api/operators/grouping.js +0 -3
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +1 -3
- package/api/operators/pipeline.js +0 -7
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +0 -2
- package/api/operators/ternary.js +0 -5
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +0 -2
- package/api/operators/unary.js +0 -3
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +0 -2
- package/api/operators/update.js +0 -3
- package/api/operators/update.js.map +1 -1
- package/api/program.d.ts +0 -2
- package/api/program.js +0 -1
- package/api/program.js.map +1 -1
- package/api/statement/control/block.d.ts +0 -2
- package/api/statement/control/block.js +3 -8
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +0 -2
- package/api/statement/control/empty.js +0 -1
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +0 -2
- package/api/statement/control/if.js +0 -5
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +0 -3
- package/api/statement/control/switch.js +0 -8
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +0 -3
- package/api/statement/control/terminate.js +0 -4
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +1 -4
- package/api/statement/declarations/declares.js +0 -6
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +1 -6
- package/api/statement/iterations/for.js +0 -18
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +0 -3
- package/api/statement/iterations/while.js +0 -8
- package/api/statement/iterations/while.js.map +1 -1
- package/package.json +3 -3
- package/scope/scope.d.ts +6 -22
- package/scope/scope.js +12 -59
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +15 -3
- package/scope/stack.js +26 -9
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +0 -7
- package/v8/enums.js +0 -15
- package/v8/enums.js.map +1 -1
- package/v8/index.d.ts +1 -0
- package/v8/index.js +1 -0
- package/v8/index.js.map +1 -1
- package/v8/inline.d.ts +5 -2
- package/v8/inline.js +31 -17
- package/v8/inline.js.map +1 -1
- package/v8/language.d.ts +7 -0
- package/v8/language.js +16 -0
- package/v8/language.js.map +1 -0
- package/v8/nodes.d.ts +1 -1
- package/v8/parser.d.ts +2 -1
- package/v8/parser.js +2 -1
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +1 -1
- package/v8/stream.js +1 -1
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +1 -1
- package/v8/token.js +1 -1
- package/v8/token.js.map +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Ibyar Expression
|
|
2
2
|
|
|
3
3
|
[![NPM Version][npm-image]][npm-url]
|
|
4
4
|
[![NPM Downloads][downloads-image]][downloads-url]
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
[lerna-url]: https://lerna.js.org/
|
|
17
17
|
[contributors]: https://img.shields.io/github/contributors/ibyar/aurora
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Your Mirror Dimension in the javascript world.
|
|
20
|
+
|
|
21
|
+
Ibyar expression, is a JavaScript expression parsing and evaluation. and template expression evaluation, with stack and scope.
|
|
20
22
|
|
|
21
23
|
- this package has no dependance, can work on both (Node.js) and any Web Browsers, that support modules and class syntax
|
|
22
24
|
- An 100% spec compliant ES2022 JavaScript toolchain
|
|
@@ -31,6 +33,9 @@ npm i --save @ibyar/expressions
|
|
|
31
33
|
yarn add @ibyar/expressions
|
|
32
34
|
```
|
|
33
35
|
|
|
36
|
+
## Try the parser
|
|
37
|
+
- Ibyar Expression parser: https://ibyar.github.io/astexplorer/
|
|
38
|
+
|
|
34
39
|
|
|
35
40
|
## Example
|
|
36
41
|
```ts
|
package/api/abstract.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Scope } from '../scope/scope.js';
|
|
2
1
|
import type { AwaitPromiseInfo, Stack } from '../scope/stack.js';
|
|
3
2
|
import type { NodeDeserializer, ExpressionNode, ExpressionNodConstructor, NodeJsonType, DeclarationExpression, ExpressionEventMap, ExpressionEventPath, VisitNodeType } from './expression.js';
|
|
4
3
|
export declare abstract class AbstractExpressionNode implements ExpressionNode {
|
|
@@ -6,7 +5,6 @@ export declare abstract class AbstractExpressionNode implements ExpressionNode {
|
|
|
6
5
|
getClass(): ExpressionNodConstructor<ExpressionNode>;
|
|
7
6
|
toJSON(key?: string): NodeJsonType;
|
|
8
7
|
events(): ExpressionEventMap;
|
|
9
|
-
abstract shareVariables(scopeList: Scope<any>[]): void;
|
|
10
8
|
abstract set(stack: Stack, value: any): any;
|
|
11
9
|
abstract get(stack: Stack, thisContext?: any): any;
|
|
12
10
|
abstract dependency(computed?: true): ExpressionNode[];
|
|
@@ -25,7 +23,6 @@ export declare abstract class InfixExpressionNode<T> extends AbstractExpressionN
|
|
|
25
23
|
getOperator(): T;
|
|
26
24
|
getLeft(): ExpressionNode;
|
|
27
25
|
getRight(): ExpressionNode;
|
|
28
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
29
26
|
set(context: object, value: any): void;
|
|
30
27
|
abstract get(stack: Stack): any;
|
|
31
28
|
dependency(computed?: true): ExpressionNode[];
|
package/api/abstract.js
CHANGED
|
@@ -60,10 +60,6 @@ export class InfixExpressionNode extends AbstractExpressionNode {
|
|
|
60
60
|
getRight() {
|
|
61
61
|
return this.right;
|
|
62
62
|
}
|
|
63
|
-
shareVariables(scopeList) {
|
|
64
|
-
this.left.shareVariables(scopeList);
|
|
65
|
-
this.right.shareVariables(scopeList);
|
|
66
|
-
}
|
|
67
63
|
set(context, value) {
|
|
68
64
|
throw new Error(`${this.constructor.name}#set() of operator: '${this.operator}' has no implementation.`);
|
|
69
65
|
}
|
package/api/abstract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../src/expressions/api/abstract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../src/expressions/api/abstract.ts"],"names":[],"mappings":"AAOA,SAAS,0BAA0B,CAAC,YAAgC,EAAE,IAA2B;IAChG,IAAI,OAAO,GAAG,YAAY,CAAC;IAC3B,iBAAiB;IACjB,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;QACD,uCAAuC;QACvC,mCAAmC;QACnC,aAAa;Q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AAV,UAAK,GAAL,KAAK,CAAK;IAAI,CAAC;IAClC,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAED,MAAM,OAAO,UAAU;IACtB,YAAmB,KAAU;QAAV,UAAK,GAAL,KAAK,CAAK;IAAI,CAAC;IAClC,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAED,MAAM,OAAO,kBAAkB;IAC9B,YAAmB,KAAU;QAAV,UAAK,GAAL,KAAK,CAAK;IAAI,CAAC;IAClC,QAAQ;QACP,OAAO,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 { 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 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\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"]}
|
package/api/class/class.d.ts
CHANGED
|
@@ -1,41 +1,85 @@
|
|
|
1
1
|
import type { DeclarationExpression, ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';
|
|
2
|
-
import { Scope } from '../../scope/scope.js';
|
|
3
2
|
import { Stack } from '../../scope/stack.js';
|
|
4
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
4
|
import { Identifier } from '../definition/values.js';
|
|
6
|
-
import { MemberExpression } from '../definition/member.js';
|
|
7
5
|
import { FunctionExpression } from '../definition/function.js';
|
|
8
6
|
import { BlockStatement } from '../statement/control/block.js';
|
|
9
7
|
import { Decorator } from './decorator.js';
|
|
10
|
-
declare const STACK: unique symbol;
|
|
11
|
-
declare const GET_PARAMETERS: unique symbol;
|
|
12
|
-
declare const CONSTRUCTOR: unique symbol;
|
|
13
8
|
declare const PRIVATE_SYMBOL: unique symbol;
|
|
14
|
-
declare const INSTANCE_PRIVATE_SYMBOL: unique symbol;
|
|
15
|
-
declare const STATIC_INITIALIZATION_BLOCK: unique symbol;
|
|
16
9
|
interface ClassConstructor {
|
|
17
10
|
/**
|
|
18
11
|
* A reference to the prototype.
|
|
19
12
|
*/
|
|
20
13
|
readonly prototype: ClassInstance;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
[CONSTRUCTOR]: Function;
|
|
30
|
-
[key: string]: any;
|
|
14
|
+
/**
|
|
15
|
+
* private static properties and methods
|
|
16
|
+
*/
|
|
17
|
+
[PRIVATE_SYMBOL]: Record<PropertyKey, any>;
|
|
18
|
+
/**
|
|
19
|
+
* public static class properties
|
|
20
|
+
*/
|
|
21
|
+
[key: PropertyKey]: any;
|
|
31
22
|
}
|
|
32
23
|
declare var ClassInstance: ClassConstructor;
|
|
33
24
|
interface ClassInstance {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
[
|
|
38
|
-
|
|
25
|
+
/**
|
|
26
|
+
* private instance properties and methods
|
|
27
|
+
*/
|
|
28
|
+
[PRIVATE_SYMBOL]: Record<PropertyKey, any>;
|
|
29
|
+
/**
|
|
30
|
+
* public instance properties
|
|
31
|
+
*/
|
|
32
|
+
[key: PropertyKey]: any;
|
|
33
|
+
}
|
|
34
|
+
declare type PropertyInitializer = () => {
|
|
35
|
+
key: PropertyKey;
|
|
36
|
+
value: any;
|
|
37
|
+
isPrivate: boolean;
|
|
38
|
+
};
|
|
39
|
+
declare class ClassInitializer {
|
|
40
|
+
/**
|
|
41
|
+
* register class public static properties and methods
|
|
42
|
+
*/
|
|
43
|
+
private staticInitializer;
|
|
44
|
+
/**
|
|
45
|
+
* register class private static properties and methods
|
|
46
|
+
*/
|
|
47
|
+
private staticPrivateInitializer;
|
|
48
|
+
/**
|
|
49
|
+
* register static initialization block
|
|
50
|
+
*/
|
|
51
|
+
private staticInitializerBlock;
|
|
52
|
+
/**
|
|
53
|
+
* register class constructor function
|
|
54
|
+
*/
|
|
55
|
+
private instanceConstructor?;
|
|
56
|
+
/**
|
|
57
|
+
* register super parameter resolver
|
|
58
|
+
*/
|
|
59
|
+
private superParameterResolver;
|
|
60
|
+
/**
|
|
61
|
+
* register in class property
|
|
62
|
+
*/
|
|
63
|
+
private instanceMethod;
|
|
64
|
+
/**
|
|
65
|
+
* register method in instance private space
|
|
66
|
+
*/
|
|
67
|
+
private privateInstanceMethod;
|
|
68
|
+
/**
|
|
69
|
+
* register property in instance itself
|
|
70
|
+
*/
|
|
71
|
+
private instanceInitializer;
|
|
72
|
+
addStaticInitializer(key: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): void;
|
|
73
|
+
addStaticPrivateInitializer(key: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): void;
|
|
74
|
+
addStaticInitializerBlock(block: () => void): void;
|
|
75
|
+
setConstructor(cstr: Function): void;
|
|
76
|
+
setParameterResolver(resolver: (params: any[]) => any[]): void;
|
|
77
|
+
addInstanceMethod(key: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): void;
|
|
78
|
+
addPrivateInstanceMethod(key: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): void;
|
|
79
|
+
addInstanceInitializer(initializer: PropertyInitializer): void;
|
|
80
|
+
initClass(classConstructor: ClassConstructor): void;
|
|
81
|
+
getSuperArguments(args: any[]): any[];
|
|
82
|
+
initInstance(instance: ClassInstance): void;
|
|
39
83
|
}
|
|
40
84
|
/**
|
|
41
85
|
* A `super` pseudo-expression.
|
|
@@ -44,9 +88,8 @@ export declare class Super extends AbstractExpressionNode {
|
|
|
44
88
|
static INSTANCE: Super;
|
|
45
89
|
static fromJSON(node: Super): Super;
|
|
46
90
|
constructor();
|
|
47
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
48
91
|
set(stack: Stack, value: any): void;
|
|
49
|
-
get(stack: Stack, thisContext?: any):
|
|
92
|
+
get(stack: Stack, thisContext?: any): any;
|
|
50
93
|
dependency(computed?: true): ExpressionNode[];
|
|
51
94
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
52
95
|
toString(): string;
|
|
@@ -61,8 +104,9 @@ export declare class Super extends AbstractExpressionNode {
|
|
|
61
104
|
*
|
|
62
105
|
* In the future, it will represent other meta properties as well.
|
|
63
106
|
*/
|
|
64
|
-
export declare class MetaProperty extends
|
|
107
|
+
export declare class MetaProperty extends AbstractExpressionNode {
|
|
65
108
|
private meta;
|
|
109
|
+
private property;
|
|
66
110
|
static NewTarget: MetaProperty;
|
|
67
111
|
static ImportMeta: MetaProperty;
|
|
68
112
|
private static getJsonName;
|
|
@@ -70,8 +114,11 @@ export declare class MetaProperty extends MemberExpression {
|
|
|
70
114
|
static visit(node: MetaProperty, visitNode: VisitNodeType): void;
|
|
71
115
|
constructor(meta: Identifier, property: Identifier);
|
|
72
116
|
getMeta(): Identifier;
|
|
73
|
-
|
|
74
|
-
get(stack: Stack
|
|
117
|
+
getProperty(): Identifier;
|
|
118
|
+
get(stack: Stack): any;
|
|
119
|
+
set(stack: Stack, value: any): void;
|
|
120
|
+
dependency(computed?: true | undefined): ExpressionNode[];
|
|
121
|
+
dependencyPath(computed?: true | undefined): ExpressionEventPath[];
|
|
75
122
|
toString(): string;
|
|
76
123
|
toJson(): {
|
|
77
124
|
[key: string]: any;
|
|
@@ -82,7 +129,8 @@ export declare class MetaProperty extends MemberExpression {
|
|
|
82
129
|
*/
|
|
83
130
|
export declare class PrivateIdentifier extends Identifier {
|
|
84
131
|
static fromJSON(node: PrivateIdentifier): PrivateIdentifier;
|
|
85
|
-
get(stack: Stack): any;
|
|
132
|
+
get(stack: Stack, thisContext: ClassInstance): any;
|
|
133
|
+
set(stack: Stack, value: any): any;
|
|
86
134
|
toString(): string;
|
|
87
135
|
}
|
|
88
136
|
/**
|
|
@@ -91,7 +139,7 @@ export declare class PrivateIdentifier extends Identifier {
|
|
|
91
139
|
export declare class StaticBlock extends BlockStatement {
|
|
92
140
|
static fromJSON(node: StaticBlock, deserializer: NodeDeserializer<any>): StaticBlock;
|
|
93
141
|
constructor(body: ExpressionNode[]);
|
|
94
|
-
get(stack: Stack,
|
|
142
|
+
get(stack: Stack, classInitializer?: ClassInitializer): void;
|
|
95
143
|
toString(): string;
|
|
96
144
|
toJson(): object;
|
|
97
145
|
}
|
|
@@ -106,18 +154,13 @@ export declare abstract class AbstractDefinition extends AbstractExpressionNode
|
|
|
106
154
|
getValue(): ExpressionNode | undefined;
|
|
107
155
|
isComputed(): boolean;
|
|
108
156
|
isStatic(): boolean;
|
|
157
|
+
isPrivate(): boolean;
|
|
109
158
|
getDecorators(): Decorator[];
|
|
110
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
111
159
|
set(stack: Stack, value: any): void;
|
|
112
160
|
dependency(computed?: true): ExpressionNode[];
|
|
113
161
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
114
|
-
getTarget(classConstructor: ClassConstructor): {
|
|
115
|
-
[key: string]: any;
|
|
116
|
-
[key: number]: any;
|
|
117
|
-
[key: symbol]: any;
|
|
118
|
-
};
|
|
119
162
|
getKeyName(stack: Stack): any;
|
|
120
|
-
abstract get(stack: Stack,
|
|
163
|
+
abstract get(stack: Stack, initializer?: ClassInitializer): void;
|
|
121
164
|
abstract toString(): string;
|
|
122
165
|
abstract toJson(): {
|
|
123
166
|
[key: string]: any;
|
|
@@ -132,10 +175,12 @@ export declare class MethodDefinition extends AbstractDefinition {
|
|
|
132
175
|
static fromJSON(node: MethodDefinition, deserializer: NodeDeserializer<any>): MethodDefinition;
|
|
133
176
|
static visit(node: MethodDefinition, visitNode: VisitNodeType): void;
|
|
134
177
|
protected value: FunctionExpression;
|
|
178
|
+
afterInstanceConstruct: any;
|
|
135
179
|
constructor(kind: MethodDefinitionKind, key: ExpressionNode | PrivateIdentifier, value: FunctionExpression, decorators: Decorator[], computed: boolean, isStatic: boolean);
|
|
136
180
|
getKind(): MethodDefinitionKind;
|
|
137
181
|
getValue(): FunctionExpression;
|
|
138
|
-
get(stack: Stack,
|
|
182
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
183
|
+
private getPropertyAttributes;
|
|
139
184
|
private initConstructor;
|
|
140
185
|
toString(): string;
|
|
141
186
|
toJson(): {
|
|
@@ -149,7 +194,7 @@ export declare class PropertyDefinition extends AbstractDefinition {
|
|
|
149
194
|
static fromJSON(node: PropertyDefinition, deserializer: NodeDeserializer<any>): PropertyDefinition;
|
|
150
195
|
static visit(node: PropertyDefinition, visitNode: VisitNodeType): void;
|
|
151
196
|
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode);
|
|
152
|
-
get(stack: Stack,
|
|
197
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
153
198
|
toString(): string;
|
|
154
199
|
toJson(): {
|
|
155
200
|
[key: string]: any;
|
|
@@ -159,7 +204,7 @@ export declare class AccessorProperty extends AbstractDefinition {
|
|
|
159
204
|
static fromJSON(node: AccessorProperty, deserializer: NodeDeserializer): AccessorProperty;
|
|
160
205
|
static visit(node: AccessorProperty, visitNode: VisitNodeType): void;
|
|
161
206
|
constructor(key: ExpressionNode, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode);
|
|
162
|
-
get(stack: Stack,
|
|
207
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
163
208
|
toString(): string;
|
|
164
209
|
toJson(): {
|
|
165
210
|
[key: string]: any;
|
|
@@ -171,9 +216,8 @@ export declare class ClassBody extends AbstractExpressionNode {
|
|
|
171
216
|
static visit(node: ClassBody, visitNode: VisitNodeType): void;
|
|
172
217
|
constructor(body: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[]);
|
|
173
218
|
getBody(): (StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty)[];
|
|
174
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
175
219
|
set(stack: Stack, value: any): void;
|
|
176
|
-
get(stack: Stack,
|
|
220
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
177
221
|
dependency(computed?: true): ExpressionNode[];
|
|
178
222
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
179
223
|
toString(): string;
|
|
@@ -186,13 +230,11 @@ export declare class Class extends AbstractExpressionNode {
|
|
|
186
230
|
protected decorators: Decorator[];
|
|
187
231
|
protected id?: Identifier | undefined;
|
|
188
232
|
protected superClass?: ExpressionNode | undefined;
|
|
189
|
-
private sharedVariables?;
|
|
190
233
|
constructor(body: ClassBody, decorators: Decorator[], id?: Identifier | undefined, superClass?: ExpressionNode | undefined);
|
|
191
234
|
getBody(): ClassBody;
|
|
192
235
|
getDecorators(): Decorator[];
|
|
193
236
|
getId(): Identifier | undefined;
|
|
194
237
|
getSuperClass(): ExpressionNode | undefined;
|
|
195
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
196
238
|
set(stack: Stack): void;
|
|
197
239
|
get(stack: Stack): ClassConstructor;
|
|
198
240
|
private createClass;
|