@ibyar/expressions 0.3.0 → 0.3.8
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 +79 -6
- package/api/abstract.d.ts +5 -7
- package/api/abstract.js +2 -5
- package/api/abstract.js.map +1 -1
- package/api/app/class.d.ts +99 -8
- package/api/app/class.js +250 -29
- package/api/app/class.js.map +1 -1
- package/api/app/program.d.ts +1 -2
- package/api/app/program.js +1 -4
- package/api/app/program.js.map +1 -1
- package/api/computing/call.d.ts +4 -4
- package/api/computing/call.js +20 -22
- package/api/computing/call.js.map +1 -1
- package/api/computing/new.d.ts +1 -2
- package/api/computing/new.js +4 -7
- package/api/computing/new.js.map +1 -1
- package/api/computing/rest.d.ts +16 -0
- package/api/computing/rest.js +40 -0
- package/api/computing/rest.js.map +1 -0
- package/api/computing/return.d.ts +1 -2
- package/api/computing/return.js +2 -5
- package/api/computing/return.js.map +1 -1
- package/api/computing/spread.d.ts +1 -2
- package/api/computing/spread.js +3 -9
- package/api/computing/spread.js.map +1 -1
- package/api/computing/throw.d.ts +3 -6
- package/api/computing/throw.js +5 -14
- package/api/computing/throw.js.map +1 -1
- package/api/definition/array.d.ts +12 -10
- package/api/definition/array.js +44 -16
- package/api/definition/array.js.map +1 -1
- package/api/definition/bind.d.ts +21 -0
- package/api/definition/bind.js +81 -0
- package/api/definition/bind.js.map +1 -0
- package/api/definition/comment.d.ts +1 -2
- package/api/definition/comment.js +1 -4
- package/api/definition/comment.js.map +1 -1
- package/api/definition/function.d.ts +12 -15
- package/api/definition/function.js +49 -58
- package/api/definition/function.js.map +1 -1
- package/api/definition/member.d.ts +8 -5
- package/api/definition/member.js +40 -31
- package/api/definition/member.js.map +1 -1
- package/api/definition/object.d.ts +16 -17
- package/api/definition/object.js +24 -16
- package/api/definition/object.js.map +1 -1
- package/api/definition/statement.d.ts +1 -2
- package/api/definition/statement.js +2 -5
- package/api/definition/statement.js.map +1 -1
- package/api/definition/values.d.ts +12 -11
- package/api/definition/values.js +17 -12
- package/api/definition/values.js.map +1 -1
- package/api/expression.d.ts +8 -4
- package/api/expression.js.map +1 -1
- package/api/index.d.ts +7 -6
- package/api/index.js +7 -6
- package/api/index.js.map +1 -1
- package/api/module/export.d.ts +1 -2
- package/api/module/export.js +1 -4
- package/api/module/export.js.map +1 -1
- package/api/module/import.d.ts +1 -2
- package/api/module/import.js +1 -4
- package/api/module/import.js.map +1 -1
- package/api/module/module.d.ts +1 -2
- package/api/module/module.js +2 -5
- package/api/module/module.js.map +1 -1
- package/api/operators/assignment.js +2 -2
- package/api/operators/assignment.js.map +1 -1
- package/api/operators/await.d.ts +1 -2
- package/api/operators/await.js +2 -5
- package/api/operators/await.js.map +1 -1
- package/api/operators/binary.js +4 -4
- package/api/operators/binary.js.map +1 -1
- package/api/operators/chaining.d.ts +9 -13
- package/api/operators/chaining.js +14 -48
- package/api/operators/chaining.js.map +1 -1
- package/api/operators/comma.d.ts +1 -2
- package/api/operators/comma.js +2 -5
- package/api/operators/comma.js.map +1 -1
- package/api/operators/grouping.d.ts +1 -2
- package/api/operators/grouping.js +2 -5
- package/api/operators/grouping.js.map +1 -1
- package/api/operators/logical.js.map +1 -1
- package/api/operators/pipeline.d.ts +4 -5
- package/api/operators/pipeline.js +23 -25
- package/api/operators/pipeline.js.map +1 -1
- package/api/operators/ternary.d.ts +1 -2
- package/api/operators/ternary.js +1 -4
- package/api/operators/ternary.js.map +1 -1
- package/api/operators/unary.d.ts +1 -2
- package/api/operators/unary.js +2 -5
- package/api/operators/unary.js.map +1 -1
- package/api/operators/update.d.ts +1 -2
- package/api/operators/update.js +2 -5
- package/api/operators/update.js.map +1 -1
- package/api/statement/{controlflow → control}/block.d.ts +1 -2
- package/api/statement/{controlflow → control}/block.js +2 -5
- package/api/statement/control/block.js.map +1 -0
- package/api/statement/{controlflow → control}/empty.d.ts +1 -2
- package/api/statement/{controlflow → control}/empty.js +1 -4
- package/api/statement/control/empty.js.map +1 -0
- package/api/statement/{controlflow → control}/if.d.ts +1 -2
- package/api/statement/{controlflow → control}/if.js +2 -5
- package/api/statement/control/if.js.map +1 -0
- package/api/statement/{controlflow → control}/switch.d.ts +2 -4
- package/api/statement/{controlflow → control}/switch.js +5 -11
- package/api/statement/control/switch.js.map +1 -0
- package/api/statement/{controlflow → control}/terminate.d.ts +1 -2
- package/api/statement/{controlflow → control}/terminate.js +1 -4
- package/api/statement/control/terminate.js.map +1 -0
- package/api/statement/declarations/declares.d.ts +13 -14
- package/api/statement/declarations/declares.js +10 -9
- package/api/statement/declarations/declares.js.map +1 -1
- package/api/statement/iterations/for.d.ts +14 -14
- package/api/statement/iterations/for.js +12 -24
- package/api/statement/iterations/for.js.map +1 -1
- package/api/statement/iterations/while.d.ts +2 -4
- package/api/statement/iterations/while.js +4 -10
- package/api/statement/iterations/while.js.map +1 -1
- package/package.json +18 -4
- package/scope/scope.d.ts +23 -3
- package/scope/scope.js +67 -1
- package/scope/scope.js.map +1 -1
- package/scope/stack.d.ts +14 -3
- package/scope/stack.js +61 -1
- package/scope/stack.js.map +1 -1
- package/v8/app.js.map +1 -1
- package/v8/nodes.d.ts +1 -2
- package/v8/nodes.js +2 -11
- package/v8/nodes.js.map +1 -1
- package/v8/parser.d.ts +5 -4
- package/v8/parser.js +165 -69
- package/v8/parser.js.map +1 -1
- package/v8/stream.js +20 -6
- package/v8/stream.js.map +1 -1
- package/v8/token.d.ts +3 -0
- package/v8/token.js +9 -0
- package/v8/token.js.map +1 -1
- package/api/operators/destruct.d.ts +0 -19
- package/api/operators/destruct.js +0 -95
- package/api/operators/destruct.js.map +0 -1
- package/api/statement/controlflow/block.js.map +0 -1
- package/api/statement/controlflow/empty.js.map +0 -1
- package/api/statement/controlflow/if.js.map +0 -1
- package/api/statement/controlflow/switch.js.map +0 -1
- package/api/statement/controlflow/terminate.js.map +0 -1
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
[downloads-url]: https://npmjs.org/package/@ibyar/expressions
|
|
14
14
|
[license-img]: https://img.shields.io/github/license/ibyar/aurora
|
|
15
15
|
[license-url]: https://github.com/ibyar/aurora/blob/master/LICENSE
|
|
16
|
-
[npm-dep-url]: https://img.shields.io/david/ibyar/
|
|
16
|
+
[npm-dep-url]: https://img.shields.io/david/ibyar/aurora?path=packages%2Fexpressions
|
|
17
17
|
[lerna-img]: https://img.shields.io/badge/maintained%20with-lerna-cc00ff.svg
|
|
18
18
|
[lerna-url]: https://lerna.js.org/
|
|
19
19
|
[contributors]: https://img.shields.io/github/contributors/ibyar/aurora
|
|
@@ -48,7 +48,7 @@ const source = `
|
|
|
48
48
|
setTimeout(() => console.log('setTimeout', alex), 500);
|
|
49
49
|
const sara = { firstName: 'sara', lastName: 'jon', age: 28, [Symbol.toStringTag]: 'SARA'};
|
|
50
50
|
console.log(sara['age']);
|
|
51
|
-
console.log('toStringTag', sara
|
|
51
|
+
console.log('toStringTag', Object.prototype.toString.call(sara));
|
|
52
52
|
console.log('compare', sara.age <=> alex.age);
|
|
53
53
|
console.log('older', sara.age >? alex.age);
|
|
54
54
|
console.log('younger', sara.age <? alex.age);
|
|
@@ -69,7 +69,16 @@ const source = `
|
|
|
69
69
|
'let taggedStringLiteral = latex`Hi\n${2+3}!`; console.log({taggedStringLiteral});'
|
|
70
70
|
;
|
|
71
71
|
|
|
72
|
-
const
|
|
72
|
+
const pipeSource = `
|
|
73
|
+
const add = (arg1, arg2) => arg1 + arg2;
|
|
74
|
+
a
|
|
75
|
+
|> function(s) {return s;}
|
|
76
|
+
|> (c => b = c + 1)
|
|
77
|
+
|> add(?, 2)
|
|
78
|
+
|> add(3, ?)
|
|
79
|
+
|> console.log:4:5;`;
|
|
80
|
+
|
|
81
|
+
const ast = JavaScriptParser.parse(source + pipeSource);
|
|
73
82
|
const esTree = ast.toJSON();
|
|
74
83
|
const esTreeString = JSON.stringify(ast, void 0, 2);
|
|
75
84
|
console.log({ esTree, esTreeString });
|
|
@@ -77,10 +86,14 @@ const context = {
|
|
|
77
86
|
Promise,
|
|
78
87
|
setTimeout,
|
|
79
88
|
console,
|
|
80
|
-
Symbol
|
|
89
|
+
Symbol,
|
|
90
|
+
Object
|
|
81
91
|
};
|
|
82
92
|
const stack = Stack.for(context);
|
|
83
|
-
const globalScope = Scope.
|
|
93
|
+
const globalScope = Scope.functionScopeFor({
|
|
94
|
+
a: 7,
|
|
95
|
+
b: undefined
|
|
96
|
+
});
|
|
84
97
|
stack.pushScope(globalScope);
|
|
85
98
|
ast.get(stack);
|
|
86
99
|
console.log(
|
|
@@ -94,5 +107,65 @@ console.log(
|
|
|
94
107
|
|
|
95
108
|
```
|
|
96
109
|
|
|
97
|
-
## follow ast of [
|
|
110
|
+
## follow ast of [ESTree](https://github.com/estree/estree/)
|
|
111
|
+
|
|
112
|
+
### Feature
|
|
113
|
+
|
|
114
|
+
- [V8 JavaScript engine](https://github.com/v8/v8) to parse js source code.
|
|
115
|
+
- for now this parser does not provide any info about `SourceLocation`
|
|
116
|
+
|
|
117
|
+
## Future Feature
|
|
118
|
+
|
|
119
|
+
- class expression
|
|
120
|
+
- Import/Export module
|
|
121
|
+
- Custom Factory Builder to convert the code to ESTree directly or to like now to Expression node
|
|
122
|
+
|
|
123
|
+
## Operators
|
|
124
|
+
|
|
125
|
+
| Operator type | Individual operators |
|
|
126
|
+
| ---------------------- | ------------------------------------------------------- |
|
|
127
|
+
| member | `. []` |
|
|
128
|
+
| call / create instance | `() new` |
|
|
129
|
+
| negation/increment | `! ~ - + ++ -- typeof void delete` |
|
|
130
|
+
| multiply/divide | `* / % ** %%` |
|
|
131
|
+
| addition/subtraction | `+ -` |
|
|
132
|
+
| bitwise shift | `<< >> >>>` |
|
|
133
|
+
| relational | `< <= > >= >? <? <=> in instanceof` |
|
|
134
|
+
| equality | `== != === !==` |
|
|
135
|
+
| bitwise-and | `&` |
|
|
136
|
+
| bitwise-xor | `^` |
|
|
137
|
+
| bitwise-or | `\|` |
|
|
138
|
+
| logical-and | `&&` |
|
|
139
|
+
| logical-or | `\|\|` |
|
|
140
|
+
| conditional | `?:` |
|
|
141
|
+
| assignment | `= += -= *= **= /= %= <<= >>= >>>= &= ^= \|= &&= \|\|= ??= >?= <?= %%=` |
|
|
142
|
+
| comma | `,` |
|
|
143
|
+
|
|
144
|
+
non-ecma operator are `%% >? <? <=> >?= <?= %%=`
|
|
145
|
+
|
|
98
146
|
|
|
147
|
+
## Pipeline Operator |> Support
|
|
148
|
+
|
|
149
|
+
- support angular-like syntax and partial operator for a call syntax:
|
|
150
|
+
|
|
151
|
+
```js
|
|
152
|
+
x |> methodName1:arg2:arg3
|
|
153
|
+
|> methodName2(arg1, ?, ...arg3);
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
function add(x, y, z) { return x + y + z };
|
|
157
|
+
const a = 88;
|
|
158
|
+
const b = 99;
|
|
159
|
+
const c = 11;
|
|
160
|
+
const z = a |> add:b:c; // === add(a, b, c)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```js
|
|
164
|
+
function add(x, y) { return x + y };
|
|
165
|
+
const a = 88;
|
|
166
|
+
argument |> map
|
|
167
|
+
|> function(x) { console.log(x); return x; }
|
|
168
|
+
|> (x) => { console.log(x); return x; }
|
|
169
|
+
|> methodName3(a)
|
|
170
|
+
|
|
171
|
+
```
|
package/api/abstract.d.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import type { ScopeType } from '../scope/scope.js';
|
|
2
|
-
import type { AwaitPromiseInfo,
|
|
3
|
-
import type { NodeDeserializer, ExpressionNode, NodeExpressionClass, NodeJsonType } from './expression.js';
|
|
2
|
+
import type { AwaitPromiseInfo, Stack } from '../scope/stack.js';
|
|
3
|
+
import type { NodeDeserializer, ExpressionNode, NodeExpressionClass, NodeJsonType, CanDeclareExpression } from './expression.js';
|
|
4
4
|
export declare abstract class AbstractExpressionNode implements ExpressionNode {
|
|
5
5
|
static fromJSON(node: ExpressionNode, deserializer: NodeDeserializer): ExpressionNode;
|
|
6
6
|
getClass(): NodeExpressionClass<ExpressionNode>;
|
|
7
7
|
toJSON(key?: string): NodeJsonType;
|
|
8
8
|
abstract set(stack: Stack, value: any): any;
|
|
9
9
|
abstract get(stack: Stack, thisContext?: any): any;
|
|
10
|
-
abstract
|
|
11
|
-
abstract event(parent?: string): string[];
|
|
10
|
+
abstract events(parent?: string): string[];
|
|
12
11
|
abstract toString(): string;
|
|
13
12
|
abstract toJson(key?: string): {
|
|
14
13
|
[key: string]: any;
|
|
@@ -24,8 +23,7 @@ export declare abstract class InfixExpressionNode<T> extends AbstractExpressionN
|
|
|
24
23
|
getRight(): ExpressionNode;
|
|
25
24
|
set(context: object, value: any): void;
|
|
26
25
|
abstract get(stack: Stack): any;
|
|
27
|
-
|
|
28
|
-
event(parent?: string): string[];
|
|
26
|
+
events(parent?: string): string[];
|
|
29
27
|
toString(): string;
|
|
30
28
|
toJson(key: string): object;
|
|
31
29
|
}
|
|
@@ -36,7 +34,7 @@ export declare class ReturnValue {
|
|
|
36
34
|
}
|
|
37
35
|
export declare class AwaitPromise implements AwaitPromiseInfo {
|
|
38
36
|
promise: Promise<any>;
|
|
39
|
-
node:
|
|
37
|
+
node: CanDeclareExpression;
|
|
40
38
|
declareVariable: boolean;
|
|
41
39
|
scopeType: ScopeType;
|
|
42
40
|
constructor(promise: Promise<any>);
|
package/api/abstract.js
CHANGED
|
@@ -30,11 +30,8 @@ export class InfixExpressionNode extends AbstractExpressionNode {
|
|
|
30
30
|
set(context, value) {
|
|
31
31
|
throw new Error(`${this.constructor.name}#set() of operator: '${this.operator}' has no implementation.`);
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
return [...this.left.
|
|
35
|
-
}
|
|
36
|
-
event(parent) {
|
|
37
|
-
return [...this.left.event(), ...this.right.event()];
|
|
33
|
+
events(parent) {
|
|
34
|
+
return [...this.left.events(), ...this.right.events()];
|
|
38
35
|
}
|
|
39
36
|
toString() {
|
|
40
37
|
return `${this.left.toString()} ${this.operator} ${this.right.toString()}`;
|
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":"AAQA,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,CAAiB,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC;IACb,CAAC;CAMD;AACD,MAAM,OAAgB,mBAAuB,SAAQ,sBAAsB;IAC1E,YAAsB,QAAW,EAAY,IAAoB,EAAY,KAAqB;QACjG,KAAK,EAAE,CAAC;QADa,aAAQ,GAAR,QAAQ,CAAG;QAAY,SAAI,GAAJ,IAAI,CAAgB;QAAY,UAAK,GAAL,KAAK,CAAgB;IAElG,CAAC;IACD,WAAW;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC;IACtB,CAAC;IACD,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;IACD,GAAG,CAAC,OAAe,EAAE,KAAU;QAC9B,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,wBAAwB,IAAI,CAAC,QAAQ,0BAA0B,CAAC,CAAC;IAC1G,CAAC;IAED,MAAM,CAAC,MAAe;QACrB,OAAO,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACxD,CAAC;IACD,QAAQ;QACP,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5E,CAAC;IACD,MAAM,CAAC,GAAW;QACjB,OAAO;YACN,EAAE,EAAE,IAAI,CAAC,QAAQ;YACjB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;YACxB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE;SAC1B,CAAC;IACH,CAAC;CACD;AAED,MAAM,OAAO,WAAW;IACvB,YAAmB,KAAU;QAAV,UAAK,GAAL,KAAK,CAAK;IAAI,CAAC;IAClC,QAAQ;QACP,OAAO,IAAI,CAAC,KAAK,CAAC;IACnB,CAAC;CACD;AAED,MAAM,OAAO,YAAY;IAIxB,YAAmB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;IAAI,CAAC;CAC7C","sourcesContent":["import type { ScopeType } from '../scope/scope.js';\nimport type { AwaitPromiseInfo, Stack } from '../scope/stack.js';\nimport type {\n\tNodeDeserializer, ExpressionNode,\n\tNodeExpressionClass, NodeJsonType,\n\tCanDeclareExpression\n} from './expression.js';\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\tabstract set(stack: Stack, value: any): any;\n\tabstract get(stack: Stack, thisContext?: any): any;\n\tabstract events(parent?: string): string[];\n\tabstract toString(): string;\n\tabstract toJson(key?: string): { [key: string]: any };\n}\nexport abstract class InfixExpressionNode<T> extends AbstractExpressionNode {\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\tevents(parent?: string): string[] {\n\t\treturn [...this.left.events(), ...this.right.events()];\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\top: 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 AwaitPromise implements AwaitPromiseInfo {\n\tnode: CanDeclareExpression;\n\tdeclareVariable: boolean;\n\tscopeType: ScopeType;\n\tconstructor(public promise: Promise<any>) { }\n}\n"]}
|
package/api/app/class.d.ts
CHANGED
|
@@ -1,16 +1,107 @@
|
|
|
1
1
|
import type { Stack } from '../../scope/stack.js';
|
|
2
|
+
import type { ScopeType } from '../../scope/scope.js';
|
|
3
|
+
import type { CanDeclareExpression, ExpressionNode, NodeDeserializer } from '../expression.js';
|
|
2
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
+
import { Identifier } from '../definition/values.js';
|
|
6
|
+
import { MemberExpression } from '../definition/member.js';
|
|
7
|
+
import { FunctionExpression } from '../definition/function.js';
|
|
8
|
+
export declare class MetaProperty extends MemberExpression {
|
|
9
|
+
private meta;
|
|
10
|
+
static NewTarget: MetaProperty;
|
|
11
|
+
static ImportMeta: MetaProperty;
|
|
12
|
+
private static getJsonName;
|
|
13
|
+
static fromJSON(node: MetaProperty, deserializer: NodeDeserializer<any>): MetaProperty;
|
|
14
|
+
constructor(meta: Identifier, property: Identifier);
|
|
15
|
+
getMeta(): Identifier;
|
|
16
|
+
toString(): string;
|
|
17
|
+
toJson(key?: string): {
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare class PrivateIdentifier extends Identifier {
|
|
22
|
+
private privateName;
|
|
23
|
+
static fromJSON(node: PrivateIdentifier): PrivateIdentifier;
|
|
24
|
+
constructor(privateName: string);
|
|
25
|
+
toString(): string;
|
|
26
|
+
toJson(key?: string): {
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export declare type MethodDefinitionKind = 'constructor' | 'method' | 'set' | 'get';
|
|
31
|
+
export declare class MethodDefinition extends AbstractExpressionNode implements CanDeclareExpression {
|
|
32
|
+
private kind;
|
|
33
|
+
private key;
|
|
34
|
+
private value;
|
|
35
|
+
private computed;
|
|
36
|
+
static fromJSON(node: MethodDefinition, deserializer: NodeDeserializer<any>): MethodDefinition;
|
|
37
|
+
private 'static';
|
|
38
|
+
constructor(kind: MethodDefinitionKind, key: ExpressionNode | PrivateIdentifier, value: FunctionExpression, computed: boolean, isStatic: boolean);
|
|
39
|
+
getKind(): MethodDefinitionKind;
|
|
40
|
+
getKey(): ExpressionNode | PrivateIdentifier;
|
|
41
|
+
getValue(): FunctionExpression;
|
|
42
|
+
isComputed(): boolean;
|
|
43
|
+
isStatic(): boolean;
|
|
44
|
+
set(stack: Stack, value: any): void;
|
|
45
|
+
get(stack: Stack, thisContext?: any): void;
|
|
46
|
+
declareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any): void;
|
|
47
|
+
events(parent?: string): string[];
|
|
48
|
+
toString(): string;
|
|
49
|
+
toJson(key?: string): {
|
|
50
|
+
[key: string]: any;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare class PropertyDefinition extends AbstractExpressionNode implements CanDeclareExpression {
|
|
54
|
+
private key;
|
|
55
|
+
private computed;
|
|
56
|
+
private value?;
|
|
57
|
+
static fromJSON(node: PropertyDefinition, deserializer: NodeDeserializer<any>): PropertyDefinition;
|
|
58
|
+
private 'static';
|
|
59
|
+
constructor(key: ExpressionNode | PrivateIdentifier, computed: boolean, isStatic: boolean, value?: ExpressionNode | undefined);
|
|
60
|
+
getKey(): ExpressionNode | PrivateIdentifier;
|
|
61
|
+
getValue(): ExpressionNode | undefined;
|
|
62
|
+
isComputed(): boolean;
|
|
63
|
+
isStatic(): boolean;
|
|
64
|
+
set(stack: Stack, value: any): void;
|
|
65
|
+
get(stack: Stack, thisContext?: any): void;
|
|
66
|
+
declareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any): void;
|
|
67
|
+
events(parent?: string): string[];
|
|
68
|
+
toString(): string;
|
|
69
|
+
toJson(key?: string): {
|
|
70
|
+
[key: string]: any;
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export declare class ClassBody extends AbstractExpressionNode {
|
|
5
74
|
private body;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
75
|
+
static fromJSON(node: ClassBody, deserializer: NodeDeserializer<any>): ClassBody;
|
|
76
|
+
constructor(body: (MethodDefinition | PropertyDefinition)[]);
|
|
77
|
+
getBody(): (MethodDefinition | PropertyDefinition)[];
|
|
78
|
+
set(stack: Stack, value: any): void;
|
|
79
|
+
get(stack: Stack, thisContext?: any): void;
|
|
80
|
+
events(parent?: string): string[];
|
|
81
|
+
toString(): string;
|
|
82
|
+
toJson(key?: string): {
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export declare class Class extends AbstractExpressionNode {
|
|
87
|
+
protected body: ClassBody;
|
|
88
|
+
protected id?: Identifier | undefined;
|
|
89
|
+
protected superClass?: ExpressionNode | undefined;
|
|
90
|
+
constructor(body: ClassBody, id?: Identifier | undefined, superClass?: ExpressionNode | undefined);
|
|
91
|
+
getBody(): ClassBody;
|
|
92
|
+
getId(): Identifier | undefined;
|
|
93
|
+
getSuperClass(): ExpressionNode | undefined;
|
|
10
94
|
set(stack: Stack): void;
|
|
11
95
|
get(stack: Stack): void;
|
|
12
|
-
|
|
13
|
-
event(parent?: string): string[];
|
|
96
|
+
events(parent?: string): string[];
|
|
14
97
|
toString(): string;
|
|
15
98
|
toJson(): object;
|
|
16
99
|
}
|
|
100
|
+
export declare class ClassDeclaration extends Class implements CanDeclareExpression {
|
|
101
|
+
static fromJSON(node: ClassDeclaration, deserializer: NodeDeserializer<any>): ClassDeclaration;
|
|
102
|
+
protected id: Identifier;
|
|
103
|
+
declareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any): void;
|
|
104
|
+
}
|
|
105
|
+
export declare class ClassExpression extends Class {
|
|
106
|
+
static fromJSON(node: ClassExpression, deserializer: NodeDeserializer<any>): ClassExpression;
|
|
107
|
+
}
|
package/api/app/class.js
CHANGED
|
@@ -1,53 +1,274 @@
|
|
|
1
|
-
var
|
|
1
|
+
var MetaProperty_1, PrivateIdentifier_1, MethodDefinition_1, PropertyDefinition_1, ClassBody_1, ClassDeclaration_1, ClassExpression_1;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
4
4
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import { Identifier } from '../definition/values.js';
|
|
6
|
+
import { MemberExpression } from '../definition/member.js';
|
|
7
|
+
import { FunctionExpression } from '../definition/function.js';
|
|
8
|
+
let MetaProperty = MetaProperty_1 = class MetaProperty extends MemberExpression {
|
|
9
|
+
constructor(meta, property) {
|
|
10
|
+
super(meta, property, false);
|
|
11
|
+
this.meta = meta;
|
|
12
|
+
}
|
|
13
|
+
static getJsonName(identifier) {
|
|
14
|
+
return Reflect.get(identifier, 'name');
|
|
15
|
+
}
|
|
16
|
+
static fromJSON(node, deserializer) {
|
|
17
|
+
if (MetaProperty_1.getJsonName(node.meta) === 'new' && MetaProperty_1.getJsonName(node.property) === 'target') {
|
|
18
|
+
return MetaProperty_1.NewTarget;
|
|
19
|
+
}
|
|
20
|
+
else if (MetaProperty_1.getJsonName(node.meta) === 'new' && MetaProperty_1.getJsonName(node.property) === 'meta') {
|
|
21
|
+
return MetaProperty_1.ImportMeta;
|
|
22
|
+
}
|
|
23
|
+
return new MetaProperty_1(deserializer(node.meta), deserializer(node.property));
|
|
24
|
+
}
|
|
25
|
+
getMeta() {
|
|
26
|
+
return this.meta;
|
|
27
|
+
}
|
|
28
|
+
toString() {
|
|
29
|
+
return `${this.meta.toString()}.${this.property.toString()}`;
|
|
30
|
+
}
|
|
31
|
+
toJson(key) {
|
|
32
|
+
return {
|
|
33
|
+
meta: this.meta.toJSON(),
|
|
34
|
+
property: this.property.toJSON(),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
MetaProperty.NewTarget = new MetaProperty_1(new Identifier('new'), new Identifier('target'));
|
|
39
|
+
MetaProperty.ImportMeta = new MetaProperty_1(new Identifier('import'), new Identifier('meta'));
|
|
40
|
+
MetaProperty = MetaProperty_1 = __decorate([
|
|
41
|
+
Deserializer('MetaProperty'),
|
|
42
|
+
__metadata("design:paramtypes", [Identifier, Identifier])
|
|
43
|
+
], MetaProperty);
|
|
44
|
+
export { MetaProperty };
|
|
45
|
+
let PrivateIdentifier = PrivateIdentifier_1 = class PrivateIdentifier extends Identifier {
|
|
46
|
+
constructor(privateName) {
|
|
47
|
+
super('ɵ_' + privateName);
|
|
48
|
+
this.privateName = privateName;
|
|
49
|
+
}
|
|
50
|
+
static fromJSON(node) {
|
|
51
|
+
return new PrivateIdentifier_1(node.name);
|
|
52
|
+
}
|
|
53
|
+
toString() {
|
|
54
|
+
return `#${this.privateName}`;
|
|
55
|
+
}
|
|
56
|
+
toJson(key) {
|
|
57
|
+
return {
|
|
58
|
+
name: this.privateName
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
PrivateIdentifier = PrivateIdentifier_1 = __decorate([
|
|
63
|
+
Deserializer('PrivateIdentifier'),
|
|
64
|
+
__metadata("design:paramtypes", [String])
|
|
65
|
+
], PrivateIdentifier);
|
|
66
|
+
export { PrivateIdentifier };
|
|
67
|
+
let MethodDefinition = MethodDefinition_1 = class MethodDefinition extends AbstractExpressionNode {
|
|
68
|
+
constructor(kind, key, value, computed, isStatic) {
|
|
69
|
+
super();
|
|
70
|
+
this.kind = kind;
|
|
71
|
+
this.key = key;
|
|
72
|
+
this.value = value;
|
|
73
|
+
this.computed = computed;
|
|
74
|
+
this.static = isStatic;
|
|
75
|
+
}
|
|
76
|
+
static fromJSON(node, deserializer) {
|
|
77
|
+
return new MethodDefinition_1(node.kind, deserializer(node.key), deserializer(node.value), node.computed, node.static);
|
|
78
|
+
}
|
|
79
|
+
getKind() {
|
|
80
|
+
return this.kind;
|
|
81
|
+
}
|
|
82
|
+
getKey() {
|
|
83
|
+
return this.key;
|
|
84
|
+
}
|
|
85
|
+
getValue() {
|
|
86
|
+
return this.value;
|
|
87
|
+
}
|
|
88
|
+
isComputed() {
|
|
89
|
+
return this.computed;
|
|
90
|
+
}
|
|
91
|
+
isStatic() {
|
|
92
|
+
return this.static;
|
|
93
|
+
}
|
|
94
|
+
set(stack, value) {
|
|
95
|
+
throw new Error('Method not implemented.');
|
|
96
|
+
}
|
|
97
|
+
get(stack, thisContext) {
|
|
98
|
+
throw new Error('Method not implemented.');
|
|
99
|
+
}
|
|
100
|
+
declareVariable(stack, scopeType, propertyValue) {
|
|
101
|
+
throw new Error('Method not implemented.');
|
|
102
|
+
}
|
|
103
|
+
events(parent) {
|
|
104
|
+
throw new Error('Method not implemented.');
|
|
105
|
+
}
|
|
106
|
+
toString() {
|
|
107
|
+
throw new Error('Method not implemented.');
|
|
108
|
+
}
|
|
109
|
+
toJson(key) {
|
|
110
|
+
return {
|
|
111
|
+
kind: this.kind,
|
|
112
|
+
key: this.key,
|
|
113
|
+
value: this.value,
|
|
114
|
+
computed: this.computed,
|
|
115
|
+
static: this.static,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
MethodDefinition = MethodDefinition_1 = __decorate([
|
|
120
|
+
Deserializer('MethodDefinition'),
|
|
121
|
+
__metadata("design:paramtypes", [String, Object, FunctionExpression, Boolean, Boolean])
|
|
122
|
+
], MethodDefinition);
|
|
123
|
+
export { MethodDefinition };
|
|
124
|
+
let PropertyDefinition = PropertyDefinition_1 = class PropertyDefinition extends AbstractExpressionNode {
|
|
125
|
+
constructor(key, computed, isStatic, value) {
|
|
126
|
+
super();
|
|
127
|
+
this.key = key;
|
|
128
|
+
this.computed = computed;
|
|
129
|
+
this.value = value;
|
|
130
|
+
this.static = isStatic;
|
|
131
|
+
}
|
|
132
|
+
static fromJSON(node, deserializer) {
|
|
133
|
+
return new PropertyDefinition_1(deserializer(node.key), node.computed, node.static, node.value && deserializer(node.value));
|
|
134
|
+
}
|
|
135
|
+
getKey() {
|
|
136
|
+
return this.key;
|
|
137
|
+
}
|
|
138
|
+
getValue() {
|
|
139
|
+
return this.value;
|
|
140
|
+
}
|
|
141
|
+
isComputed() {
|
|
142
|
+
return this.computed;
|
|
143
|
+
}
|
|
144
|
+
isStatic() {
|
|
145
|
+
return this.static;
|
|
146
|
+
}
|
|
147
|
+
set(stack, value) {
|
|
148
|
+
throw new Error('Method not implemented.');
|
|
149
|
+
}
|
|
150
|
+
get(stack, thisContext) {
|
|
151
|
+
throw new Error('Method not implemented.');
|
|
152
|
+
}
|
|
153
|
+
declareVariable(stack, scopeType, propertyValue) {
|
|
154
|
+
throw new Error('Method not implemented.');
|
|
155
|
+
}
|
|
156
|
+
events(parent) {
|
|
157
|
+
throw new Error('Method not implemented.');
|
|
158
|
+
}
|
|
159
|
+
toString() {
|
|
160
|
+
throw new Error('Method not implemented.');
|
|
161
|
+
}
|
|
162
|
+
toJson(key) {
|
|
163
|
+
return {
|
|
164
|
+
key: this.key.toJSON(),
|
|
165
|
+
computed: this.computed,
|
|
166
|
+
static: this.static,
|
|
167
|
+
value: this.value?.toJSON()
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
PropertyDefinition = PropertyDefinition_1 = __decorate([
|
|
172
|
+
Deserializer('PropertyDefinition'),
|
|
173
|
+
__metadata("design:paramtypes", [Object, Boolean, Boolean, Object])
|
|
174
|
+
], PropertyDefinition);
|
|
175
|
+
export { PropertyDefinition };
|
|
176
|
+
let ClassBody = ClassBody_1 = class ClassBody extends AbstractExpressionNode {
|
|
177
|
+
constructor(body) {
|
|
7
178
|
super();
|
|
8
179
|
this.body = body;
|
|
9
|
-
this.className = className;
|
|
10
|
-
this.extendsClass = extendsClass;
|
|
11
180
|
}
|
|
12
181
|
static fromJSON(node, deserializer) {
|
|
13
|
-
return new
|
|
182
|
+
return new ClassBody_1(node.body.map(deserializer));
|
|
183
|
+
}
|
|
184
|
+
getBody() {
|
|
185
|
+
return this.body;
|
|
186
|
+
}
|
|
187
|
+
set(stack, value) {
|
|
188
|
+
throw new Error('Method not implemented.');
|
|
189
|
+
}
|
|
190
|
+
get(stack, thisContext) {
|
|
191
|
+
throw new Error('Method not implemented.');
|
|
192
|
+
}
|
|
193
|
+
events(parent) {
|
|
194
|
+
throw new Error('Method not implemented.');
|
|
195
|
+
}
|
|
196
|
+
toString() {
|
|
197
|
+
throw new Error('Method not implemented.');
|
|
198
|
+
}
|
|
199
|
+
toJson(key) {
|
|
200
|
+
return {
|
|
201
|
+
body: this.body.map(method => method.toJSON())
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
ClassBody = ClassBody_1 = __decorate([
|
|
206
|
+
Deserializer('ClassBody'),
|
|
207
|
+
__metadata("design:paramtypes", [Array])
|
|
208
|
+
], ClassBody);
|
|
209
|
+
export { ClassBody };
|
|
210
|
+
export class Class extends AbstractExpressionNode {
|
|
211
|
+
constructor(body, id, superClass) {
|
|
212
|
+
super();
|
|
213
|
+
this.body = body;
|
|
214
|
+
this.id = id;
|
|
215
|
+
this.superClass = superClass;
|
|
216
|
+
}
|
|
217
|
+
getBody() {
|
|
218
|
+
return this.body;
|
|
219
|
+
}
|
|
220
|
+
getId() {
|
|
221
|
+
return this.id;
|
|
222
|
+
}
|
|
223
|
+
getSuperClass() {
|
|
224
|
+
return this.superClass;
|
|
14
225
|
}
|
|
15
226
|
set(stack) {
|
|
16
|
-
throw new Error(`
|
|
227
|
+
throw new Error(`Class.#set() has no implementation.`);
|
|
17
228
|
}
|
|
18
229
|
get(stack) {
|
|
19
|
-
throw new Error(`
|
|
230
|
+
throw new Error(`Class.#get() has no implementation.`);
|
|
20
231
|
}
|
|
21
|
-
|
|
22
|
-
return [];
|
|
23
|
-
}
|
|
24
|
-
event(parent) {
|
|
232
|
+
events(parent) {
|
|
25
233
|
return [];
|
|
26
234
|
}
|
|
27
235
|
toString() {
|
|
28
|
-
let classDeclaration = '';
|
|
29
|
-
if (this.
|
|
30
|
-
classDeclaration += this.
|
|
236
|
+
let classDeclaration = 'class ';
|
|
237
|
+
if (this.id) {
|
|
238
|
+
classDeclaration += this.id.toString();
|
|
31
239
|
}
|
|
32
|
-
if (this.
|
|
33
|
-
|
|
34
|
-
classDeclaration += ' ';
|
|
35
|
-
}
|
|
36
|
-
classDeclaration += 'extends ' + this.extendsClass.toString();
|
|
240
|
+
if (this.superClass) {
|
|
241
|
+
classDeclaration += ' extends ' + this.superClass.toString();
|
|
37
242
|
}
|
|
38
|
-
return
|
|
243
|
+
return `${classDeclaration} {${this.body.toString()}\n`;
|
|
39
244
|
}
|
|
40
245
|
toJson() {
|
|
41
246
|
return {
|
|
42
|
-
body: this.body.
|
|
43
|
-
|
|
44
|
-
|
|
247
|
+
body: this.body.toJSON(),
|
|
248
|
+
id: this.id?.toJSON(),
|
|
249
|
+
superClass: this.superClass?.toJSON(),
|
|
45
250
|
};
|
|
46
251
|
}
|
|
252
|
+
}
|
|
253
|
+
let ClassDeclaration = ClassDeclaration_1 = class ClassDeclaration extends Class {
|
|
254
|
+
static fromJSON(node, deserializer) {
|
|
255
|
+
return new ClassDeclaration_1(deserializer(node.body), deserializer(node.id), node.superClass && deserializer(node.superClass));
|
|
256
|
+
}
|
|
257
|
+
declareVariable(stack, scopeType, propertyValue) {
|
|
258
|
+
stack.declareVariable(scopeType, this.id.getName(), propertyValue);
|
|
259
|
+
}
|
|
260
|
+
};
|
|
261
|
+
ClassDeclaration = ClassDeclaration_1 = __decorate([
|
|
262
|
+
Deserializer('ClassDeclaration')
|
|
263
|
+
], ClassDeclaration);
|
|
264
|
+
export { ClassDeclaration };
|
|
265
|
+
let ClassExpression = ClassExpression_1 = class ClassExpression extends Class {
|
|
266
|
+
static fromJSON(node, deserializer) {
|
|
267
|
+
return new ClassExpression_1(deserializer(node.body), node.id && deserializer(node.id), node.superClass && deserializer(node.superClass));
|
|
268
|
+
}
|
|
47
269
|
};
|
|
48
|
-
|
|
49
|
-
Deserializer('
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
export { ClassNode };
|
|
270
|
+
ClassExpression = ClassExpression_1 = __decorate([
|
|
271
|
+
Deserializer('ClassExpression')
|
|
272
|
+
], ClassExpression);
|
|
273
|
+
export { ClassExpression };
|
|
53
274
|
//# sourceMappingURL=class.js.map
|
package/api/app/class.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/expressions/api/app/class.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAK7D,IAAa,SAAS,iBAAtB,MAAa,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,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IACpG,CAAC;IACD,MAAM;QACL,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACtD,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE;YACnC,YAAY,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,EAAE;SACzC,CAAC;IACH,CAAC;CACD,CAAA;AA/CY,SAAS;IADrB,YAAY,CAAC,OAAO,CAAC;;GACT,SAAS,CA+CrB;SA/CY,SAAS","sourcesContent":["import type { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport type { ExpressionNode, NodeDeserializer } from '../expression.js';\n\n\n@Deserializer('class')\nexport class ClassNode extends AbstractExpressionNode {\n\tstatic fromJSON(node: ClassNode, deserializer: NodeDeserializer): ClassNode {\n\t\treturn new ClassNode(\n\t\t\tnode.body.map(deserializer),\n\t\t\tnode.className ? deserializer(node.className) : void 0,\n\t\t\tnode.extendsClass ? deserializer(node.extendsClass) : void 0\n\t\t);\n\t}\n\tconstructor(\n\t\tprivate body: ExpressionNode[],\n\t\tprivate className?: ExpressionNode,\n\t\tprivate extendsClass?: ExpressionNode) {\n\t\tsuper();\n\t}\n\n\tset(stack: Stack) {\n\t\tthrow new Error(`ClassNode.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tthrow new Error(`ClassNode.#get() has no implementation.`);\n\t}\n\tentry(): string[] {\n\t\treturn [];\n\t}\n\tevent(parent?: string): string[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\tlet classDeclaration = '';\n\t\tif (this.className) {\n\t\t\tclassDeclaration += this.className.toString();\n\t\t}\n\t\tif (this.extendsClass) {\n\t\t\tif (this.className) {\n\t\t\t\tclassDeclaration += ' ';\n\t\t\t}\n\t\t\tclassDeclaration += 'extends ' + this.extendsClass.toString();\n\t\t}\n\t\treturn `class ${classDeclaration} {\\n\\t${this.body.map(expr => expr.toString()).join(';\\n\\t')}}\\n`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tbody: this.body.map(expression => expression.toJSON()),\n\t\t\tclassName: this.className?.toJSON(),\n\t\t\textendsClass: this.extendsClass?.toJSON(),\n\t\t};\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"class.js","sourceRoot":"","sources":["../../../../src/expressions/api/app/class.ts"],"names":[],"mappings":";;AAGA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAW/D,IAAa,YAAY,oBAAzB,MAAa,YAAa,SAAQ,gBAAgB;IAsBjD,YAAoB,IAAgB,EAAE,QAAoB;QACzD,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAC;QADV,SAAI,GAAJ,IAAI,CAAY;IAEpC,CAAC;IAlBO,MAAM,CAAC,WAAW,CAAC,UAA0B;QACpD,OAAO,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAkB,EAAE,YAAmC;QACtE,IAAI,cAAY,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,cAAY,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,QAAQ,EAAE;YAC1G,OAAO,cAAY,CA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CAAC;IACH,CAAC;IAED,eAAe,CAAC,KAAY,EAAE,SAAoB,EAAE,aAAmB;QACtE,KAAK,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,aAAa,CAAC,CAAC;IACpE,CAAC;CACD,CAAA;AAZY,gBAAgB;IAD5B,YAAY,CAAC,kBAAkB,CAAC;GACpB,gBAAgB,CAY5B;SAZY,gBAAgB;AAe7B,IAAa,eAAe,uBAA5B,MAAa,eAAgB,SAAQ,KAAK;IACzC,MAAM,CAAC,QAAQ,CAAC,IAAqB,EAAE,YAAmC;QACzE,OAAO,IAAI,iBAAe,CACzB,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,EACvB,IAAI,CAAC,EAAE,IAAI,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,EAChC,IAAI,CAAC,UAAU,IAAI,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,CAChD,CAAC;IACH,CAAC;CACD,CAAA;AARY,eAAe;IAD3B,YAAY,CAAC,iBAAiB,CAAC;GACnB,eAAe,CAQ3B;SARY,eAAe","sourcesContent":["import type { Stack } from '../../scope/stack.js';\nimport type { ScopeType } from '../../scope/scope.js';\nimport type { CanDeclareExpression, ExpressionNode, NodeDeserializer } from '../expression.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { Identifier } from '../definition/values.js';\nimport { MemberExpression } from '../definition/member.js';\nimport { FunctionExpression } from '../definition/function.js';\n\n\n/**\n * MetaProperty node represents\n * - `new.target` meta property in ES2015.\n * - `import.meta` meta property in ES2030.\n * \n * In the future, it will represent other meta properties as well.\n */\n@Deserializer('MetaProperty')\nexport class MetaProperty extends MemberExpression {\n\n\tpublic static NewTarget = new MetaProperty(new Identifier('new'), new Identifier('target'));\n\n\tpublic static ImportMeta = new MetaProperty(new Identifier('import'), new Identifier('meta'));\n\n\tprivate static getJsonName(identifier: ExpressionNode): string {\n\t\treturn Reflect.get(identifier, 'name');\n\t}\n\n\tstatic fromJSON(node: MetaProperty, deserializer: NodeDeserializer<any>): MetaProperty {\n\t\tif (MetaProperty.getJsonName(node.meta) === 'new' && MetaProperty.getJsonName(node.property) === 'target') {\n\t\t\treturn MetaProperty.NewTarget;\n\t\t}\n\t\telse if (MetaProperty.getJsonName(node.meta) === 'new' && MetaProperty.getJsonName(node.property) === 'meta') {\n\t\t\treturn MetaProperty.ImportMeta;\n\t\t}\n\t\treturn new MetaProperty(\n\t\t\tdeserializer(node.meta),\n\t\t\tdeserializer(node.property)\n\t\t);\n\t}\n\tconstructor(private meta: Identifier, property: Identifier) {\n\t\tsuper(meta, property, false);\n\t}\n\tgetMeta() {\n\t\treturn this.meta;\n\t}\n\ttoString(): string {\n\t\treturn `${this.meta.toString()}.${this.property.toString()}`;\n\t}\n\ttoJson(key?: string): { [key: string]: any; } {\n\t\treturn {\n\t\t\tmeta: this.meta.toJSON(),\n\t\t\tproperty: this.property.toJSON(),\n\t\t};\n\t}\n}\n\n/**\n * A private identifier refers to private class elements. For a private name #a, its name is a.\n */\n@Deserializer('PrivateIdentifier')\nexport class PrivateIdentifier extends Identifier {\n\tstatic fromJSON(node: PrivateIdentifier): PrivateIdentifier {\n\t\treturn new PrivateIdentifier(\n\t\t\tnode.name as string\n\t\t);\n\t}\n\tconstructor(private privateName: string) {\n\t\tsuper('ɵ_' + privateName);\n\t}\n\ttoString(): string {\n\t\treturn `#${this.privateName}`;\n\t}\n\ttoJson(key?: string): { [key: string]: any; } {\n\t\treturn {\n\t\t\tname: this.privateName\n\t\t};\n\t}\n}\n\nexport type MethodDefinitionKind = 'constructor' | 'method' | 'set' | 'get';\n\n/**\n * - When key is a PrivateIdentifier, computed must be false and kind can not be \"constructor\".\n */\n@Deserializer('MethodDefinition')\nexport class MethodDefinition extends AbstractExpressionNode implements CanDeclareExpression {\n\tstatic fromJSON(node: MethodDefinition, deserializer: NodeDeserializer<any>): MethodDefinition {\n\t\treturn new MethodDefinition(\n\t\t\tnode.kind,\n\t\t\tdeserializer(node.key),\n\t\t\tdeserializer(node.value),\n\t\t\tnode.computed,\n\t\t\tnode.static\n\t\t);\n\t}\n\tprivate 'static': boolean;\n\tconstructor(\n\t\tprivate kind: MethodDefinitionKind,\n\t\tprivate key: ExpressionNode | PrivateIdentifier,\n\t\tprivate value: FunctionExpression,\n\n\t\tprivate computed: boolean,\n\t\tisStatic: boolean) {\n\t\tsuper();\n\t\tthis.static = isStatic;\n\t}\n\tgetKind() {\n\t\treturn this.kind;\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tisComputed() {\n\t\treturn this.computed;\n\t}\n\tisStatic() {\n\t\treturn this.static;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tdeclareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tevents(parent?: string): string[] {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\ttoString(): string {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\ttoJson(key?: string): { [key: string]: any; } {\n\t\treturn {\n\t\t\tkind: this.kind,\n\t\t\tkey: this.key,\n\t\t\tvalue: this.value,\n\t\t\tcomputed: this.computed,\n\t\t\tstatic: this.static,\n\t\t};\n\t}\n}\n\n\n\n/**\n * - When key is a PrivateIdentifier, computed must be false.\n */\n@Deserializer('PropertyDefinition')\nexport class PropertyDefinition extends AbstractExpressionNode implements CanDeclareExpression {\n\tstatic fromJSON(node: PropertyDefinition, deserializer: NodeDeserializer<any>): PropertyDefinition {\n\t\treturn new PropertyDefinition(\n\t\t\tdeserializer(node.key),\n\t\t\tnode.computed,\n\t\t\tnode.static,\n\t\t\tnode.value && deserializer(node.value)\n\t\t);\n\t}\n\tprivate 'static': boolean;\n\tconstructor(\n\t\tprivate key: ExpressionNode | PrivateIdentifier,\n\t\tprivate computed: boolean,\n\t\tisStatic: boolean,\n\t\tprivate value?: ExpressionNode) {\n\t\tsuper();\n\t\tthis.static = isStatic;\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tisComputed() {\n\t\treturn this.computed;\n\t}\n\tisStatic() {\n\t\treturn this.static;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tdeclareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tevents(parent?: string): string[] {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\ttoString(): string {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\ttoJson(key?: string): { [key: string]: any; } {\n\t\treturn {\n\t\t\tkey: this.key.toJSON(),\n\t\t\tcomputed: this.computed,\n\t\t\tstatic: this.static,\n\t\t\tvalue: this.value?.toJSON()\n\t\t};\n\t}\n}\n\n@Deserializer('ClassBody')\nexport class ClassBody extends AbstractExpressionNode {\n\tstatic fromJSON(node: ClassBody, deserializer: NodeDeserializer<any>): ClassBody {\n\t\treturn new ClassBody(\n\t\t\tnode.body.map(deserializer)\n\t\t);\n\t}\n\tconstructor(private body: (MethodDefinition | PropertyDefinition)[]) {\n\t\tsuper();\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\tevents(parent?: string): string[] {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\ttoString(): string {\n\t\tthrow new Error('Method not implemented.');\n\t}\n\ttoJson(key?: string): { [key: string]: any; } {\n\t\treturn {\n\t\t\tbody: this.body.map(method => method.toJSON())\n\t\t};\n\t}\n}\n\nexport class Class extends AbstractExpressionNode {\n\tconstructor(\n\t\tprotected body: ClassBody,\n\t\tprotected id?: Identifier,\n\t\tprotected superClass?: ExpressionNode) {\n\t\tsuper();\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tgetId() {\n\t\treturn this.id;\n\t}\n\tgetSuperClass() {\n\t\treturn this.superClass;\n\t}\n\n\tset(stack: Stack) {\n\t\tthrow new Error(`Class.#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tthrow new Error(`Class.#get() has no implementation.`);\n\t}\n\tevents(parent?: string): string[] {\n\t\treturn [];\n\t}\n\ttoString() {\n\t\tlet classDeclaration = 'class ';\n\t\tif (this.id) {\n\t\t\tclassDeclaration += this.id.toString();\n\t\t}\n\t\tif (this.superClass) {\n\t\t\tclassDeclaration += ' extends ' + this.superClass.toString();\n\t\t}\n\t\treturn `${classDeclaration} {${this.body.toString()}\\n`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tbody: this.body.toJSON(),\n\t\t\tid: this.id?.toJSON(),\n\t\t\tsuperClass: this.superClass?.toJSON(),\n\t\t};\n\t}\n}\n\n@Deserializer('ClassDeclaration')\nexport class ClassDeclaration extends Class implements CanDeclareExpression {\n\tstatic fromJSON(node: ClassDeclaration, deserializer: NodeDeserializer<any>): ClassDeclaration {\n\t\treturn new ClassDeclaration(\n\t\t\tdeserializer(node.body),\n\t\t\tdeserializer(node.id),\n\t\t\tnode.superClass && deserializer(node.superClass)\n\t\t);\n\t}\n\tprotected id: Identifier;\n\tdeclareVariable(stack: Stack, scopeType: ScopeType, propertyValue?: any) {\n\t\tstack.declareVariable(scopeType, this.id.getName(), propertyValue);\n\t}\n}\n\n@Deserializer('ClassExpression')\nexport class ClassExpression extends Class {\n\tstatic fromJSON(node: ClassExpression, deserializer: NodeDeserializer<any>): ClassExpression {\n\t\treturn new ClassExpression(\n\t\t\tdeserializer(node.body),\n\t\t\tnode.id && deserializer(node.id),\n\t\t\tnode.superClass && deserializer(node.superClass)\n\t\t);\n\t}\n}\n"]}
|