@ibyar/expressions 0.8.2-dev.20221008 → 0.8.4
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 +0 -3
- package/api/abstract.d.ts +6 -5
- package/api/abstract.js +15 -12
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +99 -60
- package/api/class/class.js +285 -233
- package/api/class/class.js.map +1 -1
- package/api/class/decorator.d.ts +2 -4
- package/api/class/decorator.js +6 -9
- package/api/class/decorator.js.map +1 -1
- package/api/computing/call.d.ts +2 -4
- package/api/computing/call.js +8 -11
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +1 -4
- package/api/computing/debugger.js +2 -5
- package/api/computing/debugger.js.map +1 -1
- package/api/computing/new.d.ts +2 -4
- package/api/computing/new.js +7 -10
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +2 -4
- package/api/computing/rest.js +6 -9
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +2 -4
- package/api/computing/return.js +6 -9
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +2 -4
- package/api/computing/spread.js +6 -9
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +4 -8
- package/api/computing/throw.js +18 -23
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +2 -4
- package/api/computing/yield.js +7 -10
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +3 -6
- package/api/definition/array.js +14 -18
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +2 -3
- package/api/definition/bind.js +9 -10
- package/api/definition/bind.js.map +1 -1
- package/api/definition/comment.d.ts +3 -5
- package/api/definition/comment.js +6 -7
- package/api/definition/comment.js.map +1 -1
- package/api/definition/function.d.ts +20 -27
- package/api/definition/function.js +92 -110
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +2 -3
- package/api/definition/member.js +14 -11
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +5 -9
- package/api/definition/object.js +24 -30
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -4
- package/api/definition/statement.js +6 -9
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +15 -40
- package/api/definition/values.js +49 -79
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +40 -26
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +1 -0
- package/api/index.js +1 -0
- package/api/index.js.map +1 -1
- package/api/module/common.d.ts +4 -5
- package/api/module/common.js +12 -12
- package/api/module/common.js.map +1 -1
- package/api/module/export.d.ts +5 -10
- package/api/module/export.js +35 -38
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +6 -10
- package/api/module/import.js +28 -32
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +3 -3
- package/api/operators/assignment.js +5 -5
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +3 -5
- package/api/operators/await.js +7 -10
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +1 -1
- package/api/operators/binary.js +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +2 -3
- package/api/operators/chaining.js +6 -7
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +2 -4
- package/api/operators/comma.js +6 -9
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +2 -4
- package/api/operators/grouping.js +6 -9
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +1 -1
- package/api/operators/logical.js +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +2 -4
- package/api/operators/pipeline.js +8 -15
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +2 -4
- package/api/operators/ternary.js +8 -13
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/types.d.ts +1 -1
- package/api/operators/unary.d.ts +3 -5
- package/api/operators/unary.js +7 -10
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +3 -5
- package/api/operators/update.js +8 -11
- package/api/operators/update.js.map +1 -1
- package/api/program.d.ts +3 -5
- package/api/program.js +7 -8
- package/api/program.js.map +1 -1
- package/api/statement/control/block.d.ts +2 -4
- package/api/statement/control/block.js +9 -14
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +2 -5
- package/api/statement/control/empty.js +6 -8
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +2 -4
- package/api/statement/control/if.js +8 -13
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +4 -9
- package/api/statement/control/switch.js +19 -28
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +4 -7
- package/api/statement/control/terminate.js +11 -19
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/control/with.d.ts +21 -0
- package/api/statement/control/with.js +67 -0
- package/api/statement/control/with.js.map +1 -0
- package/api/statement/declarations/declares.d.ts +4 -7
- package/api/statement/declarations/declares.js +14 -20
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +6 -11
- package/api/statement/iterations/for.js +35 -53
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +3 -6
- package/api/statement/iterations/while.js +14 -22
- package/api/statement/iterations/while.js.map +1 -1
- package/package.json +14 -4
- package/scope/finalizer.d.ts +1 -1
- package/scope/pool.d.ts +1 -1
- package/scope/proxy.d.ts +1 -1
- package/scope/proxy.js +1 -0
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +8 -24
- package/scope/scope.js +25 -75
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +15 -3
- package/scope/stack.js +49 -32
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +4 -2
- package/v8/enums.js.map +1 -1
- package/v8/factory.d.ts +148 -0
- package/v8/factory.js +499 -0
- package/v8/factory.js.map +1 -0
- package/v8/inline.d.ts +50 -48
- package/v8/inline.js +322 -300
- package/v8/inline.js.map +1 -1
- package/v8/node.d.ts +141 -0
- package/v8/node.js +2 -0
- package/v8/node.js.map +1 -0
- package/v8/nodes.d.ts +0 -14
- package/v8/nodes.js +1 -152
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +21 -18
- package/v8/parser.js +97 -84
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +2 -1
- package/v8/stream.js +221 -311
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +3 -1
- package/v8/token.js +7 -5
- package/v8/token.js.map +1 -1
- package/visit/visitor.d.ts +1 -1
package/README.md
CHANGED
|
@@ -117,9 +117,6 @@ console.log(
|
|
|
117
117
|
|
|
118
118
|
- [V8 JavaScript engine](https://github.com/v8/v8) to parse js source code.
|
|
119
119
|
- for now this parser does not provide any info about `SourceLocation`
|
|
120
|
-
|
|
121
|
-
## Future Feature
|
|
122
|
-
|
|
123
120
|
- class expression
|
|
124
121
|
- Import/Export module
|
|
125
122
|
- Custom Factory Builder to convert the code to ESTree directly or to executable expression node
|
package/api/abstract.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import type { Scope } from '../scope/scope.js';
|
|
2
1
|
import type { AwaitPromiseInfo, Stack } from '../scope/stack.js';
|
|
3
|
-
import type { NodeDeserializer, ExpressionNode, ExpressionNodConstructor, NodeJsonType, DeclarationExpression, ExpressionEventMap, ExpressionEventPath, VisitNodeType } from './expression.js';
|
|
2
|
+
import type { NodeDeserializer, ExpressionNode, ExpressionNodConstructor, NodeJsonType, DeclarationExpression, ExpressionEventMap, ExpressionEventPath, VisitNodeType, SourceLocation } from './expression.js';
|
|
4
3
|
export declare abstract class AbstractExpressionNode implements ExpressionNode {
|
|
5
4
|
static fromJSON(node: ExpressionNode, deserializer: NodeDeserializer): ExpressionNode;
|
|
5
|
+
type: string;
|
|
6
|
+
loc?: SourceLocation;
|
|
7
|
+
range?: [number, number];
|
|
8
|
+
constructor(range?: [number, number], loc?: SourceLocation);
|
|
6
9
|
getClass(): ExpressionNodConstructor<ExpressionNode>;
|
|
7
10
|
toJSON(key?: string): NodeJsonType;
|
|
8
11
|
events(): ExpressionEventMap;
|
|
9
|
-
abstract shareVariables(scopeList: Scope<any>[]): void;
|
|
10
12
|
abstract set(stack: Stack, value: any): any;
|
|
11
13
|
abstract get(stack: Stack, thisContext?: any): any;
|
|
12
14
|
abstract dependency(computed?: true): ExpressionNode[];
|
|
@@ -21,11 +23,10 @@ export declare abstract class InfixExpressionNode<T> extends AbstractExpressionN
|
|
|
21
23
|
protected left: ExpressionNode;
|
|
22
24
|
protected right: ExpressionNode;
|
|
23
25
|
static visit(node: InfixExpressionNode<any>, visitNode: VisitNodeType): void;
|
|
24
|
-
constructor(operator: T, left: ExpressionNode, right: ExpressionNode);
|
|
26
|
+
constructor(operator: T, left: ExpressionNode, right: ExpressionNode, range?: [number, number], loc?: SourceLocation);
|
|
25
27
|
getOperator(): T;
|
|
26
28
|
getLeft(): ExpressionNode;
|
|
27
29
|
getRight(): ExpressionNode;
|
|
28
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
29
30
|
set(context: object, value: any): void;
|
|
30
31
|
abstract get(stack: Stack): any;
|
|
31
32
|
dependency(computed?: true): ExpressionNode[];
|
package/api/abstract.js
CHANGED
|
@@ -22,13 +22,20 @@ export class AbstractExpressionNode {
|
|
|
22
22
|
static fromJSON(node, deserializer) {
|
|
23
23
|
return deserializer(node);
|
|
24
24
|
}
|
|
25
|
+
constructor(range, loc) {
|
|
26
|
+
this.type = this.getClass().type;
|
|
27
|
+
range && (this.range = range);
|
|
28
|
+
loc && (this.loc = loc);
|
|
29
|
+
}
|
|
25
30
|
getClass() {
|
|
26
31
|
return this.constructor;
|
|
27
32
|
}
|
|
28
33
|
toJSON(key) {
|
|
29
|
-
const type = this.getClass().type;
|
|
30
34
|
const json = this.toJson(key);
|
|
31
|
-
|
|
35
|
+
const index = {};
|
|
36
|
+
this.range && (index.range = this.range);
|
|
37
|
+
this.loc && (index.loc = this.loc);
|
|
38
|
+
return Object.assign({ type: this.type }, json, index);
|
|
32
39
|
}
|
|
33
40
|
events() {
|
|
34
41
|
const dependencyNodes = this.dependency();
|
|
@@ -41,16 +48,16 @@ export class AbstractExpressionNode {
|
|
|
41
48
|
}
|
|
42
49
|
}
|
|
43
50
|
export class InfixExpressionNode extends AbstractExpressionNode {
|
|
44
|
-
constructor(operator, left, right) {
|
|
45
|
-
super();
|
|
46
|
-
this.operator = operator;
|
|
47
|
-
this.left = left;
|
|
48
|
-
this.right = right;
|
|
49
|
-
}
|
|
50
51
|
static visit(node, visitNode) {
|
|
51
52
|
visitNode(node.getLeft());
|
|
52
53
|
visitNode(node.getRight());
|
|
53
54
|
}
|
|
55
|
+
constructor(operator, left, right, range, loc) {
|
|
56
|
+
super(range, loc);
|
|
57
|
+
this.operator = operator;
|
|
58
|
+
this.left = left;
|
|
59
|
+
this.right = right;
|
|
60
|
+
}
|
|
54
61
|
getOperator() {
|
|
55
62
|
return this.operator;
|
|
56
63
|
}
|
|
@@ -60,10 +67,6 @@ export class InfixExpressionNode extends AbstractExpressionNode {
|
|
|
60
67
|
getRight() {
|
|
61
68
|
return this.right;
|
|
62
69
|
}
|
|
63
|
-
shareVariables(scopeList) {
|
|
64
|
-
this.left.shareVariables(scopeList);
|
|
65
|
-
this.right.shareVariables(scopeList);
|
|
66
|
-
}
|
|
67
70
|
set(context, value) {
|
|
68
71
|
throw new Error(`${this.constructor.name}#set() of operator: '${this.operator}' has no implementation.`);
|
|
69
72
|
}
|
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;IACh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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, SourceLocation\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}\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\ttype: string;\n\tloc?: SourceLocation;\n\trange?: [number, number];\n\tconstructor(range?: [number, number], loc?: SourceLocation) {\n\t\tthis.type = this.getClass().type;\n\t\trange && (this.range = range);\n\t\tloc && (this.loc = loc);\n\t}\n\tgetClass(): ExpressionNodConstructor<ExpressionNode> {\n\t\treturn this.constructor as ExpressionNodConstructor<ExpressionNode>;\n\t}\n\ttoJSON(key?: string): NodeJsonType {\n\t\tconst json = this.toJson(key);\n\t\tconst index: { range?: [number, number], loc?: SourceLocation } = {};\n\t\tthis.range && (index.range = this.range);\n\t\tthis.loc && (index.loc = this.loc);\n\t\treturn Object.assign({ type: this.type }, json, index);\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}\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, range?: [number, number], loc?: SourceLocation) {\n\t\tsuper(range, loc);\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,52 +1,94 @@
|
|
|
1
|
-
import type { DeclarationExpression, ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';
|
|
2
|
-
import { Scope } from '../../scope/scope.js';
|
|
1
|
+
import type { DeclarationExpression, ExpressionEventPath, ExpressionNode, NodeDeserializer, SourceLocation, VisitNodeType } from '../expression.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
|
+
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.
|
|
42
86
|
*/
|
|
43
87
|
export declare class Super extends AbstractExpressionNode {
|
|
44
|
-
static INSTANCE: Super;
|
|
45
88
|
static fromJSON(node: Super): Super;
|
|
46
|
-
constructor();
|
|
47
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
89
|
+
constructor(range?: [number, number], loc?: SourceLocation);
|
|
48
90
|
set(stack: Stack, value: any): void;
|
|
49
|
-
get(stack: Stack, thisContext?: any):
|
|
91
|
+
get(stack: Stack, thisContext?: any): any;
|
|
50
92
|
dependency(computed?: true): ExpressionNode[];
|
|
51
93
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
52
94
|
toString(): string;
|
|
@@ -61,17 +103,18 @@ export declare class Super extends AbstractExpressionNode {
|
|
|
61
103
|
*
|
|
62
104
|
* In the future, it will represent other meta properties as well.
|
|
63
105
|
*/
|
|
64
|
-
export declare class MetaProperty extends
|
|
106
|
+
export declare class MetaProperty extends AbstractExpressionNode {
|
|
65
107
|
private meta;
|
|
66
|
-
|
|
67
|
-
static ImportMeta: MetaProperty;
|
|
68
|
-
private static getJsonName;
|
|
108
|
+
private property;
|
|
69
109
|
static fromJSON(node: MetaProperty, deserializer: NodeDeserializer<any>): MetaProperty;
|
|
70
110
|
static visit(node: MetaProperty, visitNode: VisitNodeType): void;
|
|
71
|
-
constructor(meta: Identifier, property: Identifier);
|
|
111
|
+
constructor(meta: Identifier, property: Identifier, range?: [number, number], loc?: SourceLocation);
|
|
72
112
|
getMeta(): Identifier;
|
|
73
|
-
|
|
74
|
-
get(stack: Stack
|
|
113
|
+
getProperty(): Identifier;
|
|
114
|
+
get(stack: Stack): any;
|
|
115
|
+
set(stack: Stack, value: any): void;
|
|
116
|
+
dependency(computed?: true | undefined): ExpressionNode[];
|
|
117
|
+
dependencyPath(computed?: true | undefined): ExpressionEventPath[];
|
|
75
118
|
toString(): string;
|
|
76
119
|
toJson(): {
|
|
77
120
|
[key: string]: any;
|
|
@@ -82,7 +125,8 @@ export declare class MetaProperty extends MemberExpression {
|
|
|
82
125
|
*/
|
|
83
126
|
export declare class PrivateIdentifier extends Identifier {
|
|
84
127
|
static fromJSON(node: PrivateIdentifier): PrivateIdentifier;
|
|
85
|
-
get(stack: Stack): any;
|
|
128
|
+
get(stack: Stack, thisContext: ClassInstance): any;
|
|
129
|
+
set(stack: Stack, value: any): any;
|
|
86
130
|
toString(): string;
|
|
87
131
|
}
|
|
88
132
|
/**
|
|
@@ -90,8 +134,7 @@ export declare class PrivateIdentifier extends Identifier {
|
|
|
90
134
|
*/
|
|
91
135
|
export declare class StaticBlock extends BlockStatement {
|
|
92
136
|
static fromJSON(node: StaticBlock, deserializer: NodeDeserializer<any>): StaticBlock;
|
|
93
|
-
|
|
94
|
-
get(stack: Stack, classConstructor?: ClassConstructor): void;
|
|
137
|
+
get(stack: Stack, classInitializer?: ClassInitializer): void;
|
|
95
138
|
toString(): string;
|
|
96
139
|
toJson(): object;
|
|
97
140
|
}
|
|
@@ -101,29 +144,24 @@ export declare abstract class AbstractDefinition extends AbstractExpressionNode
|
|
|
101
144
|
protected computed: boolean;
|
|
102
145
|
protected value?: ExpressionNode | undefined;
|
|
103
146
|
protected 'static': boolean;
|
|
104
|
-
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode | undefined);
|
|
147
|
+
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode | undefined, range?: [number, number], loc?: SourceLocation);
|
|
105
148
|
getKey(): ExpressionNode | PrivateIdentifier;
|
|
106
149
|
getValue(): ExpressionNode | undefined;
|
|
107
150
|
isComputed(): boolean;
|
|
108
151
|
isStatic(): boolean;
|
|
152
|
+
isPrivate(): boolean;
|
|
109
153
|
getDecorators(): Decorator[];
|
|
110
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
111
154
|
set(stack: Stack, value: any): void;
|
|
112
155
|
dependency(computed?: true): ExpressionNode[];
|
|
113
156
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
114
|
-
getTarget(classConstructor: ClassConstructor): {
|
|
115
|
-
[key: string]: any;
|
|
116
|
-
[key: number]: any;
|
|
117
|
-
[key: symbol]: any;
|
|
118
|
-
};
|
|
119
157
|
getKeyName(stack: Stack): any;
|
|
120
|
-
abstract get(stack: Stack,
|
|
158
|
+
abstract get(stack: Stack, initializer?: ClassInitializer): void;
|
|
121
159
|
abstract toString(): string;
|
|
122
160
|
abstract toJson(): {
|
|
123
161
|
[key: string]: any;
|
|
124
162
|
};
|
|
125
163
|
}
|
|
126
|
-
export
|
|
164
|
+
export type MethodDefinitionKind = 'constructor' | 'method' | 'set' | 'get';
|
|
127
165
|
/**
|
|
128
166
|
* - When key is a PrivateIdentifier, computed must be false and kind can not be "constructor".
|
|
129
167
|
*/
|
|
@@ -131,11 +169,14 @@ export declare class MethodDefinition extends AbstractDefinition {
|
|
|
131
169
|
private kind;
|
|
132
170
|
static fromJSON(node: MethodDefinition, deserializer: NodeDeserializer<any>): MethodDefinition;
|
|
133
171
|
static visit(node: MethodDefinition, visitNode: VisitNodeType): void;
|
|
134
|
-
protected
|
|
135
|
-
|
|
172
|
+
protected 'static': boolean;
|
|
173
|
+
value: FunctionExpression;
|
|
174
|
+
afterInstanceConstruct: any;
|
|
175
|
+
constructor(kind: MethodDefinitionKind, key: ExpressionNode | PrivateIdentifier, value: FunctionExpression, decorators: Decorator[], computed: boolean, isStatic: boolean, range?: [number, number], loc?: SourceLocation);
|
|
136
176
|
getKind(): MethodDefinitionKind;
|
|
137
177
|
getValue(): FunctionExpression;
|
|
138
|
-
get(stack: Stack,
|
|
178
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
179
|
+
private getPropertyAttributes;
|
|
139
180
|
private initConstructor;
|
|
140
181
|
toString(): string;
|
|
141
182
|
toJson(): {
|
|
@@ -148,8 +189,8 @@ export declare class MethodDefinition extends AbstractDefinition {
|
|
|
148
189
|
export declare class PropertyDefinition extends AbstractDefinition {
|
|
149
190
|
static fromJSON(node: PropertyDefinition, deserializer: NodeDeserializer<any>): PropertyDefinition;
|
|
150
191
|
static visit(node: PropertyDefinition, visitNode: VisitNodeType): void;
|
|
151
|
-
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode);
|
|
152
|
-
get(stack: Stack,
|
|
192
|
+
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode, range?: [number, number], loc?: SourceLocation);
|
|
193
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
153
194
|
toString(): string;
|
|
154
195
|
toJson(): {
|
|
155
196
|
[key: string]: any;
|
|
@@ -158,8 +199,8 @@ export declare class PropertyDefinition extends AbstractDefinition {
|
|
|
158
199
|
export declare class AccessorProperty extends AbstractDefinition {
|
|
159
200
|
static fromJSON(node: AccessorProperty, deserializer: NodeDeserializer): AccessorProperty;
|
|
160
201
|
static visit(node: AccessorProperty, visitNode: VisitNodeType): void;
|
|
161
|
-
constructor(key: ExpressionNode, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode);
|
|
162
|
-
get(stack: Stack,
|
|
202
|
+
constructor(key: ExpressionNode, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode, range?: [number, number], loc?: SourceLocation);
|
|
203
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
163
204
|
toString(): string;
|
|
164
205
|
toJson(): {
|
|
165
206
|
[key: string]: any;
|
|
@@ -169,11 +210,10 @@ export declare class ClassBody extends AbstractExpressionNode {
|
|
|
169
210
|
private body;
|
|
170
211
|
static fromJSON(node: ClassBody, deserializer: NodeDeserializer<any>): ClassBody;
|
|
171
212
|
static visit(node: ClassBody, visitNode: VisitNodeType): void;
|
|
172
|
-
constructor(body: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[]);
|
|
213
|
+
constructor(body: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[], range?: [number, number], loc?: SourceLocation);
|
|
173
214
|
getBody(): (StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty)[];
|
|
174
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
175
215
|
set(stack: Stack, value: any): void;
|
|
176
|
-
get(stack: Stack,
|
|
216
|
+
get(stack: Stack, initializer: ClassInitializer): void;
|
|
177
217
|
dependency(computed?: true): ExpressionNode[];
|
|
178
218
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
179
219
|
toString(): string;
|
|
@@ -186,13 +226,11 @@ export declare class Class extends AbstractExpressionNode {
|
|
|
186
226
|
protected decorators: Decorator[];
|
|
187
227
|
protected id?: Identifier | undefined;
|
|
188
228
|
protected superClass?: ExpressionNode | undefined;
|
|
189
|
-
|
|
190
|
-
constructor(body: ClassBody, decorators: Decorator[], id?: Identifier | undefined, superClass?: ExpressionNode | undefined);
|
|
229
|
+
constructor(body: ClassBody, decorators: Decorator[], id?: Identifier | undefined, superClass?: ExpressionNode | undefined, range?: [number, number], loc?: SourceLocation);
|
|
191
230
|
getBody(): ClassBody;
|
|
192
231
|
getDecorators(): Decorator[];
|
|
193
232
|
getId(): Identifier | undefined;
|
|
194
233
|
getSuperClass(): ExpressionNode | undefined;
|
|
195
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
196
234
|
set(stack: Stack): void;
|
|
197
235
|
get(stack: Stack): ClassConstructor;
|
|
198
236
|
private createClass;
|
|
@@ -205,7 +243,7 @@ export declare class ClassDeclaration extends Class implements DeclarationExpres
|
|
|
205
243
|
static fromJSON(node: ClassDeclaration, deserializer: NodeDeserializer<any>): ClassDeclaration;
|
|
206
244
|
static visit(node: ClassDeclaration, visitNode: VisitNodeType): void;
|
|
207
245
|
protected id: Identifier;
|
|
208
|
-
constructor(body: ClassBody, decorators: Decorator[], id: Identifier, superClass?: ExpressionNode);
|
|
246
|
+
constructor(body: ClassBody, decorators: Decorator[], id: Identifier, superClass?: ExpressionNode, range?: [number, number], loc?: SourceLocation);
|
|
209
247
|
declareVariable(stack: Stack, propertyValue?: any): void;
|
|
210
248
|
getDeclarationName(): string;
|
|
211
249
|
get(stack: Stack): ClassConstructor;
|
|
@@ -213,5 +251,6 @@ export declare class ClassDeclaration extends Class implements DeclarationExpres
|
|
|
213
251
|
export declare class ClassExpression extends Class {
|
|
214
252
|
static fromJSON(node: ClassExpression, deserializer: NodeDeserializer<any>): ClassExpression;
|
|
215
253
|
static visit(node: ClassExpression, visitNode: VisitNodeType): void;
|
|
254
|
+
constructor(body: ClassBody, decorators: Decorator[], id?: Identifier, superClass?: ExpressionNode, range?: [number, number], loc?: SourceLocation);
|
|
216
255
|
}
|
|
217
256
|
export {};
|