/
ClassBody.ts
42 lines (37 loc) · 1.42 KB
/
ClassBody.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import type { InclusionContext } from '../ExecutionContext';
import ClassBodyScope from '../scopes/ClassBodyScope';
import type Scope from '../scopes/Scope';
import type MethodDefinition from './MethodDefinition';
import type * as NodeType from './NodeType';
import type PropertyDefinition from './PropertyDefinition';
import type ClassNode from './shared/ClassNode';
import { type GenericEsTreeNode, type IncludeChildren, NodeBase } from './shared/Node';
export default class ClassBody extends NodeBase {
declare body: (MethodDefinition | PropertyDefinition)[];
declare scope: ClassBodyScope;
declare type: NodeType.tClassBody;
createScope(parentScope: Scope): void {
this.scope = new ClassBodyScope(parentScope, this.parent as ClassNode, this.context);
}
include(context: InclusionContext, includeChildrenRecursively: IncludeChildren): void {
this.included = true;
this.context.includeVariableInModule(this.scope.thisVariable);
for (const definition of this.body) {
definition.include(context, includeChildrenRecursively);
}
}
parseNode(esTreeNode: GenericEsTreeNode): void {
const body: NodeBase[] = (this.body = []);
for (const definition of esTreeNode.body) {
body.push(
new (this.context.getNodeConstructor(definition.type))(
definition,
this,
definition.static ? this.scope : this.scope.instanceScope
)
);
}
super.parseNode(esTreeNode);
}
protected applyDeoptimizations() {}
}