@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/api/definition/member.js
CHANGED
|
@@ -2,28 +2,28 @@ var MemberExpression_1;
|
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
3
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
4
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
|
+
import { Identifier } from './values.js';
|
|
5
6
|
let MemberExpression = MemberExpression_1 = class MemberExpression extends AbstractExpressionNode {
|
|
6
|
-
constructor(object, property, computed, optional = false) {
|
|
7
|
-
super();
|
|
8
|
-
this.object = object;
|
|
9
|
-
this.property = property;
|
|
10
|
-
this.computed = computed;
|
|
11
|
-
this.optional = optional;
|
|
12
|
-
}
|
|
13
7
|
static fromJSON(node, deserializer) {
|
|
14
|
-
return new MemberExpression_1(deserializer(node.object), deserializer(node.property), node.computed, node.optional);
|
|
8
|
+
return new MemberExpression_1(deserializer(node.object), deserializer(node.property), node.computed, node.optional, node.range, node.loc);
|
|
15
9
|
}
|
|
16
10
|
static visit(node, visitNode) {
|
|
17
11
|
visitNode(node.object);
|
|
18
12
|
visitNode(node.property);
|
|
19
13
|
}
|
|
14
|
+
constructor(object, property, computed, optional = false, range, loc) {
|
|
15
|
+
super(range, loc);
|
|
16
|
+
this.object = object;
|
|
17
|
+
this.property = property;
|
|
18
|
+
this.computed = computed;
|
|
19
|
+
this.optional = optional;
|
|
20
|
+
}
|
|
20
21
|
getObject() {
|
|
21
22
|
return this.object;
|
|
22
23
|
}
|
|
23
24
|
getProperty() {
|
|
24
25
|
return this.property;
|
|
25
26
|
}
|
|
26
|
-
shareVariables(scopeList) { }
|
|
27
27
|
set(stack, value) {
|
|
28
28
|
const objectScope = this.object.findScope(stack);
|
|
29
29
|
let propertyKey;
|
|
@@ -31,6 +31,9 @@ let MemberExpression = MemberExpression_1 = class MemberExpression extends Abstr
|
|
|
31
31
|
propertyKey = this.property.get(stack);
|
|
32
32
|
objectScope.set(propertyKey, value);
|
|
33
33
|
}
|
|
34
|
+
else if (this.property instanceof Identifier) {
|
|
35
|
+
objectScope.set(this.property.getName(), value);
|
|
36
|
+
}
|
|
34
37
|
else {
|
|
35
38
|
stack.pushScope(objectScope);
|
|
36
39
|
this.property.set(stack, value);
|
|
@@ -44,7 +47,7 @@ let MemberExpression = MemberExpression_1 = class MemberExpression extends Abstr
|
|
|
44
47
|
if (this.optional) {
|
|
45
48
|
return;
|
|
46
49
|
}
|
|
47
|
-
throw new TypeError(`Cannot read property '${this.property.toString()}' of ${objectRef}`);
|
|
50
|
+
throw new TypeError(`Cannot read property '${this.property.toString()}' of ${objectRef}, reading [${this.toString()}]`);
|
|
48
51
|
}
|
|
49
52
|
let value;
|
|
50
53
|
if (this.computed) {
|
|
@@ -95,7 +98,7 @@ let MemberExpression = MemberExpression_1 = class MemberExpression extends Abstr
|
|
|
95
98
|
};
|
|
96
99
|
MemberExpression = MemberExpression_1 = __decorate([
|
|
97
100
|
Deserializer('MemberExpression'),
|
|
98
|
-
__metadata("design:paramtypes", [Object, Object, Boolean, Boolean])
|
|
101
|
+
__metadata("design:paramtypes", [Object, Object, Boolean, Boolean, Array, Object])
|
|
99
102
|
], MemberExpression);
|
|
100
103
|
export { MemberExpression };
|
|
101
104
|
//# sourceMappingURL=member.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"member.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/member.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"member.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/member.ts"],"names":[],"mappings":";;AAMA,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGlC,IAAM,gBAAgB,wBAAtB,MAAM,gBAAiB,SAAQ,sBAAsB;IAC3D,MAAM,CAAC,QAAQ,CAAC,IAAsB,EAAE,YAA8B;QACrE,OAAO,IAAI,kBAAgB,CAC1B,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,EACzB,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAC3B,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,QAAQ,EACb,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,GAAG,CACR,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,IAAsB,EAAE,SAAwB;QAC5D,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvB,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;IACD,YACW,MAAsB,EACtB,QAAwB,EAC1B,QAAiB,EACjB,WAAoB,KAAK,EACjC,KAAwB,EACxB,GAAoB;QACpB,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QANR,WAAM,GAAN,MAAM,CAAgB;QACtB,aAAQ,GAAR,QAAQ,CAAgB;QAC1B,aAAQ,GAAR,QAAQ,CAAS;QACjB,aAAQ,GAAR,QAAQ,CAAiB;IAIlC,CAAC;IACD,SAAS;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,WAAW;QACV,OAAO,IAA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AAY,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aACpH,CAAC;YACF,OAAO,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;SACpC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC5F,CAAC;IACD,QAAQ;QACP,IAAI,IAAI,CAAC,QAAQ,EAAE;YAClB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC;SAC5F;QACD,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5F,CAAC;IACD,MAAM;QACL,OAAO;YACN,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAC5B,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YAChC,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACH,CAAC;CACD,CAAA;AArGY,gBAAgB;IAD5B,YAAY,CAAC,kBAAkB,CAAC;;GACpB,gBAAgB,CAqG5B;SArGY,gBAAgB","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, CanFindScope,\n\tExpressionEventPath, VisitNodeType, SourceLocation\n} from '../expression.js';\nimport type { Scope, Context } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Identifier } from './values.js';\n\n@Deserializer('MemberExpression')\nexport class MemberExpression extends AbstractExpressionNode implements CanFindScope {\n\tstatic fromJSON(node: MemberExpression, deserializer: NodeDeserializer): MemberExpression {\n\t\treturn new MemberExpression(\n\t\t\tdeserializer(node.object),\n\t\t\tdeserializer(node.property),\n\t\t\tnode.computed,\n\t\t\tnode.optional,\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: MemberExpression, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.object);\n\t\tvisitNode(node.property);\n\t}\n\tconstructor(\n\t\tprotected object: ExpressionNode,\n\t\tprotected property: ExpressionNode,\n\t\tprivate computed: boolean,\n\t\tprivate optional: boolean = false,\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetObject() {\n\t\treturn this.object;\n\t}\n\tgetProperty() {\n\t\treturn this.property;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tconst objectScope = (this.object as ExpressionNode & CanFindScope).findScope<Context>(stack);\n\t\tlet propertyKey: PropertyKey;\n\t\tif (this.computed) {\n\t\t\tpropertyKey = this.property.get(stack);\n\t\t\tobjectScope.set(propertyKey, value);\n\t\t} else if (this.property instanceof Identifier) {\n\t\t\tobjectScope.set(this.property.getName(), value);\n\t\t} else {\n\t\t\tstack.pushScope(objectScope);\n\t\t\tthis.property.set(stack, value);\n\t\t\tstack.clearTo(objectScope);\n\t\t}\n\t\treturn value;\n\t}\n\tget(stack: Stack, thisContext?: any) {\n\t\tconst objectRef = thisContext ?? this.object.get(stack);\n\t\tif (objectRef === undefined || objectRef === null) {\n\t\t\tif (this.optional) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthrow new TypeError(`Cannot read property '${this.property.toString()}' of ${objectRef}, reading [${this.toString()}]`);\n\t\t}\n\t\tlet value;\n\t\tif (this.computed) {\n\t\t\tvalue = objectRef[this.property.get(stack)];\n\t\t} else {\n\t\t\tvalue = this.property.get(stack, objectRef);\n\t\t}\n\t\treturn value;\n\t}\n\tfindScope<T extends object>(stack: Stack): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, scope: Scope<any>): Scope<T>;\n\tfindScope<T extends object>(stack: Stack, objectScope?: Scope<any>): Scope<T> | undefined {\n\t\tif (!objectScope) {\n\t\t\tobjectScope = (this.object as ExpressionNode & CanFindScope).findScope(stack);\n\t\t}\n\t\treturn (this.property as ExpressionNode & CanFindScope).findScope(stack, objectScope);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn [this];\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\tif (this.computed) {\n\t\t\tconst objPath = this.object.dependencyPath(computed);\n\t\t\tconst propertyDependency = this.property.dependency(true);\n\t\t\tconst propertyDependencyPath = propertyDependency.map(exp => exp.dependencyPath(true));\n\n\t\t\tconst computedPath: ExpressionEventPath = {\n\t\t\t\tcomputed: true,\n\t\t\t\tpath: ':' + propertyDependencyPath.flatMap(paths => paths).map(prop => prop.path).join(':'),\n\t\t\t\tcomputedPath: propertyDependencyPath.flatMap(paths => paths.flatMap(prop => prop.computed ? prop.computedPath : [])),\n\t\t\t};\n\t\t\treturn objPath.concat(computedPath);\n\t\t}\n\t\treturn this.object.dependencyPath(computed).concat(this.property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\tif (this.computed) {\n\t\t\treturn `${this.object.toString()}${this.optional ? '?.' : ''}[${this.property.toString()}]`;\n\t\t}\n\t\treturn `${this.object.toString()}${this.optional ? '?.' : '.'}${this.property.toString()}`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tobject: this.object.toJSON(),\n\t\t\tproperty: this.property.toJSON(),\n\t\t\tcomputed: this.computed,\n\t\t\toptional: this.optional\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { NodeDeserializer, ExpressionNode, DeclarationExpression, ExpressionEventPath, VisitNodeType } from '../expression.js';
|
|
2
|
-
import type { Scope } from '../../scope/scope.js';
|
|
1
|
+
import type { NodeDeserializer, ExpressionNode, DeclarationExpression, ExpressionEventPath, VisitNodeType, SourceLocation } from '../expression.js';
|
|
3
2
|
import type { Stack } from '../../scope/stack.js';
|
|
4
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
4
|
import { RestElement } from '../computing/rest.js';
|
|
@@ -12,11 +11,10 @@ export declare class Property extends AbstractExpressionNode implements Declarat
|
|
|
12
11
|
protected computed: boolean;
|
|
13
12
|
static fromJSON(node: Property, deserializer: NodeDeserializer): Property;
|
|
14
13
|
static visit(node: Property, visitNode: VisitNodeType): void;
|
|
15
|
-
constructor(key: ExpressionNode, value: DeclarationExpression | ExpressionNode, kind: 'init' | 'get' | 'set', method: boolean, shorthand: boolean, computed: boolean);
|
|
14
|
+
constructor(key: ExpressionNode, value: DeclarationExpression | ExpressionNode, kind: 'init' | 'get' | 'set', method: boolean, shorthand: boolean, computed: boolean, range?: [number, number], loc?: SourceLocation);
|
|
16
15
|
getKey(): ExpressionNode;
|
|
17
|
-
getValue():
|
|
16
|
+
getValue(): ExpressionNode | DeclarationExpression;
|
|
18
17
|
set(stack: Stack, value: any): void;
|
|
19
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
20
18
|
get(stack: Stack, thisContext: ThisType<any>): any;
|
|
21
19
|
declareVariable(stack: Stack, objectValue: any): void;
|
|
22
20
|
dependency(computed?: true): ExpressionNode[];
|
|
@@ -28,10 +26,9 @@ export declare class ObjectExpression extends AbstractExpressionNode {
|
|
|
28
26
|
private properties;
|
|
29
27
|
static fromJSON(node: ObjectExpression, deserializer: NodeDeserializer): ObjectExpression;
|
|
30
28
|
static visit(node: ObjectExpression, visitNode: VisitNodeType): void;
|
|
31
|
-
constructor(properties: Property[]);
|
|
29
|
+
constructor(properties: Property[], range?: [number, number], loc?: SourceLocation);
|
|
32
30
|
getProperties(): Property[];
|
|
33
31
|
set(stack: Stack): void;
|
|
34
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
35
32
|
get(stack: Stack): {};
|
|
36
33
|
dependency(computed?: true): ExpressionNode[];
|
|
37
34
|
dependencyPath(computed?: true): ExpressionEventPath[];
|
|
@@ -42,9 +39,8 @@ export declare class ObjectPattern extends AbstractExpressionNode implements Dec
|
|
|
42
39
|
private properties;
|
|
43
40
|
static fromJSON(node: ObjectPattern, deserializer: NodeDeserializer): ObjectPattern;
|
|
44
41
|
static visit(node: ObjectPattern, visitNode: VisitNodeType): void;
|
|
45
|
-
constructor(properties: (Property | RestElement)[]);
|
|
42
|
+
constructor(properties: (Property | RestElement)[], range?: [number, number], loc?: SourceLocation);
|
|
46
43
|
getProperties(): (RestElement | Property)[];
|
|
47
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
48
44
|
set(stack: Stack, objectValue: any): void;
|
|
49
45
|
get(scopeProvider: Stack): void;
|
|
50
46
|
declareVariable(stack: Stack, objectValue: any): void;
|
package/api/definition/object.js
CHANGED
|
@@ -1,11 +1,19 @@
|
|
|
1
1
|
var Property_1, ObjectExpression_1, ObjectPattern_1;
|
|
2
2
|
import { __decorate, __metadata } from "tslib";
|
|
3
|
+
import { Identifier } from './values.js';
|
|
3
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
4
5
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
6
|
import { RestElement } from '../computing/rest.js';
|
|
6
7
|
let Property = Property_1 = class Property extends AbstractExpressionNode {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
static fromJSON(node, deserializer) {
|
|
9
|
+
return new Property_1(deserializer(node.key), deserializer(node.value), node.kind, node.method, node.shorthand, node.computed, node.range, node.loc);
|
|
10
|
+
}
|
|
11
|
+
static visit(node, visitNode) {
|
|
12
|
+
visitNode(node.key);
|
|
13
|
+
visitNode(node.value);
|
|
14
|
+
}
|
|
15
|
+
constructor(key, value, kind, method, shorthand, computed, range, loc) {
|
|
16
|
+
super(range, loc);
|
|
9
17
|
this.key = key;
|
|
10
18
|
this.value = value;
|
|
11
19
|
this.kind = kind;
|
|
@@ -13,13 +21,6 @@ let Property = Property_1 = class Property extends AbstractExpressionNode {
|
|
|
13
21
|
this.shorthand = shorthand;
|
|
14
22
|
this.computed = computed;
|
|
15
23
|
}
|
|
16
|
-
static fromJSON(node, deserializer) {
|
|
17
|
-
return new Property_1(deserializer(node.key), deserializer(node.value), node.kind, node.method, node.shorthand, node.computed);
|
|
18
|
-
}
|
|
19
|
-
static visit(node, visitNode) {
|
|
20
|
-
visitNode(node.key);
|
|
21
|
-
visitNode(node.value);
|
|
22
|
-
}
|
|
23
24
|
getKey() {
|
|
24
25
|
return this.key;
|
|
25
26
|
}
|
|
@@ -29,11 +30,8 @@ let Property = Property_1 = class Property extends AbstractExpressionNode {
|
|
|
29
30
|
set(stack, value) {
|
|
30
31
|
this.key.set(stack, value);
|
|
31
32
|
}
|
|
32
|
-
shareVariables(scopeList) {
|
|
33
|
-
this.value.shareVariables(scopeList);
|
|
34
|
-
}
|
|
35
33
|
get(stack, thisContext) {
|
|
36
|
-
const name = this.key.get(stack);
|
|
34
|
+
const name = this.key instanceof Identifier ? this.key.getName() : this.key.get(stack);
|
|
37
35
|
let value;
|
|
38
36
|
switch (this.kind) {
|
|
39
37
|
case 'get':
|
|
@@ -105,29 +103,26 @@ let Property = Property_1 = class Property extends AbstractExpressionNode {
|
|
|
105
103
|
};
|
|
106
104
|
Property = Property_1 = __decorate([
|
|
107
105
|
Deserializer('Property'),
|
|
108
|
-
__metadata("design:paramtypes", [Object, Object, String, Boolean, Boolean, Boolean])
|
|
106
|
+
__metadata("design:paramtypes", [Object, Object, String, Boolean, Boolean, Boolean, Array, Object])
|
|
109
107
|
], Property);
|
|
110
108
|
export { Property };
|
|
111
109
|
let ObjectExpression = ObjectExpression_1 = class ObjectExpression extends AbstractExpressionNode {
|
|
112
|
-
constructor(properties) {
|
|
113
|
-
super();
|
|
114
|
-
this.properties = properties;
|
|
115
|
-
}
|
|
116
110
|
static fromJSON(node, deserializer) {
|
|
117
|
-
return new ObjectExpression_1(node.properties.map(deserializer));
|
|
111
|
+
return new ObjectExpression_1(node.properties.map(deserializer), node.range, node.loc);
|
|
118
112
|
}
|
|
119
113
|
static visit(node, visitNode) {
|
|
120
114
|
node.properties.forEach(visitNode);
|
|
121
115
|
}
|
|
116
|
+
constructor(properties, range, loc) {
|
|
117
|
+
super(range, loc);
|
|
118
|
+
this.properties = properties;
|
|
119
|
+
}
|
|
122
120
|
getProperties() {
|
|
123
121
|
return this.properties;
|
|
124
122
|
}
|
|
125
123
|
set(stack) {
|
|
126
124
|
throw new Error('ObjectExpression#set() has no implementation.');
|
|
127
125
|
}
|
|
128
|
-
shareVariables(scopeList) {
|
|
129
|
-
this.properties.forEach(prop => prop.shareVariables(scopeList));
|
|
130
|
-
}
|
|
131
126
|
get(stack) {
|
|
132
127
|
const newObject = {};
|
|
133
128
|
for (const property of this.properties) {
|
|
@@ -152,24 +147,23 @@ let ObjectExpression = ObjectExpression_1 = class ObjectExpression extends Abstr
|
|
|
152
147
|
};
|
|
153
148
|
ObjectExpression = ObjectExpression_1 = __decorate([
|
|
154
149
|
Deserializer('ObjectExpression'),
|
|
155
|
-
__metadata("design:paramtypes", [Array])
|
|
150
|
+
__metadata("design:paramtypes", [Array, Array, Object])
|
|
156
151
|
], ObjectExpression);
|
|
157
152
|
export { ObjectExpression };
|
|
158
153
|
let ObjectPattern = ObjectPattern_1 = class ObjectPattern extends AbstractExpressionNode {
|
|
159
|
-
constructor(properties) {
|
|
160
|
-
super();
|
|
161
|
-
this.properties = properties;
|
|
162
|
-
}
|
|
163
154
|
static fromJSON(node, deserializer) {
|
|
164
|
-
return new ObjectPattern_1(node.properties.map(deserializer));
|
|
155
|
+
return new ObjectPattern_1(node.properties.map(deserializer), node.range, node.loc);
|
|
165
156
|
}
|
|
166
157
|
static visit(node, visitNode) {
|
|
167
158
|
node.properties.forEach(visitNode);
|
|
168
159
|
}
|
|
160
|
+
constructor(properties, range, loc) {
|
|
161
|
+
super(range, loc);
|
|
162
|
+
this.properties = properties;
|
|
163
|
+
}
|
|
169
164
|
getProperties() {
|
|
170
165
|
return this.properties;
|
|
171
166
|
}
|
|
172
|
-
shareVariables(scopeList) { }
|
|
173
167
|
set(stack, objectValue) {
|
|
174
168
|
throw new Error('ObjectPattern#set() has no implementation.');
|
|
175
169
|
}
|
|
@@ -214,7 +208,7 @@ let ObjectPattern = ObjectPattern_1 = class ObjectPattern extends AbstractExpres
|
|
|
214
208
|
};
|
|
215
209
|
ObjectPattern = ObjectPattern_1 = __decorate([
|
|
216
210
|
Deserializer('ObjectPattern'),
|
|
217
|
-
__metadata("design:paramtypes", [Array])
|
|
211
|
+
__metadata("design:paramtypes", [Array, Array, Object])
|
|
218
212
|
], ObjectPattern);
|
|
219
213
|
export { ObjectPattern };
|
|
220
214
|
//# sourceMappingURL=object.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/object.ts"],"names":[],"mappings":";;AAOA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAI5C,IAAM,QAAQ,gBAAd,MAAM,QAAS,SAAQ,sBAAsB;IAenD,YACW,GAAmB,EACnB,KAA6C,EAC7C,IAA4B,EAC5B,MAAe,EACf,SAAkB,EAClB,QAAiB;QAC3B,KAAK,EAAE,CAAC;QANE,QAAG,GAAH,GAAG,CAAgB;QACnB,UAAK,GAAL,KAAK,CAAwC;QAC7C,SAAI,GAAJ,IAAI,CAAwB;QAC5B,WAAM,GAAN,MAAM,CAAS;QACf,cAAS,GAAT,SAAS,CAAS;QAClB,aAAQ,GAAR,QAAQ,CAAS;IAE5B,CAAC;IAtBD,MAAM,CAAC,QAAQ,CAAC,IAAc,EAAE,YAA8B;QAC7D,OAA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IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACzE,CAAC;IACD,MAAM;QACL,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SACtD,CAAC;IACH,CAAC;CACD,CAAA;AAvDY,aAAa;IADzB,YAAY,CAAC,eAAe,CAAC;;GACjB,aAAa,CAuDzB;SAvDY,aAAa","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, DeclarationExpression,\n\tExpressionEventPath, VisitNodeType\n} from '../expression.js';\nimport type { Scope } from '../../scope/scope.js';\nimport type { Stack } from '../../scope/stack.js';\nimport type { Identifier } from './values.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { RestElement } from '../computing/rest.js';\nimport { FunctionDeclaration } from './function.js';\n\n@Deserializer('Property')\nexport class Property extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: Property, deserializer: NodeDeserializer): Property {\n\t\treturn new Property(\n\t\t\tdeserializer(node.key),\n\t\t\tdeserializer(node.value) as DeclarationExpression,\n\t\t\tnode.kind,\n\t\t\tnode.method,\n\t\t\tnode.shorthand,\n\t\t\tnode.computed,\n\t\t);\n\t}\n\tstatic visit(node: Property, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.key);\n\t\tvisitNode(node.value);\n\t}\n\tconstructor(\n\t\tprotected key: ExpressionNode,\n\t\tprotected value: DeclarationExpression | ExpressionNode,\n\t\tprotected kind: 'init' | 'get' | 'set',\n\t\tprotected method: boolean,\n\t\tprotected shorthand: boolean,\n\t\tprotected computed: boolean,) {\n\t\tsuper();\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthis.key.set(stack, value);\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.value.shareVariables(scopeList);\n\t}\n\tget(stack: Stack, thisContext: ThisType<any>): any {\n\t\tconst name = this.key.get(stack);\n\t\tlet value: any;\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\t\tconst get: () => any = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { get, configurable: true, enumerable: true });\n\t\t\t\tvalue = get;\n\t\t\t\tbreak;\n\t\t\tcase 'set':\n\t\t\t\tconst set: (v: any) => void = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { set, configurable: true, enumerable: true });\n\t\t\t\tvalue = set;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\tcase 'init':\n\t\t\t\tvalue = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { value, configurable: true, enumerable: true, writable: true });\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tconst propertyName = this.shorthand ? (this.key as Identifier).getName() : this.key.get(stack);\n\t\tconst propertyValue = objectValue[propertyName];\n\t\t(this.value as DeclarationExpression).declareVariable(stack, propertyValue);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.key.dependency(computed).concat(this.value.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.key.dependencyPath(computed).concat(this.value.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tconst key = this.computed ? `[${this.key.toString()}]` : this.key.toString();\n\t\tif (this.shorthand) {\n\t\t\treturn key;\n\t\t}\n\t\tlet value = '';\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\tcase 'set':\n\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\tvalue += this.kind;\n\t\t\t\tvalue += ' ' + key\n\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\tbreak;\n\t\t\tcase 'init':\n\t\t\t\tif (this.method) {\n\t\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\t\tvalue += ' ' + key\n\t\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\t} else {\n\t\t\t\t\tvalue += this.value.toString();\n\t\t\t\t\treturn `${key}: ${value}`;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tkey: this.key.toJSON(),\n\t\t\tvalue: this.value.toJSON(),\n\t\t\tkind: this.kind\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectExpression')\nexport class ObjectExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: ObjectExpression, deserializer: NodeDeserializer): ObjectExpression {\n\t\treturn new ObjectExpression(node.properties.map(deserializer) as Property[]);\n\t}\n\tstatic visit(node: ObjectExpression, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(private properties: Property[]) {\n\t\tsuper();\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack) {\n\t\tthrow new Error('ObjectExpression#set() has no implementation.');\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void {\n\t\tthis.properties.forEach(prop => prop.shareVariables(scopeList));\n\t}\n\tget(stack: Stack) {\n\t\tconst newObject = {};\n\t\tfor (const property of this.properties) {\n\t\t\tproperty.get(stack, newObject);\n\t\t}\n\t\treturn newObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectPattern')\nexport class ObjectPattern extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: ObjectPattern, deserializer: NodeDeserializer): ObjectPattern {\n\t\treturn new ObjectPattern(node.properties.map(deserializer) as (Property | RestElement)[]);\n\t}\n\tstatic visit(node: ObjectPattern, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(private properties: (Property | RestElement)[]) {\n\t\tsuper();\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tshareVariables(scopeList: Scope<any>[]): void { }\n\tset(stack: Stack, objectValue: any) {\n\t\tthrow new Error('ObjectPattern#set() has no implementation.');\n\t}\n\tget(scopeProvider: Stack) {\n\t\tthrow new Error('ObjectPattern#get() has no implementation.');\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tfor (const property of this.properties) {\n\t\t\tif (property instanceof RestElement) {\n\t\t\t\tobjectValue = this.getFromObject(stack, objectValue);\n\t\t\t}\n\t\t\tproperty.declareVariable(stack, objectValue);\n\t\t}\n\t}\n\tprivate getFromObject(stack: Stack, objectValue: { [key: PropertyKey]: any }) {\n\t\tconst keys: PropertyKey[] = [];\n\t\tkeys.push(...Object.keys(objectValue));\n\t\tkeys.push(...Object.getOwnPropertySymbols(objectValue));\n\t\tconst restObject: typeof objectValue = {};\n\t\tconst context = stack.lastScope<typeof objectValue>().getContext()!;\n\t\tfor (const key of keys) {\n\t\t\tif (!(key in context)) {\n\t\t\t\trestObject[key] = objectValue[key];\n\t\t\t}\n\t\t}\n\t\treturn restObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}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AAG,MAAM,CAAC,qBAAqB,CAAC,WAAW,CAAC,CAAC,CAAC;QACxD,MAAM,UAAU,GAAuB,EAAE,CAAC;QAC1C,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,EAAsB,CAAC,UAAU,EAAG,CAAC;QACpE,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE;YACvB,IAAI,CAAC,CAAC,GAAG,IAAI,OAAO,CAAC,EAAE;gBACtB,UAAU,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;aACnC;SACD;QACD,OAAO,UAAU,CAAC;IACnB,CAAC;IACD,UAAU,CAAC,QAAe;QACzB,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC3E,CAAC;IACD,cAAc,CAAC,QAAe;QAC7B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/E,CAAC;IACD,QAAQ;QACP,OAAO,KAAK,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;IACzE,CAAC;IACD,MAAM;QACL,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;SACtD,CAAC;IACH,CAAC;CACD,CAAA;AA7DY,aAAa;IADzB,YAAY,CAAC,eAAe,CAAC;;GACjB,aAAa,CA6DzB;SA7DY,aAAa","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode, DeclarationExpression,\n\tExpressionEventPath, VisitNodeType, SourceLocation\n} from '../expression.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { Identifier } from './values.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { RestElement } from '../computing/rest.js';\nimport { FunctionDeclaration } from './function.js';\n\n@Deserializer('Property')\nexport class Property extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: Property, deserializer: NodeDeserializer): Property {\n\t\treturn new Property(\n\t\t\tdeserializer(node.key),\n\t\t\tdeserializer(node.value) as DeclarationExpression,\n\t\t\tnode.kind,\n\t\t\tnode.method,\n\t\t\tnode.shorthand,\n\t\t\tnode.computed,\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: Property, visitNode: VisitNodeType): void {\n\t\tvisitNode(node.key);\n\t\tvisitNode(node.value);\n\t}\n\tconstructor(\n\t\tprotected key: ExpressionNode,\n\t\tprotected value: DeclarationExpression | ExpressionNode,\n\t\tprotected kind: 'init' | 'get' | 'set',\n\t\tprotected method: boolean,\n\t\tprotected shorthand: boolean,\n\t\tprotected computed: boolean,\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetKey() {\n\t\treturn this.key;\n\t}\n\tgetValue() {\n\t\treturn this.value;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthis.key.set(stack, value);\n\t}\n\tget(stack: Stack, thisContext: ThisType<any>): any {\n\t\tconst name = this.key instanceof Identifier ? this.key.getName() : this.key.get(stack);\n\t\tlet value: any;\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\t\tconst get: () => any = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { get, configurable: true, enumerable: true });\n\t\t\t\tvalue = get;\n\t\t\t\tbreak;\n\t\t\tcase 'set':\n\t\t\t\tconst set: (v: any) => void = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { set, configurable: true, enumerable: true });\n\t\t\t\tvalue = set;\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\tcase 'init':\n\t\t\t\tvalue = this.value.get(stack);\n\t\t\t\tObject.defineProperty(thisContext, name, { value, configurable: true, enumerable: true, writable: true });\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tconst propertyName = this.shorthand ? (this.key as Identifier).getName() : this.key.get(stack);\n\t\tconst propertyValue = objectValue[propertyName];\n\t\t(this.value as DeclarationExpression).declareVariable(stack, propertyValue);\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.key.dependency(computed).concat(this.value.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.key.dependencyPath(computed).concat(this.value.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\tconst key = this.computed ? `[${this.key.toString()}]` : this.key.toString();\n\t\tif (this.shorthand) {\n\t\t\treturn key;\n\t\t}\n\t\tlet value = '';\n\t\tswitch (this.kind) {\n\t\t\tcase 'get':\n\t\t\tcase 'set':\n\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\tvalue += this.kind;\n\t\t\t\tvalue += ' ' + key\n\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\tbreak;\n\t\t\tcase 'init':\n\t\t\t\tif (this.method) {\n\t\t\t\t\tconst expression = (this.value as FunctionDeclaration);\n\t\t\t\t\tvalue += ' ' + key\n\t\t\t\t\tvalue += expression.paramsAndBodyToString();\n\t\t\t\t} else {\n\t\t\t\t\tvalue += this.value.toString();\n\t\t\t\t\treturn `${key}: ${value}`;\n\t\t\t\t}\n\t\t\t\tbreak;\n\t\t\tdefault:\n\t\t\t\tbreak;\n\t\t}\n\t\treturn value;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tkey: this.key.toJSON(),\n\t\t\tvalue: this.value.toJSON(),\n\t\t\tkind: this.kind\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectExpression')\nexport class ObjectExpression extends AbstractExpressionNode {\n\tstatic fromJSON(node: ObjectExpression, deserializer: NodeDeserializer): ObjectExpression {\n\t\treturn new ObjectExpression(\n\t\t\tnode.properties.map(deserializer) as Property[],\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ObjectExpression, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate properties: Property[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack) {\n\t\tthrow new Error('ObjectExpression#set() has no implementation.');\n\t}\n\tget(stack: Stack) {\n\t\tconst newObject = {};\n\t\tfor (const property of this.properties) {\n\t\t\tproperty.get(stack, newObject);\n\t\t}\n\t\treturn newObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n\n@Deserializer('ObjectPattern')\nexport class ObjectPattern extends AbstractExpressionNode implements DeclarationExpression {\n\tstatic fromJSON(node: ObjectPattern, deserializer: NodeDeserializer): ObjectPattern {\n\t\treturn new ObjectPattern(\n\t\t\tnode.properties.map(deserializer) as (Property | RestElement)[],\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ObjectPattern, visitNode: VisitNodeType): void {\n\t\tnode.properties.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate properties: (Property | RestElement)[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetProperties() {\n\t\treturn this.properties;\n\t}\n\tset(stack: Stack, objectValue: any) {\n\t\tthrow new Error('ObjectPattern#set() has no implementation.');\n\t}\n\tget(scopeProvider: Stack) {\n\t\tthrow new Error('ObjectPattern#get() has no implementation.');\n\t}\n\tdeclareVariable(stack: Stack, objectValue: any): void {\n\t\tfor (const property of this.properties) {\n\t\t\tif (property instanceof RestElement) {\n\t\t\t\tobjectValue = this.getFromObject(stack, objectValue);\n\t\t\t}\n\t\t\tproperty.declareVariable(stack, objectValue);\n\t\t}\n\t}\n\tprivate getFromObject(stack: Stack, objectValue: { [key: PropertyKey]: any }) {\n\t\tconst keys: PropertyKey[] = [];\n\t\tkeys.push(...Object.keys(objectValue));\n\t\tkeys.push(...Object.getOwnPropertySymbols(objectValue));\n\t\tconst restObject: typeof objectValue = {};\n\t\tconst context = stack.lastScope<typeof objectValue>().getContext()!;\n\t\tfor (const key of keys) {\n\t\t\tif (!(key in context)) {\n\t\t\t\trestObject[key] = objectValue[key];\n\t\t\t}\n\t\t}\n\t\treturn restObject;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.properties.flatMap(property => property.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.properties.flatMap(property => property.dependencyPath(computed));\n\t}\n\ttoString() {\n\t\treturn `{ ${this.properties.map(item => item.toString()).join(', ')} }`;\n\t}\n\ttoJson(): object {\n\t\treturn {\n\t\t\tproperties: this.properties.map(item => item.toJSON())\n\t\t};\n\t}\n}\n"]}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType } from '../expression.js';
|
|
2
|
-
import type { Scope } from '../../scope/scope.js';
|
|
1
|
+
import type { NodeDeserializer, ExpressionNode, ExpressionEventPath, VisitNodeType, SourceLocation } from '../expression.js';
|
|
3
2
|
import type { Stack } from '../../scope/stack.js';
|
|
4
3
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
5
4
|
export declare class ExpressionStatement extends AbstractExpressionNode {
|
|
6
5
|
private body;
|
|
7
6
|
static fromJSON(node: ExpressionStatement, deserializer: NodeDeserializer): ExpressionStatement;
|
|
8
7
|
static visit(node: ExpressionStatement, visitNode: VisitNodeType): void;
|
|
9
|
-
constructor(body: ExpressionNode[]);
|
|
8
|
+
constructor(body: ExpressionNode[], range?: [number, number], loc?: SourceLocation);
|
|
10
9
|
getBody(): ExpressionNode[];
|
|
11
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
12
10
|
set(stack: Stack, value: any): void;
|
|
13
11
|
get(stack: Stack): undefined;
|
|
14
12
|
dependency(computed?: true): ExpressionNode[];
|
|
@@ -4,22 +4,19 @@ import { AbstractExpressionNode } from '../abstract.js';
|
|
|
4
4
|
import { Deserializer } from '../deserialize/deserialize.js';
|
|
5
5
|
import { isDeclarationExpression } from '../utils.js';
|
|
6
6
|
let ExpressionStatement = ExpressionStatement_1 = class ExpressionStatement extends AbstractExpressionNode {
|
|
7
|
-
constructor(body) {
|
|
8
|
-
super();
|
|
9
|
-
this.body = body;
|
|
10
|
-
}
|
|
11
7
|
static fromJSON(node, deserializer) {
|
|
12
|
-
return new ExpressionStatement_1(node.body.map(
|
|
8
|
+
return new ExpressionStatement_1(node.body.map(deserializer), node.range, node.loc);
|
|
13
9
|
}
|
|
14
10
|
static visit(node, visitNode) {
|
|
15
11
|
node.body.forEach(visitNode);
|
|
16
12
|
}
|
|
13
|
+
constructor(body, range, loc) {
|
|
14
|
+
super(range, loc);
|
|
15
|
+
this.body = body;
|
|
16
|
+
}
|
|
17
17
|
getBody() {
|
|
18
18
|
return this.body;
|
|
19
19
|
}
|
|
20
|
-
shareVariables(scopeList) {
|
|
21
|
-
this.body.forEach(statement => statement.shareVariables(scopeList));
|
|
22
|
-
}
|
|
23
20
|
set(stack, value) {
|
|
24
21
|
throw new Error(`ExpressionStatement#set() has no implementation.`);
|
|
25
22
|
}
|
|
@@ -46,7 +43,7 @@ let ExpressionStatement = ExpressionStatement_1 = class ExpressionStatement exte
|
|
|
46
43
|
};
|
|
47
44
|
ExpressionStatement = ExpressionStatement_1 = __decorate([
|
|
48
45
|
Deserializer('ExpressionStatement'),
|
|
49
|
-
__metadata("design:paramtypes", [Array])
|
|
46
|
+
__metadata("design:paramtypes", [Array, Array, Object])
|
|
50
47
|
], ExpressionStatement);
|
|
51
48
|
export { ExpressionStatement };
|
|
52
49
|
//# sourceMappingURL=statement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"statement.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/statement.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"statement.js","sourceRoot":"","sources":["../../../../src/expressions/api/definition/statement.ts"],"names":[],"mappings":";;AAKA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAG/C,IAAM,mBAAmB,2BAAzB,MAAM,mBAAoB,SAAQ,sBAAsB;IAC9D,MAAM,CAAC,QAAQ,CAAC,IAAyB,EAAE,YAA8B;QACxE,OAAO,IAAI,qBAAmB,CAC7B,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,EAC3B,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,GAAG,CACR,CAAC;IACH,CAAC;IACD,MAAM,CAAC,KAAK,CAAC,IAAyB,EAAE,SAAwB;QAC/D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9B,CAAC;IACD,YACS,IAAsB,EAC9B,KAAwB,EACxB,GAAoB;QACpB,KAAK,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAHV,SAAI,GAAJ,IAAI,CAAkB;IAI/B,CAAC;IACD,OAAO;QACN,OAAO,IAAI,CAAC,IAAI,CAAC;IAClB,CAAC;IACD,GAAG,C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B,CA2C/B;SA3CY,mBAAmB","sourcesContent":["import type {\n\tNodeDeserializer, ExpressionNode,\n\tExpressionEventPath, VisitNodeType, SourceLocation,\n} from '../expression.js';\nimport type { Stack } from '../../scope/stack.js';\nimport { AbstractExpressionNode } from '../abstract.js';\nimport { Deserializer } from '../deserialize/deserialize.js';\nimport { isDeclarationExpression } from '../utils.js';\n\n@Deserializer('ExpressionStatement')\nexport class ExpressionStatement extends AbstractExpressionNode {\n\tstatic fromJSON(node: ExpressionStatement, deserializer: NodeDeserializer): ExpressionStatement {\n\t\treturn new ExpressionStatement(\n\t\t\tnode.body.map(deserializer),\n\t\t\tnode.range,\n\t\t\tnode.loc\n\t\t);\n\t}\n\tstatic visit(node: ExpressionStatement, visitNode: VisitNodeType): void {\n\t\tnode.body.forEach(visitNode);\n\t}\n\tconstructor(\n\t\tprivate body: ExpressionNode[],\n\t\trange?: [number, number],\n\t\tloc?: SourceLocation) {\n\t\tsuper(range, loc);\n\t}\n\tgetBody() {\n\t\treturn this.body;\n\t}\n\tset(stack: Stack, value: any) {\n\t\tthrow new Error(`ExpressionStatement#set() has no implementation.`);\n\t}\n\tget(stack: Stack) {\n\t\tlet value;\n\t\tthis.body.forEach(node => value = node.get(stack));\n\t\treturn value;\n\t}\n\tdependency(computed?: true): ExpressionNode[] {\n\t\treturn this.body.flatMap(exp => exp.dependency(computed));\n\t}\n\tdependencyPath(computed?: true): ExpressionEventPath[] {\n\t\treturn this.body.flatMap(node => node.dependencyPath(computed));\n\t}\n\ttoString(): string {\n\t\treturn this.body\n\t\t\t.map(node => ({ insert: !isDeclarationExpression(node), string: node.toString() }))\n\t\t\t.map(ref => `${ref.string}${ref.insert ? ';' : ''}`)\n\t\t\t.join('\\n');\n\t}\n\ttoJson(): object {\n\t\treturn { body: this.body.map(exp => exp.toJSON()) };\n\t}\n}\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DeclarationExpression, ExpressionNode, NodeDeserializer, CanFindScope, ExpressionEventPath, VisitNodeType } from '../expression.js';
|
|
1
|
+
import type { DeclarationExpression, ExpressionNode, NodeDeserializer, CanFindScope, ExpressionEventPath, VisitNodeType, SourceLocation } from '../expression.js';
|
|
2
2
|
import type { Context, Scope } from '../../scope/scope.js';
|
|
3
3
|
import type { Stack } from '../../scope/stack.js';
|
|
4
4
|
import { AbstractExpressionNode } from '../abstract.js';
|
|
@@ -14,9 +14,8 @@ import { AbstractExpressionNode } from '../abstract.js';
|
|
|
14
14
|
export declare class Identifier extends AbstractExpressionNode implements DeclarationExpression, CanFindScope {
|
|
15
15
|
protected name: string | number;
|
|
16
16
|
static fromJSON(node: Identifier): Identifier;
|
|
17
|
-
constructor(name: string | number);
|
|
17
|
+
constructor(name: string | number, range?: [number, number], loc?: SourceLocation);
|
|
18
18
|
getName(): string | number;
|
|
19
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
20
19
|
set(stack: Stack, value: any): any;
|
|
21
20
|
get(stack: Stack, thisContext?: any): any;
|
|
22
21
|
findScope<T extends object>(stack: Stack): Scope<T>;
|
|
@@ -30,21 +29,23 @@ export declare class Identifier extends AbstractExpressionNode implements Declar
|
|
|
30
29
|
}
|
|
31
30
|
export declare class ThisExpression extends Identifier {
|
|
32
31
|
static fromJSON(node: ThisExpression): ThisExpression;
|
|
33
|
-
constructor();
|
|
32
|
+
constructor(range?: [number, number], loc?: SourceLocation);
|
|
33
|
+
toJson(): object;
|
|
34
34
|
}
|
|
35
35
|
export declare class Literal<T> extends AbstractExpressionNode implements CanFindScope {
|
|
36
|
-
|
|
36
|
+
value: T;
|
|
37
37
|
static fromJSON(node: Literal<any>): Literal<string> | Literal<number> | Literal<boolean> | Literal<RegExp> | Literal<bigint> | Literal<null> | Literal<undefined>;
|
|
38
|
-
|
|
38
|
+
type: 'Literal';
|
|
39
|
+
regex?: {
|
|
39
40
|
pattern: string;
|
|
40
41
|
flags: string;
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
|
|
43
|
+
bigint?: string;
|
|
44
|
+
raw?: string;
|
|
44
45
|
constructor(value: T, raw?: string, regex?: {
|
|
45
46
|
pattern: string;
|
|
46
47
|
flags: string;
|
|
47
|
-
}, bigint?: string);
|
|
48
|
+
}, bigint?: string, range?: [number, number], loc?: SourceLocation);
|
|
48
49
|
getValue(): T;
|
|
49
50
|
getRegex(): {
|
|
50
51
|
pattern: string;
|
|
@@ -52,7 +53,6 @@ export declare class Literal<T> extends AbstractExpressionNode implements CanFin
|
|
|
52
53
|
} | undefined;
|
|
53
54
|
getBigint(): string | undefined;
|
|
54
55
|
geRaw(): string | undefined;
|
|
55
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
56
56
|
set(): void;
|
|
57
57
|
get(): T;
|
|
58
58
|
findScope<V extends Context>(stack: Stack): Scope<V>;
|
|
@@ -66,12 +66,10 @@ export declare class TemplateLiteralExpressionNode extends AbstractExpressionNod
|
|
|
66
66
|
protected quasis: string[];
|
|
67
67
|
protected expressions: ExpressionNode[];
|
|
68
68
|
protected tag?: ExpressionNode | undefined;
|
|
69
|
-
static fromJSON(node: TemplateLiteralExpressionNode, deserializer: NodeDeserializer): TemplateLiteralExpressionNode;
|
|
70
69
|
static visit(node: TemplateLiteralExpressionNode, visitNode: VisitNodeType): void;
|
|
71
|
-
constructor(quasis: string[], expressions: ExpressionNode[], tag?: ExpressionNode | undefined);
|
|
70
|
+
constructor(quasis: string[], expressions: ExpressionNode[], tag?: ExpressionNode | undefined, range?: [number, number], loc?: SourceLocation);
|
|
72
71
|
getTag(): ExpressionNode | undefined;
|
|
73
72
|
getExpressions(): ExpressionNode[];
|
|
74
|
-
shareVariables(scopeList: Scope<any>[]): void;
|
|
75
73
|
set(stack: Stack, value: any): void;
|
|
76
74
|
get(stack: Stack): any;
|
|
77
75
|
dependency(computed?: true): ExpressionNode[];
|
|
@@ -80,37 +78,14 @@ export declare class TemplateLiteralExpressionNode extends AbstractExpressionNod
|
|
|
80
78
|
toJson(): object;
|
|
81
79
|
}
|
|
82
80
|
export declare class TemplateLiteral extends TemplateLiteralExpressionNode {
|
|
81
|
+
static fromJSON(node: TemplateLiteral, deserializer: NodeDeserializer): TemplateLiteralExpressionNode;
|
|
83
82
|
protected tag: undefined;
|
|
84
|
-
constructor(quasis: string[], expressions: ExpressionNode[]);
|
|
83
|
+
constructor(quasis: string[], expressions: ExpressionNode[], range?: [number, number], loc?: SourceLocation);
|
|
85
84
|
getTag(): undefined;
|
|
86
85
|
}
|
|
87
86
|
export declare class TaggedTemplateExpression extends TemplateLiteralExpressionNode {
|
|
87
|
+
static fromJSON(node: TaggedTemplateExpression, deserializer: NodeDeserializer): TemplateLiteralExpressionNode;
|
|
88
88
|
protected tag: ExpressionNode;
|
|
89
|
-
constructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[]);
|
|
89
|
+
constructor(tag: ExpressionNode, quasis: string[], expressions: ExpressionNode[], range?: [number, number], loc?: SourceLocation);
|
|
90
90
|
getTag(): ExpressionNode;
|
|
91
91
|
}
|
|
92
|
-
export declare const TRUE: string;
|
|
93
|
-
export declare const FALSE: string;
|
|
94
|
-
export declare const NULL: string;
|
|
95
|
-
export declare const UNDEFINED: string;
|
|
96
|
-
export declare const NullNode: Literal<null>;
|
|
97
|
-
export declare const UndefinedNode: Literal<undefined>;
|
|
98
|
-
export declare const TrueNode: Literal<boolean>;
|
|
99
|
-
export declare const FalseNode: Literal<boolean>;
|
|
100
|
-
export declare const ThisNode: ThisExpression;
|
|
101
|
-
export declare const GlobalThisNode: Identifier;
|
|
102
|
-
export declare const SymbolNode: Identifier;
|
|
103
|
-
export declare const OfNode: Identifier;
|
|
104
|
-
export declare const AsNode: Identifier;
|
|
105
|
-
export declare const DefaultNode: Identifier;
|
|
106
|
-
export declare const GetIdentifier: Identifier;
|
|
107
|
-
export declare const SetIdentifier: Identifier;
|
|
108
|
-
export declare const AsyncIdentifier: Identifier;
|
|
109
|
-
export declare const AwaitIdentifier: Identifier;
|
|
110
|
-
export declare const ConstructorIdentifier: Identifier;
|
|
111
|
-
export declare const NameIdentifier: Identifier;
|
|
112
|
-
export declare const EvalIdentifier: Identifier;
|
|
113
|
-
export declare const ArgumentsIdentifier: Identifier;
|
|
114
|
-
export declare const YieldIdentifier: Identifier;
|
|
115
|
-
export declare const SuperIdentifier: Identifier;
|
|
116
|
-
export declare const LetIdentifier: Identifier;
|