@ibyar/expressions 0.5.1 → 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.
- package/LICENSE +1 -1
- package/README.md +5 -4
- package/api/abstract.d.ts +5 -6
- package/api/abstract.js +3 -3
- package/api/abstract.js.map +1 -1
- package/api/class/class.d.ts +202 -0
- package/api/class/class.js +635 -0
- package/api/class/class.js.map +1 -0
- package/api/class/decorator.d.ts +20 -0
- package/api/class/decorator.js +48 -0
- package/api/class/decorator.js.map +1 -0
- package/api/computing/call.d.ts +3 -1
- package/api/computing/call.js +16 -4
- package/api/computing/call.js.map +1 -1
- package/api/computing/debugger.d.ts +15 -0
- package/api/computing/debugger.js +35 -0
- package/api/computing/debugger.js.map +1 -0
- package/api/computing/new.d.ts +2 -1
- package/api/computing/new.js +4 -0
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +6 -6
- package/api/computing/rest.js +5 -2
- package/api/computing/rest.js.map +1 -1
- package/api/computing/return.d.ts +2 -1
- package/api/computing/return.js +3 -0
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +2 -1
- package/api/computing/spread.js +5 -2
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +2 -1
- package/api/computing/throw.js +3 -0
- package/api/computing/throw.js.map +1 -1
- package/api/computing/yield.d.ts +2 -1
- package/api/computing/yield.js +3 -0
- package/api/computing/yield.js.map +1 -1
- package/api/definition/array.d.ts +12 -12
- package/api/definition/array.js +31 -25
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +2 -2
- package/api/definition/bind.js +1 -1
- package/api/definition/bind.js.map +1 -1
- package/api/definition/function.d.ts +40 -51
- package/api/definition/function.js +291 -309
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +2 -2
- package/api/definition/member.js +1 -1
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +15 -12
- package/api/definition/object.js +43 -13
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +2 -2
- package/api/definition/statement.js +7 -3
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +35 -50
- package/api/definition/values.js +66 -149
- package/api/definition/values.js.map +1 -1
- package/api/deserialize/deserialize.d.ts +2 -1
- package/api/deserialize/deserialize.js +4 -1
- package/api/deserialize/deserialize.js.map +1 -1
- package/api/deserialize/type-store.d.ts +2 -2
- package/api/deserialize/type-store.js.map +1 -1
- package/api/expression.d.ts +13 -18
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +2 -0
- package/api/index.js +2 -0
- package/api/index.js.map +1 -1
- package/api/module/common.d.ts +29 -0
- package/api/module/common.js +71 -0
- package/api/module/common.js.map +1 -0
- package/api/module/export.d.ts +66 -25
- package/api/module/export.js +270 -58
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +61 -25
- package/api/module/import.js +226 -68
- package/api/module/import.js.map +1 -1
- package/api/operators/assignment.d.ts +2 -2
- package/api/operators/assignment.js +1 -1
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +2 -2
- package/api/operators/await.js +1 -1
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.d.ts +2 -2
- package/api/operators/binary.js +1 -1
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +2 -2
- package/api/operators/chaining.js +1 -1
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +2 -2
- package/api/operators/comma.js +2 -2
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +2 -2
- package/api/operators/grouping.js +1 -1
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.d.ts +2 -2
- package/api/operators/logical.js +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +2 -2
- package/api/operators/pipeline.js +1 -1
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +2 -2
- package/api/operators/ternary.js +1 -1
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +3 -3
- package/api/operators/unary.js +4 -3
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +2 -2
- package/api/operators/update.js +1 -1
- package/api/operators/update.js.map +1 -1
- package/api/{app/program.d.ts → program.d.ts} +8 -9
- package/api/program.js +45 -0
- package/api/program.js.map +1 -0
- package/api/statement/control/block.d.ts +4 -5
- package/api/statement/control/block.js +22 -23
- package/api/statement/control/block.js.map +1 -1
- package/api/statement/control/empty.d.ts +1 -1
- package/api/statement/control/empty.js.map +1 -1
- package/api/statement/control/if.d.ts +2 -2
- package/api/statement/control/if.js +1 -1
- package/api/statement/control/if.js.map +1 -1
- package/api/statement/control/switch.d.ts +4 -5
- package/api/statement/control/switch.js +13 -9
- package/api/statement/control/switch.js.map +1 -1
- package/api/statement/control/terminate.d.ts +38 -13
- package/api/statement/control/terminate.js +81 -20
- package/api/statement/control/terminate.js.map +1 -1
- package/api/statement/declarations/declares.d.ts +17 -16
- package/api/statement/declarations/declares.js +24 -19
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +5 -5
- package/api/statement/iterations/for.js +29 -23
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +3 -3
- package/api/statement/iterations/while.js +17 -13
- package/api/statement/iterations/while.js.map +1 -1
- package/api/utils.d.ts +5 -0
- package/api/utils.js +4 -0
- package/api/utils.js.map +1 -0
- package/package.json +5 -5
- package/scope/event.d.ts +2 -2
- package/scope/event.js +8 -14
- package/scope/event.js.map +1 -1
- package/scope/finalizer.d.ts +4 -0
- package/scope/finalizer.js +11 -0
- package/scope/finalizer.js.map +1 -0
- package/scope/proxy.d.ts +2 -3
- package/scope/proxy.js +22 -26
- package/scope/proxy.js.map +1 -1
- package/scope/scope.d.ts +42 -53
- package/scope/scope.js +73 -143
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +43 -26
- package/scope/stack.js +148 -102
- package/scope/stack.js.map +1 -1
- package/v8/enums.d.ts +204 -0
- package/v8/enums.js +375 -0
- package/v8/enums.js.map +1 -0
- package/v8/index.d.ts +2 -1
- package/v8/index.js +2 -1
- package/v8/index.js.map +1 -1
- package/v8/inline.d.ts +177 -0
- package/v8/inline.js +1973 -0
- package/v8/inline.js.map +1 -0
- package/v8/nodes.d.ts +8 -7
- package/v8/nodes.js +37 -63
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +41 -151
- package/v8/parser.js +507 -1578
- package/v8/parser.js.map +1 -1
- package/v8/stream.d.ts +35 -3
- package/v8/stream.js +616 -164
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +15 -9
- package/v8/token.js +79 -46
- package/v8/token.js.map +1 -1
- package/visit/visitor.js +4 -7
- package/visit/visitor.js.map +1 -1
- package/api/app/class.d.ts +0 -117
- package/api/app/class.js +0 -292
- package/api/app/class.js.map +0 -1
- package/api/app/program.js +0 -39
- package/api/app/program.js.map +0 -1
- package/api/module/module.d.ts +0 -26
- package/api/module/module.js +0 -63
- package/api/module/module.js.map +0 -1
- package/v8/app.d.ts +0 -0
- package/v8/app.js +0 -2
- package/v8/app.js.map +0 -1
package/LICENSE
CHANGED
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
|
|
|
@@ -136,7 +137,7 @@ console.log(
|
|
|
136
137
|
| logical-and | `&&` |
|
|
137
138
|
| logical-or | `\|\|` |
|
|
138
139
|
| conditional | `?:` |
|
|
139
|
-
| pipeline |
|
|
140
|
+
| pipeline | `\|>` |
|
|
140
141
|
| assignment | `= += -= *= **= /= %= <<= >>= >>>= &= ^= \|= &&= \|\|= ??= >?= <?= %%=` |
|
|
141
142
|
| comma | `,` |
|
|
142
143
|
|
|
@@ -192,8 +193,8 @@ const stack1 = new Stack();
|
|
|
192
193
|
|
|
193
194
|
// OR
|
|
194
195
|
|
|
195
|
-
const scope1 = new Scope<{x: number, y: number}>( {x: 8, y: 6}
|
|
196
|
-
const scope2 = Scope.
|
|
196
|
+
const scope1 = new Scope<{x: number, y: number}>( {x: 8, y: 6});
|
|
197
|
+
const scope2 = Scope.for({z: 9});
|
|
197
198
|
|
|
198
199
|
const stack2 = new Stack([scope1, scope2]);
|
|
199
200
|
|
|
@@ -205,7 +206,7 @@ const stack2 = new Stack([scope1, scope2]);
|
|
|
205
206
|
```ts
|
|
206
207
|
import { ReadOnlyScope } from '@ibyar/expressions';
|
|
207
208
|
|
|
208
|
-
stack1.pushScope(ReadOnlyScope.
|
|
209
|
+
stack1.pushScope(ReadOnlyScope.for({
|
|
209
210
|
Math: {
|
|
210
211
|
E: Math.E,
|
|
211
212
|
LN10: Math.LN10,
|
package/api/abstract.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { Scope
|
|
1
|
+
import type { Scope } from '../scope/scope.js';
|
|
2
2
|
import type { AwaitPromiseInfo, Stack } from '../scope/stack.js';
|
|
3
|
-
import type { NodeDeserializer, ExpressionNode,
|
|
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():
|
|
6
|
+
getClass(): ExpressionNodConstructor<ExpressionNode>;
|
|
7
7
|
toJSON(key?: string): NodeJsonType;
|
|
8
8
|
events(): ExpressionEventMap;
|
|
9
9
|
abstract shareVariables(scopeList: Scope<any>[]): void;
|
|
@@ -20,7 +20,7 @@ export declare abstract class InfixExpressionNode<T> extends AbstractExpressionN
|
|
|
20
20
|
protected operator: T;
|
|
21
21
|
protected left: ExpressionNode;
|
|
22
22
|
protected right: ExpressionNode;
|
|
23
|
-
static visit(node: InfixExpressionNode<any>, visitNode: VisitNodeType
|
|
23
|
+
static visit(node: InfixExpressionNode<any>, visitNode: VisitNodeType): void;
|
|
24
24
|
constructor(operator: T, left: ExpressionNode, right: ExpressionNode);
|
|
25
25
|
getOperator(): T;
|
|
26
26
|
getLeft(): ExpressionNode;
|
|
@@ -50,8 +50,7 @@ export declare class YieldDelegateValue {
|
|
|
50
50
|
}
|
|
51
51
|
export declare class AwaitPromise implements AwaitPromiseInfo {
|
|
52
52
|
promise: Promise<any>;
|
|
53
|
-
node:
|
|
53
|
+
node: DeclarationExpression;
|
|
54
54
|
declareVariable: boolean;
|
|
55
|
-
scopeType: ScopeType;
|
|
56
55
|
constructor(promise: Promise<any>);
|
|
57
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
|
-
|
|
26
|
-
return json;
|
|
26
|
+
return { type, ...json };
|
|
27
27
|
}
|
|
28
28
|
events() {
|
|
29
29
|
const dependencyNodes = this.dependency();
|
|
@@ -42,7 +42,7 @@ export class InfixExpressionNode extends AbstractExpressionNode {
|
|
|
42
42
|
this.left = left;
|
|
43
43
|
this.right = right;
|
|
44
44
|
}
|
|
45
|
-
static visit(node, visitNode
|
|
45
|
+
static visit(node, visitNode) {
|
|
46
46
|
visitNode(node.getLeft());
|
|
47
47
|
visitNode(node.getRight());
|
|
48
48
|
}
|
package/api/abstract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abstract.js","sourceRoot":"","sources":["../../../src/expressions/api/abstract.ts"],"names":[],"mappings":"AAQA,SAAS,0BAA0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K,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 { Scope } from '../scope/scope.js';\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"]}
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import type { DeclarationExpression, ExpressionEventPath, ExpressionNode, NodeDeserializer, VisitNodeType } from '../expression.js';
|
|
2
|
+
import type { Scope } from '../../scope/scope.js';
|
|
3
|
+
import { Stack } from '../../scope/stack.js';
|
|
4
|
+
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
|
+
import { Identifier } from '../definition/values.js';
|
|
6
|
+
import { MemberExpression } from '../definition/member.js';
|
|
7
|
+
import { FunctionExpression } from '../definition/function.js';
|
|
8
|
+
import { BlockStatement } from '../statement/control/block.js';
|
|
9
|
+
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
|
+
declare const PRIVATE_SYMBOL: unique symbol;
|
|
14
|
+
declare const INSTANCE_PRIVATE_SYMBOL: unique symbol;
|
|
15
|
+
declare const STATIC_INITIALIZATION_BLOCK: unique symbol;
|
|
16
|
+
interface ClassConstructor {
|
|
17
|
+
readonly prototype: ClassInstance;
|
|
18
|
+
[GET_PARAMETERS](args: any[]): any[];
|
|
19
|
+
[STATIC_INITIALIZATION_BLOCK]: Function[];
|
|
20
|
+
[PRIVATE_SYMBOL]: {
|
|
21
|
+
[key: PropertyKey]: any;
|
|
22
|
+
};
|
|
23
|
+
[INSTANCE_PRIVATE_SYMBOL]: {
|
|
24
|
+
[key: PropertyKey]: any;
|
|
25
|
+
};
|
|
26
|
+
[CONSTRUCTOR]: Function;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
}
|
|
29
|
+
declare var ClassInstance: ClassConstructor;
|
|
30
|
+
interface ClassInstance {
|
|
31
|
+
[PRIVATE_SYMBOL]: {
|
|
32
|
+
[key: PropertyKey]: any;
|
|
33
|
+
};
|
|
34
|
+
[STACK]: Stack;
|
|
35
|
+
[key: string]: any;
|
|
36
|
+
}
|
|
37
|
+
export declare class Super extends AbstractExpressionNode {
|
|
38
|
+
static INSTANCE: Super;
|
|
39
|
+
static fromJSON(node: Super): Super;
|
|
40
|
+
constructor();
|
|
41
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
42
|
+
set(stack: Stack, value: any): void;
|
|
43
|
+
get(stack: Stack, thisContext?: any): void;
|
|
44
|
+
dependency(computed?: true): ExpressionNode[];
|
|
45
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
46
|
+
toString(): string;
|
|
47
|
+
toJson(): {
|
|
48
|
+
[key: string]: any;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export declare class MetaProperty extends MemberExpression {
|
|
52
|
+
private meta;
|
|
53
|
+
static NewTarget: MetaProperty;
|
|
54
|
+
static ImportMeta: MetaProperty;
|
|
55
|
+
private static getJsonName;
|
|
56
|
+
static fromJSON(node: MetaProperty, deserializer: NodeDeserializer<any>): MetaProperty;
|
|
57
|
+
static visit(node: MetaProperty, visitNode: VisitNodeType): void;
|
|
58
|
+
constructor(meta: Identifier, property: Identifier);
|
|
59
|
+
getMeta(): Identifier;
|
|
60
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
61
|
+
get(stack: Stack, thisContext?: any): any;
|
|
62
|
+
toString(): string;
|
|
63
|
+
toJson(): {
|
|
64
|
+
[key: string]: any;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export declare class PrivateIdentifier extends AbstractExpressionNode {
|
|
68
|
+
private name;
|
|
69
|
+
static fromJSON(node: PrivateIdentifier): PrivateIdentifier;
|
|
70
|
+
constructor(name: string);
|
|
71
|
+
getName(): string;
|
|
72
|
+
set(stack: Stack, value: any): void;
|
|
73
|
+
get(stack: Stack, thisContext?: ClassInstance | ClassConstructor): any;
|
|
74
|
+
dependency(computed?: true): ExpressionNode[];
|
|
75
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
76
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
77
|
+
toString(): string;
|
|
78
|
+
toJson(): {
|
|
79
|
+
[key: string]: any;
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
export declare class StaticBlock extends BlockStatement {
|
|
83
|
+
static fromJSON(node: StaticBlock, deserializer: NodeDeserializer<any>): StaticBlock;
|
|
84
|
+
constructor(body: ExpressionNode[]);
|
|
85
|
+
get(stack: Stack, classConstructor?: ClassConstructor): void;
|
|
86
|
+
toString(): string;
|
|
87
|
+
toJson(): object;
|
|
88
|
+
}
|
|
89
|
+
export declare abstract class AbstractDefinition extends AbstractExpressionNode {
|
|
90
|
+
protected key: ExpressionNode | PrivateIdentifier;
|
|
91
|
+
protected decorators: Decorator[];
|
|
92
|
+
protected computed: boolean;
|
|
93
|
+
protected value?: ExpressionNode | undefined;
|
|
94
|
+
protected 'static': boolean;
|
|
95
|
+
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode | undefined);
|
|
96
|
+
getKey(): ExpressionNode | PrivateIdentifier;
|
|
97
|
+
getValue(): ExpressionNode | undefined;
|
|
98
|
+
isComputed(): boolean;
|
|
99
|
+
isStatic(): boolean;
|
|
100
|
+
getDecorators(): Decorator[];
|
|
101
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
102
|
+
set(stack: Stack, value: any): void;
|
|
103
|
+
dependency(computed?: true): ExpressionNode[];
|
|
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;
|
|
111
|
+
abstract get(stack: Stack, classConstructor: ClassConstructor): void;
|
|
112
|
+
abstract toString(): string;
|
|
113
|
+
abstract toJson(): {
|
|
114
|
+
[key: string]: any;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
export declare type MethodDefinitionKind = 'constructor' | 'method' | 'set' | 'get';
|
|
118
|
+
export declare class MethodDefinition extends AbstractDefinition {
|
|
119
|
+
private kind;
|
|
120
|
+
static fromJSON(node: MethodDefinition, deserializer: NodeDeserializer<any>): MethodDefinition;
|
|
121
|
+
static visit(node: MethodDefinition, visitNode: VisitNodeType): void;
|
|
122
|
+
protected value: FunctionExpression;
|
|
123
|
+
constructor(kind: MethodDefinitionKind, key: ExpressionNode | PrivateIdentifier, value: FunctionExpression, decorators: Decorator[], computed: boolean, isStatic: boolean);
|
|
124
|
+
getKind(): MethodDefinitionKind;
|
|
125
|
+
getValue(): FunctionExpression;
|
|
126
|
+
get(stack: Stack, classConstructor: ClassConstructor): void;
|
|
127
|
+
private initConstructor;
|
|
128
|
+
toString(): string;
|
|
129
|
+
toJson(): {
|
|
130
|
+
[key: string]: any;
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export declare class PropertyDefinition extends AbstractDefinition {
|
|
134
|
+
static fromJSON(node: PropertyDefinition, deserializer: NodeDeserializer<any>): PropertyDefinition;
|
|
135
|
+
static visit(node: PropertyDefinition, visitNode: VisitNodeType): void;
|
|
136
|
+
constructor(key: ExpressionNode | PrivateIdentifier, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode);
|
|
137
|
+
get(stack: Stack, classConstructor: ClassConstructor): void;
|
|
138
|
+
toString(): string;
|
|
139
|
+
toJson(): {
|
|
140
|
+
[key: string]: any;
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
export declare class AccessorProperty extends AbstractDefinition {
|
|
144
|
+
static fromJSON(node: AccessorProperty, deserializer: NodeDeserializer): AccessorProperty;
|
|
145
|
+
static visit(node: AccessorProperty, visitNode: VisitNodeType): void;
|
|
146
|
+
constructor(key: ExpressionNode, decorators: Decorator[], computed: boolean, isStatic: boolean, value?: ExpressionNode);
|
|
147
|
+
get(stack: Stack, classConstructor: ClassConstructor): void;
|
|
148
|
+
toString(): string;
|
|
149
|
+
toJson(): {
|
|
150
|
+
[key: string]: any;
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export declare class ClassBody extends AbstractExpressionNode {
|
|
154
|
+
private body;
|
|
155
|
+
static fromJSON(node: ClassBody, deserializer: NodeDeserializer<any>): ClassBody;
|
|
156
|
+
static visit(node: ClassBody, visitNode: VisitNodeType): void;
|
|
157
|
+
constructor(body: (MethodDefinition | PropertyDefinition | AccessorProperty | StaticBlock)[]);
|
|
158
|
+
getBody(): (StaticBlock | MethodDefinition | PropertyDefinition | AccessorProperty)[];
|
|
159
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
160
|
+
set(stack: Stack, value: any): void;
|
|
161
|
+
get(stack: Stack, classConstructor: ClassConstructor): void;
|
|
162
|
+
dependency(computed?: true): ExpressionNode[];
|
|
163
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
164
|
+
toString(): string;
|
|
165
|
+
toJson(): {
|
|
166
|
+
[key: string]: any;
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
export declare class Class extends AbstractExpressionNode {
|
|
170
|
+
protected body: ClassBody;
|
|
171
|
+
protected decorators: Decorator[];
|
|
172
|
+
protected id?: Identifier | undefined;
|
|
173
|
+
protected superClass?: ExpressionNode | undefined;
|
|
174
|
+
private sharedVariables?;
|
|
175
|
+
constructor(body: ClassBody, decorators: Decorator[], id?: Identifier | undefined, superClass?: ExpressionNode | undefined);
|
|
176
|
+
getBody(): ClassBody;
|
|
177
|
+
getDecorators(): Decorator[];
|
|
178
|
+
getId(): Identifier | undefined;
|
|
179
|
+
getSuperClass(): ExpressionNode | undefined;
|
|
180
|
+
shareVariables(scopeList: Scope<any>[]): void;
|
|
181
|
+
set(stack: Stack): void;
|
|
182
|
+
get(stack: Stack): ClassConstructor;
|
|
183
|
+
private createClass;
|
|
184
|
+
dependency(computed?: true): ExpressionNode[];
|
|
185
|
+
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
186
|
+
toString(): string;
|
|
187
|
+
toJson(): object;
|
|
188
|
+
}
|
|
189
|
+
export declare class ClassDeclaration extends Class implements DeclarationExpression {
|
|
190
|
+
static fromJSON(node: ClassDeclaration, deserializer: NodeDeserializer<any>): ClassDeclaration;
|
|
191
|
+
static visit(node: ClassDeclaration, visitNode: VisitNodeType): void;
|
|
192
|
+
protected id: Identifier;
|
|
193
|
+
constructor(body: ClassBody, decorators: Decorator[], id: Identifier, superClass?: ExpressionNode);
|
|
194
|
+
declareVariable(stack: Stack, propertyValue?: any): void;
|
|
195
|
+
getDeclarationName(): string;
|
|
196
|
+
get(stack: Stack): ClassConstructor;
|
|
197
|
+
}
|
|
198
|
+
export declare class ClassExpression extends Class {
|
|
199
|
+
static fromJSON(node: ClassExpression, deserializer: NodeDeserializer<any>): ClassExpression;
|
|
200
|
+
static visit(node: ClassExpression, visitNode: VisitNodeType): void;
|
|
201
|
+
}
|
|
202
|
+
export {};
|