-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
PropertyDefinition.ts
78 lines (68 loc) · 2.41 KB
/
PropertyDefinition.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import type { CallOptions } from '../CallOptions';
import type { DeoptimizableEntity } from '../DeoptimizableEntity';
import type { HasEffectsContext } from '../ExecutionContext';
import type { NodeEvent } from '../NodeEvents';
import type { ObjectPath, PathTracker } from '../utils/PathTracker';
import type * as NodeType from './NodeType';
import type PrivateIdentifier from './PrivateIdentifier';
import {
type ExpressionEntity,
type LiteralValueOrUnknown,
UNKNOWN_EXPRESSION,
UnknownValue
} from './shared/Expression';
import { type ExpressionNode, NodeBase } from './shared/Node';
export default class PropertyDefinition extends NodeBase {
declare computed: boolean;
declare key: ExpressionNode | PrivateIdentifier;
declare static: boolean;
declare type: NodeType.tPropertyDefinition;
declare value: ExpressionNode | null;
deoptimizePath(path: ObjectPath): void {
this.value?.deoptimizePath(path);
}
deoptimizeThisOnEventAtPath(
event: NodeEvent,
path: ObjectPath,
thisParameter: ExpressionEntity,
recursionTracker: PathTracker
): void {
this.value?.deoptimizeThisOnEventAtPath(event, path, thisParameter, recursionTracker);
}
getLiteralValueAtPath(
path: ObjectPath,
recursionTracker: PathTracker,
origin: DeoptimizableEntity
): LiteralValueOrUnknown {
return this.value
? this.value.getLiteralValueAtPath(path, recursionTracker, origin)
: UnknownValue;
}
getReturnExpressionWhenCalledAtPath(
path: ObjectPath,
callOptions: CallOptions,
recursionTracker: PathTracker,
origin: DeoptimizableEntity
): ExpressionEntity {
return this.value
? this.value.getReturnExpressionWhenCalledAtPath(path, callOptions, recursionTracker, origin)
: UNKNOWN_EXPRESSION;
}
hasEffects(context: HasEffectsContext): boolean {
return this.key.hasEffects(context) || (this.static && !!this.value?.hasEffects(context));
}
hasEffectsWhenAccessedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return !this.value || this.value.hasEffectsWhenAccessedAtPath(path, context);
}
hasEffectsWhenAssignedAtPath(path: ObjectPath, context: HasEffectsContext): boolean {
return !this.value || this.value.hasEffectsWhenAssignedAtPath(path, context);
}
hasEffectsWhenCalledAtPath(
path: ObjectPath,
callOptions: CallOptions,
context: HasEffectsContext
): boolean {
return !this.value || this.value.hasEffectsWhenCalledAtPath(path, callOptions, context);
}
protected applyDeoptimizations() {}
}